From 1cf6c9aa119b409656d4de2988d7037d43ad719f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 11 May 2021 14:27:29 +0200 Subject: [PATCH] Drop PHP v7.3 support and upgrade CS Fixer to v3 (#303) --- .github/workflows/test-unit.yml | 4 ++-- .php_cs.dist => .php-cs-fixer.dist.php | 19 ++++++++++--------- composer.json | 8 ++++---- src/Connection.php | 17 ++++++++++------- src/Expression.php | 4 ++-- 5 files changed, 28 insertions(+), 24 deletions(-) rename .php_cs.dist => .php-cs-fixer.dist.php (79%) diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index b4dcf6a6..89809a06 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -63,7 +63,7 @@ jobs: - name: Check Coding Style (only for CodingStyle) if: matrix.type == 'CodingStyle' - run: vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --diff-format=udiff --verbose --show-progress=dots + run: vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --verbose - name: Run Static Analysis (only for StaticAnalysis) if: matrix.type == 'StaticAnalysis' @@ -79,7 +79,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.3', '7.4', 'latest'] + php: ['7.4', 'latest'] type: ['Phpunit'] include: - php: 'latest' diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 79% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index e7c20aba..b64ce0ae 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -8,13 +8,13 @@ 'vendor', ]); -return PhpCsFixer\Config::create() +return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) ->setRules([ '@PhpCsFixer' => true, - '@PhpCsFixer:risky' =>true, - '@PHP71Migration:risky' => true, - '@PHP73Migration' => true, + '@PhpCsFixer:risky' => true, + '@PHP74Migration:risky' => true, + '@PHP74Migration' => true, // required by PSR-12 'concat_space' => [ @@ -31,10 +31,8 @@ 'equal' => false, 'identical' => false, ], + 'native_constant_invocation' => true, 'native_function_invocation' => false, - 'non_printable_character' => [ - 'use_escape_sequences_in_strings' => true, - ], 'void_return' => false, 'blank_line_before_statement' => [ 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'], @@ -52,13 +50,16 @@ 'phpdoc_add_missing_param_annotation' => false, 'return_assignment' => false, 'comment_to_phpdoc' => false, - 'list_syntax' => ['syntax' => 'short'], 'general_phpdoc_annotation_remove' => [ 'annotations' => ['author', 'copyright', 'throws'], ], 'nullable_type_declaration_for_default_null_value' => [ 'use_nullable_type_declaration' => false, ], + + // fn => without curly brackets is less readable, + // also prevent bounding of unwanted variables for GC + 'use_arrow_functions' => false, ]) ->setFinder($finder) - ->setCacheFile(__DIR__ . '/.php_cs.cache'); + ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache'); diff --git a/composer.json b/composer.json index ee65fe91..7d47024f 100644 --- a/composer.json +++ b/composer.json @@ -27,24 +27,24 @@ } ], "require": { - "php": ">=7.3.0", + "php": ">=7.4.0", "ext-pdo": "*", "atk4/core": "dev-develop", "doctrine/dbal": "^2.10 || ^3.0" }, "require-release": { - "php": ">=7.3.0", + "php": ">=7.4.0", "ext-pdo": "*", "atk4/core": "~3.0.0", "doctrine/dbal": "^2.10 || ^3.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.13", - "friendsofphp/php-cs-fixer": "^2.17", + "friendsofphp/php-cs-fixer": "^3.0", "johnkary/phpunit-speedtrap": "^3.2", "phpstan/phpstan": "^0.12.58", "phpunit/phpcov": "*", - "phpunit/phpunit": ">=9.1" + "phpunit/phpunit": ">=9.3" }, "suggest": { "jdorn/sql-formatter": "*" diff --git a/src/Connection.php b/src/Connection.php index 1e625df6..14515db1 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -341,11 +341,12 @@ public function getAddExtendedPropertySQL( . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level0Name) . ', N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level1Name) - . ($level2Type !== null || $level2Name !== null + . ( + $level2Type !== null || $level2Name !== null ? ', N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level2Name) : '' - ); + ); } public function getDropExtendedPropertySQL( @@ -363,11 +364,12 @@ public function getDropExtendedPropertySQL( . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level0Name) . ', N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level1Name) - . ($level2Type !== null || $level2Name !== null + . ( + $level2Type !== null || $level2Name !== null ? ', N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level2Name) : '' - ); + ); } public function getUpdateExtendedPropertySQL( @@ -386,11 +388,12 @@ public function getUpdateExtendedPropertySQL( . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level0Name) . ', N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level1Name) - . ($level2Type !== null || $level2Name !== null + . ( + $level2Type !== null || $level2Name !== null ? ', N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $this->quoteSingleIdentifierAsStringLiteral((string) $level2Name) : '' - ); + ); } protected function getCommentOnTableSQL(string $tableName, ?string $comment): string @@ -422,7 +425,7 @@ protected function getCommentOnTableSQL(string $tableName, ?string $comment): st $dbalConnection->platform = new class() extends OraclePlatform { private function forwardTypeDeclarationSQL(string $targetMethodName, array $column): string { - $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS); + $backtrace = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS); foreach ($backtrace as $frame) { if ($this === ($frame['object'] ?? null) && $targetMethodName === ($frame['function'] ?? null)) { diff --git a/src/Expression.php b/src/Expression.php index e33807a4..4c15f23c 100644 --- a/src/Expression.php +++ b/src/Expression.php @@ -112,7 +112,7 @@ public function __construct($properties = [], $arguments = null) */ public function __toString() { - 'trigger_error'('Method is deprecated. Use $this->getOne() instead', E_USER_DEPRECATED); + 'trigger_error'('Method is deprecated. Use $this->getOne() instead', \E_USER_DEPRECATED); return $this->getOne(); } @@ -613,7 +613,7 @@ private function getCastValue($v): ?string */ public function get(): array { - 'trigger_error'('Method is deprecated. Use getRows instead', E_USER_DEPRECATED); + 'trigger_error'('Method is deprecated. Use getRows instead', \E_USER_DEPRECATED); return $this->getRows(); }