Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add support for PHP 7.3 #930

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand All @@ -425,7 +426,6 @@ jobs:

dependencies:
- "lowest"
- "locked"
- "highest"

steps:
Expand Down Expand Up @@ -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/[email protected]"
with:
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions src/Construct.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@

final class Construct
{
private string $name;
/**
* @var string
*/
private $name;

/**
* @var list<string>
*/
private array $fileNames = [];
private $fileNames = [];

private function __construct(string $name)
{
Expand Down
5 changes: 4 additions & 1 deletion src/Exception/DirectoryDoesNotExist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/MultipleDefinitionsFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class MultipleDefinitionsFound extends \RuntimeException implements Except
/**
* @var list<Construct>
*/
private array $constructs = [];
private $constructs = [];

/**
* Returns a new exception from constructs.
Expand Down
107 changes: 107 additions & 0 deletions test/DataProvider/Php73.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2017-2024 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/classy
*/

namespace Ergebnis\Classy\Test\DataProvider;

use Ergebnis\Classy\Construct;
use Ergebnis\Classy\Test;

final class Php73
{
/**
* @return \Generator<string, array{0: Test\Util\Scenario}>
*/
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,
];
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithMethodsNamedAfterKeywords;

class Foo
{
public function class()
{
}

public function interface()
{
}

public function trait()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithMethodsNamedAfterKeywordsAndReturnType;


class Foo
{
public function class(): string
{
return '';
}

public function interface(): string
{
return '';
}

public function trait(): string
{
return '';
}
}
19 changes: 19 additions & 0 deletions test/Fixture/Classy/Php73/WithinMultipleNamespaces/source.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Foo;
{
class Foo {}

interface Bar {}

trait Baz {}
}

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Bar;
{
class Foo {}

interface Bar {}

trait Baz {}
}
9 changes: 9 additions & 0 deletions test/Fixture/Classy/Php73/WithinNamespace/source.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithinNamespace;

class Foo {}

interface Bar {}

trait Baz {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithinNamespaceAndMultiLineComments;

/* foo */ class /* bar */ Foo /* baz */ {}

/* foo */ interface /* bar */ Bar /* baz */ {}

/* foo */ trait /* bar */ Baz /* baz */ {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithinNamespaceAndShellStyleComments;

class # foo
Foo # bar
{}

interface # foo
Bar # bar
{}

trait # foo
Baz // bar
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithinNamespaceAndSingleLineComments;

class // foo
Foo // bar
{}

interface // foo
Bar // bar
{}

trait // foo
Baz // bar
{}
10 changes: 10 additions & 0 deletions test/Fixture/Classy/Php73/WithinNamespaceWithBraces/source.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Ergebnis\Classy\Test\Fixture\Classy\Php73\WithinNamespaceWithBraces
{
class Foo {}

interface Bar {}

trait Baz {}
}
Loading
Loading