PK ƒcUñXeaƒ ƒ lib/Doctrine/ruleset.xmlnu €žÙ˜
The Doctrine coding standard.
error
5
PK ƒcUksTåL L Makefilenu €žÙ˜ .PHONY: test test-report test-fix update-compatibility-patch
test: test-report test-fix
test-report: vendor
./bin/test-report
test-fix: vendor
./bin/test-fix
update-compatibility-patch-72:
@git apply tests/php72-compatibility.patch
@printf "Please open your editor and apply your changes\n"
@until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved=
@git diff -- tests/expected_report.txt tests/fixed tests/input > .tmp-patch && mv .tmp-patch tests/php72-compatibility.patch && git apply -R tests/php72-compatibility.patch
@git commit -m 'Update compatibility patch' tests/php72-compatibility.patch
update-compatibility-patch-73:
@git apply tests/php73-compatibility.patch
@printf "Please open your editor and apply your changes\n"
@until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved=
@git diff -- tests/expected_report.txt tests/fixed tests/input > .tmp-patch && mv .tmp-patch tests/php73-compatibility.patch && git apply -R tests/php73-compatibility.patch
@git commit -m 'Update compatibility patch' tests/php73-compatibility.patch
update-compatibility-patch-74:
@git apply tests/php74-compatibility.patch
@printf "Please open your editor and apply your changes\n"
@until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved=
@git diff -- tests/expected_report.txt tests/fixed tests/input > .tmp-patch && mv .tmp-patch tests/php74-compatibility.patch && git apply -R tests/php74-compatibility.patch
@git commit -m 'Update compatibility patch' tests/php74-compatibility.patch
update-compatibility-patch-80:
@git apply tests/php80-compatibility.patch
@printf "Please open your editor and apply your changes\n"
@until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved=
@git diff -- tests/expected_report.txt tests/fixed tests/input > .tmp-patch && mv .tmp-patch tests/php80-compatibility.patch && git apply -R tests/php80-compatibility.patch
@git commit -m 'Update compatibility patch' tests/php80-compatibility.patch
vendor: composer.json
composer update
touch -c vendor
PK ƒcUÁþþÖ Ö README.mdnu €žÙ˜ # Doctrine Coding Standard
[![Build Status](https://github.com/doctrine/coding-standard/workflows/Continuous%20Integration/badge.svg)](https://github.com/doctrine/coding-standard/actions?query=workflow%3A%22Continuous+Integration%22+)
[![Continuous Integration](https://github.com/doctrine/coding-standard/workflows/Continuous%20Integration/badge.svg?branch=8.2.x)](https://github.com/doctrine/coding-standard/actions)
[![Total Downloads](https://img.shields.io/packagist/dt/doctrine/coding-standard.svg?style=flat-square)](https://packagist.org/packages/doctrine/coding-standard)
[![Latest Stable Version](https://img.shields.io/packagist/v/doctrine/coding-standard.svg?style=flat-square)](https://packagist.org/packages/doctrine/coding-standard)
The Doctrine Coding Standard is a set of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) rules applied to all Doctrine projects. Doctrine Coding Standard is heavily based on [Slevomat Coding Standard](https://github.com/slevomat/coding-standard).
## More resources:
* [Website](https://www.doctrine-project.org/)
* [Documentation](https://www.doctrine-project.org/projects/coding-standard.html)
* [Downloads](https://github.com/doctrine/coding-standard/coding-standard)
PK ƒcU³ÛN”ƒ ƒ CONTRIBUTING.mdnu €žÙ˜ # Contributing
See https://www.doctrine-project.org/projects/doctrine-coding-standard/en/stable/reference/index.html#contributing
PK ƒcUUæ.ò7 7
.gitignorenu €žÙ˜ vendor/
phpcs.xml
composer.lock
tests/input2
phpcs.log
PK ƒcU½ƒz=h h phpcs.xml.distnu €žÙ˜
Check the code of the sniffs in doctrine/coding-standards.
lib
PK ƒcUþUËÛ> > .github/CODEOWNERSnu €žÙ˜ /lib/Doctrine/ruleset.xml @doctrine/coding-standard-approvers
PK ƒcU%ê
rš š , .github/workflows/continuous-integration.ymlnu €žÙ˜ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Continuous Integration"
on:
pull_request:
push:
branches:
- "*.*.x"
schedule:
- cron: "0 17 * * *"
jobs:
coding-standards:
name: "Coding Standards"
runs-on: "ubuntu-18.04"
strategy:
matrix:
php-version:
- "7.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-"
- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress --no-suggest"
- name: "Run squizlabs/php_codesniffer"
run: "vendor/bin/phpcs"
validate-against-schema:
name: "Validate against schema"
runs-on: "ubuntu-18.04"
strategy:
matrix:
php-version:
- "7.2"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.json') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress --no-suggest"
- name: "Build Docker image"
uses: "./.docker/validate-against-schema"
- name: "Lint XML configuration files"
uses: "./.docker/validate-against-schema"
with:
args: "xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd lib/Doctrine/ruleset.xml"
test-report:
name: "Test report"
runs-on: "ubuntu-18.04"
strategy:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-"
- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress --no-suggest"
- name: "Test reports"
run: "make test-report"
test-fixes:
name: "Test fixes"
runs-on: "ubuntu-18.04"
strategy:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.json') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress --no-suggest"
- name: "Test fixes"
run: "make test-fix"
PK ƒcUð_á á 1 .github/workflows/release-on-milestone-closed.ymlnu €žÙ˜ name: "Automatic Releases"
on:
milestone:
types:
- "closed"
jobs:
release:
name: "Git tag, release & create merge-up PR"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@2.0.0"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
PK ƒcUøiýÛ’ ’ .github/dependabot.ymlnu €žÙ˜ version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "11:00"
open-pull-requests-limit: 10
reviewers:
- doctrine/coding-standard-approvers
labels:
- Dependencies
versioning-strategy: increase-if-necessary
ignore:
- dependency-name: slevomat/coding-standard
versions:
- 7.0.0
- 7.0.1
- 7.0.2
- 7.0.4
- 7.0.5
PK ƒcU7Ÿšý ý .gitattributesnu €žÙ˜ /.docker export-ignore
/.doctrine-project.json export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/bin/ export-ignore
/docs/ export-ignore
/phpcs.xml.dist export-ignore
/tests/ export-ignore
/bin/ export-ignore
PK ƒcUvµe&9 9 * .docker/validate-against-schema/Dockerfilenu €žÙ˜ FROM alpine:3.11.3
RUN apk add --no-cache libxml2-utils
PK ƒcUw²eÿz z .doctrine-project.jsonnu €žÙ˜ {
"active": true,
"name": "Coding Standard",
"slug": "coding-standard",
"docsSlug": "doctrine-coding-standard",
"versions": [
{
"name": "11.0",
"branchName": "11.0.x",
"slug": "11.0",
"upcoming": true
},
{
"name": "10.0",
"branchName": "10.0.x",
"slug": "10.0",
"current": true,
"aliases": [
"current",
"stable"
]
},
{
"name": "9.0",
"branchName": "9.0.x",
"slug": "9.0",
"maintained": false
},
{
"name": "8.2",
"branchName": "8.2.x",
"slug": "8.2",
"maintained": false
},
{
"name": "8.1",
"branchName": "8.1.x",
"slug": "8.1",
"maintained": false
},
{
"name": "8.0",
"branchName": "8.0.x",
"slug": "8.0",
"maintained": false
},
{
"name": "7.0",
"branchName": "7.0.x",
"slug": "7.0",
"maintained": false
},
{
"name": "6.0",
"branchName": "6.x",
"slug": "6.0",
"maintained": false
},
{
"name": "5.0",
"branchName": "5.x",
"slug": "5.0",
"maintained": false
},
{
"name": "4.0",
"branchName": "4.x",
"slug": "4.0",
"maintained": false
}
]
}
PK ƒcU)”â¶3 ¶3 tests/php74-compatibility.patchnu €žÙ˜ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index d1e1fad..ed67841 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -12,30 +12,27 @@ tests/input/class-references.php 10 0
tests/input/ClassPropertySpacing.php 2 0
tests/input/concatenation_spacing.php 49 0
tests/input/constants-no-lsb.php 2 0
tests/input/constants-var.php 6 0
tests/input/ControlStructures.php 28 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
-tests/input/EarlyReturn.php 7 0
-tests/input/example-class.php 47 0
-tests/input/ExampleBackedEnum.php 3 0
-tests/input/Exceptions.php 1 0
+tests/input/EarlyReturn.php 6 0
+tests/input/example-class.php 44 0
tests/input/forbidden-comments.php 14 0
tests/input/forbidden-functions.php 6 0
tests/input/inline_type_hint_assertions.php 10 0
tests/input/LowCaseTypes.php 2 0
tests/input/namespaces-spacing.php 7 0
-tests/input/NamingCamelCase.php 9 0
+tests/input/NamingCamelCase.php 6 0
tests/input/negation-operator.php 2 0
tests/input/new_with_parentheses.php 19 0
tests/input/not_spacing.php 8 0
tests/input/null_coalesce_equal_operator.php 5 0
tests/input/null_coalesce_operator.php 3 0
-tests/input/null_safe_operator.php 1 0
tests/input/optimized-functions.php 1 0
-tests/input/PropertyDeclaration.php 14 0
-tests/input/return_type_on_closures.php 26 0
-tests/input/return_type_on_methods.php 22 0
+tests/input/PropertyDeclaration.php 6 0
+tests/input/return_type_on_closures.php 21 0
+tests/input/return_type_on_methods.php 17 0
tests/input/semicolon_spacing.php 3 0
tests/input/single-line-array-spacing.php 5 0
tests/input/spread-operator.php 6 0
@@ -44,17 +41,17 @@ tests/input/strings.php 1 0
tests/input/superfluous-naming.php 11 0
tests/input/test-case.php 8 0
tests/input/trailing_comma_on_array.php 1 0
-tests/input/TrailingCommaOnFunctions.php 6 0
+tests/input/TrailingCommaOnFunctions.php 2 0
tests/input/traits-uses.php 11 0
-tests/input/type-hints.php 9 0
+tests/input/type-hints.php 8 0
tests/input/UnusedVariables.php 1 0
tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
-tests/input/UselessConditions.php 21 0
+tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 453 ERRORS AND 0 WARNINGS WERE FOUND IN 48 FILES
+A TOTAL OF 417 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 375 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 339 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
diff --git a/tests/fixed/ControlStructures.php b/tests/fixed/ControlStructures.php
index f8f7f65..a653086 100644
--- a/tests/fixed/ControlStructures.php
+++ b/tests/fixed/ControlStructures.php
@@ -104,7 +104,7 @@ class ControlStructures
try {
echo 4;
- } catch (Throwable) {
+ } catch (Throwable $throwable) {
}
echo 5;
diff --git a/tests/fixed/EarlyReturn.php b/tests/fixed/EarlyReturn.php
index fc734db..caf1dbb 100644
--- a/tests/fixed/EarlyReturn.php
+++ b/tests/fixed/EarlyReturn.php
@@ -11,7 +11,7 @@ class EarlyReturn
return $bar === 'bar';
}
- public function foo(): string|null
+ public function foo(): ?string
{
foreach ($items as $item) {
if (! $item->isItem()) {
diff --git a/tests/fixed/ExampleBackedEnum.php b/tests/fixed/ExampleBackedEnum.php
index cc38c54..fe54eb9 100644
--- a/tests/fixed/ExampleBackedEnum.php
+++ b/tests/fixed/ExampleBackedEnum.php
@@ -3,7 +3,3 @@
declare(strict_types=1);
namespace ExampleBackedEnum;
-
-enum ExampleBackedEnum: int
-{
-}
diff --git a/tests/fixed/Exceptions.php b/tests/fixed/Exceptions.php
index db7408b..9b146c6 100644
--- a/tests/fixed/Exceptions.php
+++ b/tests/fixed/Exceptions.php
@@ -3,11 +3,3 @@
declare(strict_types=1);
namespace Exceptions;
-
-use Exception;
-use Throwable;
-
-try {
- throw new Exception();
-} catch (Throwable) {
-}
diff --git a/tests/fixed/NamingCamelCase.php b/tests/fixed/NamingCamelCase.php
index 5493471..57d9f2b 100644
--- a/tests/fixed/NamingCamelCase.php
+++ b/tests/fixed/NamingCamelCase.php
@@ -6,11 +6,14 @@ namespace Example;
class NamingCamelCase
{
- public mixed $A;
+ /** @var mixed */
+ public $A;
- protected mixed $B;
+ /** @var mixed */
+ protected $B;
- private mixed $C;
+ /** @var mixed */
+ private $C;
public function fcn(string $A): void
{
diff --git a/tests/fixed/PropertyDeclaration.php b/tests/fixed/PropertyDeclaration.php
index 9703897..5c3f27b 100644
--- a/tests/fixed/PropertyDeclaration.php
+++ b/tests/fixed/PropertyDeclaration.php
@@ -9,10 +9,5 @@ final class PropertyDeclaration
public bool $boolPropertyWithDefaultValue = false;
public string $stringProperty;
public int $intProperty;
- public string|null $nullableString = null;
-
- public function __construct(
- public readonly Foo $foo,
- ) {
- }
+ public ?string $nullableString = null;
}
diff --git a/tests/fixed/TrailingCommaOnFunctions.php b/tests/fixed/TrailingCommaOnFunctions.php
index 4248238..67173b3 100644
--- a/tests/fixed/TrailingCommaOnFunctions.php
+++ b/tests/fixed/TrailingCommaOnFunctions.php
@@ -15,7 +15,7 @@ class TrailingCommaOnFunctions
}
public function b(
- int $arg,
+ int $arg
): void {
}
@@ -28,7 +28,7 @@ class TrailingCommaOnFunctions
};
$multiLine = static function (int $arg) use (
- $var,
+ $var
): void {
var_dump($var);
};
diff --git a/tests/fixed/UselessConditions.php b/tests/fixed/UselessConditions.php
index 71e0cfb..2151b17 100644
--- a/tests/fixed/UselessConditions.php
+++ b/tests/fixed/UselessConditions.php
@@ -95,7 +95,7 @@ class UselessConditions
return false;
}
- public function nullShouldNotBeTreatedAsFalse(): bool|null
+ public function nullShouldNotBeTreatedAsFalse(): ?bool
{
if (! $this->isAdmin) {
return null;
diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
index 4988dab..c31e53f 100644
--- a/tests/fixed/example-class.php
+++ b/tests/fixed/example-class.php
@@ -29,10 +29,21 @@ class Example extends ParentClass implements IteratorAggregate
{
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
- private ControlStructureSniff|int|string|null $baxBax = null;
+ private ?int $foo = null;
- public function __construct(private int|null $foo = null, private array $bar = [], private bool $baz = false, $baxBax = 'unused')
+ /** @var string[] */
+ private array $bar;
+
+ private bool $baz;
+
+ /** @var ControlStructureSniff|int|string|null */
+ private $baxBax;
+
+ public function __construct(?int $foo = null, array $bar = [], bool $baz = false, $baxBax = 'unused')
{
+ $this->foo = $foo;
+ $this->bar = $bar;
+ $this->baz = $baz;
$this->baxBax = $baxBax;
parent::__construct();
@@ -41,7 +52,7 @@ class Example extends ParentClass implements IteratorAggregate
/**
* Description
*/
- public function getFoo(): int|null
+ public function getFoo(): ?int
{
return $this->foo;
}
diff --git a/tests/fixed/null_safe_operator.php b/tests/fixed/null_safe_operator.php
index 7ce8a3d..5bbb636 100644
--- a/tests/fixed/null_safe_operator.php
+++ b/tests/fixed/null_safe_operator.php
@@ -2,4 +2,4 @@
declare(strict_types=1);
-$var = $object?->property;
+$var = $object === null ? null : $object->property;
diff --git a/tests/fixed/return_type_on_closures.php b/tests/fixed/return_type_on_closures.php
index 80ad413..134bade 100644
--- a/tests/fixed/return_type_on_closures.php
+++ b/tests/fixed/return_type_on_closures.php
@@ -22,7 +22,7 @@ static function (
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
@@ -31,7 +31,7 @@ static function (
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
@@ -40,7 +40,7 @@ static function (
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
@@ -49,7 +49,7 @@ static function (
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
@@ -58,6 +58,6 @@ static function (
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
diff --git a/tests/fixed/return_type_on_methods.php b/tests/fixed/return_type_on_methods.php
index 0c897ae..8e2c6f7 100644
--- a/tests/fixed/return_type_on_methods.php
+++ b/tests/fixed/return_type_on_methods.php
@@ -31,7 +31,7 @@ class Test
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
@@ -40,7 +40,7 @@ class Test
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
@@ -49,7 +49,7 @@ class Test
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
@@ -58,7 +58,7 @@ class Test
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
@@ -67,7 +67,7 @@ class Test
int $c,
int $d,
int $e,
- int $b,
+ int $b
): void {
}
}
diff --git a/tests/fixed/type-hints.php b/tests/fixed/type-hints.php
index 5e26ed8..bfa6d4f 100644
--- a/tests/fixed/type-hints.php
+++ b/tests/fixed/type-hints.php
@@ -25,5 +25,6 @@ class TraversableTypeHints
class UnionTypeHints
{
- private int|string|null $x = 1;
+ /** @var int|string|null */
+ private $x = 1;
}
diff --git a/tests/input/ControlStructures.php b/tests/input/ControlStructures.php
index 73944e3..a0e0b2e 100644
--- a/tests/input/ControlStructures.php
+++ b/tests/input/ControlStructures.php
@@ -93,7 +93,7 @@ class ControlStructures
}
try {
echo 4;
- } catch (Throwable) {
+ } catch (Throwable $throwable) {
}
echo 5;
}
diff --git a/tests/input/ExampleBackedEnum.php b/tests/input/ExampleBackedEnum.php
index 0c47286..fe54eb9 100644
--- a/tests/input/ExampleBackedEnum.php
+++ b/tests/input/ExampleBackedEnum.php
@@ -3,7 +3,3 @@
declare(strict_types=1);
namespace ExampleBackedEnum;
-
-enum ExampleBackedEnum : int
-{
-}
diff --git a/tests/input/Exceptions.php b/tests/input/Exceptions.php
index 3aaa30f..9b146c6 100644
--- a/tests/input/Exceptions.php
+++ b/tests/input/Exceptions.php
@@ -3,11 +3,3 @@
declare(strict_types=1);
namespace Exceptions;
-
-use Exception;
-use Throwable;
-
-try {
- throw new Exception();
-} catch (Throwable $throwable) {
-}
diff --git a/tests/input/PropertyDeclaration.php b/tests/input/PropertyDeclaration.php
index acdc445..0891e12 100644
--- a/tests/input/PropertyDeclaration.php
+++ b/tests/input/PropertyDeclaration.php
@@ -10,9 +10,4 @@ final class PropertyDeclaration
public string $stringProperty;
public int $intProperty;
public ? string $nullableString = null;
-
- public function __construct(
- public readonly Foo $foo,
- ) {
- }
}
diff --git a/tests/input/TrailingCommaOnFunctions.php b/tests/input/TrailingCommaOnFunctions.php
index fc5480e..8adcedf 100644
--- a/tests/input/TrailingCommaOnFunctions.php
+++ b/tests/input/TrailingCommaOnFunctions.php
@@ -10,7 +10,7 @@ use function var_dump;
class TrailingCommaOnFunctions
{
- public function a(int $arg,): void
+ public function a(int $arg): void
{
}
@@ -23,7 +23,7 @@ class TrailingCommaOnFunctions
{
$var = null;
- $singleLine = static function (int $arg) use ($var,): void {
+ $singleLine = static function (int $arg) use ($var): void {
var_dump($var);
};
PK ƒcU¢Msþ þ tests/fixed/use-ordering.phpnu €žÙ˜ format(DateTimeInterface::ATOM)) . PHP_EOL;
PK ƒcUpz9_ _ ! tests/fixed/ExampleBackedEnum.phpnu €žÙ˜ property ??= 'Default Value';
Test::$foo ??= 123;
PK ƒcUPŠœ³Û Û tests/fixed/traits-uses.phpnu €žÙ˜ $a + $b;
$uselessParentheses = static fn ($x) => $x + $y;
$withReturnType = static fn (): int => 1 + 2;
$withTypesInArguments = static fn (int $a, int $b): int => $a + $b;
$spacing = static fn (int $x) => $x * 2;
$nested = static fn ($x) => static fn ($y) => $x * $y + $z;
$returningObject = static fn () => new stdClass();
$multiLineArrowFunctions = Collection::from([1, 2])
->map(
static fn (int $v): int => $v * 2,
)
->reduce(
static fn (int $tmp, int $v): int => $tmp + $v,
);
$thisIsNotAnArrowFunction = [$this->fn => 'value'];
$arrayWithArrowFunctions = [
'true' => static fn () => true,
'false' => static fn () => false,
];
$singleLineArrayReturn = Collection::map(
static fn () => [1, 2]
);
$wrongMultiLineArrayReturn = Collection::map(
static fn () => [
1,
2,
]
);
PK ƒcU|)v–Ú Ú ( tests/fixed/TrailingCommaOnFunctions.phpnu €žÙ˜ a(1);
$class->a(
1,
);
PK ƒcU¾äWü” ” ! tests/fixed/useless-semicolon.phpnu €žÙ˜ 'value',
'key2' => 'value',
];
PK ƒcUÖì
# # % tests/fixed/concatenation_spacing.phpnu €žÙ˜ 0) {
echo 1;
} elseif (! $test === 0) {
echo 0;
} else {
echo -1;
}
while (! true) {
echo 1;
}
do {
echo 1;
} while (! true);
PK ƒcUCŠ.È… … tests/fixed/binary_operators.phpnu €žÙ˜ = 10;
}
PK ƒcUk:kn¯ ¯ ! tests/fixed/ControlStructures.phpnu €žÙ˜ */
public function varAndIfNoSpaceBetween(): iterable
{
$var = 1;
if (self::VERSION !== 0) {
return;
}
yield 0;
}
/** @return iterable */
public function ifAndYieldSpaceBetween(): iterable
{
if (self::VERSION === 0) {
yield 0;
}
yield 1;
}
/** @return iterable */
public function ifAndYieldFromSpaceBetween(): iterable
{
if (self::VERSION === 0) {
yield 0;
}
yield from [];
}
public function ifAndThrowSpaceBetween(): void
{
if (self::VERSION === 0) {
return;
}
throw new InvalidArgumentException();
}
public function ifAndReturnSpaceBetween(): int
{
if (self::VERSION === 0) {
return 0;
}
return 1;
}
public function noSpaceAroundCase(): void
{
switch (self::VERSION) {
case 1:
case 2:
// do something
break;
case 3:
// do something else
break;
default:
}
}
public function spaceBelowBlocks(): void
{
if (true) {
echo 1;
}
do {
echo 2;
} while (true);
while (true) {
echo 3;
}
for ($i = 0; $i < 1; $i++) {
echo $i;
}
foreach ([] as $item) {
echo $item;
}
switch (true) {
default:
}
try {
echo 4;
} catch (Throwable) {
}
echo 5;
}
public function spaceAroundMultilineIfs(): void
{
if (
true
&& false
) {
echo 1;
} elseif (
false
|| true
) {
echo 2;
}
}
public function spacingAroundCasesWithBreakAndReturn(): void
{
switch (true) {
case 1:
throw new InvalidArgumentException();
case 2:
return;
case 3:
break;
case 4:
echo 1;
}
}
}
PK ƒcUŽ*:Æ &