diff --git a/.github/settings.yml b/.github/settings.yml index c1da6d10..142203fd 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -21,20 +21,17 @@ branches: - context: "Refactoring (7.4, locked)" - context: "Security Analysis (7.4, locked)" - context: "Static Code Analysis (7.4, locked)" + - context: "Tests (7.3, highest)" + - context: "Tests (7.3, lowest)" - context: "Tests (7.4, highest)" - - context: "Tests (7.4, locked)" - context: "Tests (7.4, lowest)" - context: "Tests (8.0, highest)" - - context: "Tests (8.0, locked)" - context: "Tests (8.0, lowest)" - context: "Tests (8.1, highest)" - - context: "Tests (8.1, locked)" - context: "Tests (8.1, lowest)" - context: "Tests (8.2, highest)" - - context: "Tests (8.2, locked)" - context: "Tests (8.2, lowest)" - context: "Tests (8.3, highest)" - - context: "Tests (8.3, locked)" - context: "Tests (8.3, lowest)" strict: false restrictions: diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 96519fd7..c09d8245 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -417,6 +417,7 @@ jobs: fail-fast: false matrix: php-version: + - "7.3" - "7.4" - "8.0" - "8.1" @@ -425,7 +426,6 @@ jobs: dependencies: - "lowest" - - "locked" - "highest" steps: @@ -458,10 +458,18 @@ jobs: key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" + - name: "Remove incompatible dependencies with composer" + if: "matrix.dependencies != 'locked'" + run: "composer remove ergebnis/composer-normalize ergebnis/license ergebnis/php-cs-fixer-config infection/infection psalm/plugin-phpunit rector/rector vimeo/psalm --ansi --dev --no-interaction --no-progress" + - name: "Remove platform configuration with composer" if: "matrix.dependencies != 'locked'" run: "composer config platform.php --ansi --unset" + - name: "Require fakerphp/faker:^1.20.0" + if: "matrix.dependencies != 'locked' && matrix.php-version == '7.3'" + run: "composer require fakerphp/faker:^1.20.0 --ansi --no-interaction --no-progress --update-with-all-dependencies" + - name: "Install ${{ matrix.dependencies }} dependencies with composer" uses: "ergebnis/.github/actions/composer/install@1.9.2" with: diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 1df0b7af..e668fdda 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -26,7 +26,7 @@ $license->save(); -$ruleSet = PhpCsFixer\Config\RuleSet\Php74::create()->withHeader($license->header()); +$ruleSet = PhpCsFixer\Config\RuleSet\Php73::create()->withHeader($license->header()); $config = PhpCsFixer\Config\Factory::fromRuleSet($ruleSet); diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a9d3a4..ba17cb48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ For a full diff see [`1.6.0...main`][1.6.0...main]. - Added support for PHP 8.0 ([#926]), by [@localheinz] - Added support for PHP 7.4 ([#929]), by [@localheinz] +- Added support for PHP 7.3 ([#930]), by [@localheinz] ## [`1.6.0`][1.6.0] @@ -187,6 +188,7 @@ For a full diff see [`0.4.0...0.5.0`][0.4.0...0.5.0]. [#795]: https://github.com/ergebnis/classy/pull/795 [#926]: https://github.com/ergebnis/classy/pull/926 [#929]: https://github.com/ergebnis/classy/pull/929 +[#930]: https://github.com/ergebnis/classy/pull/930 [@ergebnis]: https://github.com/ergebnis [@localheinz]: https://github.com/localheinz diff --git a/composer.json b/composer.json index d9857e00..d08ee507 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "source": "https://github.com/ergebnis/classy" }, "require": { - "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "php": "~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", "ext-tokenizer": "*" }, "require-dev": { diff --git a/composer.lock b/composer.lock index c01b301c..bd49bf85 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5de42436143393349399122a85f23795", + "content-hash": "a74f17b24e3c6b404571f86fda992d35", "packages": [], "packages-dev": [ { @@ -7068,7 +7068,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "php": "~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", "ext-tokenizer": "*" }, "platform-dev": [], diff --git a/rector.php b/rector.php index 5c368d77..6772dbc2 100644 --- a/rector.php +++ b/rector.php @@ -26,7 +26,7 @@ __DIR__ . '/test/Util/', ]); - $rectorConfig->phpVersion(ValueObject\PhpVersion::PHP_74); + $rectorConfig->phpVersion(ValueObject\PhpVersion::PHP_73); $rectorConfig->sets([ PHPUnit\Set\PHPUnitSetList::PHPUNIT_90, diff --git a/src/Construct.php b/src/Construct.php index 0f703dca..4a9e6190 100644 --- a/src/Construct.php +++ b/src/Construct.php @@ -15,12 +15,15 @@ final class Construct { - private string $name; + /** + * @var string + */ + private $name; /** * @var list */ - private array $fileNames = []; + private $fileNames = []; private function __construct(string $name) { diff --git a/src/Exception/DirectoryDoesNotExist.php b/src/Exception/DirectoryDoesNotExist.php index 673484c4..6980a346 100644 --- a/src/Exception/DirectoryDoesNotExist.php +++ b/src/Exception/DirectoryDoesNotExist.php @@ -15,7 +15,10 @@ final class DirectoryDoesNotExist extends \InvalidArgumentException implements ExceptionInterface { - private string $directory = ''; + /** + * @var string + */ + private $directory = ''; /** * Returns a new exception from a directory. diff --git a/src/Exception/MultipleDefinitionsFound.php b/src/Exception/MultipleDefinitionsFound.php index 89afe02c..46403e30 100644 --- a/src/Exception/MultipleDefinitionsFound.php +++ b/src/Exception/MultipleDefinitionsFound.php @@ -20,7 +20,7 @@ final class MultipleDefinitionsFound extends \RuntimeException implements Except /** * @var list */ - private array $constructs = []; + private $constructs = []; /** * Returns a new exception from constructs. diff --git a/test/DataProvider/Php73.php b/test/DataProvider/Php73.php new file mode 100644 index 00000000..b7200668 --- /dev/null +++ b/test/DataProvider/Php73.php @@ -0,0 +1,107 @@ + + */ + public static function classyConstructs(): \Generator + { + $scenarios = [ + Test\Util\Scenario::create( + 'php73-within-namespace', + __DIR__ . '/../Fixture/Classy/Php73/WithinNamespace/source.php', + Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespace\Bar::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespace\Baz::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespace\Foo::class), + ), + Test\Util\Scenario::create( + 'php73-within-namespace-with-braces', + __DIR__ . '/../Fixture/Classy/Php73/WithinNamespaceWithBraces/source.php', + Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceWithBraces\Bar::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceWithBraces\Baz::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceWithBraces\Foo::class), + ), + Test\Util\Scenario::create( + 'php73-within-multiple-namespaces-with-braces', + __DIR__ . '/../Fixture/Classy/Php73/WithinMultipleNamespaces/source.php', + Construct::fromName(Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Bar\Bar::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Bar\Baz::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Bar\Foo::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Foo\Bar::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Foo\Baz::class), + Construct::fromName(Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Foo\Foo::class), + ), + Test\Util\Scenario::create( + 'php73-within-namespace-with-single-segment', + __DIR__ . '/../Fixture/Classy/Php73/WithinNamespaceWithSingleSegment/source.php', + Construct::fromName('Ergebnis\\Bar'), + Construct::fromName('Ergebnis\\Baz'), + Construct::fromName('Ergebnis\\Foo'), + ), + Test\Util\Scenario::create( + 'php73-with-methods-named-after-keywords', + __DIR__ . '/../Fixture/Classy/Php73/WithMethodsNamedAfterKeywords/source.php', + Construct::fromName(Test\Fixture\Classy\Php73\WithMethodsNamedAfterKeywords\Foo::class), + ), + /** + * @see https://github.com/zendframework/zend-file/pull/41 + */ + Test\Util\Scenario::create( + 'php73-with-methods-named-after-keywords-and-return-type', + __DIR__ . '/../Fixture/Classy/Php73/WithMethodsNamedAfterKeywordsAndReturnType/source.php', + Construct::fromName(Test\Fixture\Classy\Php73\WithMethodsNamedAfterKeywordsAndReturnType\Foo::class), + ), + Test\Util\Scenario::create( + 'php73-without-namespace', + __DIR__ . '/../Fixture/Classy/Php73/WithoutNamespace/source.php', + Construct::fromName('Bar'), + Construct::fromName('Baz'), + Construct::fromName('Foo'), + ), + Test\Util\Scenario::create( + 'php73-without-namespace-and-multi-line-comments', + __DIR__ . '/../Fixture/Classy/Php73/WithoutNamespaceAndMultiLineComments/source.php', + Construct::fromName('Bar'), + Construct::fromName('Baz'), + Construct::fromName('Foo'), + ), + Test\Util\Scenario::create( + 'php73-without-namespace-and-shell-line-comments', + __DIR__ . '/../Fixture/Classy/Php73/WithoutNamespaceAndShellStyleComments/source.php', + Construct::fromName('Bar'), + Construct::fromName('Baz'), + Construct::fromName('Foo'), + ), + Test\Util\Scenario::create( + 'php73-without-namespace-and-single-line-comments', + __DIR__ . '/../Fixture/Classy/Php73/WithoutNamespaceAndSingleLineComments/source.php', + Construct::fromName('Bar'), + Construct::fromName('Baz'), + Construct::fromName('Foo'), + ), + ]; + + foreach ($scenarios as $scenario) { + yield $scenario->description() => [ + $scenario, + ]; + } + } +} diff --git a/test/Fixture/Classy/Php73/WithMethodsNamedAfterKeywords/source.php b/test/Fixture/Classy/Php73/WithMethodsNamedAfterKeywords/source.php new file mode 100644 index 00000000..4f43b5ac --- /dev/null +++ b/test/Fixture/Classy/Php73/WithMethodsNamedAfterKeywords/source.php @@ -0,0 +1,18 @@ +source()); + + $expected = \array_map(static function (Construct $construct): Construct { + return Construct::fromName($construct->name()); + }, $scenario->constructsSortedByName()); + + self::assertIsList($constructs); + self::assertEquals($expected, $constructs); + } + /** * @dataProvider \Ergebnis\Classy\Test\DataProvider\Php74::classyConstructs() * @@ -178,6 +198,19 @@ public function testFromDirectoryReturnsEmptyArrayWhenNoClassyConstructsHaveBeen self::assertSame([], $constructs); } + /** + * @dataProvider \Ergebnis\Classy\Test\DataProvider\Php73::classyConstructs() + * + * @requires PHP 7.3 + */ + public function testFromDirectoryReturnsListOfClassyConstructsOnPhp73(Test\Util\Scenario $scenario): void + { + $constructs = Constructs::fromDirectory($scenario->directory()); + + self::assertIsList($constructs); + self::assertEquals($scenario->constructsSortedByName(), $constructs); + } + /** * @dataProvider \Ergebnis\Classy\Test\DataProvider\Php74::classyConstructs() * diff --git a/test/Util/Scenario.php b/test/Util/Scenario.php index 96ed063a..973d3069 100644 --- a/test/Util/Scenario.php +++ b/test/Util/Scenario.php @@ -17,14 +17,25 @@ final class Scenario { - private string $description; - private string $fileName; - private string $source; + /** + * @var string + */ + private $description; + + /** + * @var string + */ + private $fileName; + + /** + * @var string + */ + private $source; /** * @var list */ - private array $constructs; + private $constructs; private function __construct( string $description,