Skip to content

Commit

Permalink
Merge pull request #482 from ergebnis/feature/php73
Browse files Browse the repository at this point in the history
Enhancement: Use `Php73` rule set
  • Loading branch information
localheinz authored Dec 30, 2021
2 parents 66d64e1 + 44a4e1c commit 6184923
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
__DIR__ . '/LICENSE.md',
License\Range::since(
License\Year::fromString('2017'),
new \DateTimeZone('UTC')
new \DateTimeZone('UTC'),
),
License\Holder::fromString('Andreas Möller'),
License\Url::fromString('https://github.com/ergebnis/classy')
License\Url::fromString('https://github.com/ergebnis/classy'),
);

$license->save();

$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php72($license->header()));
$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php73($license->header()));

$config->getFinder()
->exclude([
Expand Down
10 changes: 5 additions & 5 deletions src/Constructs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function fromSource(string $source): array
try {
$sequence = \token_get_all(
$source,
\TOKEN_PARSE
\TOKEN_PARSE,
);
} catch (\ParseError $exception) {
throw Exception\ParseError::fromParseError($exception);
Expand Down Expand Up @@ -120,7 +120,7 @@ public static function fromSource(string $source): array
\usort($constructs, static function (Construct $a, Construct $b): int {
return \strcmp(
$a->name(),
$b->name()
$b->name(),
);
});

Expand All @@ -143,7 +143,7 @@ public static function fromDirectory(string $directory): array

$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(
$directory,
\RecursiveDirectoryIterator::FOLLOW_SYMLINKS
\RecursiveDirectoryIterator::FOLLOW_SYMLINKS,
));

$constructs = [];
Expand All @@ -169,7 +169,7 @@ public static function fromDirectory(string $directory): array
} catch (Exception\ParseError $exception) {
throw Exception\ParseError::fromFileNameAndParseError(
$fileName,
$exception
$exception,
);
}

Expand All @@ -191,7 +191,7 @@ public static function fromDirectory(string $directory): array
\usort($constructs, static function (Construct $a, Construct $b): int {
return \strcmp(
$a->name(),
$b->name()
$b->name(),
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/DirectoryDoesNotExist.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function fromDirectory(string $directory): self
{
$exception = new self(\sprintf(
'Directory "%s" does not exist.',
$directory
$directory,
));

$exception->directory = $directory;
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/MultipleDefinitionsFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public static function fromConstructs(array $constructs): self
return \sprintf(
' - "%s" defined in "%s"',
$construct->name(),
\implode('", "', $construct->fileNames())
\implode('", "', $construct->fileNames()),
);
}, $constructs))
}, $constructs)),
));

$exception->constructs = $constructs;
Expand Down
6 changes: 3 additions & 3 deletions src/Exception/ParseError.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function fromParseError(\ParseError $exception): self
return new self(
$exception->getMessage(),
0,
$exception
$exception,
);
}

Expand All @@ -32,10 +32,10 @@ public static function fromFileNameAndParseError(
\sprintf(
'A parse error occurred when parsing "%s": "%s".',
$fileName,
$exception->getMessage()
$exception->getMessage(),
),
0,
$exception
$exception,
);
}
}
2 changes: 1 addition & 1 deletion test/Unit/ConstructTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testDefinedInClonesInstanceAndAddsFileNames(): void
return \sprintf(
'%s.%s',
$faker->word(),
$faker->fileExtension()
$faker->fileExtension(),
);
}, \range(0, 5));

Expand Down
56 changes: 28 additions & 28 deletions test/Unit/ConstructsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,37 +74,37 @@ public function provideScenarioWithoutClassyConstructs(): \Generator
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'no-php-file',
__DIR__ . '/../Fixture/NoClassy/NoPhpFile/source.md'
__DIR__ . '/../Fixture/NoClassy/NoPhpFile/source.md',
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'with-anonymous-class',
__DIR__ . '/../Fixture/NoClassy/WithAnonymousClass/source.php'
__DIR__ . '/../Fixture/NoClassy/WithAnonymousClass/source.php',
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'with-anonymous-class-and-multi-line-comments',
__DIR__ . '/../Fixture/NoClassy/WithAnonymousClassAndMultiLineComments/source.php'
__DIR__ . '/../Fixture/NoClassy/WithAnonymousClassAndMultiLineComments/source.php',
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'with-anonymous-class-and-shell-style-comments',
__DIR__ . '/../Fixture/NoClassy/WithAnonymousClassAndShellStyleComments/source.php'
__DIR__ . '/../Fixture/NoClassy/WithAnonymousClassAndShellStyleComments/source.php',
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'with-anonymous-class-and-single-line-comments',
__DIR__ . '/../Fixture/NoClassy/WithAnonymousClassAndSingleLineComments/source.php'
__DIR__ . '/../Fixture/NoClassy/WithAnonymousClassAndSingleLineComments/source.php',
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'with-class-keyword',
__DIR__ . '/../Fixture/NoClassy/WithClassKeyword/source.php'
__DIR__ . '/../Fixture/NoClassy/WithClassKeyword/source.php',
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'with-nothing',
__DIR__ . '/../Fixture/NoClassy/WithNothing/source.php'
__DIR__ . '/../Fixture/NoClassy/WithNothing/source.php',
),
];

Expand Down Expand Up @@ -257,7 +257,7 @@ private static function scenariosWithClassyConstructs(): array
__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)
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespace\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(80100),
Expand All @@ -266,39 +266,39 @@ private static function scenariosWithClassyConstructs(): array
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespace\Bar::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespace\Baz::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespace\Foo::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespace\Qux::class)
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespace\Qux::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'php73-within-namespace-and-shell-style-comments',
__DIR__ . '/../Fixture/Classy/Php73/WithinNamespaceAndShellStyleComments/source.php',
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndShellStyleComments\Bar::class),
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndShellStyleComments\Baz::class),
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndShellStyleComments\Foo::class)
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndShellStyleComments\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'php73-within-namespace-and-single-line-comments',
__DIR__ . '/../Fixture/Classy/Php73/WithinNamespaceAndSingleLineComments/source.php',
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndSingleLineComments\Bar::class),
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndSingleLineComments\Baz::class),
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndSingleLineComments\Foo::class)
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndSingleLineComments\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'php73-within-namespace-and-multi-line-comments',
__DIR__ . '/../Fixture/Classy/Php73/WithinNamespaceAndMultiLineComments/source.php',
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndMultiLineComments\Bar::class),
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndMultiLineComments\Baz::class),
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndMultiLineComments\Foo::class)
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceAndMultiLineComments\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'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)
Construct::fromName(Test\Fixture\Classy\Php73\WithinNamespaceWithBraces\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(80100),
Expand All @@ -307,7 +307,7 @@ private static function scenariosWithClassyConstructs(): array
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespaceWithBraces\Bar::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespaceWithBraces\Baz::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespaceWithBraces\Foo::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespaceWithBraces\Qux::class)
Construct::fromName(Test\Fixture\Classy\Php81\WithinNamespaceWithBraces\Qux::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
Expand All @@ -318,7 +318,7 @@ private static function scenariosWithClassyConstructs(): array
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)
Construct::fromName(Test\Fixture\Classy\Php73\WithinMultipleNamespaces\Foo\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(80100),
Expand All @@ -331,15 +331,15 @@ private static function scenariosWithClassyConstructs(): array
Construct::fromName(Test\Fixture\Classy\Php81\WithinMultipleNamespaces\Foo\Bar::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinMultipleNamespaces\Foo\Baz::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinMultipleNamespaces\Foo\Foo::class),
Construct::fromName(Test\Fixture\Classy\Php81\WithinMultipleNamespaces\Foo\Qux::class)
Construct::fromName(Test\Fixture\Classy\Php81\WithinMultipleNamespaces\Foo\Qux::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'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')
Construct::fromName('Ergebnis\\Foo'),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(80100),
Expand All @@ -348,19 +348,19 @@ private static function scenariosWithClassyConstructs(): array
Construct::fromName('Ergebnis\\Bar'),
Construct::fromName('Ergebnis\\Baz'),
Construct::fromName('Ergebnis\\Foo'),
Construct::fromName('Ergebnis\\Qux')
Construct::fromName('Ergebnis\\Qux'),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'php73-with-methods-named-after-keywords',
__DIR__ . '/../Fixture/Classy/Php73/WithMethodsNamedAfterKeywords/source.php',
Construct::fromName(Test\Fixture\Classy\Php73\WithMethodsNamedAfterKeywords\Foo::class)
Construct::fromName(Test\Fixture\Classy\Php73\WithMethodsNamedAfterKeywords\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(80100),
'php81-with-methods-named-after-keywords',
__DIR__ . '/../Fixture/Classy/Php81/WithMethodsNamedAfterKeywords/source.php',
Construct::fromName(Test\Fixture\Classy\Php81\WithMethodsNamedAfterKeywords\Foo::class)
Construct::fromName(Test\Fixture\Classy\Php81\WithMethodsNamedAfterKeywords\Foo::class),
),
/**
* @see https://github.com/zendframework/zend-file/pull/41
Expand All @@ -369,21 +369,21 @@ private static function scenariosWithClassyConstructs(): array
Test\Util\PhpVersion::fromInt(70300),
'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)
Construct::fromName(Test\Fixture\Classy\Php73\WithMethodsNamedAfterKeywordsAndReturnType\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(80100),
'php81-with-methods-named-after-keywords-and-return-type',
__DIR__ . '/../Fixture/Classy/Php81/WithMethodsNamedAfterKeywordsAndReturnType/source.php',
Construct::fromName(Test\Fixture\Classy\Php81\WithMethodsNamedAfterKeywordsAndReturnType\Foo::class)
Construct::fromName(Test\Fixture\Classy\Php81\WithMethodsNamedAfterKeywordsAndReturnType\Foo::class),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'php73-without-namespace',
__DIR__ . '/../Fixture/Classy/Php73/WithoutNamespace/source.php',
Construct::fromName('Bar'),
Construct::fromName('Baz'),
Construct::fromName('Foo')
Construct::fromName('Foo'),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(80100),
Expand All @@ -392,31 +392,31 @@ private static function scenariosWithClassyConstructs(): array
Construct::fromName('Bar'),
Construct::fromName('Baz'),
Construct::fromName('Foo'),
Construct::fromName('Qux')
Construct::fromName('Qux'),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'php73-without-namespace-and-multi-line-comments',
__DIR__ . '/../Fixture/Classy/Php73/WithoutNamespaceAndMultiLineComments/source.php',
Construct::fromName('Quux'),
Construct::fromName('Quuz'),
Construct::fromName('Qux')
Construct::fromName('Qux'),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'php73-without-namespace-and-shell-line-comments',
__DIR__ . '/../Fixture/Classy/Php73/WithoutNamespaceAndShellStyleComments/source.php',
Construct::fromName('Corge'),
Construct::fromName('Garply'),
Construct::fromName('Grault')
Construct::fromName('Grault'),
),
Test\Util\Scenario::create(
Test\Util\PhpVersion::fromInt(70300),
'php73-without-namespace-and-single-line-comments',
__DIR__ . '/../Fixture/Classy/Php73/WithoutNamespaceAndSingleLineComments/source.php',
Construct::fromName('Fred'),
Construct::fromName('Plugh'),
Construct::fromName('Waldo')
Construct::fromName('Waldo'),
),
];
}
Expand All @@ -428,7 +428,7 @@ private static function realPath(string $path): string
if (!\is_string($resolved)) {
throw new \RuntimeException(\sprintf(
'Failed resolving the real path of "%s".',
$path
$path,
));
}

Expand Down
2 changes: 1 addition & 1 deletion test/Unit/Exception/DirectoryDoesNotExistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testFromDirectoryReturnsException(): void

$message = \sprintf(
'Directory "%s" does not exist.',
$directory
$directory,
);

self::assertSame($message, $exception->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/Exception/MultipleDefinitionsFoundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testFromConstructsReturnsException(): void
$message = \sprintf(
$format,
$name,
\implode('", "', $fileNames)
\implode('", "', $fileNames),
);

self::assertSame($message, $exception->getMessage());
Expand Down
4 changes: 2 additions & 2 deletions test/Unit/Exception/ParseErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public function testFromFileNameAndParseErrorReturnsException(): void

$exception = Exception\ParseError::fromFileNameAndParseError(
$fileName,
$parseError
$parseError,
);

$expectedMessage = \sprintf(
'A parse error occurred when parsing "%s": "%s".',
$fileName,
$parseError->getMessage()
$parseError->getMessage(),
);

self::assertSame($expectedMessage, $exception->getMessage());
Expand Down
Loading

0 comments on commit 6184923

Please sign in to comment.