1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00
Commit Graph

3950 Commits

Author SHA1 Message Date
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
sji
19554de6f6
Add @ignore-var and @psalm-ignore-var (#5488)
* add `@ignore-var` and `@psalm-ignore-var`

* Change two words

Co-authored-by: Matthew Brown <github@muglug.com>
2021-03-26 21:20:23 -04:00
Saif Eddin Gmati
9f74676524
allow dismissing return value of pure functions with by-reference arguments (#5463) 2021-03-25 09:05:59 -04:00
Matt Brown
929f931c14 Taint mixed keys too 2021-03-24 16:42:30 -04:00
Jean-Nicolas
30f64b79de
Checks the intersection type if the magic method does not exist (#5473) 2021-03-24 15:34:05 -04:00
Matt Brown
10ccbdd8be Add tainting for array keys
Fixes #5470
2021-03-24 15:32:56 -04:00
Saif Eddin Gmati
477ae33cd6
allow dismissing return value of no-return pure functions (#5461) 2021-03-23 19:34:12 -04:00
Matt Brown
a96645d2e3 Fix many uses of offsets 2021-03-23 01:30:51 -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
Matt Brown
ae1fd44b13 Resolve build issues 2021-03-22 19:37:49 -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
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
17f23ccb30
Fix false-positive with non-empty object like array (fixes #5436) (#5437) 2021-03-19 21:54:01 -04:00
AndrolGenhald
b859fba52d
Fix array spread false negative that crashes (fixes #5431, reverts #2852) (#5432) 2021-03-19 21:51:36 -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
04f3e29f94 Expand documentation method return type to ensure we’re giving a fair shot 2021-03-18 11:07:02 -04:00
AndrolGenhald
45694d37d4
Fix composer major.minor version detection (fixes #5415) (#5416)
* Fix composer major.minor version detection (fixes #5415)

* Add PHP 8 polyfill dependency.

* Fix version check.
2021-03-18 09:42:01 -04:00
Matt Brown
95287d2a41 Fix directory separators 2021-03-18 09:37:31 -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
Bruce Weirdan
97fe86c4e1
Fix BC break introduced in 4.6.3 (#5410)
Fixes vimeo/psalm#5405

Requires new patch release.

This PR reverts changes to the signature of `IssueBuffer::finish()` and
introduces separate method to be used to capture `$_SERVER`
2021-03-16 19:28:18 -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
orklah
1a3ff5676a
fix stub for array_combine + remove false in PHP8 + improve tests (#5395) 2021-03-16 13:43:49 -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
orklah
dd4d970a37
makes array_combine return non-empty-array for most cases (#5393)
* makes array_combine return non-empty-array for most cases

* Add back newline

Co-authored-by: Matthew Brown <github@muglug.com>
2021-03-14 21:18:19 -04: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
Bruce Weirdan
205fdd197e
Wrap entrypoints into IIFE to protect their variables (#5366)
* Wrap entrypoints into IIFE to protect their variables

Fixes vimeo/psalm#5359

* Add tests for Psalm variable isolation

* Capture environment before registering autoloader
2021-03-11 00:14:22 -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
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
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
Bruce Weirdan
beca4a127f
Suppress test issues with Symony functions used with ::class constant (#5335)
These appeared in symfony/symfony#40203
2021-03-06 15:29:15 -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
Bruce Weirdan
841efbdfaf
Make WeakMap generic (#5313) 2021-03-02 22:25:19 -05:00