diff --git a/.travis.yml b/.travis.yml index eff3999d0d9..784ceefbd27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: php php: + - '5.4' + - '5.5' - '5.6' - '7.0' - hhvm diff --git a/composer.json b/composer.json index 26112441ea8..934ef839d85 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ } ], "require": { - "php": ">=5.5", - "nikic/PHP-Parser": ">=3.0.2" + "php": ">=5.4", + "nikic/PHP-Parser": "2.1.1" }, "bin": ["bin/psalm"], "autoload": { @@ -25,12 +25,14 @@ } }, "require-dev": { - "phpunit/phpunit": ">=5.7.4", + "phpunit/phpunit": "4.8.30", + "phpdocumentor/reflection-docblock": "2.0.4", + "symfony/yaml": "2.8.14", "squizlabs/php_codesniffer": "^2.7" }, "scripts": { - "psalm": "./bin/psalm", + "psalm": "./bin/psalm --self-check", "standards": "phpcs --standard=phpcs.xml", - "tests": "phpunit" + "tests": "phpunit tests/" } } diff --git a/composer.lock b/composer.lock index 4e5b21890b5..b9123a2018a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,29 +4,29 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "2f9bbd2aff61c88e305273c1b5ff89f9", - "content-hash": "374dd7edc5ef60c6a23102a40acfcd21", + "hash": "a8ae943b97b319593735df71a43200ff", + "content-hash": "5b4f509e6c69d23d51be8765b1bb8075", "packages": [ { "name": "nikic/php-parser", - "version": "v3.0.2", + "version": "v2.1.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "adf44419c0fc014a0f191db6f89d3e55d4211744" + "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/adf44419c0fc014a0f191db6f89d3e55d4211744", - "reference": "adf44419c0fc014a0f191db6f89d3e55d4211744", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4dd659edadffdc2143e4753df655d866dbfeedf0", + "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.5" + "php": ">=5.4" }, "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" + "phpunit/phpunit": "~4.0" }, "bin": [ "bin/php-parse" @@ -34,7 +34,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -56,7 +56,7 @@ "parser", "php" ], - "time": "2016-12-06 11:30:35" + "time": "2016-09-16 12:04:44" } ], "packages-dev": [ @@ -114,178 +114,39 @@ ], "time": "2015-06-14 21:17:01" }, - { - "name": "myclabs/deep-copy", - "version": "1.5.5", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/399c1f9781e222f6eb6cc238796f5200d1b7f108", - "reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2016-10-31 17:19:45" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "1.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "time": "2015-12-27 11:43:31" - }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.1.1", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.2.0", - "webmozart/assert": "^1.0" + "php": ">=5.3.3" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-09-30 07:12:33" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "0.2.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", - "shasum": "" - }, - "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0" + "phpunit/phpunit": "~4.0" }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ + "psr-0": { + "phpDocumentor": [ "src/" ] } @@ -297,10 +158,10 @@ "authors": [ { "name": "Mike van Riel", - "email": "me@mikevanriel.com" + "email": "mike.vanriel@naenius.com" } ], - "time": "2016-11-25 06:54:22" + "time": "2015-02-03 12:10:50" }, { "name": "phpspec/prophecy", @@ -367,40 +228,39 @@ }, { "name": "phpunit/php-code-coverage", - "version": "4.0.4", + "version": "2.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "c14196e64a78570034afd0b7a9f3757ba71c2a0a" + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c14196e64a78570034afd0b7a9f3757ba71c2a0a", - "reference": "c14196e64a78570034afd0b7a9f3757ba71c2a0a", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0", + "php": ">=5.3.3", "phpunit/php-file-iterator": "~1.3", "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "^1.4.2", - "sebastian/code-unit-reverse-lookup": "~1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "~1.0|~2.0" + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "^1.3.2", + "sebastian/version": "~1.0" }, "require-dev": { "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "^5.4" + "phpunit/phpunit": "~4" }, "suggest": { "ext-dom": "*", - "ext-xdebug": ">=2.4.0", + "ext-xdebug": ">=2.2.1", "ext-xmlwriter": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "2.2.x-dev" } }, "autoload": { @@ -426,7 +286,7 @@ "testing", "xunit" ], - "time": "2016-12-20 15:22:42" + "time": "2015-10-06 15:47:00" }, { "name": "phpunit/php-file-iterator", @@ -611,50 +471,40 @@ }, { "name": "phpunit/phpunit", - "version": "5.7.4", + "version": "4.8.30", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09" + "reference": "a534e04d0bd39c557c2881c341efd06fa6f1292a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af91da3f2671006ff5d0628023de3b7ac4d1ef09", - "reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a534e04d0bd39c557c2881c341efd06fa6f1292a", + "reference": "a534e04d0bd39c557c2881c341efd06fa6f1292a", "shasum": "" }, "require": { "ext-dom": "*", "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.3", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "^1.3.1", + "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.2", + "phpunit/phpunit-mock-objects": "~2.3", "sebastian/comparator": "~1.2.2", "sebastian/diff": "~1.2", - "sebastian/environment": "^1.3.4 || ^2.0", - "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.0 || ^2.0", - "sebastian/object-enumerator": "~2.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0|~2.0", + "sebastian/environment": "~1.3", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", "symfony/yaml": "~2.1|~3.0" }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" - }, - "require-dev": { - "ext-pdo": "*" - }, "suggest": { - "ext-xdebug": "*", "phpunit/php-invoker": "~1.1" }, "bin": [ @@ -663,7 +513,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7.x-dev" + "dev-master": "4.8.x-dev" } }, "autoload": { @@ -689,33 +539,30 @@ "testing", "xunit" ], - "time": "2016-12-13 16:19:44" + "time": "2016-12-01 17:05:48" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.4.3", + "version": "2.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24" + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", - "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", - "php": "^5.6 || ^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2 || ^2.0" - }, - "conflict": { - "phpunit/phpunit": "<5.4.0" + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" }, "require-dev": { - "phpunit/phpunit": "^5.4" + "phpunit/phpunit": "~4.4" }, "suggest": { "ext-soap": "*" @@ -723,7 +570,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2.x-dev" + "dev-master": "2.3.x-dev" } }, "autoload": { @@ -748,52 +595,7 @@ "mock", "xunit" ], - "time": "2016-12-08 20:27:08" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "phpunit/phpunit": "~5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2016-02-13 06:45:14" + "time": "2015-10-02 06:51:40" }, { "name": "sebastian/comparator", @@ -913,28 +715,28 @@ }, { "name": "sebastian/environment", - "version": "2.0.0", + "version": "1.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^4.8 || ^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -959,25 +761,25 @@ "environment", "hhvm" ], - "time": "2016-11-26 07:53:53" + "time": "2016-08-18 05:49:44" }, { "name": "sebastian/exporter", - "version": "2.0.0", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", "shasum": "" }, "require": { "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" + "sebastian/recursion-context": "~1.0" }, "require-dev": { "ext-mbstring": "*", @@ -986,7 +788,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -1026,7 +828,7 @@ "export", "exporter" ], - "time": "2016-11-19 08:54:04" + "time": "2016-06-17 09:04:28" }, { "name": "sebastian/global-state", @@ -1079,64 +881,18 @@ ], "time": "2015-10-12 03:26:01" }, - { - "name": "sebastian/object-enumerator", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", - "reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2016-11-19 07:35:10" - }, { "name": "sebastian/recursion-context", - "version": "2.0.0", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + "reference": "913401df809e99e4f47b27cdd781f4a258d58791" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", + "reference": "913401df809e99e4f47b27cdd781f4a258d58791", "shasum": "" }, "require": { @@ -1148,7 +904,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -1176,73 +932,23 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-11-19 07:33:16" - }, - { - "name": "sebastian/resource-operations", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "shasum": "" - }, - "require": { - "php": ">=5.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28 20:34:47" + "time": "2015-11-11 19:50:13" }, { "name": "sebastian/version", - "version": "2.0.1", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", "shasum": "" }, - "require": { - "php": ">=5.6" - }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, "autoload": { "classmap": [ "src/" @@ -1261,7 +967,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03 07:35:21" + "time": "2015-06-21 13:59:46" }, { "name": "squizlabs/php_codesniffer", @@ -1343,31 +1049,25 @@ }, { "name": "symfony/yaml", - "version": "v3.2.1", + "version": "v2.8.14", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "a7095af4b97a0955f85c8989106c249fa649011f" + "reference": "befb26a3713c97af90d25dd12e75621ef14d91ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/a7095af4b97a0955f85c8989106c249fa649011f", - "reference": "a7095af4b97a0955f85c8989106c249fa649011f", + "url": "https://api.github.com/repos/symfony/yaml/zipball/befb26a3713c97af90d25dd12e75621ef14d91ff", + "reference": "befb26a3713c97af90d25dd12e75621ef14d91ff", "shasum": "" }, "require": { - "php": ">=5.5.9" - }, - "require-dev": { - "symfony/console": "~2.8|~3.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -1394,57 +1094,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-12-10 10:07:06" - }, - { - "name": "webmozart/assert", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "time": "2016-11-23 20:04:58" + "time": "2016-11-14 16:15:57" } ], "aliases": [], @@ -1453,7 +1103,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.5" + "php": ">=5.4" }, "platform-dev": [] } diff --git a/src/Psalm/Checker/ClassLikeChecker.php b/src/Psalm/Checker/ClassLikeChecker.php index f6d6bc11991..f2027ea0ea0 100644 --- a/src/Psalm/Checker/ClassLikeChecker.php +++ b/src/Psalm/Checker/ClassLikeChecker.php @@ -45,7 +45,6 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc 'empty' => 'empty', 'callable' => 'callable', 'array' => 'array', - 'iterable' => 'iterable', 'null' => 'null', 'mixed' => 'mixed', ]; @@ -184,13 +183,7 @@ public function visit( foreach ($this->class->stmts as $stmt) { if ($stmt instanceof PhpParser\Node\Stmt\ClassConst) { foreach ($stmt->consts as $const) { - if ($stmt->isProtected()) { - $storage->protected_class_constants[$const->name] = Type::getMixed(); - } elseif ($stmt->isPrivate()) { - $storage->private_class_constants[$const->name] = Type::getMixed(); - } else { - $storage->public_class_constants[$const->name] = Type::getMixed(); - } + $storage->public_class_constants[$const->name] = Type::getMixed(); } } } @@ -445,7 +438,6 @@ protected function analyzeClassMethod( if ($class_context->self && $class_context->self !== $source->getFQCLN()) { $analyzed_method_id = (string)$method_checker->getMethodId($class_context->self); - $declaring_method_id = MethodChecker::getDeclaringMethodId($analyzed_method_id); if ($actual_method_id !== $declaring_method_id) { @@ -576,7 +568,6 @@ protected function registerParentClassInfo($parent_class) $storage->class_implements += $parent_storage->class_implements; $storage->public_class_constants = $parent_storage->public_class_constants; - $storage->protected_class_constants = $parent_storage->protected_class_constants; $storage->parent_classes = array_merge([strtolower($parent_class)], $parent_storage->parent_classes); @@ -793,13 +784,7 @@ protected function visitClassConstDeclaration( $const_type = $type_in_comment ? $type_in_comment : Type::getMixed(); foreach ($stmt->consts as $const) { - if ($stmt->isProtected()) { - $storage->protected_class_constants[$const->name] = $const_type; - } elseif ($stmt->isPrivate()) { - $storage->private_class_constants[$const->name] = $const_type; - } else { - $storage->public_class_constants[$const->name] = $const_type; - } + $storage->public_class_constants[$const->name] = $const_type; } } @@ -982,7 +967,7 @@ public function getFQCLN() } /** - * @return string|null + * @return string */ public function getClassName() { @@ -1067,7 +1052,6 @@ public static function registerReflectedClass( $storage->class_implements = $parent_storage->class_implements; $storage->public_class_constants = $parent_storage->public_class_constants; - $storage->protected_class_constants = $parent_storage->protected_class_constants; $storage->parent_classes = array_merge([strtolower($parent_class_name)], $parent_storage->parent_classes); $storage->used_traits = $parent_storage->used_traits; @@ -1297,7 +1281,8 @@ public static function getTypeFromValue($value) */ public static function getConstantsForClass($class_name, $visibility) { - $class_name = strtolower($class_name); + // remove for PHP 7.1 support + $visibility = ReflectionProperty::IS_PUBLIC; $class_name = strtolower($class_name); @@ -1311,21 +1296,6 @@ public static function getConstantsForClass($class_name, $visibility) return $storage->public_class_constants; } - if ($visibility === ReflectionProperty::IS_PROTECTED) { - return array_merge( - $storage->public_class_constants, - $storage->protected_class_constants - ); - } - - if ($visibility === ReflectionProperty::IS_PRIVATE) { - return array_merge( - $storage->public_class_constants, - $storage->protected_class_constants, - $storage->private_class_constants - ); - } - throw new \InvalidArgumentException('Must specify $visibility'); } @@ -1340,13 +1310,7 @@ public static function setConstantType($class_name, $const_name, Type\Union $typ { $storage = self::$storage[strtolower($class_name)]; - if ($visibility === ReflectionProperty::IS_PUBLIC) { - $storage->public_class_constants[$const_name] = $type; - } elseif ($visibility === ReflectionProperty::IS_PROTECTED) { - $storage->protected_class_constants[$const_name] = $type; - } elseif ($visibility === ReflectionProperty::IS_PRIVATE) { - $storage->private_class_constants[$const_name] = $type; - } + $storage->public_class_constants[$const_name] = $type; } /** diff --git a/src/Psalm/Checker/FileChecker.php b/src/Psalm/Checker/FileChecker.php index 2b897592c94..42c768843a5 100644 --- a/src/Psalm/Checker/FileChecker.php +++ b/src/Psalm/Checker/FileChecker.php @@ -510,7 +510,7 @@ public static function getStatementsForFile($file_path, $debug_output = false) $cache_location = null; $name_cache_key = null; - $version = 'parsercache4'; + $version = 'parsercache2'; $file_contents = $project_checker->getFileContents($file_path); $file_content_hash = md5($version . $file_contents); diff --git a/src/Psalm/Checker/FunctionLikeChecker.php b/src/Psalm/Checker/FunctionLikeChecker.php index 52560d8cc43..aaf1e6e58ab 100644 --- a/src/Psalm/Checker/FunctionLikeChecker.php +++ b/src/Psalm/Checker/FunctionLikeChecker.php @@ -504,11 +504,6 @@ public static function register( if ($parser_return_type = $function->getReturnType()) { $suffix = ''; - if ($parser_return_type instanceof PhpParser\Node\NullableType) { - $suffix = '|null'; - $parser_return_type = $parser_return_type->type; - } - if (is_string($parser_return_type)) { $return_type_string = $parser_return_type . $suffix; } else { @@ -1056,11 +1051,6 @@ public static function getTranslatedParam( $param_typehint = $param->type; - if ($param_typehint instanceof PhpParser\Node\NullableType) { - $is_nullable = true; - $param_typehint = $param_typehint->type; - } - if ($param_typehint) { if (is_string($param_typehint)) { $param_type_string = $param_typehint; diff --git a/src/Psalm/Checker/Statements/Block/ForeachChecker.php b/src/Psalm/Checker/Statements/Block/ForeachChecker.php index ee4dc7025bf..fdbfb79e918 100644 --- a/src/Psalm/Checker/Statements/Block/ForeachChecker.php +++ b/src/Psalm/Checker/Statements/Block/ForeachChecker.php @@ -156,14 +156,20 @@ public static function analyze( $statements_checker->registerVariable('$' . $stmt->keyVar->name, $stmt->getLine()); } - AssignmentChecker::analyze( - $statements_checker, - $stmt->valueVar, - null, - $value_type ?: Type::getMixed(), - $foreach_context, - (string)$stmt->getDocComment() - ); + + if ($stmt->valueVar instanceof PhpParser\Node\Expr\List_) { + foreach ($stmt->valueVar->vars as $var) { + if ($var && $var instanceof PhpParser\Node\Expr\Variable && is_string($var->name)) { + $foreach_context->vars_in_scope['$' . $var->name] = Type::getMixed(); + $foreach_context->vars_possibly_in_scope['$' . $var->name] = true; + $statements_checker->registerVariable('$' . $var->name, $var->getLine()); + } + } + } elseif ($stmt->valueVar instanceof PhpParser\Node\Expr\Variable && is_string($stmt->valueVar->name)) { + $foreach_context->vars_in_scope['$' . $stmt->valueVar->name] = $value_type ? $value_type : Type::getMixed(); + $foreach_context->vars_possibly_in_scope['$' . $stmt->valueVar->name] = true; + $statements_checker->registerVariable('$' . $stmt->valueVar->name, $stmt->getLine()); + } CommentChecker::getTypeFromComment( (string) $stmt->getDocComment(), diff --git a/src/Psalm/Checker/Statements/Block/TryChecker.php b/src/Psalm/Checker/Statements/Block/TryChecker.php index 5e5941aad85..8d28710a2a8 100644 --- a/src/Psalm/Checker/Statements/Block/TryChecker.php +++ b/src/Psalm/Checker/Statements/Block/TryChecker.php @@ -34,40 +34,27 @@ public static function analyze( foreach ($stmt->catches as $catch) { $catch_context = clone $original_context; - $fq_catch_classes = []; + $catch_class = ClassLikeChecker::getFQCLNFromNameObject( + $catch->type, + $statements_checker + ); - foreach ($catch->types as $catch_type) { - $fq_catch_class = ClassLikeChecker::getFQCLNFromNameObject( - $catch_type, - $statements_checker - ); + if ($context->check_classes) { + $fq_class_name = $catch_class; - if ($context->check_classes) { - if (ClassLikeChecker::checkFullyQualifiedClassLikeName( - $fq_catch_class, - $statements_checker->getFileChecker(), - new CodeLocation($statements_checker->getSource(), $catch_type), - $statements_checker->getSuppressedIssues() - ) === false) { - return false; - } + if (ClassLikeChecker::checkFullyQualifiedClassLikeName( + $fq_class_name, + $statements_checker->getFileChecker(), + new CodeLocation($statements_checker->getSource(), $catch), + $statements_checker->getSuppressedIssues() + ) === false) { + return false; } - - $fq_catch_classes[] = $fq_catch_class; } - $catch_context->vars_in_scope['$' . $catch->var] = new Type\Union( - array_map( - /** - * @param string $fq_catch_class - * @return Type\Atomic - */ - function ($fq_catch_class) { - return new TNamedObject($fq_catch_class); - }, - $fq_catch_classes - ) - ); + $catch_context->vars_in_scope['$' . $catch->var] = new Type\Union([ + new Type\Atomic\TNamedObject($catch_class) + ]); $catch_context->vars_possibly_in_scope['$' . $catch->var] = true; @@ -95,8 +82,8 @@ function ($fq_catch_class) { } } - if ($stmt->finally) { - $statements_checker->analyze($stmt->finally->stmts, $context, $loop_context); + if ($stmt->finallyStmts) { + $statements_checker->analyze($stmt->finallyStmts, $context, $loop_context); } return null; diff --git a/src/Psalm/Checker/Statements/Expression/AssignmentChecker.php b/src/Psalm/Checker/Statements/Expression/AssignmentChecker.php index 2977dc0fa1c..64c82395bc2 100644 --- a/src/Psalm/Checker/Statements/Expression/AssignmentChecker.php +++ b/src/Psalm/Checker/Statements/Expression/AssignmentChecker.php @@ -139,17 +139,13 @@ public static function analyze( $context->vars_in_scope[$var_id] = $assign_value_type; $context->vars_possibly_in_scope[$var_id] = true; $statements_checker->registerVariable($var_id, $assign_var->getLine()); - } elseif ($assign_var instanceof PhpParser\Node\Expr\List_ - || $assign_var instanceof PhpParser\Node\Expr\Array_ - ) { - foreach ($assign_var->items as $offset => $assign_var_item) { - // $assign_var_item can be null e.g. list($a, ) = ['a', 'b'] - if (!$assign_var_item) { + } elseif ($assign_var instanceof PhpParser\Node\Expr\List_) { + foreach ($assign_var->vars as $offset => $var) { + // $var can be null e.g. list($a, ) = ['a', 'b'] + if (!$var) { continue; } - $var = $assign_var_item->value; - if ($assign_value instanceof PhpParser\Node\Expr\Array_ && isset($assign_value->items[$offset]->value->inferredType) ) { @@ -177,19 +173,10 @@ public static function analyze( if (isset($assign_value_type->types['array'])) { if ($assign_value_type->types['array'] instanceof Type\Atomic\TArray) { - $context->vars_in_scope[$list_var_id] = clone $assign_value_type->types['array']->type_params[1]; + $context->vars_in_scope[$list_var_id] = + clone $assign_value_type->types['array']->type_params[1]; continue; - } elseif ($assign_value_type->types['array'] instanceof Type\Atomic\ObjectLike) { - if ($assign_var_item->key - && $assign_var_item->key instanceof PhpParser\Node\Scalar\String_ - && isset($assign_value_type->types['array']->properties[$assign_var_item->key->value]) - ) { - $context->vars_in_scope[$list_var_id] = - clone $assign_value_type->types['array']->properties[$assign_var_item->key->value]; - - continue; - } } } diff --git a/src/Psalm/Checker/Statements/Expression/FetchChecker.php b/src/Psalm/Checker/Statements/Expression/FetchChecker.php index 587aa51023b..6e4e299bc66 100644 --- a/src/Psalm/Checker/Statements/Expression/FetchChecker.php +++ b/src/Psalm/Checker/Statements/Expression/FetchChecker.php @@ -14,7 +14,6 @@ use Psalm\Issue\InvalidArrayAccess; use Psalm\Issue\InvalidArrayAssignment; use Psalm\Issue\InvalidPropertyFetch; -use Psalm\Issue\InaccessibleClassConstant; use Psalm\Issue\InaccessibleProperty; use Psalm\Issue\MissingPropertyType; use Psalm\Issue\MixedArrayAccess; @@ -442,47 +441,16 @@ public static function analyzeClassConstFetch( $const_id = $fq_class_name . '::' . $stmt->name; - if ($fq_class_name === $context->self - || ( - $statements_checker->getSource()->getSource() instanceof TraitChecker && - $fq_class_name === $statements_checker->getSource()->getFQCLN() - ) - ) { - $class_visibility = \ReflectionProperty::IS_PRIVATE; - } elseif ($context->self && - ClassChecker::classExtends($context->self, $fq_class_name) - ) { - $class_visibility = \ReflectionProperty::IS_PROTECTED; - } else { - $class_visibility = \ReflectionProperty::IS_PUBLIC; - } - - $class_constants = ClassLikeChecker::getConstantsForClass($fq_class_name, $class_visibility); + $class_constants = ClassLikeChecker::getConstantsForClass($fq_class_name, \ReflectionProperty::IS_PUBLIC); if (!isset($class_constants[$stmt->name])) { - $all_class_constants = []; - - if ($fq_class_name !== $context->self) { - $all_class_constants = ClassLikeChecker::getConstantsForClass( - $fq_class_name, - \ReflectionProperty::IS_PRIVATE - ); - } - - if ($all_class_constants && isset($all_class_constants[$stmt->name])) { - IssueBuffer::add( - new InaccessibleClassConstant( - 'Constant ' . $const_id . ' is not visible in this context', - new CodeLocation($statements_checker->getSource(), $stmt) - ) - ); - } else { - IssueBuffer::add( - new UndefinedConstant( - 'Constant ' . $const_id . ' is not defined', - new CodeLocation($statements_checker->getSource(), $stmt) - ) - ); + if (IssueBuffer::accepts( + new UndefinedConstant( + 'Constant ' . $const_id . ' is not defined', + new CodeLocation($statements_checker->getSource(), $stmt) + ) + )) { + // fall through } return false; diff --git a/src/Psalm/Checker/StatementsChecker.php b/src/Psalm/Checker/StatementsChecker.php index ae882a254aa..b737cd386d5 100644 --- a/src/Psalm/Checker/StatementsChecker.php +++ b/src/Psalm/Checker/StatementsChecker.php @@ -263,14 +263,6 @@ public function analyze( } elseif ($stmt instanceof PhpParser\Node\Stmt\ClassConst) { $const_visibility = \ReflectionProperty::IS_PUBLIC; - if ($stmt->isProtected()) { - $const_visibility = \ReflectionProperty::IS_PROTECTED; - } - - if ($stmt->isPrivate()) { - $const_visibility = \ReflectionProperty::IS_PRIVATE; - } - foreach ($stmt->consts as $const) { ExpressionChecker::analyze($this, $const->value, $context); diff --git a/src/Psalm/Checker/TypeChecker.php b/src/Psalm/Checker/TypeChecker.php index db78aa32874..595f54ab45f 100644 --- a/src/Psalm/Checker/TypeChecker.php +++ b/src/Psalm/Checker/TypeChecker.php @@ -455,8 +455,6 @@ public static function reconcileKeyedTypes( } } - $result_types = []; - if (empty($new_types)) { return $existing_types; } @@ -808,21 +806,6 @@ public static function isContainedBy( $type_match_found = true; } - if ($container_type_part instanceof TNamedObject && - strtolower($container_type_part->value) === 'iterable' && - ( - $input_type_part instanceof TArray || - ($input_type_part instanceof TNamedObject && - ClassChecker::classExtendsOrImplements( - $input_type_part->value, - 'Traversable' - ) - ) - ) - ) { - $type_match_found = true; - } - if ($container_type_part instanceof TScalar && $input_type_part instanceof Scalar) { $type_match_found = true; } diff --git a/src/Psalm/EffectsAnalyser.php b/src/Psalm/EffectsAnalyser.php index d327156f655..4053ac1699a 100644 --- a/src/Psalm/EffectsAnalyser.php +++ b/src/Psalm/EffectsAnalyser.php @@ -60,8 +60,8 @@ public static function getReturnTypes(array $stmts, array &$yield_types, $collap $return_types = array_merge($return_types, self::getReturnTypes($catch->stmts, $yield_types)); } - if ($stmt->finally) { - $return_types = array_merge($return_types, self::getReturnTypes($stmt->finally->stmts, $yield_types)); + if ($stmt->finallyStmts) { + $return_types = array_merge($return_types, self::getReturnTypes($stmt->finallyStmts, $yield_types)); } } elseif ($stmt instanceof PhpParser\Node\Stmt\For_) { $return_types = array_merge($return_types, self::getReturnTypes($stmt->stmts, $yield_types)); diff --git a/src/Psalm/PropertyMap.php b/src/Psalm/PropertyMap.php index 47c0bb0ceae..a353c110c7e 100644 --- a/src/Psalm/PropertyMap.php +++ b/src/Psalm/PropertyMap.php @@ -434,14 +434,12 @@ 'stmts' => 'array' ], 'phpparser\\node\\stmt\\trycatch' => [ - 'stmts' => 'array' + 'stmts' => 'array', + 'finallyStmts' => 'array' ], 'phpparser\\node\\stmt\\catch_' => [ 'stmts' => 'array' ], - 'phpparser\\node\\stmt\\finally_' => [ - 'stmts' => 'array' - ], 'phpparser\\node\\stmt\\case_' => [ 'stmts' => 'array' ], diff --git a/src/Psalm/Type.php b/src/Psalm/Type.php index 243c722cb4a..479d448962c 100644 --- a/src/Psalm/Type.php +++ b/src/Psalm/Type.php @@ -92,7 +92,6 @@ public static function fixScalarTerms($type_string) 'mixed', 'resource', 'callable', - 'iterable', ] )) { return strtolower($type_string); diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index 9f366f6099b..3f68a243631 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -238,8 +238,9 @@ class A { /** * @param A $a * @param bool $b + * @return void */ - public function g(A $a, $b) : void { + public function g(A $a, $b) { } } '); @@ -261,8 +262,9 @@ class A { /** * @param \Foo\A $a * @param bool $b + * @return void */ - public function g(A $a, $b) : void { + public function g(A $a, $b) { } } '); diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 24f9758ba46..3043d6e686e 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -201,7 +201,8 @@ public function testBadByRef() { $this->markTestIncomplete('Does not throw an error'); $stmts = self::$parser->parse('parse('parse('markTestIncomplete('Requires PHP 5.5+'); + } + Config::getInstance()->setCustomErrorLevel('MixedAssignment', Config::REPORT_SUPPRESS); $stmts = self::$parser->parse('create(ParserFactory::PREFER_PHP7); - } - - /** - * @return void - */ - public function setUp() - { - $config = new TestConfig(); - $config->use_docblock_types = true; - - FileChecker::clearCache(); - $this->project_checker = new \Psalm\Checker\ProjectChecker(); - } - - /** - * @return void - */ - public function testNullableReturnType() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - $this->assertEquals('string|null', (string) $context->vars_in_scope['$a']); - } - - /** - * @return void - */ - public function testNullableArgument() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @return void - */ - public function testPrivateClassConst() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @expectedException \Psalm\Exception\CodeException - * @expectedExceptionMessage InaccessibleClassConstant - * @return void - */ - public function testInvalidPrivateClassConstFetch() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @expectedException \Psalm\Exception\CodeException - * @expectedExceptionMessage InaccessibleClassConstant - * @return void - */ - public function testInvalidPrivateClassConstFetchFromSubclass() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @return void - */ - public function testProtectedClassConst() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @expectedException \Psalm\Exception\CodeException - * @expectedExceptionMessage InaccessibleClassConstant - * @return void - */ - public function testInvalidProtectedClassConstFetch() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @return void - */ - public function testPublicClassConstFetch() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @return void - */ - public function testArrayDestructuring() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - $this->assertEquals('string|int', (string) $context->vars_in_scope['$id1']); - $this->assertEquals('string|int', (string) $context->vars_in_scope['$name1']); - $this->assertEquals('string|int', (string) $context->vars_in_scope['$id2']); - $this->assertEquals('string|int', (string) $context->vars_in_scope['$name2']); - } - - /** - * @return void - */ - public function testArrayDestructuringInForeach() - { - $stmts = self::$parser->parse('project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @return void - */ - public function testArrayDestructuringWithKeys() - { - $stmts = self::$parser->parse(' 1, "name" => "Tom"], - ["id" => 2, "name" => "Fred"], - ]; - - // list() style - list("id" => $id1, "name" => $name1) = $data[0]; - - // [] style - ["id" => $id2, "name" => $name2] = $data[1]; - '); - - $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - $this->assertEquals('int', (string) $context->vars_in_scope['$id1']); - $this->assertEquals('string', (string) $context->vars_in_scope['$name1']); - $this->assertEquals('int', (string) $context->vars_in_scope['$id2']); - $this->assertEquals('string', (string) $context->vars_in_scope['$name2']); - } - - /** - * @return void - */ - public function testArrayListDestructuringInForeachWithKeys() - { - $stmts = self::$parser->parse(' 1, "name" => "Tom"], - ["id" => 2, "name" => "Fred"], - ]; - - $last_id = null; - $last_name = null; - - // list() style - foreach ($data as list("id" => $id, "name" => $name)) { - $last_id = $id; - $last_name = $name; - } - '); - - $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - $this->assertEquals('null|int', (string) $context->vars_in_scope['$last_id']); - $this->assertEquals('null|string', (string) $context->vars_in_scope['$last_name']); - } - - /** - * @return void - */ - public function testArrayDestructuringInForeachWithKeys() - { - $stmts = self::$parser->parse(' 1, "name" => "Tom"], - ["id" => 2, "name" => "Fred"], - ]; - - $last_id = null; - $last_name = null; - - // [] style - foreach ($data as ["id" => $id, "name" => $name]) { - $last_id = $id; - $last_name = $name; - } - '); - - $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - $this->assertEquals('null|int', (string) $context->vars_in_scope['$last_id']); - $this->assertEquals('null|string', (string) $context->vars_in_scope['$last_name']); - } - - /** - * @return void - */ - public function testIterableArg() - { - $stmts = self::$parser->parse(' $iter - */ - function iterator(iterable $iter) : void - { - foreach ($iter as $val) { - // - } - } - - iterator([1, 2, 3, 4]); - iterator(new SplFixedArray(5)); - '); - - $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } - - /** - * @expectedException \Psalm\Exception\CodeException - * @expectedExceptionMessage InvalidArgument - * @return void - */ - public function testInvalidIterableArg() - { - $stmts = self::$parser->parse(' $iter - */ - function iterator(iterable $iter) : void - { - foreach ($iter as $val) { - // - } - } - - class A { - } - - iterator(new A()); - '); - - $file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts); - $context = new Context('somefile.php'); - $file_checker->visitAndAnalyzeMethods($context); - } -}