Skip to content

@ondrejmirtes ondrejmirtes released this Jan 16, 2019 · 514 commits to master since this release

PHPStan 0.11 has been made possible by LOVOO:

LOVOO: PHPStan is an elementary part of our development workflow. We cannot live without it! Thanks for the great work!

Also, my work on PHPStan is enabled by generous patrons over at Patreon. If PHPStan makes your life easier, consider a contribution, it'll be greatly appreciated!

Check out the article about PHPStan in 2018 and this new release at Medium.com!

Major new features

  • Ability to ignore errors by path (#1411, #1619), thanks @josephzidell, @damnedest!
  • Check - reporting unreachable conditions on level 4. Previously, only projects with checkAlwaysTrue* flags set to true (usually with installed strict-rules) found out about always true conditions. With this change, always-true conditions with else branches and ternary operators are reported (186e4e0, e06af0e):
if ($alwaysTrue) {
	// ...
} else {
	// dead - reported on level 4!
}
  • Improved analysis of non-empty arrays (5716b2e, 21309e2, deb70ef) - #336, #165, #1539, #1073, #959, #1505, #1409
  • Check (level 3) - validate method signatures against parents and implemented interfaces - forces Liskov substitution principle (#1292), thanks @iluuu1994!
  • Check - validation of patterns used in preg_* functions on level 0 (#1567), thanks @iluuu1994!
  • Check (level 2) - string and castable-to-string types in echo and print statements (#1462), thanks @dmitrydymarchuk!
  • Check (level 3) - report invalid offset assignments (56be6db) - e.g. $string['foo'] = 'bar' leads to an error.
  • Check (level 2) - invalid comparison between an object and a number (#1582), thanks @jasny!
  • Check (level 2) - check default function parameter type against typehint and phpDoc (#1608), thanks @iluuu1994!
  • Loaded extensions for known functions in PHP runtime are no longer needed for successful ananlysis (8e6a215)

Improvements

  • Implicit @inheritDoc from parent classes and interfaces (#1533), thanks @iluuu1994!
  • Memory consumption improvement - limit amount of cached files for parser (#1673), thanks @damnedest!
  • Improved precision of reported lines in some rules (9f7ab5b, eaedf17, 9a2646d)
  • Dead branches are not analysed (295c8f2)
  • IncompatiblePhpDocTypeRule - detect NeverType in @param and @return (a0e2a76)
  • IncompatiblePropertyPhpDocTypeRule - check for ErrorType and NeverType in properties (7e66cee)
  • Report traits in anonymous function typehints - traits are not valid types (2a96f14)
  • Always have a nice progressbar (6b04dca)
  • Detect $var[] used in read context (#1309), thanks @iluuu1994!
  • Improved invalid offset access detection (7a630b8)
  • Moved reporting of object accesses and calls to level 6 (216fb2e)
  • Moved partially correct types in an encapsed string to level 6 (0470c53)
  • Array from pathinfo may or may not contain extension key (#1637), thanks @jasny!
  • Make binary operations aware of strings (#1628), thanks @wata727!
  • Collecting error handler to report multiple parse errors at once (7b38a23)
  • AppendedArrayItemTypeRule - improved message in case of incompatible callables (c1b8540)
  • Report all analysed code exceptions for a node at once (663c6d0)
  • Simplified and made array_merge extension faster (002aa73) - #1620

Bugfixes

  • Fix @inheritdoc for recursive interfaces (#1574), thanks @iluuu1994!
  • Fixed UnionType::accepts() by checking inner type to given type (#1581), thanks @jasny!
  • Fix inheritdoc issue with traits (#1575), thanks @iluuu1994!
  • Fix phpDoc resolution for trait methods in same file as class (#1603), thanks @iluuu1994!
  • Fix phpDoc resolving for nested traits (7155f2f) - thanks @iluuu1994!
  • ImpossibleCheckTypeHelper: improved union type support in in_array function (#1545), thanks @pepakriz!
  • Fix phpdoc resolving for traits in PhpClassReflectionExtension (#1587), thanks @iluuu1994!
  • ImpossibleCheckTypeHelper: fixed case with mixed $haystackType (#1592), thanks @pepakriz!
  • Fixed: Call to function is_callable() with array(object, 'yo') will always evaluate to false. (e38f882) - #1271
  • Fix copy and paste error (#1621), thanks @dereuromark!
  • False positive for strict comparison on objects (92c9b2b) - #1625
  • Fixed ConstantArrayType::hasOffsetValueType() (46f2264) - #1593
  • Fixed union of multiple array&callable (bceec5f) - #1615
  • ConstantArrayTypeBuilder - quickfix for integer overflow (bb6a250) - #1422
  • Fix HasMethodType and ObjectType::hasMethod() (#1639), thanks @JanTvrdik!
  • Unify HasPropertyType and ObjectType::hasProperty() with HasMethodType (#1721), thanks @CZechBoY!
  • Unified hasConstant with hasProperty and hasMethod (24178d1)
  • Fix condition filtering in short ternary operator (#1677, fixes #1598, #1355), thanks @lookyman!
  • Fixed invoking methods on unions (91aea3a) - #1349, #1529
  • Fixed fetching union properties (2ba0f4e)
  • Report missing ignored errors in checkstyle format (#1717, fixes #1427), thanks @khaperets!
  • Fix error message for incompatible callables (#1719), thanks @dmitrydymarchuk!
  • Fix failure to recognise initialize int type (#1718), thanks @dmitrydymarchuk!
  • Array incorrectly inferred as string after using list() (#1737), thanks @dmitrydymarchuk!
  • Fix nullable string parameter when the |null is not in phpDoc (4c17a30)
  • dump-deps - add literal array dependencies as callables (6261cb4)
  • Get dynamicConstantNames from configuration to avoid filtering (#1781), thanks @rarila!
  • Offset does not exist on array() when incrementing key (#1785, cfb0b43), thanks @dmitrydymarchuk!

Function signatures fixes

  • Correct return type for Redis::delete, add unlink alias (#1569), thanks @spaze!
  • openssl_csr_get_subject returns false on error (#1572), thanks @spaze!
  • Update imap signatures to RETURN_FALSE instructions (#1541), thanks @Slamdunk!
  • Optional parameters for ldap (#1588), thanks @mamchenkov!
  • Fix ZipArchive::getFromName() (#1599), thanks @enumag!
  • Fix Fix DOMDocument::saveHTML() (#1596), thanks @enumag!
  • Fix incorrect "offset" parameter types for IntlBreakIterator (#1635), thanks @tominventisbe!
  • parse_url return type extension (#1198), thanks @CZechBoY!
  • Some pspell functions can return false (#1653), thanks @Stadly!
  • pg_fetch_a* return also false (#1651), thanks @forrest79!
  • pg_field_type_oid returns int|false (#1701), thanks @sukei!
  • Update IMAP functions map to return stdClass instead of object (#1681), thanks @Slamdunk!
    * Correct return type for array_slice (#1576, fixes #1566), thanks @thewilkybarkid!
  • Better handling of mb_* function return types (#1688), thanks @dmitrydymarchuk!
  • Fix: return type of array_filter($mixed) (#1691, fixes #1607)
  • hrtime() support for PHP 7.3 (#1697), thanks @lookyman!
  • Support encoding aliases for mb_* functions (#1699), thanks @dmitrydymarchuk!
  • Added key() dynamic return type extension (#1726), thanks @CZechBoY!
  • Fix signature of extract (#1729), thanks @josephzidell!
  • Fix signature for MongoDB\Driver\WriteConcern::__construct (#1730), thanks @alcaeus!
  • ReflectionClass::getReflectionConstant can return false (f7d74e3)
  • tmpfile returns false on error (#1738), thanks @Andrewsville!
  • Fix Transliterator::transliterate and transliterator_transliterate signatures (#1748), thanks @Daeroni!
  • Add the failure return type for shmop_open() (#1749), thanks @duncan3dc!
  • Updating oci_set_db_operation signature (#1754), thanks @moufmouf!
  • Fix signature for jddayofweek - 2nd parameter is optional (#1776), thanks @muster-mark!
  • Fix SNMP function mapping (#1765), thanks @simPod!
  • Fix iconv return types (#1759), thanks @voku!
  • Serializable::unserialize has parameter $serialized of type string (#1782), thanks @CZechBoY!

BC breaks

  • Moved UselessCastRule to phpstan-strict-rules (08c3b79)
  • CLI option --errorFormat superceded by --error-format (12545ac)
  • Moved MockObjectTypeNodeResolverExtension to phpstan-phpunit extension (338cab7)
  • Reworded an error message: Negated boolean <expression> is always false. (#1200), thanks @sanmai!

BC breaks for extension developers

  • $analysedPaths in ContainerFactory::create() are required (baa8ffe)
  • Removed the old RelativePathHelper - use PHPStan\File\RelativePathHelper (1401d9a)
  • RuleLevelHelper::findTypeToCheck(): FoundTypeResult's unknown class errors are now RuleError[] (eaedf17)
  • Type::hasProperty(), hasMethod() and hasConstant() return TrinaryLogic instead of boolean (e38f882)
  • In order to safely call Type::getProperty(), getMethod() or getConstant(), result of Type::hasProperty(), hasMethod() and hasConstant() respectively has to be checked for yes() first.
  • ParametersAcceptorSelector - disallow zero variants (60f8382)
Assets 4
You can’t perform that action at this time.