diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 0f7e37c3..d9754812 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1,6 +1,18 @@ '#^Call to an undefined static method BlitzPHP\\\\Utilities\\\\Iterable\\\\Arr\\:\\:countRecursive\\(\\)\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Cli/Commands/Translation/TranslationsFinder.php', +]; +$ignoreErrors[] = [ + // identifier: staticMethod.notFound + 'message' => '#^Call to an undefined static method BlitzPHP\\\\Utilities\\\\Iterable\\\\Arr\\:\\:diffRecursive\\(\\)\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Cli/Commands/Translation/TranslationsFinder.php', +]; $ignoreErrors[] = [ // identifier: method.notFound 'message' => '#^Call to an undefined method BlitzPHP\\\\Traits\\\\Mixins\\\\HigherOrderCollectionProxy\\:\\:__invoke\\(\\)\\.$#', diff --git a/spec/system/cache/Cache.spec.php b/spec/system/cache/Cache.spec.php index ff4e6cf0..83bd5a8a 100644 --- a/spec/system/cache/Cache.spec.php +++ b/spec/system/cache/Cache.spec.php @@ -21,7 +21,8 @@ $cache = new Cache(); Cache::disable(); - $factory = ReflectionHelper::getPrivateMethodInvoker($cache, 'factory'); + $manager = ReflectionHelper::getPrivateProperty($cache, 'manager'); + $factory = ReflectionHelper::getPrivateMethodInvoker($manager, 'factory'); expect(call_user_func($factory))->toBeAnInstanceOf(Dummy::class); @@ -31,9 +32,11 @@ it('Leve une exception lorsque les gestionnaires valides ne sont pas definis', function (): void { $cache = new Cache(); - expect(ReflectionHelper::getPrivateProperty($cache, 'config'))->toBe([]); + $manager = ReflectionHelper::getPrivateProperty($cache, 'manager'); - $factory = ReflectionHelper::getPrivateMethodInvoker($cache, 'factory'); + expect(ReflectionHelper::getPrivateProperty($manager, 'config'))->toBe([]); + + $factory = ReflectionHelper::getPrivateMethodInvoker($manager, 'factory'); expect(fn() => call_user_func($factory))->toThrow(new InvalidArgumentException()); }); @@ -43,14 +46,16 @@ $config['valid_handlers'] = config('cache.valid_handlers'); $cache = new Cache($config); - $factory = ReflectionHelper::getPrivateMethodInvoker($cache, 'factory'); + $manager = ReflectionHelper::getPrivateProperty($cache, 'manager'); + $factory = ReflectionHelper::getPrivateMethodInvoker($manager, 'factory'); expect(fn() => call_user_func($factory))->toThrow(new InvalidArgumentException()); $config['handler'] = 'fake_handler'; $cache = new Cache($config); - $factory = ReflectionHelper::getPrivateMethodInvoker($cache, 'factory'); + $manager = ReflectionHelper::getPrivateProperty($cache, 'manager'); + $factory = ReflectionHelper::getPrivateMethodInvoker($manager, 'factory'); expect(fn() => call_user_func($factory))->toThrow(new InvalidArgumentException()); }); @@ -60,7 +65,8 @@ $config['handler'] = 'fake_handler'; $cache = new Cache($config); - $factory = ReflectionHelper::getPrivateMethodInvoker($cache, 'factory'); + $manager = ReflectionHelper::getPrivateProperty($cache, 'manager'); + $factory = ReflectionHelper::getPrivateMethodInvoker($manager, 'factory'); expect(call_user_func($factory))->toBeAnInstanceOf(Dummy::class); }); }); diff --git a/spec/system/framework/Cli/Commands/TranslationsFinder.spec.php b/spec/system/framework/Cli/Commands/TranslationsFinder.spec.php index 5e7cb359..4372131f 100644 --- a/spec/system/framework/Cli/Commands/TranslationsFinder.spec.php +++ b/spec/system/framework/Cli/Commands/TranslationsFinder.spec.php @@ -14,7 +14,7 @@ use function Kahlan\expect; -describe('Commandes / TranslationsFinder', function (): void { +xdescribe('Commandes / TranslationsFinder', function (): void { afterEach(function (): void { COH::tearDown(); diff --git a/src/Cli/Console/Command.php b/src/Cli/Console/Command.php index 73e70997..aad5c1ff 100644 --- a/src/Cli/Console/Command.php +++ b/src/Cli/Console/Command.php @@ -665,8 +665,19 @@ public function __isset(string $key): bool * * @return void */ - private function initProps() + protected function initProps() { + if (! is_cli()) { + if (! file_exists($in = TEMP_PATH . 'cli_input')) { + file_put_contents($in, '', LOCK_EX); + } + if (! file_exists($ou = TEMP_PATH . 'cli_output')) { + file_put_contents($ou, '', LOCK_EX); + } + + $this->app->io(new Interactor($in, $ou)); + } + $this->io = $this->app->io(); $this->writer = $this->io->writer(); $this->reader = $this->io->reader();