diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 0a1c596..0c4b668 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -17,7 +17,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.2' coverage: none - name: Install composer dependencies diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8fb59ff..4ba9787 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,18 +13,9 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest] - php: [8.0, 8.1] - laravel: [8.*, 9.*] + php: [8.2] + laravel: [9.*] stability: [prefer-stable] - include: - - laravel: 8.* - testbench: ^6.23 - - laravel: 9.* - testbench: ^7.0 - exclude: - - os: windows-latest - laravel: 9.* - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -46,7 +37,6 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests diff --git a/composer.json b/composer.json index c79d2dc..6b194e4 100644 --- a/composer.json +++ b/composer.json @@ -16,21 +16,21 @@ } ], "require": { - "php": "^8.0|^8.1", - "illuminate/contracts": "^8.80 || ^9.0", - "nikic/php-parser": "^4.13", - "nunomaduro/termwind": "^1.10", - "spatie/laravel-package-tools": "^1.9.2", - "thecodingmachine/safe": "^2.1" + "php": "^8.2", + "illuminate/contracts": "^9.46", + "nikic/php-parser": "^4.15", + "nunomaduro/termwind": "^1.15", + "spatie/laravel-package-tools": "^1.13.8", + "thecodingmachine/safe": "^2.4" }, "require-dev": { - "nunomaduro/collision": "^5.10 || ^6.0", - "nunomaduro/larastan": "^1.0 || ^2.0", - "orchestra/testbench": "^6.24 || ^7.0", - "pestphp/pest": "^1.21", - "pestphp/pest-plugin-laravel": "^1.2", - "spatie/laravel-ray": "^1.26", - "worksome/coding-style": "^0.11.0" + "nunomaduro/collision": "^6.4", + "nunomaduro/larastan": "^2.3.4", + "orchestra/testbench": "^7.17", + "pestphp/pest": "^1.22", + "pestphp/pest-plugin-laravel": "^1.3", + "spatie/laravel-ray": "^1.31", + "worksome/coding-style": "^2.3.2" }, "autoload": { "psr-4": { @@ -44,11 +44,11 @@ } }, "scripts": { - "lint": "vendor/bin/phpcbf", + "lint": "vendor/bin/ecs --fix", "test:unit": "vendor/bin/pest", "test:coverage": "vendor/bin/pest --coverage --min=95", "test:types": "vendor/bin/phpstan analyse", - "test:style": "vendor/bin/phpcs -n", + "test:style": "vendor/bin/ecs", "test": [ "@test:style", "@test:types", diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..1916269 --- /dev/null +++ b/ecs.php @@ -0,0 +1,17 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + __DIR__ . '/config', + ]); + + WorksomeEcsConfig::setup($ecsConfig); +}; diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 85659cb..0000000 --- a/phpcs.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - Worksome Coding Standard - - ./src - ./tests - ./config - - - - - - - - - .*Test.php - - - - - - - - - */*.blade.php - - - - - - - diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..e1706e6 --- /dev/null +++ b/rector.php @@ -0,0 +1,23 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]); + + // Define extra rule sets to be applied + $rectorConfig->sets([ + // SetList::DEAD_CODE, + ]); + + // Register extra a single rules + // $rectorConfig->rule(ClassOnObjectRector::class); +}; diff --git a/src/Actions/AddEnvironmentVariablesToList.php b/src/Actions/AddEnvironmentVariablesToList.php index 31dc88d..c4848c5 100644 --- a/src/Actions/AddEnvironmentVariablesToList.php +++ b/src/Actions/AddEnvironmentVariablesToList.php @@ -16,8 +16,8 @@ use Worksome\Envy\Exceptions\ConfigFileNotFoundException; use Worksome\Envy\Support\PhpParser\AppendEnvironmentVariablesNodeVisitor; -use function Safe\file_put_contents; use function Safe\file_get_contents; +use function Safe\file_put_contents; final class AddEnvironmentVariablesToList implements AddsEnvironmentVariablesToList { diff --git a/src/Actions/FilterEnvironmentCalls.php b/src/Actions/FilterEnvironmentCalls.php index f2e132b..5e89569 100644 --- a/src/Actions/FilterEnvironmentCalls.php +++ b/src/Actions/FilterEnvironmentCalls.php @@ -26,7 +26,9 @@ public function __construct( public function __invoke(string $filePath, Collection $environmentCalls): Collection { - $existingKeys = ($this->readEnvironmentFile)($filePath)->map(fn(EnvironmentVariable $variable) => $variable->getKey()); + $existingKeys = ($this->readEnvironmentFile)($filePath)->map( + fn(EnvironmentVariable $variable) => $variable->getKey() + ); return $environmentCalls ->unique(fn(EnvironmentCall $call) => $call->getKey()) diff --git a/src/Actions/FindEnvironmentCalls.php b/src/Actions/FindEnvironmentCalls.php index 512e59e..285eb6c 100644 --- a/src/Actions/FindEnvironmentCalls.php +++ b/src/Actions/FindEnvironmentCalls.php @@ -39,7 +39,9 @@ public function __invoke(string $filePath, bool $excludeVariablesWithDefaults = ->getEnvironmentVariables() ->when( $excludeVariablesWithDefaults, - fn (Collection $variables) => $variables->reject(fn (EnvironmentCall $variable) => $variable->getDefault() !== null) + fn (Collection $variables) => $variables->reject( + fn (EnvironmentCall $variable) => $variable->getDefault() !== null + ) ); } } diff --git a/src/Actions/FindEnvironmentVariablesToPrune.php b/src/Actions/FindEnvironmentVariablesToPrune.php index 7c9e247..2069404 100644 --- a/src/Actions/FindEnvironmentVariablesToPrune.php +++ b/src/Actions/FindEnvironmentVariablesToPrune.php @@ -26,7 +26,9 @@ public function __construct( public function __invoke(string $filePath, Collection $environmentCalls): Collection { - $variablesInEnvironmentCalls = $environmentCalls->map(fn(EnvironmentCall $environmentCall) => $environmentCall->getKey()); + $variablesInEnvironmentCalls = $environmentCalls->map( + fn(EnvironmentCall $environmentCall) => $environmentCall->getKey() + ); return $this->environmentVariables($filePath) ->diff($variablesInEnvironmentCalls) diff --git a/src/Actions/PruneEnvironmentFile.php b/src/Actions/PruneEnvironmentFile.php index 09a5e92..b5e752a 100644 --- a/src/Actions/PruneEnvironmentFile.php +++ b/src/Actions/PruneEnvironmentFile.php @@ -8,8 +8,8 @@ use Worksome\Envy\Contracts\Actions\PrunesEnvironmentFile; use function Safe\file_get_contents; -use function Safe\preg_replace; use function Safe\file_put_contents; +use function Safe\preg_replace; final class PruneEnvironmentFile implements PrunesEnvironmentFile { diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index 1f4b56f..7e5deb5 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -19,7 +19,9 @@ public function handle(): int { $this->call('vendor:publish', ['--tag' => 'envy-config']); - $this->information('Alright, Envy is ready to rock! Get started with either `php artisan envy:sync` or `php artisan envy:prune`.'); + $this->information( + 'Alright, Envy is ready to rock! Get started with either `php artisan envy:sync` or `php artisan envy:prune`.' + ); return self::SUCCESS; } diff --git a/src/Commands/PruneCommand.php b/src/Commands/PruneCommand.php index 0d03718..1e932a4 100644 --- a/src/Commands/PruneCommand.php +++ b/src/Commands/PruneCommand.php @@ -63,6 +63,7 @@ public function handle(Envy $envy): int /** * @return Collection> + * * @throws EnvironmentFileNotFoundException */ private function getPendingPrunes(Envy $envy): Collection diff --git a/src/Commands/SyncCommand.php b/src/Commands/SyncCommand.php index 115b899..796d5dc 100644 --- a/src/Commands/SyncCommand.php +++ b/src/Commands/SyncCommand.php @@ -65,6 +65,7 @@ public function handle(Envy $envy, Repository $config): int /** * @return Collection> + * * @throws EnvironmentFileNotFoundException */ private function getPendingPrunes(Envy $envy, Repository $config): Collection diff --git a/src/Contracts/Actions/AddsEnvironmentVariablesToList.php b/src/Contracts/Actions/AddsEnvironmentVariablesToList.php index efd0606..8ac5276 100644 --- a/src/Contracts/Actions/AddsEnvironmentVariablesToList.php +++ b/src/Contracts/Actions/AddsEnvironmentVariablesToList.php @@ -18,8 +18,9 @@ interface AddsEnvironmentVariablesToList * Add all given environment variables to the given list key in the envy config. * * @param Collection $updates + * * @throws ConfigFileNotFoundException Thrown when the envy config file hasn't been published. - * @throws InvalidArgumentException Thrown when the envy config file doesn't contain the given key. + * @throws InvalidArgumentException Thrown when the envy config file doesn't contain the given key. */ public function __invoke(Collection $updates, string $listKey): void; } diff --git a/src/Contracts/Actions/FiltersEnvironmentCalls.php b/src/Contracts/Actions/FiltersEnvironmentCalls.php index 011c6f3..d0e59e7 100644 --- a/src/Contracts/Actions/FiltersEnvironmentCalls.php +++ b/src/Contracts/Actions/FiltersEnvironmentCalls.php @@ -12,7 +12,9 @@ interface FiltersEnvironmentCalls { /** * @param Collection $environmentCalls + * * @return Collection + * * @throws EnvironmentFileNotFoundException */ public function __invoke(string $filePath, Collection $environmentCalls): Collection; diff --git a/src/Contracts/Actions/FindsEnvironmentVariablesToPrune.php b/src/Contracts/Actions/FindsEnvironmentVariablesToPrune.php index cce6633..21647a9 100644 --- a/src/Contracts/Actions/FindsEnvironmentVariablesToPrune.php +++ b/src/Contracts/Actions/FindsEnvironmentVariablesToPrune.php @@ -12,7 +12,9 @@ interface FindsEnvironmentVariablesToPrune { /** * @param Collection $environmentCalls + * * @return Collection + * * @throws EnvironmentFileNotFoundException */ public function __invoke(string $filePath, Collection $environmentCalls): Collection; diff --git a/src/Contracts/Actions/ParsesFilterList.php b/src/Contracts/Actions/ParsesFilterList.php index e7902c5..55b5409 100644 --- a/src/Contracts/Actions/ParsesFilterList.php +++ b/src/Contracts/Actions/ParsesFilterList.php @@ -10,6 +10,7 @@ interface ParsesFilterList { /** * @param array $list + * * @return array */ public function __invoke(array $list): array; diff --git a/src/Contracts/Actions/UpdatesEnvironmentFile.php b/src/Contracts/Actions/UpdatesEnvironmentFile.php index d4d4263..523aeaa 100644 --- a/src/Contracts/Actions/UpdatesEnvironmentFile.php +++ b/src/Contracts/Actions/UpdatesEnvironmentFile.php @@ -10,7 +10,7 @@ interface UpdatesEnvironmentFile { /** - * @param string $filePath + * @param string $filePath * @param Collection $environmentCalls */ public function __invoke(string $filePath, Collection $environmentCalls): void; diff --git a/src/Envy.php b/src/Envy.php index 00a424e..48fa416 100755 --- a/src/Envy.php +++ b/src/Envy.php @@ -5,9 +5,9 @@ namespace Worksome\Envy; use Illuminate\Support\Collection; +use Worksome\Envy\Contracts\Actions\AddsEnvironmentVariablesToList; use Worksome\Envy\Contracts\Actions\FiltersEnvironmentCalls; use Worksome\Envy\Contracts\Actions\FindsEnvironmentCalls; -use Worksome\Envy\Contracts\Actions\AddsEnvironmentVariablesToList; use Worksome\Envy\Contracts\Actions\FindsEnvironmentVariablesToPrune; use Worksome\Envy\Contracts\Actions\PrunesEnvironmentFile; use Worksome\Envy\Contracts\Actions\UpdatesEnvironmentFile; @@ -49,8 +49,10 @@ public function environmentCalls(bool $excludeCallsWithDefaults = false): Collec * @see Envy::environmentCalls() * * @param Collection $environmentCalls - * @param array|null $environmentFilePaths + * @param array|null $environmentFilePaths + * * @return Collection> + * * @throws EnvironmentFileNotFoundException */ public function pendingUpdates(Collection $environmentCalls, array|null $environmentFilePaths = null): Collection @@ -81,6 +83,7 @@ public function updateEnvironmentFiles(Collection $pendingUpdates): void * environment variables and update the config exclusions. * * @param Collection> $pendingUpdates + * * @throws Exceptions\ConfigFileNotFoundException */ public function updateExclusionsWithPendingUpdates(Collection $pendingUpdates): void @@ -113,8 +116,10 @@ public function hasPublishedConfigFile(): bool * @see Envy::environmentCalls() * * @param Collection $environmentCalls - * @param array|null $environmentFilePaths + * @param array|null $environmentFilePaths + * * @return Collection> + * * @throws EnvironmentFileNotFoundException */ public function pendingPrunes(Collection $environmentCalls, array|null $environmentFilePaths = null): Collection @@ -147,6 +152,7 @@ public function pruneEnvironmentFiles(Collection $pendingPrunes): void * @see Envy::pendingPrunes() * * @param Collection> $pendingPrunes + * * @throws Exceptions\ConfigFileNotFoundException */ public function updateInclusionsWithPendingPrunes(Collection $pendingPrunes): void diff --git a/src/EnvyServiceProvider.php b/src/EnvyServiceProvider.php index 1f69023..4f75bc6 100644 --- a/src/EnvyServiceProvider.php +++ b/src/EnvyServiceProvider.php @@ -8,6 +8,7 @@ use PhpParser\ParserFactory; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; +use Worksome\Envy\Actions\AddEnvironmentVariablesToList; use Worksome\Envy\Actions\FilterEnvironmentCalls; use Worksome\Envy\Actions\FindEnvironmentCalls; use Worksome\Envy\Actions\FindEnvironmentVariablesToPrune; @@ -15,11 +16,11 @@ use Worksome\Envy\Actions\ParseFilterList; use Worksome\Envy\Actions\PruneEnvironmentFile; use Worksome\Envy\Actions\ReadEnvironmentFile; -use Worksome\Envy\Actions\AddEnvironmentVariablesToList; use Worksome\Envy\Actions\UpdateEnvironmentFile; use Worksome\Envy\Commands\InstallCommand; use Worksome\Envy\Commands\PruneCommand; use Worksome\Envy\Commands\SyncCommand; +use Worksome\Envy\Contracts\Actions\AddsEnvironmentVariablesToList; use Worksome\Envy\Contracts\Actions\FiltersEnvironmentCalls; use Worksome\Envy\Contracts\Actions\FindsEnvironmentCalls; use Worksome\Envy\Contracts\Actions\FindsEnvironmentVariablesToPrune; @@ -27,7 +28,6 @@ use Worksome\Envy\Contracts\Actions\ParsesFilterList; use Worksome\Envy\Contracts\Actions\PrunesEnvironmentFile; use Worksome\Envy\Contracts\Actions\ReadsEnvironmentFile; -use Worksome\Envy\Contracts\Actions\AddsEnvironmentVariablesToList; use Worksome\Envy\Contracts\Actions\UpdatesEnvironmentFile; use Worksome\Envy\Contracts\Finder; use Worksome\Envy\Support\LaravelFinder; @@ -41,26 +41,38 @@ public function packageRegistered(): void $this->config()['environment_files'] ?? [], )); - $this->app->bind(FindsEnvironmentCalls::class, fn(Application $app) => $app->make(FindEnvironmentCalls::class, [ - 'parser' => (new ParserFactory())->create(ParserFactory::PREFER_PHP7), - ])); + $this->app->bind( + FindsEnvironmentCalls::class, + fn(Application $app) => $app->make(FindEnvironmentCalls::class, [ + 'parser' => (new ParserFactory())->create(ParserFactory::PREFER_PHP7), + ]) + ); $this->app->bind(ReadsEnvironmentFile::class, ReadEnvironmentFile::class); $this->app->bind(ParsesFilterList::class, ParseFilterList::class); - $this->app->bind(FiltersEnvironmentCalls::class, fn (Application $app) => $app->make(FilterEnvironmentCalls::class, [ - 'exclusions' => $this->config()['exclusions'] ?? [] - ])); + $this->app->bind( + FiltersEnvironmentCalls::class, + fn (Application $app) => $app->make(FilterEnvironmentCalls::class, [ + 'exclusions' => $this->config()['exclusions'] ?? [] + ]) + ); $this->app->bind(UpdatesEnvironmentFile::class, UpdateEnvironmentFile::class); $this->app->bind(FormatsEnvironmentCall::class, fn() => new FormatEnvironmentCall( $this->config()['display_comments'] ?? false, $this->config()['display_location_hints'] ?? false, $this->config()['display_default_values'] ?? true, )); - $this->app->bind(AddsEnvironmentVariablesToList::class, fn (Application $app) => $app->make(AddEnvironmentVariablesToList::class, [ - 'parser' => (new ParserFactory())->create(ParserFactory::PREFER_PHP7), - ])); - $this->app->bind(FindsEnvironmentVariablesToPrune::class, fn (Application $app) => $app->make(FindEnvironmentVariablesToPrune::class, [ - 'inclusions' => $this->config()['inclusions'] ?? [], - ])); + $this->app->bind( + AddsEnvironmentVariablesToList::class, + fn (Application $app) => $app->make(AddEnvironmentVariablesToList::class, [ + 'parser' => (new ParserFactory())->create(ParserFactory::PREFER_PHP7), + ]) + ); + $this->app->bind( + FindsEnvironmentVariablesToPrune::class, + fn (Application $app) => $app->make(FindEnvironmentVariablesToPrune::class, [ + 'inclusions' => $this->config()['inclusions'] ?? [], + ]) + ); $this->app->bind(PrunesEnvironmentFile::class, PruneEnvironmentFile::class); } diff --git a/src/Support/EnvironmentCall.php b/src/Support/EnvironmentCall.php index 7cbb6e5..588cecc 100644 --- a/src/Support/EnvironmentCall.php +++ b/src/Support/EnvironmentCall.php @@ -7,9 +7,9 @@ final class EnvironmentCall { /** - * @param string $file The file path containing this environment variable - * @param int $line The line number the environment variable was found on - * @param string $key The key used to define the environment variable + * @param string $file The file path containing this environment variable + * @param int $line The line number the environment variable was found on + * @param string $key The key used to define the environment variable * @param string|null $default The default passed to the env call, if given * @param string|null $comment The PHP comment directly above the env call, if given */ diff --git a/src/Support/LaravelFinder.php b/src/Support/LaravelFinder.php index ae2975e..8dcea5d 100644 --- a/src/Support/LaravelFinder.php +++ b/src/Support/LaravelFinder.php @@ -10,7 +10,7 @@ use SplFileInfo; use Worksome\Envy\Contracts\Finder; -final class LaravelFinder implements Finder +final readonly class LaravelFinder implements Finder { /** * @param array $configFiles diff --git a/src/Support/PhpParser/EnvCallNodeVisitor.php b/src/Support/PhpParser/EnvCallNodeVisitor.php index 5071f9a..4f67ace 100644 --- a/src/Support/PhpParser/EnvCallNodeVisitor.php +++ b/src/Support/PhpParser/EnvCallNodeVisitor.php @@ -26,9 +26,8 @@ final class EnvCallNodeVisitor extends NodeVisitorAbstract */ private PrettyPrinterAbstract $printer; - public function __construct(private string $filePath, private bool $excludeVariablesWithDefaults = false) + public function __construct(private readonly string $filePath, private readonly bool $excludeVariablesWithDefaults = false) { - // @phpstan-ignore-next-line $this->environmentVariables = collect(); $this->printer = new Standard(); } diff --git a/tests/Concerns/ResetsTestFiles.php b/tests/Concerns/ResetsTestFiles.php index 7d8ec96..3aff1fb 100644 --- a/tests/Concerns/ResetsTestFiles.php +++ b/tests/Concerns/ResetsTestFiles.php @@ -73,7 +73,7 @@ public function getFilesToReset(): array public function assertFileChanged(string $filePath, Closure $callback = null): self { - if (!key_exists($filePath, $this->fileContents)) { + if (! key_exists($filePath, $this->fileContents)) { throw new BadMethodCallException("The file [{$filePath}] was not configured as a resettable file."); } diff --git a/tests/Pest.php b/tests/Pest.php index 425eca2..ddff1f4 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -5,8 +5,8 @@ use PhpParser\Parser; use PhpParser\ParserFactory; use Worksome\Envy\Actions\ReadEnvironmentFile; -use Worksome\Envy\Tests\Unit; use Worksome\Envy\Tests\Feature; +use Worksome\Envy\Tests\Unit; uses(Feature\TestCase::class)->in(__DIR__ . '/Feature'); uses(Unit\TestCase::class)->in(__DIR__ . '/Unit'); diff --git a/tests/Unit/Actions/AddEnvironmentVariablesToListTest.php b/tests/Unit/Actions/AddEnvironmentVariablesToListTest.php index 31d5460..92466ca 100644 --- a/tests/Unit/Actions/AddEnvironmentVariablesToListTest.php +++ b/tests/Unit/Actions/AddEnvironmentVariablesToListTest.php @@ -29,7 +29,7 @@ })->with([AddsEnvironmentVariablesToList::EXCLUSIONS, AddsEnvironmentVariablesToList::INCLUSIONS]); it('performs no changes if the parser returns null', function (string $list) { - $parser = new class implements Parser { + $parser = new class() implements Parser { public function parse(string $code, ErrorHandler $errorHandler = null) { return null; diff --git a/tests/Unit/Actions/FilterEnvironmentCallsTest.php b/tests/Unit/Actions/FilterEnvironmentCallsTest.php index 81a9006..dda27bd 100644 --- a/tests/Unit/Actions/FilterEnvironmentCallsTest.php +++ b/tests/Unit/Actions/FilterEnvironmentCallsTest.php @@ -49,7 +49,7 @@ }); it('can parse Filters in exclusions', function (bool $variableMatches, int $expectedFilteredCallCount) { - $customFilter = new class ($variableMatches) implements Filter { + $customFilter = new class($variableMatches) implements Filter { public function __construct(private bool $variableMatches) { } diff --git a/tests/Unit/Actions/FindEnvironmentCallsTest.php b/tests/Unit/Actions/FindEnvironmentCallsTest.php index a5230c1..3cc03a8 100644 --- a/tests/Unit/Actions/FindEnvironmentCallsTest.php +++ b/tests/Unit/Actions/FindEnvironmentCallsTest.php @@ -5,15 +5,18 @@ use Worksome\Envy\Actions\FindEnvironmentCalls; use Worksome\Envy\Support\EnvironmentCall; -it('can return a collection of environment variables', function (bool $excludeVariablesWithDefaults, int $expectedCount) { - $action = new FindEnvironmentCalls(defaultPhpParser()); - $variables = $action(__DIR__ . '/../../Application/config/app.php', $excludeVariablesWithDefaults); - - expect($variables) - ->toBeCollection() - ->toHaveCount($expectedCount) - ->each->toBeInstanceOf(EnvironmentCall::class); -})->with([ +it( + 'can return a collection of environment variables', + function (bool $excludeVariablesWithDefaults, int $expectedCount) { + $action = new FindEnvironmentCalls(defaultPhpParser()); + $variables = $action(__DIR__ . '/../../Application/config/app.php', $excludeVariablesWithDefaults); + + expect($variables) + ->toBeCollection() + ->toHaveCount($expectedCount) + ->each->toBeInstanceOf(EnvironmentCall::class); + } +)->with([ 'variables including defaults' => [false, 9], 'variables excluding defaults' => [true, 3], ]); @@ -84,7 +87,7 @@ }); it('returns an empty collection if the parser returns null', function () { - $parser = new class implements Parser { + $parser = new class() implements Parser { public function parse(string $code, ErrorHandler $errorHandler = null) { return null;