Skip to content
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
2 changes: 0 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
strategy:
matrix:
include:
- php-version: 8.3
docker-image: 'anzusystems/php:4.1.0-php83-cli'
- php-version: 8.4
docker-image: 'anzusystems/php:5.0.1-php84-cli'
- php-version: 8.5
Expand Down
8 changes: 3 additions & 5 deletions bin/ecs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/bin/bash
# Script used to run ECS check in the application docker container
# Script used to run ECS check in the application container

PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
CHECK_DIR=${1:-src}

cd "${PROJECT_ROOT}" || exit 1

if [ -f /.dockerenv ]; then
echo "[INFO] Running ECS check"
vendor/bin/ecs check --fix --config=ecs.php "${CHECK_DIR}"
vendor/bin/ecs check --fix --config=ecs.php
exit
fi

bin/docker-compose run --rm app bash -c \'bin/ecs "${CHECK_DIR}"\'
bin/docker-compose run --rm app bash -c \'bin/ecs\'
34 changes: 17 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">=8.3",
"php": ">=8.4",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
Expand All @@ -27,33 +27,33 @@
"mongodb/mongodb": "^2.0",
"monolog/monolog": "^2.0|^3.0",
"nelmio/api-doc-bundle": "^5.9",
"symfony/cache": "^7.0",
"symfony/console": "^6.0|^7.0",
"symfony/dependency-injection": "^6.0|^7.0",
"symfony/dotenv": "^6.0|^7.0",
"symfony/event-dispatcher": "^6.0|^7.0",
"symfony/expression-language": "^6.0|^7.0",
"symfony/framework-bundle": "^6.0|^7.0",
"symfony/cache": "^7.0|^8.0",
"symfony/console": "^7.0|^8.0",
"symfony/dependency-injection": "^7.0|^8.0",
"symfony/dotenv": "^7.0|^8.0",
"symfony/event-dispatcher": "^7.0|^8.0",
"symfony/expression-language": "^7.0|^8.0",
"symfony/framework-bundle": "^7.0|^8.0",
"symfony/http-client-contracts": "^3.1",
"symfony/http-kernel": "^6.0|^7.0",
"symfony/lock": "^6.0|^7.0",
"symfony/messenger": "^6.0|^7.0",
"symfony/http-kernel": "^7.0|^8.0",
"symfony/lock": "^7.0|^8.0",
"symfony/messenger": "^7.0|^8.0",
"symfony/monolog-bundle": ">=3.9",
"symfony/polyfill-uuid": "^1.23",
"symfony/runtime": "^6.0|^7.0",
"symfony/security-bundle": "^6.0|^7.0",
"symfony/uid": "^6.0|^7.0",
"symfony/validator": "^6.0|^7.0",
"symfony/runtime": "^7.0|^8.0",
"symfony/security-bundle": "^7.0|^8.0",
"symfony/uid": "^7.0|^8.0",
"symfony/validator": "^7.0|^8.0",
"symfony/var-exporter": "^6.4|^7.0",
"symfony/yaml": "^6.0|^7.0"
"symfony/yaml": "^7.0|^8.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.4",
"jetbrains/phpstorm-attributes": "^1.0",
"phpunit/phpunit": "^9.5",
"slevomat/coding-standard": "8.20",
"symfony/test-pack": "^1.0",
"symplify/easy-coding-standard": "^11.0",
"symplify/easy-coding-standard": "^13.0",
"vimeo/psalm": "^6.10"
},
"autoload": {
Expand Down
205 changes: 81 additions & 124 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

declare(strict_types=1);
use AnzuSystems\CommonBundle\DependencyInjection\Configuration;

use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
Expand All @@ -18,18 +18,13 @@
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocTagRenameFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocInlineTagNormalizerFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
use SlevomatCodingStandard\Sniffs\Classes\MethodSpacingSniff;
use SlevomatCodingStandard\Sniffs\Classes\ModernClassNameReferenceSniff;
use SlevomatCodingStandard\Sniffs\Classes\ParentCallSpacingSniff;
use SlevomatCodingStandard\Sniffs\Classes\PropertySpacingSniff;
use SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff;
use SlevomatCodingStandard\Sniffs\Commenting\UselessInheritDocCommentSniff;
use SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullCoalesceOperatorSniff;
use SlevomatCodingStandard\Sniffs\Functions\ArrowFunctionDeclarationSniff;
Expand All @@ -41,27 +36,19 @@
use SlevomatCodingStandard\Sniffs\Namespaces\UseFromSameNamespaceSniff;
use SlevomatCodingStandard\Sniffs\Numbers\RequireNumericLiteralSeparatorSniff;
use SlevomatCodingStandard\Sniffs\PHP\UselessParenthesesSniff;
use SlevomatCodingStandard\Sniffs\TypeHints\UselessConstantTypeHintSniff;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ECSConfig): void {
$ECSConfig->import(SetList::CLEAN_CODE);
$ECSConfig->import(SetList::PSR_12);
$ECSConfig->import(SetList::COMMON);

$parameters = $ECSConfig->parameters();
$parameters->set(Option::PARALLEL, true);
$parameters->set(Option::DEBUG, true);

$ECSConfig->cacheDirectory(__DIR__ . '/var/ecs_cache');

$ECSConfig->skip([
Configuration::class,
PhpdocTypesOrderFixer::class,
return ECSConfig::configure()
->withPreparedSets(psr12: true, common: true, cleanCode: true)
->withParallel()
->withCache(directory: __DIR__ . '/var/ecs_cache')
->withPaths(paths: [
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withSkip([
ArrayListItemNewlineFixer::class => null,
PhpdocToCommentFixer::class => null,
PhpdocAlignFixer::class => null,
Expand All @@ -74,105 +61,75 @@
DoctrineAnnotationBracesFixer::class => null,
NotOperatorWithSuccessorSpaceFixer::class => null,
UselessParenthesesSniff::class => null,
PhpdocSeparationFixer::class => null, // some bug with infinity applied checker
MethodChainingIndentationFixer::class => ['DependencyInjection/*Configuration.php'],
'SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff.DuplicateDeclareStrictTypesSpaces' => null,
MethodChainingIndentationFixer::class => ['src/DependencyInjection/*Configuration.php'],
'SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff.WriteOnlyProperty' => ['src/Entity/User.php'],
'SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff.DuplicateSpaces' => null,
'SlevomatCodingStandard\Sniffs\Commenting\DisallowCommentAfterCodeSniff.DisallowedCommentAfterCode' => null,
PhpdocAnnotationWithoutDotFixer::class => null,
'src/Model/Enum/*.php',
PhpCsFixer\Fixer\Import\NoUnusedImportsFixer::class => null // bug: removes usages of attributes if attributes are in one line i.e. #[OARequest, OAResponse]
]);

$services = $ECSConfig->services();

$services->set(NoSuperfluousPhpdocTagsFixer::class)
->call('configure', [['remove_inheritdoc' => false, 'allow_mixed' => false]]);

$services->set(ClassDefinitionFixer::class)
->call('configure', [['multi_line_extends_each_single_line' => false]]);

$services->set(ClassAttributesSeparationFixer::class)
->call('configure', [['elements' => ['method', 'property']]]);

$services->set(DocCommentSpacingSniff::class)
->property('annotationsGroups', [
'@inheritDoc',
'@template, @extends, @implements, @template-implements @template-extends',
'@var, @psalm-var, @param, @psalm-param',
'@return, @psalm-return',
'@throws',
'@psalm-suppress',
])
;

$services->set(MethodSpacingSniff::class);
$services->set(PropertySpacingSniff::class)
->property('minLinesCountBeforeWithComment', 1)
->property('maxLinesCountBeforeWithComment', 1)
->property('maxLinesCountBeforeWithoutComment', 0);

$services->set(UnusedUsesSniff::class)
->property('searchAnnotations', true);

$services->set(DeclareStrictTypesFixer::class);
$services->set(NoNullPropertyInitializationFixer::class);
$services->set(YodaStyleFixer::class);
$services->set(ArrowFunctionDeclarationSniff::class);
$services->set(StrictCallSniff::class);
$services->set(UseDoesNotStartWithBackslashSniff::class);
$services->set(AlphabeticallySortedUsesSniff::class);
$services->set(RequireNumericLiteralSeparatorSniff::class);
$services->set(UselessParenthesesSniff::class);
$services->set(RequireNullCoalesceOperatorSniff::class);
$services->set(ModernClassNameReferenceSniff::class);
$services->set(UselessInheritDocCommentSniff::class);
$services->set(UseFromSameNamespaceSniff::class);
$services->set(UnusedInheritedVariablePassedToClosureSniff::class);
$services->set(UselessConstantTypeHintSniff::class);
$services->set(DoctrineAnnotationArrayAssignmentFixer::class);
$services->set(DoctrineAnnotationIndentationFixer::class);
$services->set(DoctrineAnnotationSpacesFixer::class);

$services->set(ForbiddenFunctionsSniff::class)
->property('forbiddenFunctions', [
'chop' => 'rtrim',
'close' => 'closedir',
'delete' => 'unset',
'doubleval' => 'floatval',
'fputs' => 'fwrite',
'imap_create' => 'createmailbox',
'imap_fetchtext' => 'body',
'imap_header' => 'headerinfo',
'imap_listmailbox' => 'list',
'imap_listsubscribed' => 'lsub',
'imap_rename' => 'renamemailbox',
'imap_scan' => 'listscan',
'imap_scanmailbox' => 'listscan',
'mt_rand' => 'random_int',
'ini_alter' => 'set',
'is_double' => 'is_float',
'is_integer' => 'is_int',
'is_null' => '!== null',
'is_real' => 'is_float',
'is_writeable' => 'is_writable',
'join' => 'implode',
'key_exists' => 'array_key_exists',
'magic_quotes_runtime' => 'set_magic_quotes_runtime',
'pos' => 'current',
'rand' => 'random_int',
'show_source' => 'file',
'sizeof' => 'count',
'strchr' => 'strstr',
'create_function' => null,
'call_user_func' => null,
'call_user_func_array' => null,
'forward_static_call' => null,
'forward_static_call_array' => null,
]);

$services->set(ArraySyntaxFixer::class)
->call('configure', [['syntax' => 'short']]);

$services->set(ListSyntaxFixer::class)
->call('configure', [['syntax' => 'short']]);
};
])
->withConfiguredRule(NoSuperfluousPhpdocTagsFixer::class, ['remove_inheritdoc' => false, 'allow_mixed' => false])
->withConfiguredRule(ClassDefinitionFixer::class, ['multi_line_extends_each_single_line' => false])
->withConfiguredRule(ClassAttributesSeparationFixer::class, ['elements' => ['method', 'property']])
->withConfiguredRule(ArraySyntaxFixer::class, ['syntax' => 'short'])
->withConfiguredRule(ListSyntaxFixer::class, ['syntax' => 'short'])
->withConfiguredRule(PropertySpacingSniff::class, ['minLinesCountBeforeWithComment' => 1, 'maxLinesCountBeforeWithComment' => 1, 'maxLinesCountBeforeWithoutComment' => 0])
->withConfiguredRule(UnusedUsesSniff::class, ['searchAnnotations' => true])
->withConfiguredRule(YodaStyleFixer::class, ['identical' => true])
->withConfiguredRule(ForbiddenFunctionsSniff::class, ['forbiddenFunctions' => [
'chop' => 'rtrim',
'close' => 'closedir',
'delete' => 'unset',
'doubleval' => 'floatval',
'fputs' => 'fwrite',
'imap_create' => 'createmailbox',
'imap_fetchtext' => 'body',
'imap_header' => 'headerinfo',
'imap_listmailbox' => 'list',
'imap_listsubscribed' => 'lsub',
'imap_rename' => 'renamemailbox',
'imap_scan' => 'listscan',
'imap_scanmailbox' => 'listscan',
'mt_rand' => 'random_int',
'ini_alter' => 'set',
'is_double' => 'is_float',
'is_integer' => 'is_int',
'is_null' => '!== null',
'is_real' => 'is_float',
'is_writeable' => 'is_writable',
'join' => 'implode',
'key_exists' => 'array_key_exists',
'magic_quotes_runtime' => 'set_magic_quotes_runtime',
'pos' => 'current',
'rand' => 'random_int',
'show_source' => 'file',
'sizeof' => 'count',
'strchr' => 'strstr',
'create_function' => null,
'call_user_func' => null,
'call_user_func_array' => null,
'forward_static_call' => null,
'forward_static_call_array' => null,
'dump' => null,
'die' => null,
'dd' => null,
'echo' => null,
'var_dump' => null,
]])
->withRules([
DeclareStrictTypesFixer::class,
NoNullPropertyInitializationFixer::class,
ArrowFunctionDeclarationSniff::class,
StrictCallSniff::class,
UseDoesNotStartWithBackslashSniff::class,
AlphabeticallySortedUsesSniff::class,
RequireNumericLiteralSeparatorSniff::class,
UselessParenthesesSniff::class,
RequireNullCoalesceOperatorSniff::class,
ModernClassNameReferenceSniff::class,
UselessInheritDocCommentSniff::class,
UseFromSameNamespaceSniff::class,
UnusedInheritedVariablePassedToClosureSniff::class,
DoctrineAnnotationArrayAssignmentFixer::class,
DoctrineAnnotationIndentationFixer::class,
DoctrineAnnotationSpacesFixer::class,
])
;
7 changes: 4 additions & 3 deletions src/AnzuTap/AnzuTapBodyPostprocessor.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace AnzuSystems\CommonBundle\AnzuTap;

use AnzuSystems\CommonBundle\Model\AnzuTap\Node\AnzuTapDocNode;
Expand Down Expand Up @@ -42,7 +44,6 @@ public function postprocess(AnzuTapDocNode $body): void
$this->removeInvalidNodes($body);
}


protected function removeInvalidNodes(AnzuTapDocNode $body): void
{
$body->setContent(array_filter(
Expand All @@ -54,7 +55,7 @@ protected function removeInvalidNodes(AnzuTapDocNode $body): void
protected function fixParagraphs(AnzuTapNodeInterface $body): void
{
foreach ($body->getContent() as $node) {
if ($node->getType() === AnzuTapParagraphNode::NODE_NAME) {
if (AnzuTapParagraphNode::NODE_NAME === $node->getType()) {
$this->fixNode($node, self::PARAGRAPH_ALLOWED_CONTENT_TYPES);
}

Expand Down Expand Up @@ -97,7 +98,7 @@ protected function shakeNodes(AnzuTapDocNode $body, array $nodeTypesToShake): vo
// Check if root node was paragraph and after shaking, it lost content.
foreach ($shakenNodes as $shakenNode) {
if ($shakenNode === $node &&
$shakenNode->getType() === AnzuTapParagraphNode::NODE_NAME &&
AnzuTapParagraphNode::NODE_NAME === $shakenNode->getType() &&
0 === count($shakenNode->getContent()) &&
0 < $contentCount
) {
Expand Down
2 changes: 2 additions & 0 deletions src/AnzuTap/AnzuTapBodyPreprocessor.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace AnzuSystems\CommonBundle\AnzuTap;

class AnzuTapBodyPreprocessor
Expand Down
1 change: 0 additions & 1 deletion src/AnzuTap/AnzuTapEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use AnzuSystems\CommonBundle\Model\AnzuTap\EmbedContainer;
use AnzuSystems\CommonBundle\Model\AnzuTap\Node\AnzuTapDocNode;
use AnzuSystems\CommonBundle\Model\AnzuTap\Node\AnzuTapEmbedNodeNode;
use AnzuSystems\CommonBundle\Model\AnzuTap\Node\AnzuTapNode;
use AnzuSystems\CommonBundle\Model\AnzuTap\Node\AnzuTapNodeInterface;
use DOMDocument;
use DOMElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace AnzuSystems\CommonBundle\AnzuTap\Transformer\Mark;

use DOMElement;
use DOMText;

abstract class AbstractMarkNodeTransformer implements AnzuMarkTransformerInterface
{
Expand Down
2 changes: 0 additions & 2 deletions src/AnzuTap/Transformer/Mark/AnzuMarkTransformerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace AnzuSystems\CommonBundle\AnzuTap\Transformer\Mark;

use AnzuSystems\CommonBundle\AnzuSystemsCommonBundle;
use DOMElement;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;

interface AnzuMarkTransformerInterface
{
Expand Down
Loading