-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from koriym/drop_php7x
Drop support for PHP 7.x and optimize for PHP 8
- Loading branch information
Showing
42 changed files
with
544 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,90 @@ | ||
<?xml version="1.0"?> | ||
<ruleset> | ||
<!-- 2. General --> | ||
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/> | ||
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/> | ||
<rule ref="Generic.Strings.UnnecessaryStringConcat"/> | ||
<!-- Include the whole PSR-2 standard --> | ||
<rule ref="PSR2"> | ||
<exclude name="Generic.Files.LineLength"/> | ||
</rule> | ||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/> | ||
<rule ref="PEAR.Commenting.FunctionComment"> | ||
<exclude name="PEAR.Commenting.FunctionComment.MissingReturn"/> | ||
<exclude name="PEAR.Commenting.FunctionComment.MissingParamComment"/> | ||
<exclude name="PEAR.Commenting.FunctionComment.SpacingBeforeTags"/> | ||
<exclude name="PEAR.Commenting.FunctionComment.MissingParamTag"/> | ||
<exclude name="PEAR.Commenting.FunctionComment.Missing"/> | ||
<exclude name="PEAR.Commenting.FunctionComment.ParameterCommentsNotAligned"/> | ||
<ruleset | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
|
||
<arg name="basepath" value="."/> | ||
<arg name="extensions" value="php"/> | ||
<arg name="parallel" value="80"/> | ||
<arg name="cache" value=".phpcs-cache"/> | ||
|
||
<!-- Compatibility with PHP 8.0 --> | ||
<config name="php_version" value="80000"/> | ||
|
||
<!-- Ignore warnings, show progress of the run and show sniff names --> | ||
<arg value="nps"/> | ||
|
||
<!-- Directories to be checked --> | ||
<file>src</file> | ||
<file>tests</file> | ||
<exclude-pattern>*/tests/tmp/*</exclude-pattern> | ||
|
||
<!-- PSR12 Coding Standard --> | ||
<rule ref="PSR12"/> | ||
|
||
<!-- Exclude NativeTypeHintrule from interface and abstract class --> | ||
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"> | ||
<exclude-pattern>*/src/*Interface.php</exclude-pattern> | ||
<exclude-pattern>*/src/Abstract*.php</exclude-pattern> | ||
<exclude-pattern>*/src/ResourceObject.php</exclude-pattern> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"> | ||
<exclude-pattern>*/src/*Interface.php</exclude-pattern> | ||
<exclude-pattern>*/src/Abstract*.php</exclude-pattern> | ||
<exclude-pattern>*/src/ResourceObject.php</exclude-pattern> | ||
</rule> | ||
<!-- Doctrine Coding Standard --> | ||
<rule ref="Doctrine"> | ||
<!-- Inapplicable for this project --> | ||
<!-- Base --> | ||
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame"/> | ||
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/> | ||
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable"/> | ||
<exclude name="SlevomatCodingStandard.Commenting.UselessInheritDocComment.UselessInheritDocComment"/> | ||
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn"/> | ||
<!-- /Base --> | ||
<!-- Option --> | ||
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed"/> | ||
<exclude name="SlevomatCodingStandard.PHP.RequireExplicitAssertion.RequiredExplicitAssertion"/> | ||
<!-- /Option --> | ||
<!-- Exclude Fake files form Doctrine CS --> | ||
<exclude-pattern>*/tests/Fake/*</exclude-pattern> | ||
</rule> | ||
|
||
<!-- Additional Rules --> | ||
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"> | ||
<properties> | ||
<property name="searchAnnotations" value="true"/> | ||
</properties> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing"> | ||
<properties> | ||
<property name="annotationsGroups" type="array"> | ||
<element value="@param, @psalm-param, @phpstan-param"/> | ||
<element value="@return, @psalm-return, @phpstan-return"/> | ||
<element value="@throws"/> | ||
</property> | ||
</properties> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"> | ||
<include-pattern>tests/*</include-pattern> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"> | ||
<properties> | ||
<property name="minLinesCountBeforeWithComment" value="1"/> | ||
<property name="maxLinesCountBeforeWithComment" value="1"/> | ||
<property name="maxLinesCountBeforeWithoutComment" value="0"/> | ||
</properties> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"> | ||
<properties> | ||
<property name="searchAnnotations" value="true"/> | ||
</properties> | ||
</rule> | ||
|
||
<exclude-pattern>*/Fake/*</exclude-pattern> | ||
<exclude-pattern>*/tmp/*</exclude-pattern> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Madapaja\TwigModule\Annotation\TwigDebug; | ||
use Madapaja\TwigModule\Annotation\TwigErrorPath; | ||
use Madapaja\TwigModule\Annotation\TwigLoader; | ||
use Madapaja\TwigModule\Annotation\TwigOptions; | ||
use Madapaja\TwigModule\Annotation\TwigPaths; | ||
use Madapaja\TwigModule\Annotation\TwigRedirectPath; | ||
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; | ||
use Rector\Config\RectorConfig; | ||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; | ||
use Rector\Php80\ValueObject\AnnotationToAttribute; | ||
use Rector\Ray\AnnotationBinding\Rector\ClassMethod\AnnotationBindingRector; | ||
use Rector\Set\ValueObject\LevelSetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->paths([ | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
]); | ||
|
||
// register a single rule | ||
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); | ||
$rectorConfig->rule(AnnotationBindingRector::class); | ||
$rectorConfig->ruleWithConfiguration( | ||
AnnotationToAttributeRector::class, | ||
[ | ||
new AnnotationToAttribute(TwigDebug::class), | ||
new AnnotationToAttribute(TwigErrorPath::class), | ||
new AnnotationToAttribute(TwigLoader::class), | ||
new AnnotationToAttribute(TwigOptions::class), | ||
new AnnotationToAttribute(TwigPaths::class), | ||
new AnnotationToAttribute(TwigRedirectPath::class), | ||
] | ||
); | ||
|
||
// define sets of rules | ||
$rectorConfig->sets([ | ||
LevelSetList::UP_TO_PHP_80 | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Madapaja.TwigModule package. | ||
* | ||
* @license http://opensource.org/licenses/MIT MIT | ||
*/ | ||
|
||
namespace Madapaja\TwigModule\Annotation; | ||
|
||
use Attribute; | ||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; | ||
use Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation; | ||
use Ray\Di\Di\Qualifier; | ||
|
||
/** | ||
* @Annotation | ||
* @Target("METHOD") | ||
* @Qualifier | ||
* @NamedArgumentConstructor() | ||
* @NamedArgumentConstructor | ||
*/ | ||
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER), Qualifier] | ||
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER)] | ||
#[Qualifier] | ||
final class TwigLoader | ||
{ | ||
/** @var string */ | ||
public $value; | ||
|
||
public function __construct(string $value) | ||
public function __construct(public string $value = '') | ||
{ | ||
$this->value = $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.