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

3835 Commits

Author SHA1 Message Date
Matt Brown
4b0fe42a05
Union types if stmt already has one 2021-01-29 11:47:19 +01:00
Matt Brown
e1e0c20861
Fix get magic property checks 2021-01-29 11:47:19 +01:00
Matt Brown
c33ea06ffa
Improve accuracy of optional example 2021-01-29 11:47:19 +01:00
Matt Brown
d64c49be92
Be smarter when choosing inherited param types
Ref #4803
2021-01-29 11:47:19 +01:00
Matt Brown
3e2d998cfe
Fix #4817 - allow optional inference 2021-01-29 11:47:19 +01:00
Matt Brown
cfe2e81629
Fix #4791 - only generate special has-array-key assertions for unknown key types 2021-01-29 11:47:18 +01:00
Matt Brown
b15384bbff
Tighten up rules arouund when mutation-free methods get memoised 2021-01-29 11:47:18 +01:00
Matt Brown
35ed9d4d8d
Fix #4812 - reconcile array assertion on template as type correctly 2021-01-29 11:47:18 +01:00
Matt Brown
2ff3f867c5
Fix #4803 - always derive method params the same way 2021-01-29 11:47:18 +01:00
Matt Brown
91115d651f
Use better stubs for Serializable and SoapClient 2021-01-29 11:47:18 +01:00
2e3s
df8d2e2296
Overwrite memoized return type after sum-type candidate is calculated (#4805)
* Overwrite memoized return type after sum-type candidate is calculated

* Fix mismatched types

* Fix code style
2021-01-29 11:47:18 +01:00
Matt Brown
7825a71351
Fix #4797 - sanitise assertion output of template result 2021-01-29 11:47:18 +01:00
Matt Brown
50611d5b91
Fix #4798 - improve conversion from type back to PhpParser node 2021-01-29 11:47:18 +01:00
Matt Brown
5e4bece7d3
Fix #4802 - don’t clone context when analysing coalesce 2021-01-29 11:47:17 +01:00
Matt Brown
ae8aaaf1d8
Support simple list assignment in foreach
Ref #4741
2021-01-29 11:47:17 +01:00
Matt Brown
ce9d100908
Fix #4794 - invvalidate dependent types when their variables change 2021-01-29 11:47:17 +01:00
Matt Brown
c4b1c63dd1
Taint all when conditional return is used
Ref #4792
2021-01-29 11:47:16 +01:00
Matt Brown
a5408aafc9
Fix #4778 - remove already-initialized properties when checking initialisation 2021-01-29 11:47:16 +01:00
Matt Brown
8bfb0412e7
Fix #4782 - don’t replace closure types with upper bounds when replacing class param types 2021-01-29 11:47:16 +01:00
Matt Brown
b21e138cc7
Allow nested specialisation 2021-01-29 11:47:15 +01:00
Matt Brown
309c13700d
Fix #4769 – don’t use unique ids for new generated nodes 2021-01-29 11:47:15 +01:00
Bruce Weirdan
5bce554cbb
Fix windows builds (#4775)
* Choco now offers PHP 8 only

* Bump build deps to allow PHP 8 builds

* Bump slevomat

* Disable coverage to allow paratest

* Bump dummy project version to allow testing on PHP 8
2021-01-29 11:47:15 +01:00
Matt Brown
326c47ef75
Fix implicit void closure not getting recognised 2021-01-29 11:47:14 +01:00
Matt Brown
73fc7d9491
Fix #4767 - rescan directly-affected class-interface relationships 2021-01-29 11:47:14 +01:00
orklah
48f55f3c3b
Allow int casts if the type comes from calculation (#4768) 2021-01-29 11:47:14 +01:00
Matt Brown
6f598464a9
Mixed array access should mark vars as used just in case 2021-01-29 11:47:14 +01:00
Matt Brown
dd20e838ce
Make more try vars potentially undefined
Fixes #4764
2021-01-29 11:47:14 +01:00
Matt Brown
ba1a076059
Fix interface property regression 2021-01-29 11:47:13 +01:00
Matt Brown
eba91f741b
Fix #4760 - prevent unpacked vars from breaking call when checking unitialised properties 2021-01-29 11:47:13 +01:00
Matt Brown
9c5cc02f90
Fix #4759 – don’t generate assertion when assigning to same-named variable 2021-01-29 11:47:13 +01:00
Matt Brown
1780541501
Ref #4753 - allow int literals to inform key type 2021-01-29 11:47:12 +01:00
Matt Brown
a20db1ce34
Fix #4751 - allow MethodSignatureMismatch to be overridable when info comes from docblock 2021-01-29 11:47:12 +01:00
Matt Brown
c54416090f
Don’t suggest a potential value that’s undefined
Fixes #4754
2021-01-29 11:47:12 +01:00
Matt Brown
f8e22ab7ac
Break out array_key_exists tests 2021-01-29 11:47:12 +01:00
Matt Brown
ace372bfb4
Fix #4752 - add property base assertions too 2021-01-29 11:47:12 +01:00
Matt Brown
7cc0f65f11
Don’t do new isset conversion on try-set vars 2021-01-29 11:47:11 +01:00
Matt Brown
b1996262ba
Ensure that strict empty handling always happens 2021-01-29 11:47:11 +01:00
Matt Brown
2d1222ddec
Fix assertions on unions 2021-01-29 11:47:11 +01:00
Matt Brown
d6b98f2afe
Fix null array access complaints 2021-01-29 11:47:11 +01:00
Matt Brown
06d69ba5f3
Break out RedundantCast issues 2021-01-29 11:47:10 +01:00
orklah
feeaaeb03c
handle return flag for a try/catch/finally (#4746)
* handle return flag for a try/catch/finally

* add tests for psalter
2021-01-29 11:47:10 +01:00
Matt Brown
7206db2cb6
Fix #4705 - clear documenting method ids when scanning stubs 2021-01-29 11:47:10 +01:00
Matt Brown
14040ed1fa
Add failing testcase for #4705 2021-01-29 11:47:10 +01:00
Matt Brown
024bbef5cd
Fix #4743 - simplify assertions generated from array_key_exists check 2021-01-29 11:47:09 +01:00
orklah
5f9aff5734
support shift and bitwise operations in constants (#4740) 2021-01-29 11:47:07 +01:00
orklah
08d9246b9a
improve Atomic Types documentation (#4735)
* improve Atomic Types documentation

* add doc

* add doc
2021-01-29 11:47:07 +01:00
orklah
4ded1080e3
Check from_docblock property to emit the right issue (#4736) 2021-01-29 11:47:06 +01:00
Matt Brown
9789b53617
Fix #4731 - expand out class-bound generic types when evaluating instance method 2021-01-29 11:47:06 +01:00
Matt Brown
8c33bedfca
Fix #4733 - don’t replace template types when they’re defined on the same class 2021-01-29 11:47:06 +01:00
Matt Brown
fb474c2e07
Expand out constants in param types earlier 2021-01-29 11:47:06 +01:00
Matt Brown
ad5ec9501d
Ensure class template types are mapped to static methods where necessary
Ref #4733
2021-01-29 11:47:06 +01:00
Matt Brown
e9ec1b28a2
Simplify storage and retrieval of extended template params 2021-01-29 11:47:05 +01:00
Matthew Brown
cbd8150fde
Add RedundantPropertyInitializationCheck (#4732)
* Add RedundantPropertyInitializationCheck

* add documentation for RedundantPropertyInitializationCheck (#4734)

Co-authored-by: orklah <orklah@users.noreply.github.com>
2021-01-29 11:47:05 +01:00
Matt Brown
a3cf052314
Remove unset thing 2021-01-29 11:47:05 +01:00
Matt Brown
27c303ee39
Detect some erroneous issets 2021-01-29 11:47:05 +01:00
Matt Brown
9fdc56ff75
Fix template type selection 2021-01-29 11:47:04 +01:00
Bruce Weirdan
d13f0b6a7c
Added test to enforce that all supported annotations are documented (#4723)
* Added test to enforce that all supported annotations are documented

Well, at least mentioned.

Refs vimeo/psalm#3816

* Type things

* Make things pretty

* Only check @psalm- annotations, group

* Add documentation for `@psalm-require-extends` and `@psalm-require-implements`

* Dropped logicalOr that has become redundant

* Add explicit tag

* Document @psalm-template

* Add @psalm-template-covariant

* Document `@psalm-method`

* Add list of undocumented docblock annotations

Co-authored-by: Matthew Brown <github@muglug.com>
2021-01-29 11:47:04 +01:00
Matt Brown
5cf5aecb2f
Fix #3017 - use correct keys when converting list to array 2021-01-29 11:47:04 +01:00
orklah
0df867cdff
fix array_column with possibly_undefined keys (#4719) 2021-01-29 11:47:03 +01:00
orklah
b084e2c4bd
add annotation @psalm-param-out (#4717)
* add annotation @psalm-param-out

* add tag in documentation
2021-01-29 11:47:02 +01:00
Matt Brown
3be31563d6
Add complex issue error 2021-01-29 11:46:28 +01:00
Matt Brown
9089f77176
Turn template bound tuples into object
Ref #4714
2021-01-29 11:46:27 +01:00
orklah
45d058c2dd
better fix for reconciling iterable and object (#4712) 2021-01-29 11:46:27 +01:00
Matt Brown
9539c0f27f
Fix generic ArrayAccess creation cc @orklah 2021-01-29 11:46:27 +01:00
orklah
1966766a79
Allow reconciling between object and iterable (#4706)
* Allow reconciling between object and iterable

* add tests
2021-01-29 11:46:27 +01:00
orklah
1511989521
Fix PHPMAXINT offset (#4707) 2021-01-29 11:46:27 +01:00
Matt Brown
ecbb5c77b2
Fix test failures 2021-01-29 11:46:26 +01:00
Matt Brown
033a209950
Treat $a ?? $b identically to isset($a) ? $a : $b 2021-01-29 11:46:26 +01:00
Matt Brown
5228ff6369
Fix #4699 - treat isset like !== null when variable is defined 2021-01-29 11:46:26 +01:00
orklah
005373bbc2
Detect redundant cast (#4695)
* detect redundant cast

* fix redundant cast issues

* fix redundant cast in tests
2021-01-29 11:46:25 +01:00
Matt Brown
e5f25c7780
Add support for some dependent types 2021-01-29 11:46:25 +01:00
Benjamin Morel
e9c608e7cb
Fix PdoStatementReturnTypeProvider (#4683)
* Fix PdoStatementReturnTypeProvider

Methods returning scalars may return null as well.

* Fix tests
2021-01-29 11:46:24 +01:00
Matt Brown
8155a5c7aa
Fix tests 2021-01-29 11:46:24 +01:00
orklah
597b7aa064
Prevent illegal array keys (#4660)
* Emit an issue when an array-key is not legal

* tests
2021-01-29 11:46:23 +01:00
Matt Brown
401573c696
Fix test 2021-01-29 11:46:23 +01:00
erikjwaxx
62ca9f42bc
Narrow inference of $a <=> $b from "int" to "-1|0|1" (#4680)
* A <=> operator has a literal type of -1|0|1 and not simply int

* Test to verify inferred type of $a <=> $b is -1|0|1
2021-01-29 11:46:23 +01:00
Matt Brown
a0fee98962
Move param taint sink addition after arguuments have been analysed 2021-01-29 11:46:22 +01:00
Matt Brown
aa4be209fc
Make sure conditional escaping works for static methods too 2021-01-29 11:46:22 +01:00
Matt Brown
30ee5334a1
Fix #4661 - support conditional escaping for functions 2021-01-29 11:46:22 +01:00
Matt Brown
676a0ed2d1
Fix #4609 - add more attribute rules 2021-01-29 11:46:21 +01:00
Matt Brown
14807326fe
Fix #4475 - verify that used attributes actual use the Attribute attribute 2021-01-29 11:46:21 +01:00
Matt Brown
763eff2e8b
Fix #4611 - flag invalid attribute arguments correctly 2021-01-29 11:46:21 +01:00
Matt Brown
2fff4eb5c1
Fix #4653 - prevent crash with recursive type in root namespace 2021-01-29 11:46:20 +01:00
Matt Brown
56918001a8
Fix #4643 - use PHP8 union types when possible 2021-01-29 11:46:20 +01:00
Matt Brown
48a58c56e3
Don’t erase already-known literal ints
Fixes #4644
2021-01-29 11:46:20 +01:00
Matt Brown
48fba8a6b9
Only run unused code analysis where necessary 2021-01-29 11:46:20 +01:00
Matt Brown
d43bb3923b
Break aparat type combiner 2021-01-29 11:46:20 +01:00
Lukas Reschke
b2143f1da5
Implement variadic taint propagation (#4649)
* Implement variadic taint propagation

* Lint code
2021-01-29 11:46:19 +01:00
orklah
58ddeaafdf
use int|string in phpdoc format for array-key (#4645) 2021-01-29 11:46:19 +01:00
Lukas Reschke
4de2bf8f7f
Add psalm-flow for string functions from sscanf to wordwrap (#4591)
* Add string functions from sscanf to wordwrap

This should conclude all string functions from https://www.php.net/manual/en/book.strings.php

Continuation of https://github.com/vimeo/psalm/pull/4576

Ref https://github.com/vimeo/psalm/issues/3636

* Add StrTrReturnTypeProvider

* Fix psalm error

* phpcs

* Line length

* Ignore false return on vsprintf

Co-authored-by: Matthew Brown <github@muglug.com>
2021-01-29 11:46:19 +01:00
Matt Brown
38d1dded4e
Fix test 2021-01-29 11:46:19 +01:00
Matt Brown
b539fdf70e
Allow Psalm to run in taint analysis mode without a config 2021-01-29 11:46:18 +01:00
orklah
289a3b220b
allow static return type in PHP8 (#4641) 2021-01-29 11:46:18 +01:00
Matt Brown
068907327d
Fix #4637 - prevent regression when negating function call with === false 2021-01-29 11:46:18 +01:00
Dalibor Karlović
ea089d9696
feature: allow plugin manager to work without config file (#4639) 2021-01-29 11:46:17 +01:00
orklah
5afbf5f831
return static instead of self when static context detected (#4632)
* return this instead of self when static context detected

* replace $this by static
2021-01-29 11:46:17 +01:00
Matt Brown
02b1cc2288
Change TaintedText to TaintedCallable 2021-01-29 11:46:17 +01:00
Lukas Reschke
2ad5eee193
Add dedicated types for 'file', 'header' and 'cookie' (#4630)
* [WIP] Add dedicated sinks for 'file', 'header' and 'cookie'

* Add documentation

* Add mapping for taint flows

* Add tests

* Fix test
2021-01-29 11:46:16 +01:00
Matt Brown
3b3239635b
Fix #4626 - array_key_exists should infer type for first arg where possible 2021-01-29 11:46:16 +01:00
Matt Brown
7b4f0745f5
Simplify assertion negations, centralising as much as possible
Now the flag passed to scrapeAssertions just determines the errors emitted
2021-01-29 11:46:16 +01:00