From 009d4c42644887ae937950611402c816241155f5 Mon Sep 17 00:00:00 2001 From: Damien Debin Date: Thu, 20 Aug 2020 15:42:43 +0200 Subject: [PATCH] More CS fixes. --- .github/workflows/main.yml | 4 +- .idea/mc-google-visualization.iml | 1 + .idea/php.xml | 1 + .php_cs | 34 ++++- composer.json | 6 +- examples/callback_fields.php | 9 +- examples/complete.php | 10 +- examples/index.php | 4 +- examples/joins.php | 10 +- examples/simple.php | 6 +- lib/MC/Google/Visualization.php | 152 +++++++++++---------- lib/MC/Google/Visualization_Error.php | 2 + lib/MC/Google/Visualization_QueryError.php | 2 + lib/MC/Parser.php | 66 ++------- lib/MC/Parser/Def.php | 27 +--- lib/MC/Parser/Def/IsEmpty.php | 11 +- lib/MC/Parser/Def/Literal.php | 14 +- lib/MC/Parser/Def/NOrMore.php | 12 +- lib/MC/Parser/Def/OneOf.php | 7 +- lib/MC/Parser/Def/Recursive.php | 12 +- lib/MC/Parser/Def/Regex.php | 33 ++--- lib/MC/Parser/Def/Set.php | 9 +- lib/MC/Parser/Def/Word.php | 8 +- lib/MC/Parser/DefError.php | 2 + lib/MC/Parser/Error.php | 2 + lib/MC/Parser/ParseError.php | 2 + lib/MC/Parser/Token.php | 5 +- lib/MC/Parser/Token/Group.php | 12 +- phpstan.neon | 3 + tests/ExampleTest.php | 8 +- tests/ParserTest.php | 53 +++---- tests/VisualizationTest.php | 42 +++--- 32 files changed, 265 insertions(+), 304 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d00c597..257a784 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,10 +8,10 @@ on: jobs: tests: - runs-on: ubuntu-latest + runs-on: ubuntu-16.04 strategy: matrix: - php: ['7.1', '7.2', '7.3', '7.4'] + php: ['7.0', '7.1', '7.2', '7.3', '7.4'] name: PHP ${{ matrix.php }} tests steps: - uses: actions/checkout@v2 diff --git a/.idea/mc-google-visualization.iml b/.idea/mc-google-visualization.iml index d2e6df0..2c56724 100644 --- a/.idea/mc-google-visualization.iml +++ b/.idea/mc-google-visualization.iml @@ -28,6 +28,7 @@ + diff --git a/.idea/php.xml b/.idea/php.xml index d89811f..c622d21 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -57,6 +57,7 @@ + diff --git a/.php_cs b/.php_cs index 0edcd51..0e24561 100644 --- a/.php_cs +++ b/.php_cs @@ -1,19 +1,41 @@ name('.php_cs') ->exclude('vendor') ->in(__DIR__) ; -return PhpCsFixer\Config::create() +return Config::create() ->setRules([ - '@PSR1' => true, - '@PSR2' => true, '@PhpCsFixer' => true, '@PhpCsFixer:risky' => true, - 'array_syntax' => ['syntax' => 'short'], - 'php_unit_test_class_requires_covers' => false, + '@DoctrineAnnotation' => true, + '@PHP70Migration:risky' => true, + '@PHPUnit75Migration:risky' => true, + 'backtick_to_shell_exec' => true, + 'blank_line_before_statement' => [ + 'statements' => ['declare', 'return', 'case'], + ], + 'comment_to_phpdoc' => false, + 'declare_equal_normalize' => ['space' => 'single'], + 'doctrine_annotation_array_assignment' => ['operator' => '='], + 'doctrine_annotation_spaces' => [ + 'after_array_assignments_equals' => false, + 'before_array_assignments_equals' => false + ], + 'final_static_access' => true, + 'global_namespace_import' => true, + 'linebreak_after_opening_tag' => true, + 'mb_str_functions' => true, 'native_function_invocation' => false, + 'no_unset_on_property' => false, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'phpdoc_to_comment' => false, + 'self_static_accessor' => true, ]) ->setFinder($finder) ; \ No newline at end of file diff --git a/composer.json b/composer.json index 92355a7..caefc1d 100644 --- a/composer.json +++ b/composer.json @@ -24,12 +24,14 @@ "require": { "php": "^7.0", "ext-json": "*", - "ext-pdo": "*" + "ext-pdo": "*", + "symfony/polyfill-php74": "^1.0" }, "require-dev": { "phpunit/phpunit": "^6.0|^7.0", "phpstan/phpstan": "^0.9|^0.10|^0.11", - "phpstan/phpstan-phpunit": "^0.9|^0.10|^0.11" + "phpstan/phpstan-phpunit": "^0.9|^0.10|^0.11", + "phpstan/phpstan-strict-rules": "^0.9|^0.10|^0.11" }, "autoload": { "psr-4": { diff --git a/examples/callback_fields.php b/examples/callback_fields.php index 307ba8f..1c2d287 100644 --- a/examples/callback_fields.php +++ b/examples/callback_fields.php @@ -2,13 +2,16 @@ /** @noinspection PhpUnhandledExceptionInspection */ +declare(strict_types = 1); + use MC\Google\Visualization; require_once __DIR__.'/../vendor/autoload.php'; /** * @param mixed $row - * @return string|null + * + * @return null|string */ function most_common($row) { @@ -60,13 +63,13 @@ function most_common($row)