1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00
Commit Graph

3998 Commits

Author SHA1 Message Date
Matthew Brown
832a190dd4
Support enums (#5699)
* Add initial enum preparation

* Support cases method

* Ignore bad use error

cc @weirdan

* Fix type
2021-05-03 17:54:09 -04:00
Bruce Weirdan
105c6f3a1c
Remove (and prevent) unused uses (#5704)
* Updates `slevomat/coding-standard`
* Removes unused uses
* Prevents unused uses
* Fixes a number of symbol case mismatches
2021-05-03 17:22:15 -04:00
Matt Brown
d93c30d997 Fix Never test for latest PHP Parser 2021-05-03 16:59:24 -04:00
Matt Brown
eb71506a59 Fix #5697 - don’t consider docblocks when checking for invariant properties 2021-05-02 10:45:55 -04:00
Matt Brown
12844621b4 Fix #5693 - revert fix for #2048
The original fix was just a bit too narrow, and led to this bug
2021-05-01 21:13:42 -04:00
Matt Brown
0f7aaa5405 Fix #5696 - combinations of scalars should remove empty-scalar 2021-05-01 20:13:49 -04:00
Matt Brown
3a87f18b5a Fix #5685 - properly negate complex conditionals 2021-05-01 20:00:01 -04:00
Vincent Langlet
fb5c5a9c59
Fix array<empty, empty> not in array{foo?: mixed}<string, mixed> (#5677)
* Fix array<empty, empty> not in array{foo?: mixed}<string, mixed>

* Add tests
2021-04-30 09:00:49 -04:00
Matt Brown
123a9bc703 Add type-accepts-type unit test 2021-04-27 11:26:27 -04:00
Matt Brown
698adeff07 Rename incorrectly-named test 2021-04-25 18:26:00 -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
83f08bc1b8 Fix property tests 2021-04-25 15:22:32 -04:00
Matt Brown
67c5dc3c79 Fix #5517 - don’t let a variable’s by-refness be overwritten by a @var docblock 2021-04-25 15:11:23 -04:00
Matt Brown
7b7354efa3 Fix #5518 - add type for property with variable name 2021-04-25 14:49:43 -04:00
Matt Brown
daa40281df Add slashes 2021-04-25 13:32:58 -04:00
Matt Brown
2fa55d147a Allow parent class to call child protected method 2021-04-25 12:44:53 -04:00
Matt Brown
64fdac33e8 Fix #5641 - types should always be comparable to themselves 2021-04-25 10:45:43 -04:00
Vincent Langlet
39e61ae942
Add support for phpstan import-type and type annotations (#5648)
* Add support for phpstan import-type and type annotations

* Add test

* Fix cs
2021-04-19 22:56:08 -04:00
Matt Brown
642f2f435c Fix #5640 - improve handling of assignments in conditional 2021-04-18 16:16:54 -04:00
Bruce Weirdan
93946d0827
Forbid rejecting named arguments when parent allows them (#5627)
Fixes vimeo/psalm#5622
2021-04-15 06:55:13 -04:00
Matt Brown
012dafad79 Fix #5383 - prevent unsound use of new static for generics 2021-04-10 13:16:19 -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
AndrolGenhald
9a03598a6d
Improve type resolution of class constants. (#5591)
Handle array plus operator (fixes #5588).
Handle array spread operator.
Improve string concatenation to resolve to literal instead of unknown string.

I feel like it should be possible to let ConstantTypeResolver take advantage of
the better type analysis in ArrayAnalyzer, ConcatAnalyzer, etc, but it would
require a restructuring that's beyond me for the time being.
2021-04-07 21:56:35 -04:00
Matt Brown
a469c82653 Fix #5587 - detect final class calls when routed through parent 2021-04-06 12:35:09 -04:00
Matt Brown
7080bc3bff Fix #5578 - variables always set in conditionals should be combined 2021-04-06 11:11:40 -04:00
Matt Brown
517b2030c9 Fix #5545 - throwing uses method 2021-04-04 21:17:12 -04:00
Bruce Weirdan
f07b6e675e
Support array of objects in array_column() (#5567)
Fixes vimeo/psalm#5460
2021-04-04 00:01:01 -04:00
Bruce Weirdan
34cb21c7fc
Report cases where object is coerced into object with properties (#5566)
Fixes vimeo/psalm#5565
2021-04-04 00:00:31 -04:00
Bruce Weirdan
106c7db5d1
Provide more detailed return type for get_object_vars() (#5557)
Handle keyed objects and named objects, including support for property
visibility.
2021-04-02 15:39:43 -04:00
Valentin Udaltsov
31096d9361
Marked iterator_to_array as an impure function (#5532) 2021-04-02 15:38:15 -04:00
AndrolGenhald
d022910599
ConcatAnalyzer improvements and non-falsy-string fixes. (#5544)
* ConcatAnalyzer improvements.

Deduplicate code.
Improve type inference.
Allow literal type inference when only one side has multiple types (fixes #5483).
Fix invalid type inference with negative int as right operand.

* Fix inference to be lowercase-string when concatenating int.

* Fix TNonEmptyLowercaseString to not be subtype of TNonFalsyString.

'0' is a non-empty-lowercase-string that is falsy.

* Fix other issues with non-falsy-string.

* Nest ands and ors

Co-authored-by: Matthew Brown <github@muglug.com>
2021-03-31 23:16:21 -04:00
Matt Brown
fe97aa0722 Fix #5542 - nullsafe method calls are assumed used 2021-03-31 10:08:52 -04:00
Matt Brown
150dd00060 Fix #5540 - function is used inside throw expression 2021-03-31 10:03:25 -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
Bruce Weirdan
6bd7f5b867
Forbid template annotation on closures (#5499)
They don't work properly anyway.

Fixes vimeo/psalm#5472
2021-03-29 15:10:04 -04:00
orklah
adc5368b97
fix Int overflow for pow (#5510) 2021-03-29 15:09:44 -04:00
Matt Brown
17e147935a Fix #5506 – make array_values and iterator_to_array respect nested templates 2021-03-29 09:37:51 -04:00
Bruce Weirdan
d57dde0d15
Allow phantom classes in instanceof expression (#5498)
Fixes vimeo/psalm#5481
2021-03-29 00:11:45 -04:00
Bruce Weirdan
ec7de89f0c
Do not let string subtypes subsume class-strings (#5497)
Previously, Psalm would treat unions like `class-string|numeric-string`
as `numeric-string`, while the only case when string should subsume
`class-string` is when we're combining `class-string` with non-specific
`string`.

Fixes vimeo/psalm#5491
2021-03-28 23:12:23 -04:00
Matt Brown
9a714b759e Fix #5496 - ensure params extended in properties are properly fleshed out 2021-03-28 23:10:38 -04:00
Matt Brown
f41deeab0a Taint through reset call 2021-03-28 13:14:35 -04:00
Matt Brown
93743d1465 Also add better message for MixedArgumentTypeCoercion 2021-03-28 11:32:38 -04:00
Matt Brown
54ac13b190 Allow nested template unwrapping inside reset, end
Fixes #5208
2021-03-28 09:52:23 -04:00
Matt Brown
c64e879178 Only check param-out when no exception is thrown 2021-03-27 09:50:20 -04:00
orklah
12cd9590c8
allow $var::class on templates (#5484) 2021-03-26 21:21:38 -04:00