Bruce Weirdan
a4b6fbcbdf
Simplified InArrayTest a bit
2021-08-13 01:27:28 +03:00
Alexandr Zolotukhin
3d61f6ca65
Add more tests
2021-08-05 16:42:52 +03:00
Alexandr Zolotukhin
c51f0f4fbf
Add tests with needle/haystack value of union types which intersect partially
2021-08-03 21:09:59 +03:00
Alexandr Zolotukhin
586e8a157e
Fix tests with loose types. Fix return type in the reconciler.
2021-08-03 19:34:35 +03:00
Alexandr Zolotukhin
e278b4fd93
Add failing test cases
2021-08-03 17:29:28 +03:00
Jack Robertson
c8574a6347
Simplify FQNs
2021-07-26 13:56:15 +01:00
Jack Robertson
8bec5fc743
Add expected behaviour tests
2021-07-26 08:50:12 +01:00
ElisDN
61b78e117f
Fix negative numbers
2021-07-08 19:17:31 +03:00
Bruce Weirdan
76be96ce53
Drop FakeFileProvider from tests folder
...
And use Psalm\Internal\Provider\FakeFileProvider
2021-07-02 03:57:57 +03:00
Andrey Klimenko
3ad3375777
Fix generic destruction in assertion ( #5888 )
2021-06-04 15:33:37 -04:00
Andrey Klimenko
e5e397a6c5
Type negation in generic context ( #5879 )
...
* Type negation in generic context
* Fix cs
2021-06-03 01:06:25 -04:00
orklah
f62b83a190
Assert intersection type when two variables are compared ( #5774 )
2021-05-18 16:14:58 -04:00
Matt Brown
787c0f30d6
Fix #5784 - only real-asserted variables from context knowledge
...
Any assertions added in the addNestedAssertions method should not illegitimise current knowledge
2021-05-17 15:11:27 -05:00
orklah
1bb4a05725
NullsafeMethodCall makes the variable not null for the rest of the scope ( #5771 )
2021-05-14 19:21:01 -04:00
Matthew Brown
859b4a2caa
Fix #5725 – don’t transform non-docblock types unnecessarily
2021-05-09 12:03:42 -04:00
Matt Brown
3a87f18b5a
Fix #5685 - properly negate complex conditionals
2021-05-01 20:00:01 -04:00
Matt Brown
4f5c205c57
Improve error message for #5489
2021-04-25 16:02:00 -04:00
Bruce Weirdan
933822e400
Do not consider isset checks on static properties as redundant ( #5525 )
...
* Do not consider isset checks on static properties as redundant
Unlike normal properties, static properties do not have a prescribed
initialization sequence, so they can always be uninitialized (or unset).
Thus `isset()` checks on them are never redundant.
Fixes vimeo/psalm#5489
* Fix issue with nullable is_static
2021-04-25 15:53:07 -04:00
Matthew Brown
85a0ef0456
Revert "Do not consider isset checks on static properties as redundant ( #5525 )" ( #5670 )
...
This reverts commit cd002e6a87
.
2021-04-25 15:46:13 -04:00
Matt Brown
642f2f435c
Fix #5640 - improve handling of assignments in conditional
2021-04-18 16:16:54 -04:00
orklah
bb88cff28a
Int and Float can be reconciled with Numeric ( #5611 )
2021-04-09 23:59:59 -04:00
3b3065c881
Allow variable keys with array_key_exists ( #5606 )
...
* Allow variable keys with array_key_exists
* Switch to elseif
2021-04-09 11:29:45 -04:00
AndrolGenhald
518d0af895
Strict int/float comparison for conditional types, improve range return type ( #5601 )
2021-04-09 11:28:48 -04:00
orklah
5f4a21190f
Numeric can be Falsy ( #5598 )
2021-04-07 22:02:13 -04:00
Matt Brown
7080bc3bff
Fix #5578 - variables always set in conditionals should be combined
2021-04-06 11:11:40 -04:00
Bruce Weirdan
cd002e6a87
Do not consider isset checks on static properties as redundant ( #5525 )
...
* Do not consider isset checks on static properties as redundant
Unlike normal properties, static properties do not have a prescribed
initialization sequence, so they can always be uninitialized (or unset).
Thus `isset()` checks on them are never redundant.
Fixes vimeo/psalm#5489
* Fix issue with nullable is_static
2021-03-30 11:56:08 -04:00
AndrolGenhald
d4590711d6
Fix object-like array keys when combining string and automatic keys ( fixes #5427 ). ( #5428 )
...
* Fix object-like array keys (fixes #5427 ).
* Fix incorrect return types for tests.
* Fix false positive list with literal int key.
2021-03-19 21:44:44 -04:00
orklah
2777b62d0b
String can be reconciled with Scalar ( #5402 )
2021-03-16 13:46:23 -04:00
Matt Brown
f8cbb229f6
Fix #5236 - improve reconciliation of interfaces when unioned with class
2021-02-24 00:05:12 -05:00
Matt Brown
fe9eb6d91e
Make test reconciler names better
2021-02-23 22:37:26 -05:00
Alberto Piai
144bb37f76
Fix array_key_exists() with all int literal keys ( #5197 )
...
When checking code like the following:
```
<?php
function checkNegated(string $key): void {
$arr = [
0 => "foo",
1 => "bar",
];
if (!array_key_exists($key, $arr)) {
printf("not found\n");
}
}
function check(string $key): void {
$arr = [
0 => "foo",
1 => "bar",
];
if (array_key_exists($key, $arr)) {
printf("found\n");
}
}
```
the `if` in `checkNegated` would cause:
```
ERROR: RedundantCondition - 9:10 - Type string for $key is never =int(0)
```
This happens when the array keys are all int literals, but the "needle"
is a string.
`array_key_exists()` uses a loose equality comparison, but the generated
assertions for this specific case
(`AssertionFinder::getArrayKeyExistsAssertions`) was generating strict
equality clauses. This commit fixes it by changing the generated clause
from `=` to `~`.
2021-02-12 17:00:38 -05:00
Matt Brown
a0420fb704
Add non-falsy-string to allow more accurate checks
2021-02-03 17:19:48 -05:00
Matt Brown
03665b9646
Revert "Correct Psalm’s concept of string emptiness"
...
This reverts commit 331ce8ead4
.
It was too hasty
2021-02-03 01:09:58 -05:00
Matt Brown
331ce8ead4
Correct Psalm’s concept of string emptiness
...
It contrasted with PHP’s idea
2021-02-02 23:07:51 -05:00
Matt Brown
0624098865
Ensure getId() output can always be parsed as a type
...
Ref #5105
2021-01-25 23:41:51 -05:00
orklah
b61831345c
only transform a Keyed array into callable-array if there's two elements ( #5086 )
...
* only transform a Keyed array into callable-array if there's two elements in array
* add tests
2021-01-22 16:14:29 -05:00
Matt Brown
f1107ab4d9
Fix #5049 - assertion of !empty
on bool makes true
2021-01-19 17:19:47 -05:00
Matt Brown
ef4afd72bc
Unset should change array with keyed offsets
2021-01-13 18:10:59 -05:00
Matt Brown
4faa6bb320
Fix #4976 - improve type narrowing
2021-01-11 17:14:23 -05:00
Lukas Bestle
245a331be3
Full support for $this
in @var
annotations ( #4922 )
...
Fixes #4916 .
2021-01-03 01:44:35 +00:00
Matt Brown
9423324d65
Fix #4791 - only generate special has-array-key assertions for unknown key types
2020-12-08 19:45:47 -05:00
Matt Brown
f5dd6e76f8
Fix #4802 - don’t clone context when analysing coalesce
2020-12-07 14:30:57 -05:00
orklah
62d5ea83a1
Allow int casts if the type comes from calculation ( #4768 )
2020-12-03 23:15:07 -05:00
Matt Brown
bef9ab37e6
Fix #4759 – don’t generate assertion when assigning to same-named variable
2020-12-03 09:42:26 -05:00
Matt Brown
6f916553a8
Ref #4753 - allow int literals to inform key type
2020-12-02 17:13:45 -05:00
Matt Brown
e2bb02e93c
Don’t suggest a potential value that’s undefined
...
Fixes #4754
2020-12-02 14:49:30 -05:00
Matt Brown
b64eb6d716
Break out array_key_exists tests
2020-12-02 14:42:16 -05:00
Matt Brown
7bd4d969a4
Ensure that strict empty handling always happens
2020-12-01 22:50:21 -05:00
Matt Brown
5a200ca442
Fix assertions on unions
2020-12-01 21:12:03 -05:00
Matt Brown
61e374f33b
Fix null array access complaints
2020-12-01 20:10:48 -05:00