From 7ddac104668249f0f4803b128eb30d0564467a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Sch=C3=B6llhorn?= Date: Wed, 13 Mar 2019 00:36:36 +0100 Subject: [PATCH 01/18] Add Psalm generic annotations --- composer.json | 3 +- composer.lock | 1006 ++++++++++++++++- .../Collections/AbstractLazyCollection.php | 5 + .../Common/Collections/ArrayCollection.php | 18 +- .../Common/Collections/Collection.php | 46 +- lib/Doctrine/Common/Collections/Criteria.php | 2 + .../Common/Collections/Selectable.php | 4 + psalm.xml.dist | 53 + 8 files changed, 1129 insertions(+), 8 deletions(-) create mode 100644 psalm.xml.dist diff --git a/composer.json b/composer.json index aa9c30abf..100f274c1 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "require-dev": { "phpunit/phpunit": "^7.0", "doctrine/coding-standard": "^6.0", - "phpstan/phpstan-shim": "^0.9.2" + "phpstan/phpstan-shim": "^0.9.2", + "vimeo/psalm": "^3.1" }, "autoload": { "psr-4": { "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" } diff --git a/composer.lock b/composer.lock index 7a9c341b7..ad2c5bde6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,188 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3110654c561f87d0733ed1cc2af09006", + "content-hash": "7014339bd22658dfdc6a95cff353a5e2", "packages": [], "packages-dev": [ + { + "name": "amphp/amp", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/amp.git", + "reference": "7075ef7d74dbd32626bfd31c976b23055c3ade6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/amp/zipball/7075ef7d74dbd32626bfd31c976b23055c3ade6a", + "reference": "7075ef7d74dbd32626bfd31c976b23055c3ade6a", + "shasum": "" + }, + "require": { + "php": ">=7" + }, + "require-dev": { + "amphp/phpunit-util": "^1", + "friendsofphp/php-cs-fixer": "^2.3", + "phpstan/phpstan": "^0.8.5", + "phpunit/phpunit": "^6.0.9", + "react/promise": "^2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Amp\\": "lib" + }, + "files": [ + "lib/functions.php", + "lib/Internal/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + } + ], + "description": "A non-blocking concurrency framework for PHP applications.", + "homepage": "http://amphp.org/amp", + "keywords": [ + "async", + "asynchronous", + "awaitable", + "concurrency", + "event", + "event-loop", + "future", + "non-blocking", + "promise" + ], + "time": "2018-12-11T10:31:37+00:00" + }, + { + "name": "amphp/byte-stream", + "version": "v1.5.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/byte-stream.git", + "reference": "6bbfcb6f47e92577e739586ba0c87e867be70a23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/6bbfcb6f47e92577e739586ba0c87e867be70a23", + "reference": "6bbfcb6f47e92577e739586ba0c87e867be70a23", + "shasum": "" + }, + "require": { + "amphp/amp": "^2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1", + "friendsofphp/php-cs-fixer": "^2.3", + "infection/infection": "^0.9.3", + "phpunit/phpunit": "^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Amp\\ByteStream\\": "lib" + }, + "files": [ + "lib/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + } + ], + "description": "A stream abstraction to make working with non-blocking I/O simple.", + "homepage": "http://amphp.org/byte-stream", + "keywords": [ + "amp", + "amphp", + "async", + "io", + "non-blocking", + "stream" + ], + "time": "2018-12-27T18:08:06+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "1.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "d17708133b6c276d6e42ef887a877866b909d892" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/d17708133b6c276d6e42ef887a877866b909d892", + "reference": "d17708133b6c276d6e42ef887a877866b909d892", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2019-01-28T20:25:53+00:00" + }, { "name": "dealerdirect/phpcodesniffer-composer-installer", "version": "v0.5.0", @@ -188,6 +367,150 @@ ], "time": "2017-07-22T11:58:36+00:00" }, + { + "name": "felixfbecker/advanced-json-rpc", + "version": "v3.0.3", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", + "reference": "241c470695366e7b83672be04ea0e64d8085a551" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/241c470695366e7b83672be04ea0e64d8085a551", + "reference": "241c470695366e7b83672be04ea0e64d8085a551", + "shasum": "" + }, + "require": { + "netresearch/jsonmapper": "^1.0", + "php": ">=7.0", + "phpdocumentor/reflection-docblock": "^4.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "AdvancedJsonRpc\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "A more advanced JSONRPC implementation", + "time": "2018-09-10T08:58:41+00:00" + }, + { + "name": "felixfbecker/language-server-protocol", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-language-server-protocol.git", + "reference": "1bdd1bcc95428edf85ec04c7b558d0886c07280f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/1bdd1bcc95428edf85ec04c7b558d0886c07280f", + "reference": "1bdd1bcc95428edf85ec04c7b558d0886c07280f", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpstan/phpstan": "*", + "phpunit/phpunit": "^6.3", + "squizlabs/php_codesniffer": "^3.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "LanguageServerProtocol\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "PHP classes for the Language Server Protocol", + "keywords": [ + "language", + "microsoft", + "php", + "server" + ], + "time": "2018-09-25T11:42:25+00:00" + }, + { + "name": "muglug/package-versions-56", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/muglug/PackageVersions.git", + "reference": "a67bed26deaaf9269a348e53063bc8d4dcc60ffd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/muglug/PackageVersions/zipball/a67bed26deaaf9269a348e53063bc8d4dcc60ffd", + "reference": "a67bed26deaaf9269a348e53063bc8d4dcc60ffd", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "composer/composer": "^1.3", + "ext-zip": "*", + "phpunit/phpunit": "^5.7.5" + }, + "type": "composer-plugin", + "extra": { + "class": "Muglug\\PackageVersions\\Installer", + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Muglug\\PackageVersions\\": "src/PackageVersions" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + }, + { + "name": "Abdul Malik Ikhsan", + "email": "samsonasik@gmail.com" + }, + { + "name": "Matt Brown", + "email": "github@muglug.com" + } + ], + "description": "A backport of ocramius/package-versions that supports php ^5.6. Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "time": "2018-03-26T03:22:13+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.7.0", @@ -233,6 +556,148 @@ ], "time": "2017-10-19T19:58:43+00:00" }, + { + "name": "netresearch/jsonmapper", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/cweiske/jsonmapper.git", + "reference": "3868fe1128ce1169228acdb623359dca74db5ef3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/3868fe1128ce1169228acdb623359dca74db5ef3", + "reference": "3868fe1128ce1169228acdb623359dca74db5ef3", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "autoload": { + "psr-0": { + "JsonMapper": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Christian Weiske", + "email": "cweiske@cweiske.de", + "homepage": "http://github.com/cweiske/jsonmapper/", + "role": "Developer" + } + ], + "description": "Map nested JSON structures onto PHP classes", + "time": "2017-11-28T21:30:01+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.2.1", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "5221f49a608808c1e4d436df32884cbc1b821ac0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/5221f49a608808c1e4d436df32884cbc1b821ac0", + "reference": "5221f49a608808c1e4d436df32884cbc1b821ac0", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.5 || ^7.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2019-02-16T20:54:15+00:00" + }, + { + "name": "openlss/lib-array2xml", + "version": "0.5.1", + "source": { + "type": "git", + "url": "https://github.com/nullivex/lib-array2xml.git", + "reference": "c8b5998a342d7861f2e921403f44e0a2f3ef2be0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nullivex/lib-array2xml/zipball/c8b5998a342d7861f2e921403f44e0a2f3ef2be0", + "reference": "c8b5998a342d7861f2e921403f44e0a2f3ef2be0", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "LSS": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Bryan Tong", + "email": "contact@nullivex.com", + "homepage": "http://bryantong.com" + }, + { + "name": "Tony Butler", + "email": "spudz76@gmail.com", + "homepage": "http://openlss.org" + } + ], + "description": "Array2XML conversion library credit to lalit.org", + "homepage": "http://openlss.org", + "keywords": [ + "array", + "array conversion", + "xml", + "xml conversion" + ], + "time": "2016-11-10T19:10:18+00:00" + }, { "name": "phar-io/manifest", "version": "1.0.1", @@ -335,6 +800,57 @@ "description": "Library for handling version information and constraints", "time": "2017-03-05T17:38:23+00:00" }, + { + "name": "php-cs-fixer/diff", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "SpacePossum" + } + ], + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "time": "2018-02-15T16:58:55+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -477,15 +993,76 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14T14:27:02+00:00" + }, + { + "name": "phpmyadmin/sql-parser", + "version": "v4.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpmyadmin/sql-parser.git", + "reference": "0eb16ef5e3acacbc792be336754e42d98791a33f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/0eb16ef5e3acacbc792be336754e42d98791a33f", + "reference": "0eb16ef5e3acacbc792be336754e42d98791a33f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/polyfill-mbstring": "^1.3" + }, + "conflict": { + "phpmyadmin/motranslator": "<3.0" + }, + "require-dev": { + "phpunit/php-code-coverage": "*", + "phpunit/phpunit": "~4.8 || ~5.7 || ~6.5", + "sami/sami": "^4.0" + }, + "suggest": { + "ext-mbstring": "For best performance", + "phpmyadmin/motranslator": "Translate messages to your favorite locale" + }, + "bin": [ + "bin/highlight-query", + "bin/lint-query" + ], + "type": "library", + "autoload": { + "psr-4": { + "PhpMyAdmin\\SqlParser\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" ], "authors": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" + "name": "The phpMyAdmin Team", + "email": "developers@phpmyadmin.net", + "homepage": "https://www.phpmyadmin.net/team/" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A validating SQL lexer and parser with a focus on MySQL dialect.", + "homepage": "https://github.com/phpmyadmin/sql-parser", + "keywords": [ + "analysis", + "lexer", + "parser", + "sql" + ], + "time": "2019-01-05T13:46:38+00:00" }, { "name": "phpspec/prophecy", @@ -1018,6 +1595,53 @@ ], "time": "2018-02-15T05:27:38+00:00" }, + { + "name": "psr/log", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2018-11-20T15:27:04+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -1672,6 +2296,205 @@ ], "time": "2018-12-19T23:57:18+00:00" }, + { + "name": "symfony/console", + "version": "v4.2.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "9dc2299a016497f9ee620be94524e6c0af0280a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/9dc2299a016497f9ee620be94524e6c0af0280a9", + "reference": "9dc2299a016497f9ee620be94524e6c0af0280a9", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/contracts": "^1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2019-02-23T15:17:42+00:00" + }, + { + "name": "symfony/contracts", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/contracts.git", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "require-dev": { + "psr/cache": "^1.0", + "psr/container": "^1.0" + }, + "suggest": { + "psr/cache": "When using the Cache contracts", + "psr/container": "When using the Service contracts", + "symfony/cache-contracts-implementation": "", + "symfony/service-contracts-implementation": "", + "symfony/translation-contracts-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\": "" + }, + "exclude-from-classmap": [ + "**/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A set of abstractions extracted out of the Symfony components", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2018-12-05T08:06:11+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T13:07:52+00:00" + }, { "name": "theseer/tokenizer", "version": "1.1.0", @@ -1712,6 +2535,86 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "time": "2017-04-07T12:08:54+00:00" }, + { + "name": "vimeo/psalm", + "version": "3.1.3", + "source": { + "type": "git", + "url": "https://github.com/vimeo/psalm.git", + "reference": "6efa978680b891ef4e4ca5718323073d809cea01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/6efa978680b891ef4e4ca5718323073d809cea01", + "reference": "6efa978680b891ef4e4ca5718323073d809cea01", + "shasum": "" + }, + "require": { + "amphp/amp": "^2.1", + "amphp/byte-stream": "^1.5", + "composer/xdebug-handler": "^1.1", + "felixfbecker/advanced-json-rpc": "^3.0.3", + "felixfbecker/language-server-protocol": "^1.2", + "muglug/package-versions-56": "1.2.4", + "netresearch/jsonmapper": "^1.0", + "nikic/php-parser": "^4.0.2 || ^4.1", + "openlss/lib-array2xml": "^0.0.10||^0.5.1", + "php": "^7.0", + "php-cs-fixer/diff": "^1.2", + "phpmyadmin/sql-parser": "^4.0", + "symfony/console": "^3.0||^4.0", + "webmozart/glob": "^4.1", + "webmozart/path-util": "^2.3" + }, + "provide": { + "psalm/psalm": "self.version" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.2", + "phpunit/phpunit": "^6.0 || ^7.0", + "psalm/plugin-phpunit": "^0.5.1", + "squizlabs/php_codesniffer": "^3.0" + }, + "suggest": { + "ext-igbinary": "^2.0.5" + }, + "bin": [ + "psalm", + "psalter", + "psalm-language-server", + "psalm-plugin" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev", + "dev-2.x": "2.x-dev", + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psalm\\Plugin\\": "src/Psalm/Plugin", + "Psalm\\": "src/Psalm" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Brown" + } + ], + "description": "A static analysis tool for finding errors in PHP applications", + "keywords": [ + "code", + "inspection", + "php" + ], + "time": "2019-03-12T12:55:38+00:00" + }, { "name": "webmozart/assert", "version": "1.3.0", @@ -1761,6 +2664,99 @@ "validate" ], "time": "2018-01-29T19:49:41+00:00" + }, + { + "name": "webmozart/glob", + "version": "4.1.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/glob.git", + "reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/glob/zipball/3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe", + "reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe", + "shasum": "" + }, + "require": { + "php": "^5.3.3|^7.0", + "webmozart/path-util": "^2.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1", + "symfony/filesystem": "^2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Glob\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "A PHP implementation of Ant's glob.", + "time": "2015-12-29T11:14:33+00:00" + }, + { + "name": "webmozart/path-util", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/path-util.git", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "webmozart/assert": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\PathUtil\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", + "time": "2015-12-17T08:42:14+00:00" } ], "aliases": [], diff --git a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php index 50fcf93a4..056cfe5c8 100644 --- a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php +++ b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php @@ -6,12 +6,15 @@ /** * Lazy collection that is backed by a concrete collection + * + * @template T */ abstract class AbstractLazyCollection implements Collection { /** * The backed collection to use * + * @psalm-var Collection * @var Collection */ protected $collection; @@ -327,6 +330,8 @@ public function isInitialized() /** * Initialize the collection + * + * @return void */ protected function initialize() { diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index f423c7883..29e8701b2 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -31,12 +31,15 @@ * and may break when we change the internals in the future. If you need to * serialize a collection use {@link toArray()} and reconstruct the collection * manually. + * + * @template T */ class ArrayCollection implements Collection, Selectable { /** * An array containing the entries of this collection. * + * @psalm-var T[] * @var array */ private $elements; @@ -45,6 +48,8 @@ class ArrayCollection implements Collection, Selectable * Initializes a new ArrayCollection. * * @param array $elements + * + * @psalm-param T[] */ public function __construct(array $elements = []) { @@ -60,6 +65,9 @@ public function __construct(array $elements = []) * @param array $elements Elements. * * @return static + * + * @psalm-param T[] + * @psalm-return ArrayCollection */ protected function createFrom(array $elements) { @@ -301,6 +309,9 @@ public function getIterator() * {@inheritDoc} * * @return static + * + * @template U + * @psalm-return ArrayCollection */ public function map(Closure $func) { @@ -311,6 +322,9 @@ public function map(Closure $func) * {@inheritDoc} * * @return static + * + * @template U + * @psalm-return ArrayCollection */ public function filter(Closure $p) { @@ -397,7 +411,9 @@ public function matching(Criteria $criteria) $next = ClosureExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next); } - uasort($filtered, $next); + if ($next) { + uasort($filtered, $next); + } } $offset = $criteria->getFirstResult(); diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index 25c1e3660..33400fc11 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -23,6 +23,8 @@ * You can not rely on the internal iterator of the collection being at a certain * position unless you explicitly positioned it before. Prefer iteration with * external iterators. + * + * @template T */ interface Collection extends Countable, IteratorAggregate, ArrayAccess { @@ -32,6 +34,8 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * @param mixed $element The element to add. * * @return bool Always TRUE. + * + * @psalm-param T $element */ public function add($element); @@ -49,6 +53,8 @@ public function clear(); * @param mixed $element The element to search for. * * @return bool TRUE if the collection contains the element, FALSE otherwise. + * + * @psalm-param T $element */ public function contains($element); @@ -65,6 +71,8 @@ public function isEmpty(); * @param string|int $key The key/index of the element to remove. * * @return mixed The removed element or NULL, if the collection did not contain the element. + * + * @psalm-return T|null */ public function remove($key); @@ -74,6 +82,8 @@ public function remove($key); * @param mixed $element The element to remove. * * @return bool TRUE if this collection contained the specified element, FALSE otherwise. + * + * @psalm-param T $element */ public function removeElement($element); @@ -93,13 +103,15 @@ public function containsKey($key); * @param string|int $key The key/index of the element to retrieve. * * @return mixed + * + * @psalm-return T|null */ public function get($key); /** * Gets all keys/indices of the collection. * - * @return array The keys/indices of the collection, in the order of the corresponding + * @return int[]|string[] The keys/indices of the collection, in the order of the corresponding * elements in the collection. */ public function getKeys(); @@ -109,6 +121,8 @@ public function getKeys(); * * @return array The values of all elements in the collection, in the order they * appear in the collection. + * + * @psalm-return T[] */ public function getValues(); @@ -119,6 +133,8 @@ public function getValues(); * @param mixed $value The element to set. * * @return void + * + * @psalm-param T $value */ public function set($key, $value); @@ -126,6 +142,8 @@ public function set($key, $value); * Gets a native PHP array representation of the collection. * * @return array + * + * @psalm-return T[] */ public function toArray(); @@ -133,6 +151,8 @@ public function toArray(); * Sets the internal iterator to the first element in the collection and returns this element. * * @return mixed + * + * @psalm-return T */ public function first(); @@ -140,6 +160,8 @@ public function first(); * Sets the internal iterator to the last element in the collection and returns this element. * * @return mixed + * + * @psalm-return T */ public function last(); @@ -154,6 +176,8 @@ public function key(); * Gets the element of the collection at the current iterator position. * * @return mixed + * + * @psalm-return T */ public function current(); @@ -161,6 +185,8 @@ public function current(); * Moves the internal iterator position to the next element and returns this element. * * @return mixed + * + * @psalm-return T */ public function next(); @@ -170,6 +196,8 @@ public function next(); * @param Closure $p The predicate. * * @return bool TRUE if the predicate is TRUE for at least one element, FALSE otherwise. + * + * @psalm-param Closure(int|string, T):bool $p */ public function exists(Closure $p); @@ -180,6 +208,9 @@ public function exists(Closure $p); * @param Closure $p The predicate used for filtering. * * @return Collection A collection with the results of the filter operation. + * + * @psalm-param Closure(T):bool $p + * @psalm-return Collection */ public function filter(Closure $p); @@ -189,6 +220,8 @@ public function filter(Closure $p); * @param Closure $p The predicate. * * @return bool TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. + * + * @psalm-param Closure(int|string, T):bool $p */ public function forAll(Closure $p); @@ -197,6 +230,10 @@ public function forAll(Closure $p); * a new collection with the elements returned by the function. * * @return Collection + * + * @template U + * @psalm-param Closure(T):U $func + * @psalm-return Collection */ public function map(Closure $func); @@ -209,6 +246,9 @@ public function map(Closure $func); * @return Collection[] An array with two elements. The first element contains the collection * of elements where the predicate returned TRUE, the second element * contains the collection of elements where the predicate returned FALSE. + * + * @psalm-param Closure(int|string, T):bool $p + * @psalm-return Collection[] */ public function partition(Closure $p); @@ -220,6 +260,8 @@ public function partition(Closure $p); * @param mixed $element The element to search for. * * @return int|string|bool The key/index of the element or FALSE if the element was not found. + * + * @psalm-param T $element */ public function indexOf($element); @@ -234,6 +276,8 @@ public function indexOf($element); * @param int|null $length The maximum number of elements to return, or null for no limit. * * @return array + * + * @psalm-return T[] */ public function slice($offset, $length = null); } diff --git a/lib/Doctrine/Common/Collections/Criteria.php b/lib/Doctrine/Common/Collections/Criteria.php index 6ddaf5e40..d8c303934 100644 --- a/lib/Doctrine/Common/Collections/Criteria.php +++ b/lib/Doctrine/Common/Collections/Criteria.php @@ -61,6 +61,8 @@ public static function expr() * @param string[]|null $orderings * @param int|null $firstResult * @param int|null $maxResults + * + * @return void */ public function __construct(?Expression $expression = null, ?array $orderings = null, $firstResult = null, $maxResults = null) { diff --git a/lib/Doctrine/Common/Collections/Selectable.php b/lib/Doctrine/Common/Collections/Selectable.php index f31da812d..1e9c09ccd 100644 --- a/lib/Doctrine/Common/Collections/Selectable.php +++ b/lib/Doctrine/Common/Collections/Selectable.php @@ -13,6 +13,8 @@ * utilizing the query APIs, for example SQL in the ORM. Applications using * this API can implement efficient database access without having to ask the * EntityManager or Repositories. + * + * @template T */ interface Selectable { @@ -21,6 +23,8 @@ interface Selectable * returns a new collection containing these elements. * * @return Collection + * + * @psalm-return Collection */ public function matching(Criteria $criteria); } diff --git a/psalm.xml.dist b/psalm.xml.dist new file mode 100644 index 000000000..7d76ae7d1 --- /dev/null +++ b/psalm.xml.dist @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 371af30c37548f9fe7d453b1d349caefdfd3844a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Sch=C3=B6llhorn?= Date: Wed, 13 Mar 2019 00:50:18 +0100 Subject: [PATCH 02/18] Add Psalm to Travis build pipeline --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index d60c19b8b..e4a1e5ca5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,3 +47,8 @@ jobs: env: STATIC_ANALYSIS install: travis_retry composer install --prefer-dist script: vendor/bin/phpstan analyse -l 3 lib + + - stage: Code Quality + env: STATIC_ANALYSIS + install: travis_retry composer install --prefer-dist + script: vendor/bin/psalm From 42ba8237e3991208fcb0e4644ac8f5ee40b976df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Sch=C3=B6llhorn?= Date: Wed, 13 Mar 2019 15:40:35 +0100 Subject: [PATCH 03/18] Add Psalm annotations to concrete classes as well --- .../Collections/AbstractLazyCollection.php | 1 + .../Common/Collections/ArrayCollection.php | 88 ++++++++++++++----- .../Common/Collections/Collection.php | 8 +- psalm.xml.dist | 1 + 4 files changed, 74 insertions(+), 24 deletions(-) diff --git a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php index 056cfe5c8..3b309f62e 100644 --- a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php +++ b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php @@ -8,6 +8,7 @@ * Lazy collection that is backed by a concrete collection * * @template T + * @template-extends Collection */ abstract class AbstractLazyCollection implements Collection { diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index 29e8701b2..d1c5c3426 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -33,6 +33,8 @@ * manually. * * @template T + * @template-implements Collection + * @template-implements Selectable */ class ArrayCollection implements Collection, Selectable { @@ -49,7 +51,7 @@ class ArrayCollection implements Collection, Selectable * * @param array $elements * - * @psalm-param T[] + * @psalm-param array $elements */ public function __construct(array $elements = []) { @@ -57,41 +59,47 @@ public function __construct(array $elements = []) } /** - * Creates a new instance from the specified elements. - * - * This method is provided for derived classes to specify how a new - * instance should be created when constructor semantics have changed. - * - * @param array $elements Elements. - * - * @return static + * {@inheritDoc} * - * @psalm-param T[] - * @psalm-return ArrayCollection + * @psalm-return array */ - protected function createFrom(array $elements) + public function toArray() { - return new static($elements); + return $this->elements; } /** * {@inheritDoc} + * + * @psalm-return T */ - public function toArray() + public function first() { - return $this->elements; + return reset($this->elements); } /** - * {@inheritDoc} + * Creates a new instance from the specified elements. + * + * This method is provided for derived classes to specify how a new + * instance should be created when constructor semantics have changed. + * + * @param array $elements Elements. + * + * @return static + * + * @psalm-param array $elements + * @psalm-return ArrayCollection */ - public function first() + protected function createFrom(array $elements) { - return reset($this->elements); + return new static($elements); } /** * {@inheritDoc} + * + * @psalm-return T */ public function last() { @@ -108,6 +116,8 @@ public function key() /** * {@inheritDoc} + * + * @psalm-return T */ public function next() { @@ -116,6 +126,8 @@ public function next() /** * {@inheritDoc} + * + * @psalm-return T */ public function current() { @@ -124,6 +136,8 @@ public function current() /** * {@inheritDoc} + * + * @psalm-return T|null */ public function remove($key) { @@ -139,6 +153,8 @@ public function remove($key) /** * {@inheritDoc} + * + * @psalm-param T $element */ public function removeElement($element) { @@ -167,6 +183,8 @@ public function offsetExists($offset) * Required by interface ArrayAccess. * * {@inheritDoc} + * + * @psalm-return T|null */ public function offsetGet($offset) { @@ -177,6 +195,8 @@ public function offsetGet($offset) * Required by interface ArrayAccess. * * {@inheritDoc} + * + * @psalm-param T $value */ public function offsetSet($offset, $value) { @@ -209,6 +229,8 @@ public function containsKey($key) /** * {@inheritDoc} + * + * @psalm-param T $element */ public function contains($element) { @@ -217,6 +239,8 @@ public function contains($element) /** * {@inheritDoc} + * + * @psalm-param Closure(int|string, T):bool $p */ public function exists(Closure $p) { @@ -231,6 +255,8 @@ public function exists(Closure $p) /** * {@inheritDoc} + * + * @psalm-param T $element */ public function indexOf($element) { @@ -239,6 +265,8 @@ public function indexOf($element) /** * {@inheritDoc} + * + * @psalm-return T|null */ public function get($key) { @@ -255,6 +283,8 @@ public function getKeys() /** * {@inheritDoc} + * + * @psalm-return array */ public function getValues() { @@ -271,6 +301,8 @@ public function count() /** * {@inheritDoc} + * + * @psalm-param T $value */ public function set($key, $value) { @@ -279,6 +311,8 @@ public function set($key, $value) /** * {@inheritDoc} + * + * @psalm-param T $element */ public function add($element) { @@ -299,6 +333,8 @@ public function isEmpty() * Required by interface IteratorAggregate. * * {@inheritDoc} + * + * @psalm-return ArrayIterator */ public function getIterator() { @@ -311,7 +347,8 @@ public function getIterator() * @return static * * @template U - * @psalm-return ArrayCollection + * @psalm-param Closure(T):U $func + * @psalm-return Collection */ public function map(Closure $func) { @@ -323,8 +360,8 @@ public function map(Closure $func) * * @return static * - * @template U - * @psalm-return ArrayCollection + * @psalm-param Closure(T):bool $p + * @psalm-return Collection */ public function filter(Closure $p) { @@ -333,6 +370,8 @@ public function filter(Closure $p) /** * {@inheritDoc} + * + * @psalm-param Closure(int|string, T):bool $p */ public function forAll(Closure $p) { @@ -347,6 +386,9 @@ public function forAll(Closure $p) /** * {@inheritDoc} + * + * @psalm-param Closure(int|string, T):bool $p + * @psalm-return Collection[] */ public function partition(Closure $p) { @@ -383,6 +425,8 @@ public function clear() /** * {@inheritDoc} + * + * @psalm-return array */ public function slice($offset, $length = null) { @@ -391,6 +435,8 @@ public function slice($offset, $length = null) /** * {@inheritDoc} + * + * @psalm-return Collection */ public function matching(Criteria $criteria) { diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index 33400fc11..36776f7e1 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -25,6 +25,8 @@ * external iterators. * * @template T + * @template-extends IteratorAggregate + * @template-extends ArrayAccess */ interface Collection extends Countable, IteratorAggregate, ArrayAccess { @@ -122,7 +124,7 @@ public function getKeys(); * @return array The values of all elements in the collection, in the order they * appear in the collection. * - * @psalm-return T[] + * @psalm-return array */ public function getValues(); @@ -143,7 +145,7 @@ public function set($key, $value); * * @return array * - * @psalm-return T[] + * @psalm-return array */ public function toArray(); @@ -277,7 +279,7 @@ public function indexOf($element); * * @return array * - * @psalm-return T[] + * @psalm-return array */ public function slice($offset, $length = null); } diff --git a/psalm.xml.dist b/psalm.xml.dist index 7d76ae7d1..ad7dfc41c 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -9,6 +9,7 @@ + From 9714e3f67ca374f9c48fa613de86736a59146557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Sch=C3=B6llhorn?= Date: Wed, 13 Mar 2019 17:22:13 +0100 Subject: [PATCH 04/18] Bump PHP dependency to 7.1.3 --- .scrutinizer.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index f858712f1..73281fd1a 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,7 +1,7 @@ build: environment: php: - version: 7.1.0 + version: 7.1.3 tools: external_code_coverage: diff --git a/composer.json b/composer.json index 100f274c1..e0e3dceb4 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} ], "require": { - "php": "^7.1" + "php": "^7.1.3" }, "require-dev": { "phpunit/phpunit": "^7.0", From 0de7700ac6f2b01d319d82266b61d8f28d002d91 Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Wed, 13 Mar 2019 22:25:17 +0100 Subject: [PATCH 05/18] Add Psalm to `suggest` section in composer --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index e0e3dceb4..09fb1021c 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,9 @@ {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} ], + "suggest": { + "vimeo/psalm": "Psalm allows you to enforce template types for your collections." + }, "require": { "php": "^7.1.3" }, From 765730744d0564a9ab80a15b6dd386c8da5d6088 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Wed, 13 Mar 2019 22:44:12 +0100 Subject: [PATCH 06/18] Apply suggestions from code review Improve annotations Co-Authored-By: nschoellhorn --- .../Collections/AbstractLazyCollection.php | 2 +- lib/Doctrine/Common/Collections/Collection.php | 17 +++++++++-------- psalm.xml.dist | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php index 3b309f62e..74cda2acf 100644 --- a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php +++ b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php @@ -8,7 +8,7 @@ * Lazy collection that is backed by a concrete collection * * @template T - * @template-extends Collection + * @template-implements Collection */ abstract class AbstractLazyCollection implements Collection { diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index 36776f7e1..fafbfd979 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -26,7 +26,7 @@ * * @template T * @template-extends IteratorAggregate - * @template-extends ArrayAccess + * @template-extends ArrayAccess */ interface Collection extends Countable, IteratorAggregate, ArrayAccess { @@ -124,7 +124,7 @@ public function getKeys(); * @return array The values of all elements in the collection, in the order they * appear in the collection. * - * @psalm-return array + * @psalm-return array */ public function getValues(); @@ -145,7 +145,7 @@ public function set($key, $value); * * @return array * - * @psalm-return array + * @psalm-return array */ public function toArray(); @@ -154,7 +154,7 @@ public function toArray(); * * @return mixed * - * @psalm-return T + * @psalm-return T|false */ public function first(); @@ -163,7 +163,7 @@ public function first(); * * @return mixed * - * @psalm-return T + * @psalm-return T|false */ public function last(); @@ -179,7 +179,7 @@ public function key(); * * @return mixed * - * @psalm-return T + * @psalm-return T|false */ public function current(); @@ -188,7 +188,7 @@ public function current(); * * @return mixed * - * @psalm-return T + * @psalm-return T|false */ public function next(); @@ -264,6 +264,7 @@ public function partition(Closure $p); * @return int|string|bool The key/index of the element or FALSE if the element was not found. * * @psalm-param T $element + * @psalm-return int|string|false */ public function indexOf($element); @@ -279,7 +280,7 @@ public function indexOf($element); * * @return array * - * @psalm-return array + * @psalm-return array */ public function slice($offset, $length = null); } diff --git a/psalm.xml.dist b/psalm.xml.dist index ad7dfc41c..8c5b066d5 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -3,7 +3,7 @@ totallyTyped="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" - xsi:schemaLocation="https://getpsalm.org/schema/config file:///Users/nschoellhorn/PhpstormProjects/collections/vendor/vimeo/psalm/config.xsd" + xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" > From 6625c5b4d14d9fd9f6cf60a16f612a9341ca2896 Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Wed, 13 Mar 2019 22:45:00 +0100 Subject: [PATCH 07/18] Make partition() return type more explicit --- lib/Doctrine/Common/Collections/ArrayCollection.php | 2 +- lib/Doctrine/Common/Collections/Collection.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index d1c5c3426..327a71651 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -388,7 +388,7 @@ public function forAll(Closure $p) * {@inheritDoc} * * @psalm-param Closure(int|string, T):bool $p - * @psalm-return Collection[] + * @psalm-return array{0: Collection, 1: Collection} */ public function partition(Closure $p) { diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index fafbfd979..02735e0e6 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -250,7 +250,7 @@ public function map(Closure $func); * contains the collection of elements where the predicate returned FALSE. * * @psalm-param Closure(int|string, T):bool $p - * @psalm-return Collection[] + * @psalm-return array{0: Collection, 1: Collection} */ public function partition(Closure $p); From d1c76a58fd40af36d066d5cf5610b79dd05c64a1 Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Wed, 13 Mar 2019 22:45:18 +0100 Subject: [PATCH 08/18] Remove needless return type annotation --- lib/Doctrine/Common/Collections/Criteria.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Doctrine/Common/Collections/Criteria.php b/lib/Doctrine/Common/Collections/Criteria.php index d8c303934..6ddaf5e40 100644 --- a/lib/Doctrine/Common/Collections/Criteria.php +++ b/lib/Doctrine/Common/Collections/Criteria.php @@ -61,8 +61,6 @@ public static function expr() * @param string[]|null $orderings * @param int|null $firstResult * @param int|null $maxResults - * - * @return void */ public function __construct(?Expression $expression = null, ?array $orderings = null, $firstResult = null, $maxResults = null) { From 33ba48fcd1b9092c43225a1694941edd9e5692c6 Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Thu, 14 Mar 2019 16:57:55 +0100 Subject: [PATCH 09/18] Bump Psalm version, remove annotations in child class and introduce template parameter for collection key --- composer.json | 2 +- composer.lock | 15 +++--- .../Common/Collections/ArrayCollection.php | 51 +------------------ .../Common/Collections/Collection.php | 33 ++++++++---- 4 files changed, 33 insertions(+), 68 deletions(-) diff --git a/composer.json b/composer.json index 09fb1021c..5d0e8fee7 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "phpunit/phpunit": "^7.0", "doctrine/coding-standard": "^6.0", "phpstan/phpstan-shim": "^0.9.2", - "vimeo/psalm": "^3.1" + "vimeo/psalm": "^3.2" }, "autoload": { "psr-4": { "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" } diff --git a/composer.lock b/composer.lock index ad2c5bde6..1e792f608 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": "7014339bd22658dfdc6a95cff353a5e2", + "content-hash": "663068946b0b278bdafdd8bb777bb4c2", "packages": [], "packages-dev": [ { @@ -1593,6 +1593,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2018-02-15T05:27:38+00:00" }, { @@ -2537,16 +2538,16 @@ }, { "name": "vimeo/psalm", - "version": "3.1.3", + "version": "3.2", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "6efa978680b891ef4e4ca5718323073d809cea01" + "reference": "3704e75049703e861cda4585b66d49e3eb6810bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/6efa978680b891ef4e4ca5718323073d809cea01", - "reference": "6efa978680b891ef4e4ca5718323073d809cea01", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/3704e75049703e861cda4585b66d49e3eb6810bd", + "reference": "3704e75049703e861cda4585b66d49e3eb6810bd", "shasum": "" }, "require": { @@ -2613,7 +2614,7 @@ "inspection", "php" ], - "time": "2019-03-12T12:55:38+00:00" + "time": "2019-03-14T14:23:26+00:00" }, { "name": "webmozart/assert", @@ -2765,7 +2766,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.1" + "php": "^7.1.3" }, "platform-dev": [] } diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index 327a71651..e4c7a0fd4 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -32,6 +32,7 @@ * serialize a collection use {@link toArray()} and reconstruct the collection * manually. * + * @template TKey of string|int * @template T * @template-implements Collection * @template-implements Selectable @@ -60,8 +61,6 @@ public function __construct(array $elements = []) /** * {@inheritDoc} - * - * @psalm-return array */ public function toArray() { @@ -70,8 +69,6 @@ public function toArray() /** * {@inheritDoc} - * - * @psalm-return T */ public function first() { @@ -98,8 +95,6 @@ protected function createFrom(array $elements) /** * {@inheritDoc} - * - * @psalm-return T */ public function last() { @@ -116,8 +111,6 @@ public function key() /** * {@inheritDoc} - * - * @psalm-return T */ public function next() { @@ -126,8 +119,6 @@ public function next() /** * {@inheritDoc} - * - * @psalm-return T */ public function current() { @@ -136,8 +127,6 @@ public function current() /** * {@inheritDoc} - * - * @psalm-return T|null */ public function remove($key) { @@ -153,8 +142,6 @@ public function remove($key) /** * {@inheritDoc} - * - * @psalm-param T $element */ public function removeElement($element) { @@ -183,8 +170,6 @@ public function offsetExists($offset) * Required by interface ArrayAccess. * * {@inheritDoc} - * - * @psalm-return T|null */ public function offsetGet($offset) { @@ -195,8 +180,6 @@ public function offsetGet($offset) * Required by interface ArrayAccess. * * {@inheritDoc} - * - * @psalm-param T $value */ public function offsetSet($offset, $value) { @@ -229,8 +212,6 @@ public function containsKey($key) /** * {@inheritDoc} - * - * @psalm-param T $element */ public function contains($element) { @@ -239,8 +220,6 @@ public function contains($element) /** * {@inheritDoc} - * - * @psalm-param Closure(int|string, T):bool $p */ public function exists(Closure $p) { @@ -255,8 +234,6 @@ public function exists(Closure $p) /** * {@inheritDoc} - * - * @psalm-param T $element */ public function indexOf($element) { @@ -265,8 +242,6 @@ public function indexOf($element) /** * {@inheritDoc} - * - * @psalm-return T|null */ public function get($key) { @@ -283,8 +258,6 @@ public function getKeys() /** * {@inheritDoc} - * - * @psalm-return array */ public function getValues() { @@ -301,8 +274,6 @@ public function count() /** * {@inheritDoc} - * - * @psalm-param T $value */ public function set($key, $value) { @@ -311,8 +282,6 @@ public function set($key, $value) /** * {@inheritDoc} - * - * @psalm-param T $element */ public function add($element) { @@ -333,8 +302,6 @@ public function isEmpty() * Required by interface IteratorAggregate. * * {@inheritDoc} - * - * @psalm-return ArrayIterator */ public function getIterator() { @@ -345,10 +312,6 @@ public function getIterator() * {@inheritDoc} * * @return static - * - * @template U - * @psalm-param Closure(T):U $func - * @psalm-return Collection */ public function map(Closure $func) { @@ -360,8 +323,7 @@ public function map(Closure $func) * * @return static * - * @psalm-param Closure(T):bool $p - * @psalm-return Collection + * @psalm-return ArrayCollection */ public function filter(Closure $p) { @@ -370,8 +332,6 @@ public function filter(Closure $p) /** * {@inheritDoc} - * - * @psalm-param Closure(int|string, T):bool $p */ public function forAll(Closure $p) { @@ -386,9 +346,6 @@ public function forAll(Closure $p) /** * {@inheritDoc} - * - * @psalm-param Closure(int|string, T):bool $p - * @psalm-return array{0: Collection, 1: Collection} */ public function partition(Closure $p) { @@ -425,8 +382,6 @@ public function clear() /** * {@inheritDoc} - * - * @psalm-return array */ public function slice($offset, $length = null) { @@ -435,8 +390,6 @@ public function slice($offset, $length = null) /** * {@inheritDoc} - * - * @psalm-return Collection */ public function matching(Criteria $criteria) { diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index 02735e0e6..28d7010c9 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -24,9 +24,10 @@ * position unless you explicitly positioned it before. Prefer iteration with * external iterators. * + * @template TKey of array-key * @template T - * @template-extends IteratorAggregate - * @template-extends ArrayAccess + * @template-extends IteratorAggregate + * @template-extends ArrayAccess */ interface Collection extends Countable, IteratorAggregate, ArrayAccess { @@ -38,6 +39,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * @return bool Always TRUE. * * @psalm-param T $element + * @psalm-return true */ public function add($element); @@ -74,6 +76,7 @@ public function isEmpty(); * * @return mixed The removed element or NULL, if the collection did not contain the element. * + * @psalm-param TKey $key * @psalm-return T|null */ public function remove($key); @@ -96,6 +99,8 @@ public function removeElement($element); * * @return bool TRUE if the collection contains an element with the specified key/index, * FALSE otherwise. + * + * @psalm-param TKey $key */ public function containsKey($key); @@ -106,6 +111,7 @@ public function containsKey($key); * * @return mixed * + * @psalm-param TKey $key * @psalm-return T|null */ public function get($key); @@ -115,6 +121,8 @@ public function get($key); * * @return int[]|string[] The keys/indices of the collection, in the order of the corresponding * elements in the collection. + * + * @psalm-return TKey[] */ public function getKeys(); @@ -136,6 +144,7 @@ public function getValues(); * * @return void * + * @psalm-param TKey $key * @psalm-param T $value */ public function set($key, $value); @@ -145,7 +154,7 @@ public function set($key, $value); * * @return array * - * @psalm-return array + * @psalm-return array */ public function toArray(); @@ -171,6 +180,8 @@ public function last(); * Gets the key/index of the element at the current iterator position. * * @return int|string + * + * @psalm-return TKey */ public function key(); @@ -199,7 +210,7 @@ public function next(); * * @return bool TRUE if the predicate is TRUE for at least one element, FALSE otherwise. * - * @psalm-param Closure(int|string, T):bool $p + * @psalm-param Closure(TKey, T):bool $p */ public function exists(Closure $p); @@ -212,7 +223,7 @@ public function exists(Closure $p); * @return Collection A collection with the results of the filter operation. * * @psalm-param Closure(T):bool $p - * @psalm-return Collection + * @psalm-return Collection */ public function filter(Closure $p); @@ -223,7 +234,7 @@ public function filter(Closure $p); * * @return bool TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. * - * @psalm-param Closure(int|string, T):bool $p + * @psalm-param Closure(TKey, T):bool $p */ public function forAll(Closure $p); @@ -235,7 +246,7 @@ public function forAll(Closure $p); * * @template U * @psalm-param Closure(T):U $func - * @psalm-return Collection + * @psalm-return Collection */ public function map(Closure $func); @@ -249,8 +260,8 @@ public function map(Closure $func); * of elements where the predicate returned TRUE, the second element * contains the collection of elements where the predicate returned FALSE. * - * @psalm-param Closure(int|string, T):bool $p - * @psalm-return array{0: Collection, 1: Collection} + * @psalm-param Closure(TKey, T):bool $p + * @psalm-return array{0: Collection, 1: Collection} */ public function partition(Closure $p); @@ -264,7 +275,7 @@ public function partition(Closure $p); * @return int|string|bool The key/index of the element or FALSE if the element was not found. * * @psalm-param T $element - * @psalm-return int|string|false + * @psalm-return TKey|false */ public function indexOf($element); @@ -280,7 +291,7 @@ public function indexOf($element); * * @return array * - * @psalm-return array + * @psalm-return array */ public function slice($offset, $length = null); } From 92d49e2ccff94e6c13208d230c5c0e4171e9a4cf Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Thu, 14 Mar 2019 19:19:43 +0100 Subject: [PATCH 10/18] Apply suggestions from code review Add missing template parameters and be more consistent across classes Co-Authored-By: nschoellhorn --- .../Common/Collections/AbstractLazyCollection.php | 5 +++-- .../Common/Collections/ArrayCollection.php | 14 +++++++------- lib/Doctrine/Common/Collections/Collection.php | 5 +++-- lib/Doctrine/Common/Collections/Selectable.php | 3 ++- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php index 74cda2acf..2c425530d 100644 --- a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php +++ b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php @@ -8,14 +8,15 @@ * Lazy collection that is backed by a concrete collection * * @template T - * @template-implements Collection + * @template TKey + * @template-implements Collection */ abstract class AbstractLazyCollection implements Collection { /** * The backed collection to use * - * @psalm-var Collection + * @psalm-var Collection * @var Collection */ protected $collection; diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index e4c7a0fd4..0f540ca0a 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -34,15 +34,15 @@ * * @template TKey of string|int * @template T - * @template-implements Collection - * @template-implements Selectable + * @template-implements Collection + * @template-implements Selectable */ class ArrayCollection implements Collection, Selectable { /** * An array containing the entries of this collection. * - * @psalm-var T[] + * @psalm-var array * @var array */ private $elements; @@ -52,7 +52,7 @@ class ArrayCollection implements Collection, Selectable * * @param array $elements * - * @psalm-param array $elements + * @psalm-param array $elements */ public function __construct(array $elements = []) { @@ -85,8 +85,8 @@ public function first() * * @return static * - * @psalm-param array $elements - * @psalm-return ArrayCollection + * @psalm-param array $elements + * @psalm-return ArrayCollection */ protected function createFrom(array $elements) { @@ -323,7 +323,7 @@ public function map(Closure $func) * * @return static * - * @psalm-return ArrayCollection + * @psalm-return ArrayCollection */ public function filter(Closure $p) { diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index 28d7010c9..1a55871b2 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -40,6 +40,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * * @psalm-param T $element * @psalm-return true + * @psalm-return true */ public function add($element); @@ -132,7 +133,7 @@ public function getKeys(); * @return array The values of all elements in the collection, in the order they * appear in the collection. * - * @psalm-return array + * @psalm-return T[] */ public function getValues(); @@ -246,7 +247,7 @@ public function forAll(Closure $p); * * @template U * @psalm-param Closure(T):U $func - * @psalm-return Collection + * @psalm-return Collection */ public function map(Closure $func); diff --git a/lib/Doctrine/Common/Collections/Selectable.php b/lib/Doctrine/Common/Collections/Selectable.php index 1e9c09ccd..c4d93bc1d 100644 --- a/lib/Doctrine/Common/Collections/Selectable.php +++ b/lib/Doctrine/Common/Collections/Selectable.php @@ -15,6 +15,7 @@ * EntityManager or Repositories. * * @template T + * @template TKey */ interface Selectable { @@ -24,7 +25,7 @@ interface Selectable * * @return Collection * - * @psalm-return Collection + * @psalm-return Collection */ public function matching(Criteria $criteria); } From 7ef4170b5777d3feaedf7a71518e21b14f5b351d Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Thu, 14 Mar 2019 19:30:55 +0100 Subject: [PATCH 11/18] Fix Psalm errors (wrong/missing template constraints) --- lib/Doctrine/Common/Collections/AbstractLazyCollection.php | 2 +- lib/Doctrine/Common/Collections/ArrayCollection.php | 2 +- lib/Doctrine/Common/Collections/Selectable.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php index 2c425530d..4115df8af 100644 --- a/lib/Doctrine/Common/Collections/AbstractLazyCollection.php +++ b/lib/Doctrine/Common/Collections/AbstractLazyCollection.php @@ -7,8 +7,8 @@ /** * Lazy collection that is backed by a concrete collection * + * @template TKey of array-key * @template T - * @template TKey * @template-implements Collection */ abstract class AbstractLazyCollection implements Collection diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index 0f540ca0a..0486f4c6a 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -32,7 +32,7 @@ * serialize a collection use {@link toArray()} and reconstruct the collection * manually. * - * @template TKey of string|int + * @template TKey of array-key * @template T * @template-implements Collection * @template-implements Selectable diff --git a/lib/Doctrine/Common/Collections/Selectable.php b/lib/Doctrine/Common/Collections/Selectable.php index c4d93bc1d..692037b55 100644 --- a/lib/Doctrine/Common/Collections/Selectable.php +++ b/lib/Doctrine/Common/Collections/Selectable.php @@ -14,8 +14,8 @@ * this API can implement efficient database access without having to ask the * EntityManager or Repositories. * + * @template TKey as array-key * @template T - * @template TKey */ interface Selectable { From 744afc199626c1638113da4cd4bf2222c91dcd13 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Thu, 14 Mar 2019 20:19:44 +0100 Subject: [PATCH 12/18] Apply suggestions from code review Make closure arguments optional Co-Authored-By: nschoellhorn --- lib/Doctrine/Common/Collections/Collection.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index 1a55871b2..697e14162 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -211,7 +211,7 @@ public function next(); * * @return bool TRUE if the predicate is TRUE for at least one element, FALSE otherwise. * - * @psalm-param Closure(TKey, T):bool $p + * @psalm-param Closure(TKey=, T=):bool $p */ public function exists(Closure $p); @@ -223,7 +223,7 @@ public function exists(Closure $p); * * @return Collection A collection with the results of the filter operation. * - * @psalm-param Closure(T):bool $p + * @psalm-param Closure(T=):bool $p * @psalm-return Collection */ public function filter(Closure $p); @@ -235,7 +235,7 @@ public function filter(Closure $p); * * @return bool TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. * - * @psalm-param Closure(TKey, T):bool $p + * @psalm-param Closure(TKey=, T=):bool $p */ public function forAll(Closure $p); @@ -246,7 +246,7 @@ public function forAll(Closure $p); * @return Collection * * @template U - * @psalm-param Closure(T):U $func + * @psalm-param Closure(T=):U $func * @psalm-return Collection */ public function map(Closure $func); From 7794e42e6165b7c70e4ba0346cd1fc39061d759b Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Thu, 14 Mar 2019 20:42:29 +0100 Subject: [PATCH 13/18] Make arguments for partition() optional as well Co-Authored-By: nschoellhorn --- lib/Doctrine/Common/Collections/Collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index 697e14162..aef352f76 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -261,7 +261,7 @@ public function map(Closure $func); * of elements where the predicate returned TRUE, the second element * contains the collection of elements where the predicate returned FALSE. * - * @psalm-param Closure(TKey, T):bool $p + * @psalm-param Closure(TKey=, T=):bool $p * @psalm-return array{0: Collection, 1: Collection} */ public function partition(Closure $p); From ea513964f770f20e2baed7bdbaddb387d90b6dc1 Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Thu, 14 Mar 2019 20:44:25 +0100 Subject: [PATCH 14/18] Remove duplicate return annotation --- lib/Doctrine/Common/Collections/Collection.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index aef352f76..ce71b4350 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -40,7 +40,6 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * * @psalm-param T $element * @psalm-return true - * @psalm-return true */ public function add($element); From 18d5fbd5c6d15f4d7b6e59a0102bcff43496b052 Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Fri, 15 Mar 2019 13:53:57 +0100 Subject: [PATCH 15/18] Remove suggestion from composer.json --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index 5d0e8fee7..602f4c774 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,6 @@ {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} ], - "suggest": { - "vimeo/psalm": "Psalm allows you to enforce template types for your collections." - }, "require": { "php": "^7.1.3" }, From 60d9e6d540c38d4a0e80d6e7418d2711cb84ff8a Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Sat, 16 Mar 2019 12:35:02 +0100 Subject: [PATCH 16/18] Change phpdoc to reflect only "true" is being returned and remove additional annotation --- lib/Doctrine/Common/Collections/Collection.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Doctrine/Common/Collections/Collection.php b/lib/Doctrine/Common/Collections/Collection.php index ce71b4350..48ec6cef3 100644 --- a/lib/Doctrine/Common/Collections/Collection.php +++ b/lib/Doctrine/Common/Collections/Collection.php @@ -36,10 +36,9 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * * @param mixed $element The element to add. * - * @return bool Always TRUE. + * @return true Always TRUE. * * @psalm-param T $element - * @psalm-return true */ public function add($element); From 43e613c2ead46378c4f47823e634c60a8b31cf47 Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Mon, 18 Mar 2019 09:37:46 +0100 Subject: [PATCH 17/18] Update Psalm and roll back workaround Signed-off-by: Niklas Schoellhorn --- composer.json | 2 +- composer.lock | 83 ++++++++++++++++--- .../Common/Collections/ArrayCollection.php | 4 +- 3 files changed, 73 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 602f4c774..828a7d2f0 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "phpunit/phpunit": "^7.0", "doctrine/coding-standard": "^6.0", "phpstan/phpstan-shim": "^0.9.2", - "vimeo/psalm": "^3.2" + "vimeo/psalm": "^3.2.2" }, "autoload": { "psr-4": { "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" } diff --git a/composer.lock b/composer.lock index 1e792f608..4e84a7a18 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": "663068946b0b278bdafdd8bb777bb4c2", + "content-hash": "e0e1fd6f2f470ccb15ba29bab769a4be", "packages": [], "packages-dev": [ { @@ -2437,6 +2437,64 @@ ], "time": "2018-12-05T08:06:11+00:00" }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "backendtea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-08-06T14:22:27+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.10.0", @@ -2538,16 +2596,16 @@ }, { "name": "vimeo/psalm", - "version": "3.2", + "version": "3.2.2", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "3704e75049703e861cda4585b66d49e3eb6810bd" + "reference": "f0ddc6f3bc35ba7ecb99232903907a1d5ec1c8e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/3704e75049703e861cda4585b66d49e3eb6810bd", - "reference": "3704e75049703e861cda4585b66d49e3eb6810bd", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/f0ddc6f3bc35ba7ecb99232903907a1d5ec1c8e8", + "reference": "f0ddc6f3bc35ba7ecb99232903907a1d5ec1c8e8", "shasum": "" }, "require": { @@ -2614,24 +2672,25 @@ "inspection", "php" ], - "time": "2019-03-14T14:23:26+00:00" + "time": "2019-03-17T22:14:30+00:00" }, { "name": "webmozart/assert", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "phpunit/phpunit": "^4.6", @@ -2664,7 +2723,7 @@ "check", "validate" ], - "time": "2018-01-29T19:49:41+00:00" + "time": "2018-12-25T11:19:39+00:00" }, { "name": "webmozart/glob", diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index 0486f4c6a..f6f0c50b7 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -410,9 +410,7 @@ public function matching(Criteria $criteria) $next = ClosureExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next); } - if ($next) { - uasort($filtered, $next); - } + uasort($filtered, $next); } $offset = $criteria->getFirstResult(); From 067a13757ffebe20261d1176a49bc58efc3b4394 Mon Sep 17 00:00:00 2001 From: Niklas Schoellhorn Date: Mon, 18 Mar 2019 13:20:41 +0100 Subject: [PATCH 18/18] Merge dependency changes Signed-off-by: Niklas Schoellhorn --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 4e84a7a18..27e6bbaf6 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": "e0e1fd6f2f470ccb15ba29bab769a4be", + "content-hash": "9089934b1d5718afcff78cb110ec244a", "packages": [], "packages-dev": [ {