1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 09:47:29 +01:00
Commit Graph

3512 Commits

Author SHA1 Message Date
Matt Brown
15b0542260 Prevent more offset issues 2021-03-22 23:26:03 -04:00
Matt Brown
bf578d1024 Fix potential crash when calling magic setter 2021-03-22 23:08:38 -04:00
AndrolGenhald
de5a031088
Improve @no-named-arguments support and variadics. (#5455)
* Improve @no-named-arguments support and variadics.

Handling of argument unpacking and variadics still needs a pretty big makeover, but this is a good start.

Fixes #5420
Improves #5453 (iterable works, array still causes issues)

* Remove unneeded imports.
2021-03-22 19:58:22 -04:00
Sergey Yakimov
fb94db9b1f
Add proper handling of unpacked arguments with string keys (#5446)
* Add proper handling of unpacked arguments with string keys

* Fix undefined array key error

* Fix missed named arguments handling

* Fix false-positive on variadic parameter

* Add tests
2021-03-22 09:08:05 -04:00
Bruce Weirdan
4eca6acebd
Don't crash on index types used in a conditional type (#5447)
Fixes crash reported in vimeo/psalm#5423
2021-03-22 09:07:14 -04:00
Matt Brown
b73223f9c1 Add use statements 2021-03-20 22:17:22 -04:00
Matt Brown
44c6d3035b Add more mixed origin information 2021-03-20 21:45:38 -04:00
Matt Brown
d1740394aa Detect mixed echo argument when unused variable detection is turned on 2021-03-20 20:53:51 -04:00
Samuel Mortenson
e07337650b
Make taint source keys unique to the added taints. (#5444) 2021-03-20 15:42:24 -04:00
AndrolGenhald
0579c1109b
Fix bugs with array spread operator (fixes #5421) (#5433) 2021-03-19 22:43:58 -04:00
Samuel Mortenson
4aabb411a8
Added event to prevent tainting. (#5398)
* Added event to prevent tainting.

* Remove optional codebase parameter.

* Removed falsy check for codebase.

* Use two separate hooks for adding and removing taints

* Add slashes

* Update add/remove taint test name.

* Cleaned up SafeArrayKeyChecker example plugin.

* Added more AddRemoveTaintsEvent calls to codebase.

* Fix type check error with $added_taints param.

* Added AddRemoveTaintsEvent to remaining classes.

* Fix post-merge error.

* Add comma

* Remove $int_offset that never existed

Co-authored-by: Matt Brown <github@muglug.com>
2021-03-19 22:41:41 -04:00
AndrolGenhald
843305c8e0
Support template property invariance (fixes #5371) (#5414)
* Support property invariance with templates.

* Fix false positive NonInvariantDocblockPropertyType with grandchild.

* Redo templated property invariance check to fix issues.

* Add template covariant test.

* Fix property invariance false positive with template-covariant.
2021-03-19 21:55:50 -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
Matt Brown
42d3bceb4e Use more accurate return type 2021-03-18 15:19:29 -04:00
Matt Brown
b7a68edd0b Simplify complex methods 2021-03-18 15:09:03 -04:00
Matt Brown
04f3e29f94 Expand documentation method return type to ensure we’re giving a fair shot 2021-03-18 11:07:02 -04:00
Matt Brown
d19088bb10 Add better origins for calls 2021-03-17 19:37:21 -04:00
Matt Brown
3046468d1e Add hints for MixedAssignment issues 2021-03-17 01:10:42 -04:00
Matt Brown
9d979e3467 Fix #5406 - track more changes to assertion type 2021-03-16 16:33:09 -04:00
orklah
2777b62d0b
String can be reconciled with Scalar (#5402) 2021-03-16 13:46:23 -04:00
orklah
ff5a6cb297
iterator_to_array must always return array-key (#5400) 2021-03-16 13:45:34 -04:00
AndrolGenhald
9d840ee87b
Disable property invariance checks for properties with templates (#5380)
* Disable property invariance checks for templates

Property invariance checks were already disabled for template
properties, this also disabled the checks for arrays, lists,
class-string-maps, and iterables that contain templates.

Partially fixes #5371

* CS fixes

* Fix and simplify hasTemplate.

Add hasTemplate to TypeNode and simplify implementation with getChildNodes.

* Revert hasTemplate change and add containsTemplate.

* Check class-string too.
2021-03-16 13:43:30 -04:00
Bruce Weirdan
ae247d09a3
Don't mark promoted properties as unused params (#5404)
If anything, they should be marked as unused properties.

Fixes vimeo/psalm#4964
2021-03-16 13:41:43 -04:00
Matt Brown
817d1cf3fe Fix #5408 - avoid nullref when parser param cannot be found 2021-03-16 13:40:16 -04:00
Matt Brown
f1a840727d Improve min/max return type cc @orklah
Type::combineUnionTypes preserves metadata for union types, and is more accurate
2021-03-13 19:28:24 -05:00
Matt Brown
b549989ba7 Prevent overwriting storage type during analysis 2021-03-13 14:12:55 -05:00
orklah
90fd1c5d1f
fix usage of callable with array_map (#5373) 2021-03-12 14:05:22 -05:00
orklah
cddef00692
fix int overflow (#5369) 2021-03-12 13:24:00 -05:00
orklah
0a4ad5733b
add stubs for min/max (#5353) 2021-03-11 00:13:17 -05:00
Bruce Weirdan
4f8ba04236
Provide more specific explode() return type (#5350)
Fixes vimeo/psalm#5347

`explode()` now omits `false` from the return type  when separator is a
definitely non-empty string.
2021-03-11 00:09:15 -05:00
Bruce Weirdan
8be77aaa2e
Track variable usage in bool to int casts (#5349)
Fixes vimeo/psalm#4956
2021-03-11 00:08:32 -05:00
Bruce Weirdan
185827a7ab
Continue analysis after unknown exception being caught (#5348)
Fixes vimeo/psalm#5188
2021-03-11 00:08:02 -05:00
Bruce Weirdan
71a0457284
Emit ImplicitToStringCast in more places (#5344)
* Emit ImplicitToStringCast in more places

Fixes vimeo/psalm#5320

`to_string_cast` is set on successful comparison, thus it needs to
always bubble up (it will be ignored in UnionTypeComparator if some part
does not match).

* Fix implicit casts

* Fix handling of string method references in self-out context
2021-03-11 00:07:39 -05:00
Bruce Weirdan
7138678c63
Allow undefined variable detection in arrow functions (#5343)
Previously Psalm would assume that any variable it sees in the arrow
function body is defined (and mixed, if it's not available in the outer
scope). This prevented undefined variable detection. Dropping that
assumption allows it to work.

Fixes vimeo/psalm#5331
2021-03-11 00:06:23 -05:00
Claas Augner
3c66b755e2
Always return type inference summary, even if no files were analyzed due to caching (#5329)
* Fix #5319 – Always return type inference summary

Even if no files were analyzed (e.g. due to caching).

* fix code style
2021-03-06 17:20:01 -05:00
Bruce Weirdan
65f0fb0288
Allow multiple version-dependent method stubs (#5337)
Fixed vimeo/psalm#4836
2021-03-06 17:18:51 -05:00
Matt Brown
c97ee5ccdb Fix #5258 - allow ReflectionParameeter::hasType() to inform getType() return 2021-03-06 16:54:23 -05:00
Matt Brown
ca331f5afa Consolidate assertion sanitisation 2021-03-06 16:43:11 -05:00
Matt Brown
96e0743892 Fix #5325 – remove all memoised methods when calling a method with property mutations 2021-03-05 00:39:25 -05:00
Matt Brown
4c65d3b424 Fix #5310 - allow iterable coercion from generic object 2021-03-03 00:13:00 -05:00
404db2bb1a
Fix JSON reports with long UTF8 strings (#5300)
* Fix JSON reports with long UTF8 strings

* CS fix

* UTF8-safe snippets
2021-03-01 11:23:21 -05:00
Matt Brown
f5ed12f038 Fix tests by removing references 2021-02-28 23:58:21 -05:00
Matt Brown
3f4bb25a35 Simplify reference map updates 2021-02-28 10:36:36 -05:00
Matt Brown
ad82c93edb Fix #5297 - be more sensitive to additions and deletions in language server mode 2021-02-28 01:36:06 -05:00
Matt Brown
44f8d71e72 Fix #5290 - improve inference of nested class-string template types 2021-02-27 01:00:05 -05:00
Matt Brown
216e500ea6 Fix copy/paste error 2021-02-27 00:56:01 -05:00
Matt Brown
98eb40c4ca Improve unwrapping inference in nested templates
Ref #5290
2021-02-27 00:22:31 -05:00
Matt Brown
bca09d74ad Fix style issues 2021-02-25 21:24:18 -05:00
Matt Brown
474ebf912e Fix #5229 - new SomeTemplatedClass should expand out params even if none passed 2021-02-25 21:20:05 -05:00
Matt Brown
d4841993b2 Fix #5279 - don’t convert get_class($templated) into dependent type 2021-02-25 18:43:04 -05:00