1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 02:27:59 +01:00
Commit Graph

2809 Commits

Author SHA1 Message Date
Bruce Weirdan
395f3f7862
Merge pull request #10690 from weirdan/9649-this-out-on-constructors 2024-02-11 16:34:25 -04:00
Bruce Weirdan
a8c093aea2
Handle taking references to unspecified magic methods 2024-02-11 02:45:24 +01:00
Bruce Weirdan
d10e384338
Report first class callables generated for unknown static methods
Fixes vimeo/psalm#10170
2024-02-11 02:24:27 +01:00
Bruce Weirdan
def0489b98
Process @psalm-this-out on __construct() as well
Fixes vimeo/psalm#9649
2024-02-11 01:53:30 +01:00
Bruce Weirdan
6b405937ab
Forbid constructors from returning any values
Fixes vimeo/psalm#9713
2024-02-10 01:34:51 +01:00
Bruce Weirdan
508da9abd4
Merge pull request #10661 from vimeo/10018-flag-stdclass-constructor-with-arguments 2024-02-05 20:31:26 -04:00
Bruce Weirdan
62b525993d
Flag stdClass::__construct() calls that have arguments
Fixes vimeo/psalm#10018
2024-02-06 01:24:18 +01:00
Bruce Weirdan
b822c3339d
Suppress UndefinedClass in whatever_exists()
Fixes vimeo/psalm#7395
2024-02-05 20:44:09 +01:00
Bruce Weirdan
f40e23faef
Merge pull request #10655 from weirdan/late-binding-of-enum-properties 2024-02-05 15:17:42 -04:00
Bruce Weirdan
c40f232d31
Merge pull request #10629 from edsrzf/analyze-dynamic-fetches 2024-02-05 07:16:03 -04:00
Evan Shaw
a827806709 ParseError for dynamic constants before PHP 8.3 2024-02-05 21:49:40 +13:00
Bruce Weirdan
52eadab971
Late binding of enum cases
Resolves a number of long-standing bugs ('Failed to infer case value ...')

Fixes vimeo/psalm#10374
Fixes vimeo/psalm#10560
Fixes vimeo/psalm#10643
Fixes vimeo/psalm#8978
2024-02-05 04:12:19 +01:00
robchett
421cb0f7a1
Allow enum cases to be global constants 2024-02-01 18:38:46 +01:00
Evan Shaw
88c2e00d02 Analyze dynamic class const names 2024-02-01 17:40:25 +13:00
Evan Shaw
a66aace523 Analyze dynamic static property names 2024-02-01 17:31:15 +13:00
Bruce Weirdan
f045730927
Merge pull request #10598 from weirdan/key_exists-is-an-alias-for-array_key_exists 2024-01-29 16:23:35 -04:00
Bruce Weirdan
fd1294eef4
Merge pull request #10599 from weirdan/allow-properties-on-intersections-with-enum-interfaces 2024-01-29 16:23:20 -04:00
Bruce Weirdan
872cf58236
Merge pull request #10601 from weirdan/do-not-validate-callable-arguments-in-lenient-contexts 2024-01-29 16:22:47 -04:00
Evan Shaw
98d98be443 Re-work CheckTrivialExprVisitor
In php-parser 5.0, `ClosureUse` is no longer considered an expression.
This requires changes to Psalm's `CheckTrivialExprVisitor`, which stores
an array of "non-trivial" `Expr` nodes.

However the only use of this array is to count whether or not it's
empty. Instead of keeping the array, we can keep a boolean, and avoid
needing to change the types in this class when we upgrade to php-parser
5.0.
2024-01-29 13:25:25 +13:00
Bruce Weirdan
67a91e05b2
Do not validate callable arguments in lenient contexts
Fixes vimeo/psalm#10453
2024-01-27 16:38:37 +01:00
Bruce Weirdan
c1e22ddcaa
Allow properties on intersections with enum interfaces
Fixes vimeo/psalm#10585
2024-01-27 14:37:26 +01:00
Bruce Weirdan
6e2effaf9a
key_exists() is an alias for array_key_exists()
Fixes vimeo/psalm#10346
2024-01-27 13:41:43 +01:00
Evan Shaw
68a1d1e2b4 Switch condition order
This change is for forward-compatibility with nikic/php-parser 5.0,
where `InterpolatedStringPart` (née `EncapsedStringPart`) is no longer an expression.
Thus we can't pass it to `NodeTypeProvider::getType()` anymore. Since that call
returns `null` anyway, we can swap the condition order. Everything still
works and Psalm type-checking is happy.

This also might be a tiny performance improvement since it lets the
common, cheap instanceof check come before a method call, but I haven't actually
benchmarked it.
2024-01-24 15:38:39 -10:00
f7edaa66ac Fix #10552 2024-01-18 20:33:54 +01:00
kkmuffme
2414070849 simplify and remove redundant variable 2024-01-15 10:11:22 +01:00
kkmuffme
19b1a33a20 fix possibly undefined array key in keyed array doesnt include null when not validated
Fix https://psalm.dev/r/b153d0d248 to return 'a'|null instead of 'a' - this is required as otherwise empty would report RedundantCondition errors now which would bring back https://github.com/vimeo/psalm/issues/2681
2024-01-15 10:11:22 +01:00
kkmuffme
fb93aede12 create a separate issue type 2024-01-15 10:11:21 +01:00
kkmuffme
f3543ca9ab add the fix for empty() too and fix empty returning bool on true/false only cases hiding errors when functions called 2024-01-15 10:11:21 +01:00
kkmuffme
d5b713e439 Fix https://github.com/vimeo/psalm/issues/10501 - report error for non-strict comparison on truthy+falsy union 2024-01-15 10:11:21 +01:00
orklah
b9583493b0
Merge pull request #10499 from kkmuffme/fix-empty-string-becomes-non-empty-string-when-literal-strings-disabled
Fix empty literal string becomes non-empty-string
2024-01-14 23:41:50 +01:00
kkmuffme
02467fbb6a add support for extract to set variables for keyed arrays and respect EXTR_SKIP 2024-01-14 10:54:02 +01:00
kkmuffme
7f0f0bc361 ensure concat https://psalm.dev/r/323e33ae8a will be a non-falsy-string 2024-01-13 17:10:19 +01:00
orklah
b4ad9c00c5
Merge pull request #10505 from kkmuffme/fix-readonly-properties-by-reference-not-reported
Add error when using readonly property in by-ref arg
2024-01-09 22:01:51 +01:00
kkmuffme
9e463bbe75 make tests work in PHP < 8.2 2023-12-19 11:37:14 +01:00
kkmuffme
1ff8518888 Fix https://github.com/vimeo/psalm/issues/9840 2023-12-19 11:07:11 +01:00
kkmuffme
f8a53ebc5d Fix callable without args not handled correctly 2023-12-18 12:48:13 +01:00
mu3ic
c8748dc5c9 Add trim() in global use 2023-12-14 09:54:32 +03:00
mu3ic
2ce340782e Fix Uncaught RuntimeException: PHP Error: Uninitialized string offset 0 when $pattern is empty 2023-12-14 09:44:28 +03:00
orklah
3bc8cde539
Merge pull request #10488 from kkmuffme/invalidargument-false-not-true-param
add InvalidArgument error when passing false to true param
2023-12-13 18:48:51 +01:00
kkmuffme
d04694f4d4 Fix https://github.com/vimeo/psalm/issues/9267 2023-12-13 15:30:43 +01:00
kkmuffme
6363b57c33 fix bug equality assertion with int and float setting wrong type - required so previous commit works 2023-12-13 14:43:55 +01:00
kkmuffme
e6f24d91fd Fix https://psalm.dev/r/aada187f50 where 2 union types are not intersected and the condition contains both types 2023-12-13 14:10:22 +01:00
kkmuffme
108f626712 fix literal int/string comparisons only using one literal
Fix https://github.com/vimeo/psalm/issues/9552
2023-12-13 13:59:26 +01:00
orklah
93c7a8fd63
Merge pull request #10452 from theodorejb/patch-1
Fix remaining POSIX-only absolute path detection
2023-12-07 18:08:57 +01:00
Theodore Brown
b5ee6e0d8b Replace remaining POSIX only absolute path detection
These were missed in #10441. Fixes "Could not resolve config path" error on Windows (#10418).
2023-12-06 13:48:06 -06:00
4ed0fe934f Fix shaped array class string key combination 2023-12-06 14:12:19 +01:00
390df68966
Merge branch '5.x' into fix_literal_union_key 2023-12-03 20:55:05 +01:00
37cf82ea52
Merge branch '5.x' into fix_literal_union_key 2023-12-03 20:50:05 +01:00
18a6c0b6e9 Implement by-ref closure use analysis 2023-12-03 15:28:51 +01:00
orklah
0659967d05
Merge pull request #10429 from tscni/fix/trait-call-static
Fix static magic method pureness not being inherited from traits
2023-12-02 14:30:49 +01:00