Skip to content

Commit a70e169

Browse files
committed
Merge branch 'replace-whoops'
2 parents 38c3270 + 84cf681 commit a70e169

File tree

25 files changed

+266
-197
lines changed

25 files changed

+266
-197
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"require": {
77
"php": ">=7.4",
88
"composer-runtime-api": "^2.2",
9-
"filp/whoops": "^2",
109
"lkrms/dice": "^4.1.6",
1110
"psr/container": "^2",
1211
"psr/log": "^1"

lib/lk-util/Command/Generate/GenerateFacade.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@
1818
*/
1919
final class GenerateFacade extends GenerateCommand
2020
{
21-
private ?string $ClassFqcn;
22-
private ?string $FacadeFqcn;
23-
2421
/**
2522
* Methods that shouldn't be surfaced by the Facade
26-
*
27-
* @var string[]
2823
*/
29-
private array $SkipMethods = [
24+
private const SKIP_METHODS = [
3025
'getReadable',
3126
'getWritable',
3227
'setFacade',
@@ -38,6 +33,14 @@ final class GenerateFacade extends GenerateCommand
3833
'getInstance',
3934
];
4035

36+
private ?string $ClassFqcn;
37+
private ?string $FacadeFqcn;
38+
39+
/**
40+
* @var string[]|null
41+
*/
42+
private ?array $SkipMethods;
43+
4144
public function description(): string
4245
{
4346
return 'Generate a static interface to a class';
@@ -61,12 +64,20 @@ protected function getOptionList(): array
6164
->required()
6265
->bindTo($this->FacadeFqcn),
6366
...$this->getOutputOptionList('facade'),
67+
CliOption::build()
68+
->long('skip')
69+
->short('k')
70+
->description('Exclude a method from the facade')
71+
->optionType(CliOptionType::VALUE)
72+
->multipleAllowed()
73+
->bindTo($this->SkipMethods),
6474
];
6575
}
6676

6777
protected function run(string ...$args)
6878
{
6979
$this->reset();
80+
$this->SkipMethods = array_merge($this->SkipMethods, self::SKIP_METHODS);
7081

7182
$classFqcn = $this->getRequiredFqcnOptionValue(
7283
'class',

phpstan-baseline.neon

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,6 @@ parameters:
305305
count: 1
306306
path: src/Curler/Support/CurlerPage.php
307307

308-
-
309-
message: "#^Class Lkrms\\\\Err\\\\Err implements generic interface Lkrms\\\\Contract\\\\IFacade but does not specify its types\\: TClass$#"
310-
count: 1
311-
path: src/Err/Err.php
312-
313-
-
314-
message: "#^Method Lkrms\\\\Err\\\\Err\\:\\:__callStatic\\(\\) has no return type specified\\.$#"
315-
count: 1
316-
path: src/Err/Err.php
317-
318-
-
319-
message: "#^Method Lkrms\\\\Err\\\\Err\\:\\:__callStatic\\(\\) has parameter \\$arguments with no value type specified in iterable type array\\.$#"
320-
count: 1
321-
path: src/Err/Err.php
322-
323308
-
324309
message: "#^Method Lkrms\\\\Store\\\\CacheStore\\:\\:get\\(\\) has no return type specified\\.$#"
325310
count: 1

scripts/generate.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Lkrms\Store\CacheStore;
1616
use Lkrms\Store\TrashStore;
1717
use Lkrms\Support\ArrayMapper;
18+
use Lkrms\Support\ErrorHandler;
1819
use Lkrms\Support\EventDispatcher;
1920
use Lkrms\Sync\Support\DbSyncDefinition;
2021
use Lkrms\Sync\Support\HttpSyncDefinition;
@@ -43,6 +44,7 @@
4344
ConsoleWriter::class => \Lkrms\Facade\Console::class,
4445
Container::class => \Lkrms\Facade\DI::class,
4546
Debugging::class => \Lkrms\Facade\Debug::class,
47+
ErrorHandler::class => [\Lkrms\Facade\Err::class, '--skip', 'handleShutdown,handleError,handleException'],
4648
EventDispatcher::class => \Lkrms\Facade\Event::class,
4749
Filesystem::class => \Lkrms\Facade\File::class,
4850
Formatters::class => \Lkrms\Facade\Format::class,
@@ -83,7 +85,12 @@
8385
$status = 0;
8486

8587
foreach ($facades as $class => $facade) {
86-
$status |= $generateFacade(...[...$args, $class, $facade]);
88+
$facadeArgs = [];
89+
if (is_array($facade)) {
90+
$facadeArgs = $facade;
91+
$facade = array_shift($facadeArgs);
92+
}
93+
$status |= $generateFacade(...[...$args, ...$facadeArgs, $class, $facade]);
8794
}
8895

8996
foreach ($builders as $class => $builder) {

src/Container/Application.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
use Lkrms\Console\Target\StreamTarget;
88
use Lkrms\Container\Container;
99
use Lkrms\Contract\IApplication;
10-
use Lkrms\Err\Err;
1110
use Lkrms\Facade\Cache;
1211
use Lkrms\Facade\Composer;
1312
use Lkrms\Facade\Console;
13+
use Lkrms\Facade\Err;
1414
use Lkrms\Facade\File;
1515
use Lkrms\Facade\Format;
1616
use Lkrms\Facade\Sync;
@@ -286,13 +286,11 @@ public function __construct(
286286

287287
Console::registerStdioTargets();
288288

289-
if (!Err::isLoaded()) {
290-
Err::load();
291-
}
289+
Err::register();
292290

293291
$adodb = Composer::getPackagePath('adodb/adodb-php');
294292
if ($adodb !== null) {
295-
Err::silencePaths($adodb);
293+
Err::silencePath($adodb);
296294
}
297295
}
298296

src/Err/CliHandler.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/Err/Err.php

Lines changed: 0 additions & 115 deletions
This file was deleted.

src/Facade/Err.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Lkrms\Facade;
4+
5+
use Lkrms\Concept\Facade;
6+
use Lkrms\Support\ErrorHandler;
7+
8+
/**
9+
* A facade for \Lkrms\Support\ErrorHandler
10+
*
11+
* @method static ErrorHandler load() Load and return an instance of the underlying ErrorHandler class
12+
* @method static ErrorHandler getInstance() Get the underlying ErrorHandler instance
13+
* @method static bool isLoaded() True if an underlying ErrorHandler instance has been loaded
14+
* @method static void unload() Clear the underlying ErrorHandler instance
15+
* @method static ErrorHandler deregister() Deregister previously registered error and exception handlers
16+
* @method static ErrorHandler register() Register error, exception and shutdown handlers
17+
* @method static ErrorHandler silencePath(string $path, int $levels = 26624) Silence errors in a file or directory
18+
* @method static ErrorHandler silencePattern(string $pattern, int $levels = 26624) Silence errors in paths that match a regular expression
19+
*
20+
* @uses ErrorHandler
21+
*
22+
* @extends Facade<ErrorHandler>
23+
*/
24+
final class Err extends Facade
25+
{
26+
/**
27+
* @internal
28+
*/
29+
protected static function getServiceName(): string
30+
{
31+
return ErrorHandler::class;
32+
}
33+
}

0 commit comments

Comments
 (0)