Skip to content

Releases: vimeo/psalm

4.13.0

21 Nov 02:39
cd48940
Compare
Choose a tag to compare

What's Changed

Features

  • Forbid properties on enums by @weirdan in #6836
  • better understands value and name properties for enum by @orklah in #6838
  • Added option to forbid eval() in codebase by @thomasbley in #6856
  • Use positive integers for various time functions by @danog in #6861
  • Flag duplicate constants by @weirdan in #6884
  • Add ImagickPixel::getColor return type provider by @danog in #6890
  • Fix promoted readonly properties by @trowski in #6909
  • ConsoleReport: Add hyperlinks to open file in editor by @gharlan in #6850
  • Multiple variables in @psalm-trace by @rarila in #6920
  • Reconcile class-constant by @boesing in #6529

Fixes

  • don't consider calls to methods with assertions as Unused by @orklah in #6834
  • Forbid enum instantiation by @weirdan in #6840
  • Taint comments by @orklah in #6848
  • add stub for taint detection on vprintf by @orklah in #6847
  • Forbid declaring enums as attributes by @weirdan in #6843
  • DOMParentNode and DOMChildNode stubs (php 8) by @jirkace in #6851
  • Fixed signature for newInstanceArgs for PHP 8.0 by @jirkace in #6852
  • Fixed RedisCluster::setOption() argument types by @jirkace in #6853
  • Fixed callmap for function openssl_sign, it changed in PHP 8.0 (modif… by @jirkace in #6846
  • allow signature type for promoted property as well as property docblock by @orklah in #6872
  • load the ReturnTypeWillChange stubs for all versions to allow using it on every PHP version by @orklah in #6873
  • fix never combination by @orklah in #6874
  • do not treat __halt_compiler() as an expression being executed by @pilif in #6876
  • detect unevaluated inline-html code after an rearly return by @pilif in #6878
  • Fix --enable-autocomplete=false by @Nadyita in #6880
  • don't stop processing for class usage after raising an issue by @pilif in #6899
  • SimpleXMLIterator is not always truthy by @jnvsor in #6903
  • make ignore falsable/nullable dependent on the config by @orklah in #6895
  • Fix invalid SoapClient::__doRequest() signature by @veewee in #6905
  • Fix mb_convert_encoding to accept any array. by @rarila in #6910
  • Report deprecated config elements by @weirdan in #6913
  • Infer mb_strtolower() result as string when encoding is specified by @weirdan in #6912
  • Allow references to enum cases in class constants by @weirdan in #6922
  • session_set_cookie_params signature changed in 8.0 by @kamil-tekiela in #6932
  • expand type aliases when comparing unions by @sebkehr in #6946

Docs

  • Added ext-curl to composer.json suggest property by @sasezaki in #6844

Internal changes

Typos

New Contributors

Full Changelog: 4.12.0...4.13.0

4.12.0

06 Nov 18:54
e42bc4a
Compare
Choose a tag to compare

What's Changed

Deprecations

Features

Fixes

  • throwable Instanceof throwable negated by @orklah in #6746
  • Updated openssl_pkey_get_private function signature by @pls78 in #6758
  • Fix template parameter collection for child classes with fewer parameters (fixes #6734) by @danog in #6742
  • fix local variable defined too early by @orklah in #6774
  • fix is_a when used with Stringable classes by @orklah in #6775
  • remove second autoloader call by @orklah in #6776
  • Correct pgsql stubs by @sad-spirit in #6777
  • detect Yield in new by @orklah in #6790
  • accept ::class constant strings for literal argument by @sasezaki in #6801
  • Add pcntl_alarm to the list of impure functions by @l-x in #6802
  • added mysqli::connect() to callmap by @SMAtaurRahman in #6805
  • add "error" from php-parser to baseline by @orklah in #6815
  • Improved Github Actions output by @weirdan in #6818
  • backticks shell_exec taint by @orklah in #6812
  • Array cast pass taints by @orklah in #6810
  • don't taint the result of most binary operations by @orklah in #6809
  • don't register taints for numeric variables by @orklah in #6813
  • allow assertion to work on $var::class by @orklah in #6823
  • Fix parameter names in CoreGenericFunctions.phpstub for PHP 8 named p… by @tminich in #6820
  • Allow Symfony 6 by @loic425 in #6663
  • allow declaring functions and classLikes after a never-returning call by @orklah in #6828
  • Makes $_SESSION possibly undefined at the source by @orklah in #6824
  • create a tmp fake var for ternaries inside coalesce by @orklah in #6825
  • only return true in Union::isType if there is a single type by @orklah in #6829
  • Mixed contain every types and Never is contained in every type by @orklah in #6830

Docs

Internal changes

New Contributors

Full Changelog: 4.11.2...4.12.0

4.11.2

26 Oct 17:37
6fba5eb
Compare
Choose a tag to compare

What's Changed

Features

  • add ReturnTypeWillChange with attribute attribute by @orklah in #6732

Fixes

  • strlen of strtolower of string is not always true by @orklah in #6729
  • don't emit issues when doing arithmetics on int templates by @orklah in #6730
  • issue-6737: fix CallMap imagecropauto() arguments by @semercom in #6740
  • don't emit redundant error when checking a named type against itself by @orklah in #6739
  • Don't assert mixed type by @orklah in #6744
  • don't use is_a with user classes by @orklah in #6738

New Contributors

Full Changelog: 4.11.1...4.11.2

4.11.1

24 Oct 13:43
e334923
Compare
Choose a tag to compare

What's Changed

Features

  • flag impure calls made through __callstatic by @orklah in #6724

Fixes

Full Changelog: 4.11.0...4.11.1

4.11.0

23 Oct 22:00
99e510d
Compare
Choose a tag to compare

What's Changed

Deprecations

Features

Fixes

  • Encode XML output consistently by @weirdan in #6433
  • Force array_walk to not infer input type. by @niconoe- in #6441
  • Add an optional $options argument to hash functions for PHP 8.1 by @50bhan in #6446
  • Fix return-type for preg_filter by @tvdijen in #6453
  • type of "$http_response_header" is "list" now by @SMAtaurRahman in #6462
  • Fix #6464: false positive for RecursiveArrayIterator::CHILD_ARRAYS_ONLY by @Jean85 in #6465
  • Print exception class in case of an uncaught exception by @MorrisJobke in #6489
  • Revert mb_str_split return signature to list by @fluffycondor in #6493
  • Fix wrong template type in Sequence::copy() by @simPod in #6494
  • Permit null user_agent to get_browser() by @pawel-slowik in #6502
  • assert object type from instance of with TClassString by @orklah in #6503
  • add PropertyTypeProvider for DomDocument by @orklah in #6505
  • Changed signature of Serializable::unserialize stub by @SCIF in #6438
  • Fix false positive ParadoxicalCondition in negation of in_array by @TysonAndre in #6445
  • Fix invalid argument bug in generic trait context by @whsv26 in #6478
  • Catch ComplicatedExpressionException in ArrayFilterReturnTypeProvider by @MorrisJobke in #6498
  • fixed Uncaught Error: Call to undefined function shell_exec() by @thomasbley in #6508
  • Prevent unnecessary filter_var() warnings on primitive types by @mmcev106 in #6537
  • Update xlswriter signatures by @pawel-slowik in #6545
  • Allow null for argument context in fopen() by @vjik in #6557
  • "Undefined offset: 1" in PLS Psalm/Codebase.php::1473 by @NikolayZhebet in #6560
  • Callmap leak by @orklah in #6553
  • offset the starting position of the function in case of attributes by @orklah in #6552
  • 2> Count equal 0 assertion by @orklah in #6423
  • Show file and line in case of an exception in a forked worker by @MorrisJobke in #6522
  • improvements of alwaysTruthy/alwaysFalsy by @orklah in #6518
  • assert both sides of an equality by @orklah in #6473
  • fix wrong operator priority by @orklah in #6576
  • fix wrong type description added in signature by @orklah in #6580
  • Better understanding of Templates in lhs of callable TKeyedArray by @orklah in #6589
  • fix isAlwaysTruthy: TNonEmptyString can be falsy (with '0') by @orklah in #6585
  • Redundant return type by @orklah in #6590
  • Fix invalid class/method declaration in stub by @sasezaki in #6592
  • revert confusing change by @orklah in #6597
  • Falsable returns by @orklah in #6594
  • fix error by @orklah in #6598
  • foreach on list gives a positive|0 offset by @orklah in #6608
  • Fixed trim-stub by @Dgame in #6610
  • Array unshift on empty array by @orklah in #6604
  • array_is_list on empty array returns true by @orklah in #6612
  • allow any integer range to be satisfied by TNonspecificLiteralInt by @orklah in #6617
  • add a little details to the Incompatible types found for T error by @orklah in #6621
  • fix @return 0 by @orklah in #6622
  • Resolution of unary ops by @orklah in #6635
  • invert the meaning of the errors by @orklah in #6624
  • Templated array key by @orklah in #6623
  • Allow sending possibly_undefined inputs to optional params by @orklah in #6636
  • Refined PDO::errorInfo, PDOStatement::errorInfo by @vudaltsov in #6625
  • Refine TKeyedArray with iterable by @orklah in #6639
  • loose comparison between int/float and string result in numeric-string by @orklah in #6640
  • infer never on closures(and more?) by @orklah in #6643
  • Inside conditional by @orklah in #6642
  • tweaking with loops by @orklah in #6629
  • SimpleXMLElement is not always truthy by @orklah in #6650
  • use Attribute feature of PHP-Parser to avoid dealing with dynamic properties by @orklah in #6656
  • allow Psalm to choose PHP8.1 if it's the lower PHP version allowed by @orklah in #6669
  • Fix @psalm-method annotation parsing by @fluffycondor in #6658
  • prevent phpstorm generics from touching to signature types by @orklah in #6672
  • Fix manipulation of intersection types, arrow functions, foreign static types, parameter static types, T|false|null unions. by @danog in #6654
  • Don't emit InvalidReturnType when return type was inferred to never by @orklah in #6678
  • Improve handling of positive ints by array_filter() by @SCIF in #6679
  • add SimpleXMLIterator to universalObjectCrates by @orklah in #6690
  • improve empty/falsy ...
Read more

Better infinite loop inference, some PHP 8.1 support and a bunch of fixes

05 Sep 00:03
916b098
Compare
Choose a tag to compare

Added

Fixes

  • (#6305, #6310) SimpleXMLIterator signatures no longer depend on runtime PHP version (@weirdan)
  • (#6309, #6311) Some assertions generated by in_array() were causing crashes (@weirdan)
  • (#6312) PhpToken::getAll() was renamed to PhpToken::tokenize() (@TysonAndre)
  • (#6312) fdiv() argument names were corrected to match names used by PHP (@TysonAndre)
  • (#6312) ReflectionClass::getAttributes(), ReflectionClassConstant::getAttributes(), ReflectionFunctionAbstract::getAttributes(), ReflectionParameter::getAttributes(), ReflectionProperty::getAtributes(), ReflectionUnionType::getTypes() and ReflectionNamedType::isBuiltin() signatures were missing (@TysonAndre)
  • (#6318, #6320) socket_select()'s tv_sec parameter is nullable (@Forceu)
  • (#6323) Another case of crashes due to in_array() assertions (@boesing)
  • (#6324) str_split() and mb_str_split() return require positive-int and str_split() returns non-empty array (@VincentLanglet)
  • (#6328) Corrected message for calls from root namespace to internal methods in a different namespace (@bdsl)
  • (#6325, #6327) Interface aliases were not recognized (@boesing)
  • (#4738) is_subclass_of() requires a class-string for its parent parameter (@BenMorel)
  • (#5356, #6344) UnusedSuppression was sometimes reported in ignored folders (@orklah)
  • (#6343, #6346) @psalm-trace was reporting keys that were unset (@orklah)
  • (#5096, #6321) Constants accessed through object instance (e.g. $obj::CONST) were not inferred (@orklah)
  • (#6359) OuterIterator::getInnerIterator() always return Iterator (@drupol)
  • (#6367, #6376) Variables used in backticks (`ls $file`) were reported as unused (@orklah)
  • (#6358, #6375) openssl_x509_parse() and openssl_x509_read() signatures were outdated (@ThomasLandauer)
  • (#6338, #6339) array_walk() and array_walk_recursive() accept object (and will trigger RawObjectIteration when given one) (@niconoe-, @weirdan)
  • (#6330, #6335) Alias chains created with class_alias() (A -> B -> C) were not understood (@boesing)
  • (#6387, #6390) Type params can now be extracted from Generator argument passed to Iterator parameter (@orklah)
  • (#6388, #6391) empty() could not be forbidden via forbiddenFunctions (@ro0NL)
  • (#6333, #6317) in_array() did not produce correct assertions with non-literal types (@TysonAndre)
  • (#6384, #6420) Variables reassigned in both branches of ternary operator were not correctly inferred (@orklah)

Docs

Just a bunch of fixes + callmap tests

15 Aug 01:14
4c26293
Compare
Choose a tag to compare

Fixes

Internal changes

Typos

Improve preloading and fix template bounds checks

01 Aug 13:27
Compare
Choose a tag to compare

Fixes an issue introduced in 4.9.0: #6212

Also improves Psalm's knowledge when some stub files are loaded (#5126, #5626)

Fixed TIntRange bounds types

31 Jul 13:57
7e137f5
Compare
Choose a tag to compare

TIntRange changes

The types for int range bounds were sub-optimal. This release fixes this. Formally this is a BC break, for plugins. However, given the short time that passed since TIntRange introduction we believe it should be OK to release it as a patch release.

Fixes

First community release

31 Jul 03:22
c62adf9
Compare
Choose a tag to compare

Features

  • (#5974, #5980) Ability to turn off inferPropertyTypesFromConstructor (thanks @weirdan)
  • (#6008, #6010) LSP server now runs analysis on open and save (thanks @tm1000)
  • (#6013, #6014, #6055) LSP server now understands didChangeWatchedFiles notification (thanks @tm1000)
  • (#6058, #6059) Support for xml:base attribute (useful for modular configs) (thanks @turnabout)
  • (#6060) FunctionReturnTypeProviderEvent and MethodReturnTypeProviderEvent now provide access to the statement via getStmt() method (thanks @VincentLanglet)
  • (#6106) Added support for interface-string<FooInterface> (currently as an alias to class-string<FooInterface>) (thanks @muglug)
  • (#5512) Added option to enable Shepherd reporting with environment variables (PSALM_SHEPHERD and PSALM_SHEPHERD_HOST) (thanks @ngmy)
  • (#6117, #6130) Psalm now flags static access to non-static property (and vice versa) (thanks @weirdan)
  • (#6155) Added support for PHP 8.1 native readonly flag on properties (thanks @muglug)
  • (#6110, #6142) Now you may configure trigger_error() behavior (thanks @orklah)
  • (#6152, #6181) Psalm now understands that the only descendants of DateTimeInterface are DateTime and DateTimeImmutable (thanks @Jack97)
  • (#6207) Preliminary support for int ranges (e.g. int<min, 25>, int<2, 8> etc) (thanks @orklah)

Fixes

  • (#5981, #5992) Marked more built-in functions as impure (thanks @samsonasik)
  • (#5964) Fixed RdKafka\ProducerTopic::producev() (thanks @danog)
  • (#5975, #5989) Values used in throw are no longer considered unused (thanks @weirdan)
  • (#5979, #6000) Fixed newline-related issues when using baseline cross-platform (Windows/everything else) (thanks @bdsl)
  • (#5997, #6007) Fixed errors during LSP shutdown sequence (thanks @tm1000)
  • (#6011, #6012) Fixed psalm-language-server crash when invoked with --version argument (thanks @tm1000)
  • (#6005, #6019) Correctly resolve self and static in callable arrays passed to array_reduce() (thanks @elnoro)
  • (#3287, #6036) Fixed mbstring functions signatures (they changed in PHP 8) (thanks @mpesari)
  • (#6038, #6039) Generic part of the array shape is no longer erased by array_map() (thanks @weirdan)
  • (#6027, #6041) Fixed inferred value for __FUNCTION__ constant used in methods (thanks @orklah)
  • (#6040) DateTime::format() and DateTimeImmutable::format() return values on PHP 8 (thanks @j4nr6n)
  • (#6062) Do not interpret psalm.xml in --config psalm.xml as a file to check (thanks @simPod)
  • (#4663, #5378, #6063, #6064) Fixed parsing of negative int literals (thanks @ElisDN)
  • (#6050, #6054) Fixed crash due to internal structures getting out of sync (thanks @caugner)
  • (#6016, #6069) Improve str_word_count() signature (thanks @elnoro)
  • (#5584) Added ReflectionProperty::hasType() and ReflectionProperty::getType() stubs (thanks @franmomu)
  • (#5971, #6068) Fixed plugin crash due to missing ClassLikeStorage (thanks @caugner)
  • (#5608) Ignore string keys in callable arrays passed to preg_replace_callback() (thanks @paxal)
  • (#6066, #6072) Tightened constraints on generic type parameter inference that might lead to runtime errors (thanks @muglug)
  • (#6061, #6081) Analyze array keys before values (thanks @muglug)
  • (#6080, #6082) join() signature is synced to implode() (thanks @weirdan)
  • (#5790, #6083) Emit InvalidArgument instead of PossiblyFalseArgument when the argument is certainly false (thanks @orklah)
  • (#5957, #6084) Fixed false-positive UnusedVariable issues on values used in bitwise OR and NOT (thanks @elnoro)
  • (#6088, #6089) Fixed crash on closed resource used in switch (thanks @orklah)
  • (#6049, #6094) Fixed inference of non-empty-string returned from str_pad() and str_repeat() (thanks @weirdan)
  • (#6104) Fixed return type for strtoupper() (thanks @staabm)
  • (#6116) Fixed return type for radius_send_request() (thanks @fkooman)
  • (#2616, #6107) Fixed return type for get_defined_constants() (thanks @orklah)
  • (#6119, #6121) Allowed zero for all bitmask types (thanks @weirdan)
  • (#6122, #6123) Fixed path to be relative in CodeClimate reports (thanks @caugner)
  • (#6118, #6127) Deprecated properties are now reported even when they are read with $this->prop (thanks @weirdan)
  • (#3421) Fixed useless empty cache folder being created (thanks @JoshuaBehrens)
  • (#3903) Now Psalm emits RedundantIdentityWithTrue for !== false as it did for === true before (thanks @greg0ire)
  • (#6091, #6099) Fixed signatures for XmlWriter methods (thanks @aboks)
  • (#6111, #6129) Prevented false-positive UnusedVariable issues on global vars (thanks @orklah)
  • (#5736, #6131) bindtextdomain() is no longer considered pure (thanks @orklah)
  • (#4344, #5663, #5639, #5955, #3272, #6133) Allow more types for magic properties defined with @property (thanks @weirdan)
  • (#6146) Fixed XML report generation when issues contain taint trace (thanks @ndench)
  • (#6145, #6150) Fixed false-positive UnusedVariable when value is used as operand of unary plus and minus (thanks @weirdan)
  • (#6149) Fixed signatures of fputcsv(), SplFileObject::fputcsv() and SplTempFileObject::fputcsv() (thanks @weirdan)
  • (#6168, #6169) Arithmetic operations on numeric types are now flagged in strictBinaryOperands mode (thanks @orklah)
  • (#6160, #6170) Fixed array_slice() return type when used on generic parameters (thanks @Jack97)
  • (#6166) Fixed false positives on incrementing a numeric-string (thanks @orklah)
  • (#6172) Fixed crash on unbalanced parentheses in docblock types (thanks @Jack97)
  • (#6167) Fixed result type of non-div arithmetic operations on numeric and int|float (thanks @orklah)
  • (#6177, #6178) Fixed return type of shell_exec() (thanks @VincentLanglet)
  • (#6128, #6187) Fixed docblock parameter being reported as nullable when it was actually the native type that was nullable (thanks @orklah)
  • (#6136, #6188) Psalm no longer considers print(), exit(string) and die(string) pure (thanks @Jack97)
  • (#6186, #6192) Fixed return type of array_replace() and array_replace_recursive() (thanks @orklah)
  • (#6195, #6196) Fixed return type of exec() (thanks @weirdan)
  • (#6197, #4871) Fixed false positive ArgumentTypeCoercion for class-strings passed as attribute constructor parameters (thanks @orklah)
  • (#6199, #6206) Fixed return types for get_headers() and get_meta_tags() (thanks @Jack97)

Docs

  • (#6038) Updated Sublime LSP instructions (thanks @DannyJJK)
  • (#6047) Added example for asserting method returns (thanks @simonhammes)
  • (#6198) Clarified that taint analysis is best run when Psalm detects no regular errors (thanks @mmcev106)

Typos

@antonioeatgoat and @orklah fixed some typos (#6033, #6185, #6205)