diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 859a3a0..86f17c3 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ '7.3', '7.4', '8.0' ] + php: [ '7.3', '7.4', '8.0', '8.1' ] steps: - uses: actions/checkout@v2 - name: Setup PHP with tools diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index a9a9d32..675c435 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -42,7 +42,7 @@ 'constant_case' => true, 'lowercase_keywords' => true, 'class_attributes_separation' => ['elements' => ['method' => 'one']], - 'native_function_invocation' => ['include' => ['@compiler_optimized']], + 'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf']], 'no_alias_functions' => true, 'no_closing_tag' => true, 'no_extra_blank_lines' => [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 037eb24..07d35f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,12 @@ CHANGELOG master ------ +* Add support of PHP 8.1 +* force usage of native sprintf function +* add php cs fixer rule native_function_invocation on sprintf +v1.1.0 +------ * Added rule to ban shell execution via backticks * Added rule to ban print statements * Allow Composer plugin ergebnis/composer-normalize diff --git a/composer.json b/composer.json index 85dfab5..182098d 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "homepage": "https://github.com/ekino/phpstan-banned-code", "require": { - "php": "^7.3 || ^8.0", + "php": "^7.3 || ^8.0 || ^8.1", "phpstan/phpstan": "^1.0" }, "require-dev": { diff --git a/src/Rules/BannedNodesRule.php b/src/Rules/BannedNodesRule.php index 07fae1a..47aeea3 100644 --- a/src/Rules/BannedNodesRule.php +++ b/src/Rules/BannedNodesRule.php @@ -71,13 +71,13 @@ public function processNode(Node $node, Scope $scope): array $function = $node->name->toString(); if (\in_array($function, $this->bannedFunctions)) { - return [sprintf('Should not use function "%s", please change the code.', $function)]; + return [\sprintf('Should not use function "%s", please change the code.', $function)]; } return []; } - return [sprintf('Should not use node with type "%s", please change the code.', $type)]; + return [\sprintf('Should not use node with type "%s", please change the code.', $type)]; } /** diff --git a/src/Rules/BannedUseTestRule.php b/src/Rules/BannedUseTestRule.php index 2cc2253..865da36 100644 --- a/src/Rules/BannedUseTestRule.php +++ b/src/Rules/BannedUseTestRule.php @@ -62,14 +62,14 @@ public function processNode(Node $node, Scope $scope): array } if (!$node instanceof Use_) { - throw new \InvalidArgumentException(sprintf('$node must be an instance of %s, %s given', Use_::class, \get_class($node))); + throw new \InvalidArgumentException(\sprintf('$node must be an instance of %s, %s given', Use_::class, \get_class($node))); } $errors = []; foreach ($node->uses as $use) { if (preg_match('#^Tests#', $use->name->toString())) { - $errors[] = sprintf('Should not use %s in the non-test file %s', $use->name->toString(), $scope->getFile()); + $errors[] = \sprintf('Should not use %s in the non-test file %s', $use->name->toString(), $scope->getFile()); } }