diff --git a/.github/main.workflow b/.github/main.workflow new file mode 100644 index 0000000..04d7fe5 --- /dev/null +++ b/.github/main.workflow @@ -0,0 +1,35 @@ +workflow "Qa workflow" { + on = "push" + resolves = [ + "PHPStan", + "composer-require-checker", + "Code style check", + ] +} + +action "composer" { + uses = "docker://composer" + secrets = ["GITHUB_TOKEN"] + args = "install --no-interaction --prefer-dist --optimize-autoloader" +} + +action "PHPStan" { + uses = "docker://oskarstark/phpstan-ga" + args = "analyse src tests --level max --configuration phpstan.neon" + secrets = ["GITHUB_TOKEN"] + needs = ["composer"] +} + +action "composer-require-checker" { + uses = "docker://phpga/composer-require-checker-ga" + secrets = ["GITHUB_TOKEN"] + args = "check --config-file ./composer-require-config.json composer.json" + needs = ["composer"] +} + +action "Code style check" { + uses = "docker://oskarstark/phpcs-ga" + secrets = ["GITHUB_TOKEN"] + args = "-d memory_limit=1024M" + needs = ["composer"] +} diff --git a/.travis.yml b/.travis.yml index 049308e..0f8e8a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,19 +26,6 @@ jobs: - travis_retry php phive.phar --no-progress install --trust-gpg-keys E82B2FB314E9906E php-coveralls/php-coveralls && ./tools/php-coveralls --verbose - travis_retry wget --no-verbose https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml - - stage: analysis - php: 7.1 - before_script: - - travis_retry wget --no-verbose https://phar.io/releases/phive.phar - - travis_retry php phive.phar --no-progress install --trust-gpg-keys 8E730BA25823D8B5 phpstan - script: - - ./tools/phpstan analyse src --level max --configuration phpstan.neon - - - stage: analysis - php: 7.1 - script: - - composer create-project symplify/easy-coding-standard temp/ecs ^3 && temp/ecs/bin/ecs check src tests - cache: directories: - $HOME/.composer diff --git a/composer-require-config.json b/composer-require-config.json new file mode 100644 index 0000000..19eee4f --- /dev/null +++ b/composer-require-config.json @@ -0,0 +1,15 @@ +{ + "symbol-whitelist" : [ + "null", "true", "false", + "static", "self", "parent", + "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor" + ], + "php-core-extensions" : [ + "Core", + "pcre", + "Reflection", + "tokenizer", + "SPL", + "standard" + ] +} diff --git a/composer.json b/composer.json index df3681c..fdd0012 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ }, "require-dev": { "mockery/mockery": "~1", - "phpunit/phpunit": "~6" + "phpunit/phpunit": "~6", + "ext-tokenizer": "^7.1" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 0bb56da..72e114f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b86fda2a5ea5ce96e6f3d75584fc43fc", + "content-hash": "06b34e8692439fcd33da549a3379fe6e", "packages": [ { "name": "phpdocumentor/reflection-common", @@ -815,6 +815,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2017-02-02T10:36:38+00:00" }, { @@ -1337,9 +1338,11 @@ "phpdocumentor/reflection-common": 10 }, "prefer-stable": false, - "prefer-lowest": true, + "prefer-lowest": false, "platform": { "php": ">=7.1" }, - "platform-dev": [] + "platform-dev": { + "ext-tokenizer": "^7.1" + } } diff --git a/easy-coding-standard.neon b/easy-coding-standard.neon deleted file mode 100644 index a76d463..0000000 --- a/easy-coding-standard.neon +++ /dev/null @@ -1,37 +0,0 @@ -includes: - - temp/ecs/config/clean-code.neon - - temp/ecs/config/psr2.neon - - temp/ecs/config/common.neon - -parameters: - exclude_checkers: - # from temp/ecs/config/common.neon - - PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer - - PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer - - PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer - # from temp/ecs/config/spaces.neon - - PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer - - skip: - PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff: - - */tests/** - PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff: - - src/Types/Array_.php - - src/Types/Callable_.php - - src/Types/Float_.php - - src/Types/Iterable_.php - - src/Types/Mixed_.php - - src/Types/Null_.php - - src/Types/Object_.php - - src/Types/Parent_.php - - src/Types/Resource_.php - - src/Types/Self_.php - - src/Types/Static_.php - - src/Types/String_.php - - src/Types/Void_.php - PhpCsFixer\Fixer\Import\OrderedImportsFixer: - - *tests/unit/Types/ContextFactoryTest.php - PhpCsFixer\Fixer\Import\SingleImportPerStatementFixer: - - *tests/unit/Types/ContextFactoryTest.php - PhpCsFixer\Fixer\Import\SingleLineAfterImportsFixer: - - *tests/unit/Types/ContextFactoryTest.php diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..732b5fe --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,15 @@ + + + The coding standard for phpDocumentor. + + src + tests/unit + */tests/unit/Types/ContextFactoryTest.php + + + *\.php + + + */src/*_.php + + diff --git a/src/TypeResolver.php b/src/TypeResolver.php index ca0cf9b..e5b5fc2 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -115,7 +115,13 @@ public function resolve($type, Context $context = null) } // split the type string into tokens `|`, `?`, `(`, `)[]`, '<', '>' and type names - $tokens = preg_split('/(\\||\\?|<|>|,|\\(|\\)(?:\\[\\])+)/', $type, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); + $tokens = preg_split( + '/(\\||\\?|<|>|,|\\(|\\)(?:\\[\\])+)/', + $type, + -1, + PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE + ); + if (false === $tokens) { throw new \InvalidArgumentException('Unable to split the type string "' . $type . '" into tokens'); } @@ -200,7 +206,7 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon } $classType = array_pop($types); - if ($classType) { + if ($classType !== null) { $types[] = $this->resolveCollection($tokens, $classType, $context); }