Last active
May 8, 2024 14:17
-
-
Save burus86/0447ece9a3068e1cc0c10d2f39cc8a89 to your computer and use it in GitHub Desktop.
Interesting tools for new PHP projects: Rector, Easy Coding Standard, PHPStan, PHPUnit, ...
This file contains hidden or 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 is for unifying the coding style for different editors and IDEs. | |
| ; More information at https://editorconfig.org | |
| root = true | |
| [*] | |
| charset = utf-8 | |
| end_of_line = lf | |
| insert_final_newline = true | |
| indent_size = 4 | |
| indent_style = space | |
| trim_trailing_whitespace = true | |
| [*.php] | |
| max_line_length = 120 | |
| [*.md] | |
| trim_trailing_whitespace = false | |
| [*.{yml, yaml}] | |
| indent_size = 2 |
This file contains hidden or 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
| * text=auto | |
| /.github export-ignore | |
| /docs export-ignore | |
| /tests export-ignore | |
| /.editorconfig export-ignore | |
| /.gitattributes export-ignore | |
| /.gitignore export-ignore | |
| /ecs.php export-ignore | |
| /phpstan.neon export-ignore | |
| /phpunit.xml export-ignore | |
| /rector.php export-ignore |
This file contains hidden or 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
| /vendor | |
| .idea | |
| .phpunit.result.cache |
This file contains hidden or 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
| ## see https://github.com/qossmic/deptrac | |
| parameters: | |
| paths: | |
| - ./src | |
| exclude_files: | |
| - .*tests.* | |
| layers: | |
| - name: DomainVendor | |
| collectors: | |
| - type: className | |
| regex: Carbon\\Carbon | |
| - type: className | |
| regex: Doctrine\\Common\\Collections\\(ArrayCollection|Collection|Criteria|Expr) | |
| - type: className | |
| regex: Symfony\\Component\\Uid\\Uuid | |
| - type: className | |
| regex: Psr\\Cache | |
| - name: Vendor | |
| collectors: | |
| - type: className | |
| regex: ^Symfony\\(?!(Component\\Uid\\Uuid)) | |
| - type: className | |
| regex: ^Doctrine\\(Bundle|Common\\EventSubscriber|DBAL|ORM|Persistence) | |
| - type: className | |
| regex: Monolog\\(Handler\\*|Logger) | |
| - name: SharedDomain | |
| collectors: | |
| - type: className | |
| regex: .*App\\Shared\\Domain\\.* | |
| - name: SharedApplication | |
| collectors: | |
| - type: className | |
| regex: .*App\\Shared\\Application\\.* | |
| - name: SharedInfrastructure | |
| collectors: | |
| - type: className | |
| regex: .*App\\Shared\\Infrastructure\\.* | |
| - name: CoreDomain | |
| collectors: | |
| - type: className | |
| regex: .*App\\Core\\Domain\\.* | |
| - name: CoreApplication | |
| collectors: | |
| - type: className | |
| regex: .*App\\Core\\Application\\.* | |
| - name: CoreInfrastructure | |
| collectors: | |
| - type: className | |
| regex: .*App\\Core\\Infrastructure\\.* | |
| ruleset: | |
| SharedDomain: | |
| - DomainVendor | |
| SharedApplication: | |
| - SharedDomain | |
| SharedInfrastructure: | |
| - SharedDomain | |
| - SharedApplication | |
| - Vendor | |
| CoreDomain: | |
| - DomainVendor | |
| - SharedDomain | |
| CoreApplication: | |
| - SharedDomain | |
| - SharedApplication | |
| - CoreDomain | |
| CoreInfrastructure: | |
| - SharedDomain | |
| - SharedApplication | |
| - SharedInfrastructure | |
| - CoreDomain | |
| - CoreApplication | |
| - Vendor | |
| formatters: | |
| graphviz: | |
| hidden_layers: [] | |
| groups: | |
| Vendor: | |
| - DomainVendor | |
| - Vendor | |
| Shared: | |
| - SharedDomain | |
| - SharedApplication | |
| - SharedInfrastructure | |
| Core: | |
| - CoreDomain | |
| - CoreApplication | |
| - CoreInfrastructure | |
| point_to_groups: true |
This file contains hidden or 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
| <?php | |
| declare(strict_types=1); | |
| use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer; | |
| use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer; | |
| use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer; | |
| use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer; | |
| use Symplify\CodingStandard\Fixer\Spacing\StandaloneLinePromotedPropertyFixer; | |
| use Symplify\EasyCodingStandard\Config\ECSConfig; | |
| use Symplify\EasyCodingStandard\ValueObject\Set\SetList; | |
| return function (ECSConfig $ecsConfig): void { | |
| $ecsConfig->paths([ | |
| __DIR__ . '/src', | |
| __DIR__ . '/tests', | |
| ]); | |
| $ecsConfig->skip([ | |
| ClassDefinitionFixer::class, | |
| OrderedClassElementsFixer::class, | |
| StandaloneLinePromotedPropertyFixer::class, | |
| YodaStyleFixer::class, | |
| ]); | |
| $ecsConfig->rules([ | |
| NoUnusedImportsFixer::class, | |
| ]); | |
| $ecsConfig->sets([ | |
| SetList::PSR_12, | |
| SetList::CLEAN_CODE, | |
| SetList::ARRAY, | |
| SetList::NAMESPACES, | |
| SetList::COMMENTS, | |
| SetList::SPACES, | |
| // run and fix, one by one | |
| SetList::COMMON, | |
| ]); | |
| }; |
This file contains hidden or 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
| includes: | |
| - vendor/symplify/phpstan-rules/config/static-rules.neon | |
| - vendor/symplify/phpstan-rules/config/array-rules.neon | |
| - vendor/symplify/phpstan-rules/config/doctrine-rules.neon | |
| - vendor/symplify/phpstan-rules/config/regex-rules.neon | |
| - vendor/symplify/phpstan-rules/config/forbidden-static-rules.neon | |
| - vendor/symplify/phpstan-rules/config/test-rules.neon | |
| parameters: | |
| level: max | |
| paths: | |
| - src | |
| - tests | |
| checkMissingIterableValueType: false | |
| checkGenericClassInNonGenericObjectType: false | |
| excludePaths: | |
| # - %rootDir%/../../../src/migrations | |
| doctrine: | |
| repositoryClass: Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository |
This file contains hidden or 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
| includes: | |
| - phpstan-baseline.neon | |
| parameters: | |
| # ignoreErrors: |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <phpunit | |
| colors="true" | |
| bootstrap="vendor/autoload.php" | |
| > | |
| <testsuites> | |
| <testsuite name="main"> | |
| <directory>tests</directory> | |
| </testsuite> | |
| <testsuite name="unit"> | |
| <directory>tests/Unit</directory> | |
| </testsuite> | |
| <testsuite name="functional"> | |
| <directory>tests/Functional</directory> | |
| </testsuite> | |
| </testsuites> | |
| <coverage processUncoveredFiles="true"> | |
| <include> | |
| <directory suffix=".php">src</directory> | |
| </include> | |
| <exclude> | |
| <file>src/Kernel.php</file> | |
| </exclude> | |
| </coverage> | |
| <extensions> | |
| </extensions> | |
| </phpunit> |
This file contains hidden or 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
| <?php | |
| declare(strict_types=1); | |
| use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; | |
| use Rector\Config\RectorConfig; | |
| use Rector\Doctrine\Set\DoctrineSetList; | |
| use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector; | |
| use Rector\Nette\Set\NetteSetList; | |
| use Rector\Php80\Rector\FunctionLike\UnionTypesRector; | |
| use Rector\Set\ValueObject\LevelSetList; | |
| use Rector\Set\ValueObject\SetList; | |
| return static function (RectorConfig $rectorConfig): void { | |
| $rectorConfig->paths([ | |
| __DIR__.'/src', | |
| __DIR__.'/tests', | |
| ]); | |
| $rectorConfig->importNames(); | |
| $rectorConfig->parallel(); | |
| $rectorConfig->rules([ | |
| InlineConstructorDefaultToPropertyRector::class, | |
| ]); | |
| $rectorConfig->skip([ | |
| RenamePropertyToMatchTypeRector::class => [__DIR__ . '/tests/ORM/'], | |
| UnionTypesRector::class => [ | |
| // to keep BC return types | |
| __DIR__ . '/src/Contract/Entity', | |
| 'src/Model/*/*Trait.php', | |
| ], | |
| ]); | |
| // doctrine annotations to attributes | |
| $rectorConfig->sets([ | |
| DoctrineSetList::DOCTRINE_ORM_29, | |
| SetList::DEAD_CODE, | |
| SetList::CODE_QUALITY, | |
| SetList::CODING_STYLE, | |
| NetteSetList::NETTE_CODE_QUALITY, | |
| SetList::NAMING, | |
| LevelSetList::UP_TO_PHP_81, | |
| ]); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment