1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-14 02:07:37 +01:00
Commit Graph

2635 Commits

Author SHA1 Message Date
Paweł Tomulik
78e6545d7f
fix #4460 2023-02-28 11:38:47 +01:00
ebakulin
67d26d3c51 added case with literal string 2023-02-28 00:22:34 +07:00
ebakulin
cf35b3ce0c reworked one known operand case 2023-02-28 00:12:18 +07:00
ebakulin
31fcbd5f69 added case with one null type 2023-02-27 22:03:01 +07:00
Evan Shaw
f7eaa5daec Preserve PossiblyUndefinedVariable when fixing UnusedVariable 2023-02-25 20:08:01 +13:00
Bruce Weirdan
2315c98a73
Merge pull request #9381 from weirdan/enforce-literal-string-length-limit 2023-02-23 16:47:53 -04:00
Yannick Gottschalk
f026226aa3 Fixes #9384 2023-02-23 17:23:46 +01:00
Bruce Weirdan
5dec7f3dc3
Enforce literal string length limit
Fixes vimeo/psalm#9376

Ensures:
* that we never have a literal string exceeding the length limit
* that we call string interpreter for all literal strings
2023-02-23 04:01:29 -04:00
Bruce Weirdan
d0a14005a8
Merge pull request #9380 from weirdan/array-in-foreach-is-not-empty 2023-02-23 02:20:46 -04:00
Bruce Weirdan
1769f8b9a4
Refine arrays in foreach loops to non-empty-array
Fixes vimeo/psalm#9378
2023-02-22 20:44:50 -04:00
Javier Sanahuja
aee3665014 Fixes 2023-02-22 23:55:27 +01:00
Javier Sanahuja
fa39366cb4 Code style fix 2023-02-22 23:19:47 +01:00
Javier Sanahuja
4f83324a91 Support sizeof alias of count 2023-02-22 23:11:10 +01:00
f665e719fb
Describe changes 2023-02-21 15:44:18 +01:00
575da79801 Fix #9363 2023-02-21 10:09:58 +01:00
Bruce Weirdan
ac86981a79
Revert "#7387 Add asserting non-empty-string by strlen"
This reverts commit 0ef7ec100a.
2023-02-20 23:07:22 -04:00
88a3d288de Workaround arm64 opcache bug (fixes #9350) 2023-02-20 12:49:59 +01:00
Bruce Weirdan
73bad8967d
Forbid first-class callables in new
It's an invalid construct in PHP, not rejected by PHPParser for some
reaason.

Fixes vimeo/psalm#9335
2023-02-19 04:18:32 -04:00
Evan Shaw
c8393bd50d Fix language server first-class callable crashes 2023-02-19 14:18:17 +13:00
Bruce Weirdan
ee823619b8
Flag direct constructor calls
Fixes vimeo/psalm#2975
2023-02-15 20:14:00 -04:00
Bruce Weirdan
8c491e93e8
Flag class constant references where LHS is ordinary string
Fixes vimeo/psalm#2185
2023-02-15 02:57:00 -04:00
Bruce Weirdan
3f2ecaec7e
Allow @var annotations on global vars
The actual code was extracted from `StaticAnalyzer`

Fixes vimeo/psalm#1111
2023-02-15 01:20:03 -04:00
Bruce Weirdan
39c992c255
Emit issues for calls to is_a(string, class-string, false)
Fixes vimeo/psalm#4092
2023-02-14 02:25:46 -04:00
Andrew Boyton
5d976900d1 Fix divide by a floating point zero
The code was failing when dividing by 0.0.
2023-02-09 11:55:06 +11:00
Bruce Weirdan
3c4a829f71
Fixed more CS issues 2023-02-07 11:20:02 -04:00
Matthew Brown
d450b40da8
Remove some logic that didn't need to be there (#9209)
* Remove check to see what breaks

* Simplify following logic

* Add tests from @kkmuffme‘s branch

* Reduce scope of fix

* Clean up logic a little

* Add failing test

* Improvements

* Fix for non-Paradoxical Condition result
2023-02-03 21:08:16 -05:00
Matt Brown
234787bcd6 Fix logic bugs caught by better elseif checks 2023-02-03 00:30:42 -05:00
orklah
54cd529642
Merge pull request #9170 from mmcev106/filter-var-pure
Added @psalm-pure to filter_var()
2023-02-02 23:39:06 +01:00
Bruce Weirdan
fb65c79079
Fix newly discovered CS issues 2023-02-02 12:19:22 -04:00
Mark McEver
77ea545244 Attempted to avoid a psalm warning that was not accurate 2023-02-01 15:50:36 -06:00
Mark McEver
b5781c34e8 Fixed a case where the conditional taint, specialize, & flow features were not playing nicely together 2023-02-01 15:41:52 -06:00
Leo Viezens
7966fd574a
Merge branch 'master' into master 2023-01-30 15:38:29 +01:00
Anner Visser
d86fcf4a85
Narrow ->value of enum case(s) to only the possible values
Using $stmt_var_type to determine if we're dealing with a subset of the
enum cases. If so, we only consider those cases for the possible values.

Fixes #8568
Fixes #8812
2023-01-21 12:05:24 +01:00
kkmuffme
166df8a99f dont report MissingFile error when file_exists is validated beforehand
Fix https://github.com/vimeo/psalm/issues/3886
2023-01-05 09:32:36 +01:00
orklah
5bfb87c624
Merge pull request #9022 from Ocramius/fix/#8983-allow-large-union-types-in-array-type-inference
Better type inference and type checking for large union types used in array keys/values
2022-12-29 10:48:05 +01:00
Marco Pivetta
e6600fea21 Better type inference and type checking for large union types used in array keys/values
Fixes #8983

This patch adds a basic test showing that, when reaching a union type with 30 elements
or more, Psalm used to fail with an error, because the large union type got simplified
into a more general type as part of performance optimizations done in `TypeCombiner::combine()`.

This means that a type like `array<1|2|3|(etcetera...)|100, mixed>` was internally
simplified to `array<int, mixed>`, after reaching 30 elements or more, which in turn
led to problems and confusing errors when large union types are in play.

Such union types are relatively common in lookup-table-alike value objects.

By removing the hardcoded call-time limit of `30` types to be combined, we hereby
rely on the default `TypeCombiner::combine()` limit of `500` items, which is more
healthy.

This may come with some performance implications, but it is worth trying out, for
now.

Further parameters passed to `TypeCombiner::combine()` that were already matching
parameter default values were also omitted from the call-sites.
2022-12-29 10:05:23 +01:00
orklah
a0a9d979d5 remove useless import 2022-12-28 20:47:50 +01:00
orklah
fa4891ce58 create proper TClosure instead of TNamedObject with a Closure value 2022-12-28 20:42:59 +01:00
Theodore Brown
e4b0343f76
Fix PHPCS trailing comma 2022-12-28 09:35:34 -06:00
orklah
41ae518800
Merge pull request #9001 from fluffycondor/http_response_header-non-empty-list
Make `$http_response_header` a non-empty-list
2022-12-28 00:27:30 +01:00
fluffycondor
040737de24 Fix non-empty-list class 2022-12-25 11:45:56 +06:00
fluffycondor
a077bd4351 Make http_response_header possibly undefined 2022-12-25 11:38:51 +06:00
Jack Worman
1bb9eb4cfc forbidden function bug and better get_defined_functions() signature 2022-12-24 12:34:40 -06:00
fluffycondor
69da58d578 Make http_response_header a non-empty-list of non-falsy-string 2022-12-25 00:02:58 +06:00
8013b0eea2 Replace some LNumber usages 2022-12-19 22:14:32 +01:00
750e2da542 Cleanup 2022-12-19 21:29:13 +01:00
dc5a4576a5 Fix 2022-12-19 21:25:06 +01:00
8b4d5f871c Fix 2022-12-19 21:16:03 +01:00
ab2692fdd3 Update 2022-12-19 18:31:43 +01:00
2617b68ca9 Simplify 2022-12-19 17:40:45 +01:00