Brown
40e88095d8
Fix #4093 - prevent redundant condition in presence of positive-int
2020-08-31 10:02:23 -04:00
Brown
940b673a36
Fix fns
2020-08-30 18:29:28 -04:00
Brown
2cbe89d55a
Fix Psalm errors
2020-08-30 16:30:43 -04:00
Brown
5c043b0d41
Ignore redundant conditions inside match potentially in perpetuity?
2020-08-30 16:23:53 -04:00
Brown
54a781ad28
Support match expressions and throw expressions
2020-08-30 16:08:22 -04:00
Brown
99d6af0f9a
Support static return type
2020-08-30 13:32:42 -04:00
Brown
f34e54ec41
Support PHP 8 union types
2020-08-30 13:16:37 -04:00
Brown
92239add4d
Add some backwards-incompatible changes for 4.x
2020-08-30 11:44:14 -04:00
Brown
c13b0efd49
Improve understanding of negated count queries
2020-08-30 11:32:01 -04:00
Brown
64f08fa9dc
Improve Closure::fromCallable handling
2020-08-29 22:02:58 -04:00
Brown
cf5aa5c5cd
Fix #4083 - namespace docblock method classes the proper way
2020-08-29 11:46:24 -04:00
Brown
efed9d4480
Allow ParamNameMismatch to be suppressed locally
...
Fixes #4012
2020-08-29 11:17:57 -04:00
Brown
3ca4a576e7
Fix treatment of closure params in array_map
2020-08-29 11:10:09 -04:00
Brown
df0d426f61
Fix #4081 - better inference of positive ints
2020-08-28 16:38:50 -04:00
Brown
d29620a42b
Fix style issues
2020-08-28 15:46:55 -04:00
Brown
1825e30752
Allow pure-Callable type to be annotated
2020-08-28 13:15:04 -04:00
Brown
63b74276c6
Report use of impure closures
2020-08-28 13:01:14 -04:00
Brown
98ce590e9d
Remove some redundant calls
2020-08-28 12:48:33 -04:00
Brown
efe143a396
Fix #4077 - always track closure purity
2020-08-28 12:42:55 -04:00
Brown
5f5ce6eb32
Fix typo
2020-08-26 18:16:12 -04:00
Brown
e64d45b644
Fix #4061 - allow indirect null comparison check
2020-08-26 17:58:01 -04:00
Brown
936a7e01b6
Allow bare pure-callable in namespace cc @azjezz
2020-08-26 16:57:27 -04:00
Brown
e9adcb8d35
Simplify simplification
2020-08-26 16:51:55 -04:00
Saif Eddin G
5a20092fbd
add pure-callable type ( #4066 )
2020-08-26 16:51:22 -04:00
Brown
988e17f11d
Make clause fully immutable
2020-08-26 15:35:29 -04:00
Brown
b2b329d1a9
Prevent unset on immutable properties
2020-08-26 12:18:34 -04:00
Brown
f33d626052
Use a slightly cleaner fix
2020-08-26 11:03:27 -04:00
Brown
9878613594
Refine iterable key after is_array check
...
Ref #4038
2020-08-26 11:00:38 -04:00
Brown
8ad1c2eeb1
Use immutable data structures for clause calculations
2020-08-26 10:41:47 -04:00
Brown
20e004744f
Fix #4064 - assume most iterators are impure
2020-08-25 18:04:36 -04:00
Brown
59e7f69d7b
Fix get_class-inferred templating
2020-08-25 17:25:05 -04:00
Brown
6ab3e732fb
Fix #4038 - don’t remove null types unnecessarily in mixed union
2020-08-25 15:50:33 -04:00
Brown
d25a24ee89
Fix type bug
2020-08-25 15:09:14 -04:00
Brown
6e1218065d
Preserve intersections when expanding templated types
...
Fixes #4043
2020-08-25 14:12:57 -04:00
Brown
346d475f55
Create empty params by default for SplObjectStorage
...
Fixes #4055
2020-08-25 11:52:21 -04:00
Brown
2b060b75d3
Fix #4052 - foreach over an iterable is impure
2020-08-25 11:24:57 -04:00
Brown
3f50fbc116
Expand object-with-properties
...
Fixes #4057
2020-08-25 10:15:56 -04:00
Brown
7dba9bc50a
Add a bunch of immutable & pure annotations
2020-08-24 19:29:00 -04:00
Brown
4e10a0ed6f
Fix #4036 - add immutable annotations automatically too
2020-08-24 19:29:00 -04:00
Matthew Brown
c8ecee109c
Fix immutable tests
2020-08-24 00:35:59 -04:00
Brown
94cec15598
Only add pure when not overriding upstream
2020-08-23 22:16:03 -04:00
Brown
6103cf0f51
Fix ImpureVariable test
2020-08-23 22:07:02 -04:00
Brown
ba1ff21af4
Add a couple more pure annotations
2020-08-23 18:53:34 -04:00
Brown
140d37c7ef
Prevent isset on uknown property in pure function
2020-08-23 18:50:17 -04:00
Brown
02a2e99d42
Only add pure to functions with params
2020-08-23 18:41:31 -04:00
Brown
10f7031080
Prevent use of $this
in pure functions
2020-08-23 18:37:46 -04:00
Brown
41cf47ef0b
Add another pure annotation
2020-08-23 18:07:49 -04:00
Brown
4026b717b9
Allow function manipulators to work in threaded mode
2020-08-23 18:05:48 -04:00
Matthew Brown
8a975d7c20
Don’t add pure annotation when closure is impure
2020-08-23 14:07:19 -04:00
Matthew Brown
64fd2d60f4
Add another pure annotation
2020-08-23 14:02:10 -04:00
Matthew Brown
6efaf474d4
Don’t add @psalm-pure for void-returning functions
2020-08-23 13:58:34 -04:00
Matthew Brown
ef0486ce35
Add some pure annotations
2020-08-23 13:52:31 -04:00
Matthew Brown
d2b07ebde8
Fix docblock removal
2020-08-23 13:45:45 -04:00
Matthew Brown
06c231fbba
glob is impure
2020-08-23 13:41:43 -04:00
Matthew Brown
89dd5ee563
Nest new impure checks
2020-08-23 13:39:08 -04:00
Matthew Brown
9418be79cc
Restrict pure annotation addition a little more
2020-08-23 13:34:32 -04:00
Matthew Brown
f6135bcefc
Add more impure functions
2020-08-23 13:15:27 -04:00
Matthew Brown
6a8ad1876f
Static property fetching is bad
2020-08-23 13:10:47 -04:00
Brown
c8ea4b4e8b
Prohibit property fetches from pure contexts except when they’re on immutable objects
2020-08-23 10:57:24 -04:00
Bruce Weirdan
1cf5153700
Test parallelization ( #4045 )
...
* Run tests in random order
Being able to run tests in any order is a pre-requisite for being able
to run them in parallel.
* Reset type coverage between tests, fix affected tests
* Reset parser and lexer between test runs and on php version change
Previously lexer was reset, but parser kept the reference to the old
one, and reference to the parser was kept by StatementsProvider. This
resulted in order-dependent tests - if the parser was first initialized
with phpVersion set to 7.4 then arrow functions worked fine, but were
failing when the parser was initially constructed with settings for 7.3
This can be demonstrated on current master by upgrading to
nikic/php-parser:4.9 and running:
```
vendor/bin/phpunit --no-coverage --filter="inferredArgArrowFunction" tests/ClosureTest.php
```
Now all tests using PHP 7.4 features must set the PHP version
accordingly.
* Marked more tests using 7.4 syntax
* Reset newline-between-annotation flag between tests
* Resolve real paths before passing them to checkPaths
When checkPaths is called from psalm.php the paths are resolved, so we
just mimicking SUT behaviour here.
* Restore newline-between-annotations in DocCommentTest
* Tweak Appveyor caches
* Tweak TravisCI caches
* Tweak CircleCI caches
* Run tests in parallel
Use `vendor/bin/paratest` instead of `vendor/bin/phpunit`
* Use default paratest runner on Windows
WrapperRunner is not supported on Windows.
* TRAVIS_TAG could be empty
* Restore appveyor conditional caching
2020-08-23 10:32:07 -04:00
Brown
67f9adb33c
Allow adding pure annotations to functions
...
Ref #4036
2020-08-23 10:28:26 -04:00
Bruce Weirdan
1f54c42a4c
Don't hang when pcntl_fork is disabled ( #4039 )
...
* Don't hang when pcntl_fork is disabled
Fixes vimeo/psalm#3951
* fix CS
2020-08-22 10:01:00 -04:00
Bruce Weirdan
5bf7cc6434
Resolve typedefs that are used in var docblocks of foreach ( #4037 )
...
Fixes vimeo/psalm#4029
2020-08-22 08:20:05 -04:00
Tyson Andre
e62e964167
Set up taint analysis for pgsql functions ( #4021 )
...
I noticed that entries in InternalTaintSinkMap don't warn
unless the functions are added to CallMap.php
e.g. `pg_exec($conn, $_GET['query']);`
(pg_exec is an alias of pg_query)
2020-08-19 10:41:02 -04:00
Brown
45d9ab12e1
Fix #4017 - allow float defaults in namespaced classes
2020-08-18 12:13:27 -04:00
Brown
ebe37392eb
Fix #4019 - new static isn’t static if class is final
2020-08-18 11:25:11 -04:00
Bauke van der Woude
7ac6d2e5a4
Fix hash_*() signatures ( #4014 )
...
Functions can return false when an invalid algorithm is supplied
2020-08-18 09:35:31 -04:00
Brown
1468a28273
Fix #3999 - allow @psalm-type to reference imported type right above
2020-08-18 09:34:07 -04:00
Brown
134955a5f4
Fix #4011 - prevent mixed assignment in loop
2020-08-18 08:51:09 -04:00
Daniel Melchior
17ed440f2e
fix #4013 : prevent exception when two mixins declare methods with same name ( #4018 )
...
fixes #4013
2020-08-18 08:38:30 -04:00
SignpostMarv
9822043ca4
flag class_exists as impure per vimeo/psalm#3975 ( #4004 )
...
`class_exists()` interacts with PHP's autoloader feature, which allows
user-defined behaviour to take place when PHP tries to load a given
class or interface.
2020-08-17 15:48:48 -04:00
Gabriel Ostrolucký
81a117be85
Mark fgets impure ( #4006 )
...
This function is used to skip line of text
2020-08-17 15:48:28 -04:00
Brown
12798d1cab
Prevent access to possibly unset var
2020-08-17 15:25:13 -04:00
Brown
11f170acb4
Don’t modify object after unnecessary assertion
2020-08-16 23:38:59 -04:00
Bruce Weirdan
7adc25c421
Improve import errors ( #3997 )
...
* Better errors for invalid type imports
Fixes vimeo/psalm#3885
* Finishing touches
Docs, schema, CS
* Drop unused import
* Drop more unused imports
2020-08-16 22:53:53 -04:00
Brown
bb3c5d4c38
Fix too many arguments
2020-08-16 21:10:09 -04:00
Matthew Brown
cb243778d2
Fix #3917 - allow comparisons between classes and interfaces
2020-08-16 16:25:59 -04:00
Matthew Brown
38af5db8f0
Fix #3929 - merge expanded types where necessary
2020-08-16 16:12:29 -04:00
Matthew Brown
e972319f8c
Remove unused variable
2020-08-16 14:22:11 -04:00
Matthew Brown
5c20a5295e
Improve solution to #3964
2020-08-16 13:03:30 -04:00
Matthew Brown
ec2178d14a
Fix #3927 - prevent crash with bad type ref
2020-08-16 12:43:46 -04:00
Matthew Brown
a356a43a51
Fix #3964 - prevent incorrect intersection of unions
2020-08-16 12:26:07 -04:00
Brown
ec70d6f698
Clear out new_storage classlikes
2020-08-15 15:45:54 -04:00
Matthew Brown
a0bb5ed37d
Fix #3991 - fix test
2020-08-15 14:21:24 -04:00
Matthew Brown
8731b10bc6
Use older method
2020-08-15 10:31:24 -04:00
Brown
61a0832c05
Fix type bug
2020-08-15 09:41:21 -04:00
Brown
f12f4c8cb3
Fix issues
2020-08-15 01:18:29 -04:00
Brown
cdef4ec351
Alter docblock params too
2020-08-14 16:26:55 -04:00
Brown
dbcf154036
Add fixer for mismatching param names
2020-08-14 15:25:21 -04:00
Matthew Brown
72ecb57def
Improve names of things
2020-08-14 00:27:33 -04:00
Brown
209d17c868
Fix #2891 - treat autoloaded constants better
2020-08-13 09:14:27 -04:00
Brown
42c3a703b5
Fix #3741 - detect scalar class constants in if-true assertions
2020-08-12 17:03:41 -04:00
Toshiyuki Goto
22b339304d
Normalize file_path with uriToPath ( #3984 )
...
Fix #3983
2020-08-11 07:32:24 -04:00
m0003r
e81593f359
Localize types on magic properties ( #3971 )
...
* Fix #3949 - localize types on magic properties
* fix failing tests
* fix code style
Co-authored-by: m03r <m03r@m03r.net>
2020-08-10 12:45:21 -04:00
Brown
1533debe86
Fix style thinggs
2020-08-10 12:43:19 -04:00
Brown
6def99d653
Add ConstructorSignatureMismatch issue distinct from MethodSignatureMismatch
2020-08-10 12:26:25 -04:00
the-toster
5bdc9723ff
fix for DeprecatedClass suppress on property ( #3962 )
...
* add test case for DeprecatedClass suppress on property
* fix test case for DeprecatedClass suppress on property - suppress MissingConstructor also
* ugly way to fix - double analyze propery statement to get dockblock + fix in TypeChecker - respect given suppressed_issues in checkNamedObject
* replace double analyze propery with direct DocBlock manipulation
* replace double analyze propery with direct DocBlock manipulation
* add exception handler to keep original addContextProperties behavior
* correct way to unwrap value from array
2020-08-10 10:50:37 -04:00
lhchavez
ab3016af6e
Fix File-related analysis plugin hooks ( #3970 )
...
This change does a few things:
* Renames `BeforeAnalyzeFileInterface` to `BeforeFileAnalysisInterface`.
* Adds a few more parameters to `BeforeFileAnalysisInterface`.
* Since the analysis was never called due to a bug, the above two
changes are safe to do.
* Fix the above-mentioned bug, and now adds the hooks to the config.
* Update the documentation about the File-related analysis plugin hooks.
* Add a test to ensure that this does not break again in the future.
Fixes : #3969
2020-08-10 10:49:53 -04:00
Matthew Brown
6085e42fc1
Detect mismatching param names effectively
2020-08-10 09:58:43 -04:00
Matthew Brown
50cc3a8afa
Align paramter names
2020-08-09 23:19:59 -04:00
Matthew Brown
73321339a3
Bump nikic/php-parser
2020-08-09 16:23:43 -04:00
kazusuke sasezaki
90a50be9f0
quit using combineUnionTypes, when specific TSend provided. ( #3966 )
2020-08-09 08:26:10 -04:00
the-toster
3a1c861c43
minor: typo in message ( #3960 )
2020-08-08 08:08:57 -04:00
Brown
166134aca3
Fix bug I added
2020-08-07 15:13:03 -04:00
ygottschalk
f831ebdbcf
narrowed reset
and end
return type ( #3950 )
...
* narrowed `reset` return type
BUT psalm seems to ignore the stub
* narrowed `reset` and `end` return type, this time for real
* fixed UnusedVariable Issue
* fixed RedundantCondition Issue
caused by `end`s return type being more precise
* Improve solution slightly
Co-authored-by: Matthew Brown <github@muglug.com>
2020-08-07 12:23:20 -04:00
Isaac Rozas García
84130770f4
Improve details of functions to get the last errors parsing a date ( #3953 )
2020-08-07 12:17:08 -04:00
Brown
b6d9ee5eb1
Fix things
2020-08-07 12:16:35 -04:00
Brown
e61765ff9b
Fix #3954 - catch ComplicatedExpressionException with added workaround
2020-08-07 08:20:35 -04:00
Brown
afce2dc66f
Tighten up rules around instantiation a bit more
2020-08-06 10:18:55 -04:00
Matthew Brown
ccd4eaa8e7
Clarify language a little
2020-08-06 09:02:24 -04:00
Brown
278addd93d
Fix strtolower calls and docs
2020-08-05 21:46:15 -04:00
Brown
bcf0df4170
Fix a bug with lowercase-string unions
2020-08-05 20:05:57 -04:00
Brown
488a899823
Fix Psalm issues
2020-08-05 19:49:09 -04:00
Brown
c0b0036109
Fix #3934 - prevent unsafe use of new static
2020-08-05 19:39:27 -04:00
Brown
e0f5595307
Fix #3932 - try to get assertions of negated expression if instant negation fails
2020-08-05 16:53:30 -04:00
Brown
e808391f56
Fix #3943 - understand trait return types a bit better
2020-08-05 15:58:26 -04:00
Daniel Melchior
fa73c7c9d9
Fix #3757 - allow multiple mixins ( #3772 )
2020-08-05 15:49:19 -04:00
Brown
38bfc12b98
Fix array_shift behaviour to be more accurate with lists
...
Fixes #3941
2020-08-05 12:43:37 -04:00
Matthew Brown
9dfdcbef31
Fix #3928 - preserve list-ness when assigning with no offset
2020-08-03 12:30:58 -04:00
SignpostMarv
06d4b9d6dd
mark bcscale as impure, re: vimeo/psalm#3918 ( #3926 )
2020-08-03 10:15:59 -04:00
Brown
7fc4a85534
Fix CI
2020-08-03 02:45:55 -04:00
Brown
20a9b103ec
Restrict narrowing fix
2020-08-03 02:20:58 -04:00
Brown
bc053e5ee8
Fix #3923 - remember class name when appending array with key
2020-08-03 01:34:46 -04:00
Brown
855a4b8456
Make type combination of object-like arrays with class-string-keys work
...
Ref #3923
2020-08-03 01:34:46 -04:00
Nicolas CARPi
593a9063bb
Fix hash_file signature. See https://3v4l.org/E0BeU ( #3920 )
...
hash_file can return false if the file is not readable.
2020-08-02 15:18:42 -04:00
Matthew Brown
ab64ccab88
Fix #3913 properly
2020-07-31 14:56:29 -04:00
Matthew Brown
6e699836ff
Fix #3913 - improve resolution of array_filter checks
2020-07-31 14:39:03 -04:00
Brown
fd4ced42a7
Don’t register new assignment inside isset expr
2020-07-31 12:44:01 -04:00
Brown
57cd21346c
Fix #3914 - treat $i++ like $i = $i + 1
2020-07-31 11:26:54 -04:00
Brown
afd8874a9e
Don’t get stuck in recursive loop
...
Fixes #3912
2020-07-30 15:42:34 -04:00
Brown
6919e88423
Add performance logging under a --debug-performance flag
2020-07-30 15:30:19 -04:00
Brown
ad1920c3a2
Fix #3910 - improve handling of fgetcsv
2020-07-30 14:21:55 -04:00
Brown
a8c0d81dc1
Prevent bool > 1 in strict mode
2020-07-30 11:25:47 -04:00
Brown
6949a34ded
Put RedundantIdentityWithTrue behind a flag cc @greg0ire
2020-07-30 10:25:59 -04:00
Brown
abe91adbe7
Fix #3801 - convert static to Foo&static when @method is given
2020-07-30 09:42:23 -04:00
Brown
7367e8e6c2
Allow assertions of non-empty lists on typed lists
...
Fixes #3906
2020-07-29 18:10:43 -04:00
Brown
1c8f9e94b1
Fix #3907 - allow template as types to be refined via instanceof
2020-07-29 17:46:45 -04:00
Brown
74eea18563
Add better checks
2020-07-26 19:09:26 -04:00
Brown
d9d5fdd6c9
Add more rules around positive ints
2020-07-26 18:29:17 -04:00
Brown
4a5f74c091
Add positive-int type
2020-07-26 15:51:55 -04:00
Brown
8c5e4edab0
Fix extra test
2020-07-26 15:50:07 -04:00
Brown
657f9db2e0
Fix bugs
2020-07-26 15:21:05 -04:00
Brown
23f5d66516
Fix #3897 - support aliasing final methods
2020-07-26 14:46:52 -04:00
Brown
eddd7b8c11
Fix #1916 - support @var docblock annotations in more places
2020-07-26 13:23:21 -04:00
Brown
42ad366dc8
psalm-internal no longer requires internal annotation
...
cc @bdsl
2020-07-26 10:47:48 -04:00
Brown
e398535f9f
Fix #3872 - detect namespace violations in non-methods
2020-07-26 10:42:04 -04:00
Matthew Brown
1d077cc48e
Fix #3894 - don’t alter class-string during erroneous emptiness check
2020-07-25 22:49:19 -04:00
Grégoire Paris
2f673fbbd7
Detect redundant identity with true ( #3893 )
...
Using === true on a known boolean results in the same boolean.
2020-07-25 17:27:45 -04:00
Matthew Brown
ab714a40c4
Allow binding of static to current final class
...
Ref #3892
2020-07-25 17:26:07 -04:00
Brown
b1e583ebed
Detect concat operation on property
...
Ref #3870
2020-07-24 16:01:45 -04:00
Brown
3687d34a5a
Detect bad class constants more explicitly
2020-07-24 15:38:56 -04:00
Brown
873970a4d1
Recursively transform template types before comparison
...
Fixes #3887
2020-07-24 14:47:24 -04:00
Brown
92fe9898a1
Fix #3879 - ensure interface templates are extended where nececssary
2020-07-24 11:29:36 -04:00
Brown
cb979262c7
Add slash
2020-07-24 10:51:04 -04:00
Matthew Brown
84945a7d1b
Fix #3877 - prevent impossible subtr comparisons
2020-07-24 10:08:57 -04:00
Matthew Brown
b88b169464
Fix #3882 - prevent crash when comparing object{...} to missing class
2020-07-24 09:38:51 -04:00
Barney Laurance
ff432ff73d
Simplify error messages and implementation for internal errors ( #3881 )
...
* Use more consistent language for Internal errors
There's no meaningful distinction between something being internal and
being 'marked as internal'.
* Rename property psalm_internal to internal in all storage classes
This property holds metadata that can be set using either @internal
or @psalm-internal in docblocks
* Change types of internal properties in storage from ?string to string
Simpler type is easier to handle. Non-internal methods can be considered
to be internal to the entire universe of PHP code, i.e. that code whose
namespace starts with the empty string. It's not a special case.
2020-07-24 09:32:54 -04:00
Brown
344a732829
Warn about simple assignments
2020-07-23 02:40:35 -04:00
Brown
3848fa6872
Fix #3870 - mark properties as reference-free only for externally-immutable classes
2020-07-23 01:48:06 -04:00
Barney Laurance
3bc91b9944
Fix multiple issues with @internal and @psalm-internal ( #3841 )
...
* Add passing tests for property fetch on an @internal class
I'm trying to work out why the equivilent InvalidCodeParse test is
failing for PsalmInternal
* Treat all properties of a psalm-internal class as psalm-internal
* Remove all $internal properties from storage - use psalm_internal instead
@internal can be represented as internal to the namespace root, avoiding
the need to check for both properties in storage later.
* Raise InternalClass issue when an internal class is used with e.g. instanceOf
* fix docs and tests
* Add return type declartion to code example in doc
* Don't allow class psalm-internal to overide a tighter method psalm-internal
* Break up long line
* Code style - move && from EOL to SOL
* Restore misplaced &&
* Fix code style
* Fix namespace fetching so it works
Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-22 19:27:35 -04:00
Brown
983f233026
Improve unpacking
2020-07-22 00:35:18 -04:00
Brown
962265e98e
Hopefully final fixes
2020-07-21 23:59:11 -04:00
Brown
7ef3d4711f
Fix some more tests
2020-07-21 23:16:56 -04:00
Brown
fc8c899b3a
Fix test
2020-07-21 20:51:37 -04:00
Brown
5415a379d2
Fix style things
2020-07-21 19:44:59 -04:00
Brown
76bd5b6278
Refactor type comparison
2020-07-21 19:40:35 -04:00
Brown
3ce5478e5e
Fix what source we give the afterMethodCall analysis hook
2020-07-21 15:00:47 -04:00
Brown
295adb5763
Fix #3860 - use correct trait element positions for nested error
2020-07-21 14:17:07 -04:00
Brown
8ed9007355
Allow false to be removed from scalar
...
Fixes #3829
2020-07-21 13:02:13 -04:00
Brown
ae89a71c84
Prevent false-positive comparing template to true
2020-07-21 12:59:50 -04:00
Brown
223b0619c5
Fix #3858 - support @psalm-assert falsy for abort_if expressions
2020-07-21 12:55:11 -04:00
othercorey
1524b62181
Allow null for locale, datetime and typetime of datefmt_create ( #3851 )
2020-07-20 04:52:27 -04:00
Gregor Harlan
5212bd1f9c
Readonly: allow assignments in __unserialize ( #3845 )
2020-07-20 04:50:50 -04:00
Evgeniy
2c51f47ff6
Fix invalid UndefinedClass using array|callable ( #3842 )
...
* Do not treat string array argument as callable if it can be traeted just as string array.
* cs
2020-07-20 04:50:07 -04:00
ygottschalk
de2109234d
fixes wrong return type of key() #3838 ( #3839 )
...
* fixes wrong return type of key() #3838
fixed/added tests for key
* fixed test again
2020-07-20 04:49:36 -04:00
Tyson Andre
060ae61f31
Remove an if statement that repeats the previous if statement ( #3840 )
...
They're the exact same variables.
2020-07-17 19:46:06 -04:00
Brown
9ca8fb80b7
Carry over taints after @var docblock type hints
2020-07-17 11:30:44 -04:00
Adrien LUCAS
d44130191b
Allow taint through strval sprintf ( #3836 )
...
* Add psalm-flow to strval
* Unexpected behavior with implode
2020-07-17 10:12:04 -04:00
Nat Zimmermann
2ee126c567
correct *getcsv return types ( #3832 )
2020-07-17 10:09:21 -04:00
Brown
5392ae0b39
Fix UnusedMethodCall examples
2020-07-16 18:14:15 -04:00
Brown
26a61c47c0
Prevent mixed erasure in get_class call
2020-07-16 13:56:42 -04:00
Brown
a2dbd31371
Fix usage of array_push results
2020-07-16 13:44:51 -04:00
Brown
262bb9fd89
Invalidate memoized getter method results after property assignment
2020-07-16 12:59:49 -04:00
Brown
b361b44889
Rip out plain getter property logic cc @m0003r
...
It gets in the way of the other IMO more useful memoisation logic (e.g. when a getter is declared final)
2020-07-16 12:42:59 -04:00
Brown
96bfd144df
Fix #3825 - ensure final getters are treated as mutation free
2020-07-16 11:58:27 -04:00
kesselb
aaba3a08ec
Add option to supress a referenced but undefined global variable. ( #3827 )
2020-07-16 09:49:59 -04:00
Brown
8fbc8de98a
Fix #3820 - don’t treat a method call as memoisable if it has assertions
2020-07-15 15:09:19 -04:00
Brown
06ee1b71c7
Improve check for empty array
2020-07-15 09:49:30 -04:00
ygottschalk
94e2552d1c
Fix #3810 removing ignore-nullable-return ( #3817 )
...
* Fix #3810 removing ignore-nullable-return form stubs of key, array_key_first, array_key_last
* fixed test failing due to changes to key()
* Improve key return type
* Remove unnecessary check
Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-14 17:43:26 -04:00
Tyson Andre
f17a4911d5
Add more impure functions ( #3814 )
2020-07-14 17:14:09 -04:00
Evgeniy
fcd2ac3078
array_column check result non-emptyness ( #3813 )
...
* Update
* Update test
* Fix test
* Fix test
* inline function res in test
* cs
2020-07-14 17:13:45 -04:00
Brown
3c9028c182
Fix #3808 - allow detection of paradoxes in switch condition function calls
2020-07-14 10:51:12 -04:00
Brown
f0a5463834
Catch string subtypes that cannot be identical
2020-07-14 10:08:31 -04:00
Brown
2399643472
Fix #3811 - allow more complex negations inside boolean expressions
2020-07-13 21:31:58 -04:00
Bruce Weirdan
931d35a703
Collect and scan files included by the autoloaders ( #3183 )
...
Refs vimeo/psalm#2861
2020-07-11 17:17:22 -04:00
Joe Hoyle
b8c4abf08b
Add ability to Go to Definition on Use statements ( #3805 )
...
This adds the ability to use the LSP's "Go to Definition" on `use MyClass` statements.
Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-11 17:16:44 -04:00
Joe Hoyle
0b6d682964
Fix going to definition on return type ( #3806 )
...
* Fix going to definition on return type
If a return type of a method or function is set incorrectly (with the PHP doc), then the references are not added for the `function() : MyClass` symbol, so the "Go to definition" feature of the LSP won't work. I don't believe an invalid return type or not should stop the symbol location being tracked (and not allowing code navigation).
In moved the symbol location tracking to be before the return early short circuit.
* Update SymbolLookupTest.php
Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-11 17:14:39 -04:00
Joe Hoyle
11af82a97f
Fix jumping to definition on nullable parameters ( #3804 )
...
Currently it's not possible to "Go to definition" (LSP) on nullable args like `function( ?MyClass )` as the reference is stored a `MyClass|null` in the reference map, which will now resolve to a class name.
This PR removed any nullable type from the union before adding it to the reference map (as the reference map is only use to indicate a symbol was used in a given location, I think this makes sense).
2020-07-11 17:12:03 -04:00
Brown
2afbf58324
Prevent adding trait property types
2020-07-10 19:11:06 -04:00
Brown
9177ad5ce0
Add back fix
2020-07-10 17:13:11 -04:00
Brown
8d022307d2
Fix #3797 - prevent many chained assignments crashing Psalm
2020-07-10 16:49:45 -04:00
Brown
d71f12d250
Fix #3802 - allow increment inside isset expression
2020-07-10 16:14:24 -04:00
Brown
4f872674f9
Add space
2020-07-10 14:40:25 -04:00
Brown
8349564cc4
Fix #3790 - removing false/null from template not redundant
2020-07-10 13:19:23 -04:00
Brown
cd8420aa94
Skip optimisation for unpacked args
2020-07-10 13:04:37 -04:00
Brown
d8eca89b44
Remove redundancy
2020-07-10 10:35:26 -04:00
Brown
38fdf4bef6
Treat array_push($a, ... as $a[]= ...
2020-07-10 10:20:02 -04:00
Tyson Andre
018c4bf545
Support generating a .console report text file. ( #3777 )
...
This is useful for use cases such as saving multiline taint detection results.
Only the compact and console reports seem to use color right now.
In many cases, adding color codes to a text file would make it harder to read
in an editor.
2020-07-08 15:09:31 -04:00
Brown
bf7bcc0dca
Fix #3779 - allow ParadoxicalCondition of default to be suppressed
2020-07-08 14:51:20 -04:00
Brown
33a834bb0b
Fix some property inference bugs
2020-07-08 14:43:36 -04:00
Brown
619c384509
Add indentation as necessary between property docblocks
2020-07-08 14:32:16 -04:00
Brown
f173ef6ef0
Add mixed types to prevent bad recommendations
2020-07-08 12:18:36 -04:00
Brown
cf67b9eef1
Fix #435 - add psalter fix for MissingPropertyType
2020-07-08 12:03:12 -04:00
Brown
6bdff42cda
Add support for potentially-assigned properties
2020-07-08 11:46:55 -04:00
Brown
0034f2e4bd
Don’t manipulate property storage during analysis
2020-07-07 19:32:44 -04:00
Tyson Andre
cda6bd0553
Fix "Could not get class storage" from cache ( #3769 )
...
Fixes #3671
This is better than an uncaught exception, at least, and I can detect
new issues if the constructor body changes
2020-07-07 17:10:51 -04:00
Brown
8ecee6df6d
Fix #3760 - prevent param remapping twice
2020-07-07 11:44:22 -04:00
Brown
82a85791f2
Fix #3764 - preserve sealed-ness of array into array_map
2020-07-07 09:31:43 -04:00
Brown
279cad3599
Fix #3755 - prevent crash when throw class not found
2020-07-07 00:29:46 -04:00
Tyson Andre
cad86aae5b
Fix typo for printr
( #3754 )
...
Related to #3744
`print_r` is only a taint sink when `$return` is false or absent.
2020-07-07 00:25:14 -04:00
Brown
1b498e6dae
Remove unused variable
2020-07-06 17:41:07 -04:00
Brown
eb3ce8d368
Remove unused code
2020-07-06 15:39:52 -04:00
Brown
ada2fe033e
Remove comma
2020-07-05 15:21:44 -04:00
Brown
ab6df0a5d1
Fix #3753 - resolve self-references in trait as statements earlier
2020-07-05 12:05:25 -04:00
Brown
42a3cedd31
Fix #3742 - add null to type after possibly null array access
2020-07-05 09:12:07 -04:00
jarstelfox
3096afed99
Fix echo false issue ( #3751 )
...
* Echo: add failing test case
echo false; is a noop, not an issue
* Echo: Fix failing test case
2020-07-05 08:55:42 -04:00
Brown
7c7ebd068f
Make invalidation more robust
2020-07-03 12:59:07 -04:00
Brown
5da29955ee
Use better replacement when analysing potentially-inherited templated type
2020-07-03 12:25:33 -04:00
Brown
44d7f51857
Generalise init vars inside for loops
...
Ref #3085
2020-07-03 11:13:44 -04:00
Brown
3d0a8c4c59
Fix #3738 - allow storing references to class-strings inside immutable
2020-07-03 08:47:50 -04:00
Brown
6419788a49
Remove false from template param as necessary
...
Fixes #3737
2020-07-03 01:07:50 -04:00
lhchavez
ba63ccb825
Improve \Psalm\Internal\Scanner\DocblockParser::parse() ( #3736 )
...
This change avoids calling `str_replace()` on the original docblock and
instead only operates on the parsed (and modified) lines. This now makes
it so that if there are substrings of the docblock that match a tag
match, it won't get prematurely removed, therefore avoiding mangling of
the parsed docblock's description.
Fixes : #3735
2020-07-02 17:55:57 -04:00
Brown
1745f5cafa
Fix too-long line
2020-07-02 15:32:13 -04:00
Brown
cb94764d22
Prevent false-positive for Exception::__toString overriding
2020-07-02 14:09:56 -04:00
Brown
0c582e9993
Fix #3685 - improve handling of if conditionals inside do
2020-07-02 13:59:59 -04:00
Brown
cf1a8ac5fc
Suppress taints in instance properties
2020-07-02 12:08:42 -04:00
Brown
67b2edc328
Allow more things to be suppressed with @psalm-suppress TaintedInput
2020-07-02 11:53:51 -04:00
Brown
ea82cdc6ea
Fix #3726 - infer generic template from class-string
2020-07-02 01:11:46 -04:00
Brown
ae7c5b095b
Fix #3712 - allow taints to be suppressed with @psalm-suppress
2020-07-01 23:23:45 -04:00
Tyson Andre
e3d59bf5d4
Support taint detection on Throwable::getTraceAsString() ( #3731 )
...
And `__toString()`, which uses getTraceAsString().
Fixes #3696
```php
function login($username, $password, $secret) {
throw new RuntimeException('login failure');
}
try {
login('user', $_GET['pass'], SECRET);
} catch (Exception $e) {
// This output includes unescaped 'pass' and SECRET
echo $e, "\n";
echo $e->getTraceAsString();
}
```
2020-07-01 21:27:40 -04:00
Brown
0f548c83ea
Fix redundant condition
2020-07-01 19:31:10 -04:00
Brown
6c62e46d15
Only emit one error for erroneous array_map string closure types
2020-07-01 19:18:01 -04:00
Brown
4d73b2501b
Allow multiple args passed to array_map
2020-07-01 19:11:49 -04:00
Brown
70ab4c18f4
Fix #3720 - allow literal unions in keys to map to object-like arrays
2020-07-01 18:57:19 -04:00
Olle Härstedt
d8e8ce428e
Add new annotation: @psalm-self-out ( #3650 )
...
* Add new config: sealAllMethods
* Add some more tests
* Fix codesniffer issue with preg_quote
* Fix missing method in test
* New tag @self-out (WIP)
* Add self_out_type to method storage
* Add some notes
* More work on self-out (WIP)
* More work on self-out (WIP)
* Use psalm-self-out instead of self-out
* Remove extra file
* Cleanup
* Wrap around try-catch - how to check if a method has/should have storage?
* New method hasStorage()
* Fix indentation
* Fix some errors
* Fix indentation
* Cast storage type to type
* Add proper use-statement in method storage
* Correct test class name
* Allow self_out to be null
* method_id can be string (why, when?)
Co-authored-by: Olle <noemail>
2020-07-01 18:10:24 -04:00
Tyson Andre
b0a3de47e8
Mark create_function() as a taint sink ( #3729 )
...
create_function() is a thin wrapper around eval().
Fixes #3723
2020-07-01 18:09:30 -04:00
Brown
e13da22292
Allow cloning interfaces
2020-07-01 11:14:31 -04:00
Brown
fca350c498
Prevent a few crashes with really bad code
2020-07-01 10:30:10 -04:00
Brown
6047b7b6cb
Fix #3719 - prevent crash when cloning missing class
2020-07-01 10:10:55 -04:00
Brown
4c368da75e
Fix #3721 - prevent crash on empty @method
2020-07-01 09:00:33 -04:00
Brown
17558a5c0e
Fix #3676 - add multiline output for TaintedInput issues
2020-06-30 13:17:51 -04:00
Brown
671009a70c
Specialize constructor taints cc @TysonAndre
2020-06-29 21:08:43 -04:00
Brown
7288dfc620
Fix #3715 - unserialize is a taint sink
2020-06-29 17:54:47 -04:00
Brown
7253e01000
Fix #3716 - prevent crash for Foo|? return type
2020-06-29 17:52:55 -04:00
Brown
e56483bb54
Fix #3711 - generalize call of specialized class without specializations
2020-06-29 17:42:01 -04:00
Brown
ab29ac0e51
Only cast in echo when tracking taints
2020-06-29 15:06:11 -04:00
Brown
cff976049d
Remove unused vars
2020-06-29 13:24:05 -04:00
Brown
f6e2e0a84a
Perform string casting for taints in ArgumentAnalyzer
2020-06-29 13:21:33 -04:00
Brown
45c21853e5
Fix #3709 - don’t crash on inherited __toString tainting
2020-06-29 12:11:11 -04:00
Brown
aab90fb74e
Fix Psalm errors
2020-06-29 09:29:19 -04:00
Brown
38977d797e
Fix #3697 - cast types via implied __toString method
2020-06-29 09:13:19 -04:00
Brown
b54b832838
Break out method call tainting
2020-06-29 00:14:49 -04:00
Barney Laurance
3f8aa64ee9
Treat methods of internal or psalm internal classes as internal ( #3698 )
...
When both the method and the class are annotated as psalm-internal,
but to different namespaces, we consider the method internal to
whichever namespace is longer, i.e. the smaller code module.
Issue reported at https://github.com/vimeo/psalm/issues/3457
2020-06-28 13:15:54 -04:00
Simon Podlipsky
0f727e7607
Add RdKafka\ProducerTopic::producev() to CallMap ( #3700 )
2020-06-28 13:15:11 -04:00
Brown
c95ebfeb21
Fix #3694 - allow two args for PDO::query
2020-06-26 18:26:06 -04:00
Fabien Villepinte
c42dadaf0d
Redis::getDbNum|getHost can return false ( #3673 ) ( #3693 )
2020-06-26 18:14:10 -04:00
Tyson Andre
3a9c7432e1
Add psalm-taint-specialize for preg_replace_callback ( #3683 )
...
Fixes https://psalm.dev/r/517c4a169e
2020-06-26 08:58:57 -04:00
Brown
bcd7478352
Reduce memory footprint a little
2020-06-25 19:12:30 -04:00
Brown
559b3d3471
Fix #3681 - taint exit like echo
2020-06-25 17:17:08 -04:00
Brown
07f7e5ccaf
Reconciling should preserve taints
...
Fixes #3680
2020-06-25 17:04:18 -04:00
Brown
9837a60853
Fix #3675 - add taints to filter_var return
...
Doesn’t yet take callback into account
2020-06-25 13:24:26 -04:00
Brown
9e7650586b
Fix bugs
2020-06-25 13:21:11 -04:00
Brown
95bf7f835b
Improve handling of array_map, faking out calls where nececssary
2020-06-25 13:05:34 -04:00
Brown
f458959af5
Add param type
2020-06-25 01:40:19 -04:00
Brown
d7f1bde6da
Refactor taint acccess checks
2020-06-25 01:32:57 -04:00
Brown
b8ebed0b85
Add a bit more accuracy
2020-06-25 01:00:11 -04:00
Brown
e26922010a
Improve accuracy of array nesting checks
2020-06-25 00:50:52 -04:00
Brown
b84cf74754
Fix #3668 - taint property types for magic properties without @property
2020-06-25 00:24:37 -04:00
Brown
dd25b81d3a
Fix #3670 - taint mixed foreach access
2020-06-24 19:16:30 -04:00
Brown
a6c7a48387
Add support for argument unpacking
...
Ref #3670
2020-06-24 18:43:15 -04:00
Tyson Andre
1670848267
Mark print() statement as the same sink type as echo ( #3669 )
2020-06-24 17:23:16 -04:00
Brown
de85e7c539
Fix blips
2020-06-24 13:19:14 -04:00
Brown
7a7cd91c24
Fix #3631 - better treatment for assignments in complex conditionals
2020-06-24 13:16:52 -04:00
Brown
9aa0aca949
Fix handling of coerced callmap args
2020-06-24 11:51:31 -04:00
Brown
c29b3744ec
Change storage of out types
2020-06-24 11:51:31 -04:00
Brown
96d05ab06b
Fix #3654 - use correct function id for namespaced functions
2020-06-23 16:53:11 -04:00
Brown
6a746b65ea
Fix #3655 - taint encapsulated strings
2020-06-23 16:38:59 -04:00
Brown
13fc8a75fd
Allow taints to flow where no return type exists
...
Fixes #3652
2020-06-23 15:52:19 -04:00
Brown
f46236ad71
Taint flows through preg_replace_callback
2020-06-23 15:28:31 -04:00
Brown
f72b609d42
Fix #3642 - detect missing property when name matches
2020-06-23 13:12:46 -04:00
Brown
4d6fc4d0ca
Fix get_class($foo) === static::class checks
2020-06-23 13:11:19 -04:00
Brown
9b860214d5
Fix #3639 - allow coerced types to count when picking callmap options
2020-06-22 20:24:34 -04:00
Brown
1f86afece7
Revert "Fix #3631 - apply assertions to RHS of equality in conditional"
...
This reverts commit 9c17795545
.
2020-06-22 20:01:27 -04:00
Brown
fc8212e207
Fix static call specialisation via annotation
2020-06-22 18:40:43 -04:00
Brown
e8be2c500e
Support taint flows in more functions
2020-06-22 17:53:03 -04:00
Brown
7f05b3c530
Add $_REQUEST as a taint source
...
Ref #3636
2020-06-22 17:16:15 -04:00
Brown
9c17795545
Fix #3631 - apply assertions to RHS of equality in conditional
2020-06-22 15:16:16 -04:00
Brown
dddc159694
Add explicit path object
2020-06-22 02:10:03 -04:00
Brown
36f1630e03
Add more steps for clearer output
2020-06-22 01:08:58 -04:00
Brown
02e8313c39
Allow taintedness to propagate to some stubbed methods
2020-06-21 18:07:39 -04:00
Brown
fbe3433edd
Use escape terminology
2020-06-21 11:43:08 -04:00
Brown
07adecc6eb
Use correct method id when creating taints
2020-06-21 02:06:08 -04:00
Brown
dc83c2e2fc
Add annotation for taint sources
2020-06-21 00:58:56 -04:00
Brown
f21d3a8346
Remove html and sql taints for simple preg_replace patterns
2020-06-20 23:11:42 -04:00
Brown
8edee96d8d
Fix taint regression
2020-06-20 18:10:01 -04:00
Brown
80ed1daf33
Allow static method mixin to invoke instance method
2020-06-20 18:05:35 -04:00
Brown
2ccec821f8
Fix #3624 - inherit magic property annotations from traits
2020-06-20 16:53:17 -04:00
Brown
2c5c9e95e1
Don’t add two @return docblocks after @method
2020-06-20 15:30:47 -04:00
Brown
edbeec2c6a
Fix @method annotation namespacing
2020-06-20 15:18:22 -04:00
Ilija Tovilo
2f646d29db
Fix #3607 - constant string class reference with leading backslash ( #3612 )
2020-06-19 18:02:39 -04:00
Brown
51202c75ea
Add taint docs
2020-06-19 11:56:12 -04:00
Andrei Petre
6024fe4761
use original case in error messages when reporting undefined methods ( #3615 )
2020-06-19 11:51:08 -04:00
Brown
b1c836e5f3
Improve specialisation after call
2020-06-19 01:59:45 -04:00
Brown
8f2e28c36b
Improve tainting of specializable classes
2020-06-19 01:22:51 -04:00
Brown
078b8b7b1a
Fix #3618 - add way to load non-analyzed files
2020-06-19 00:13:09 -04:00
Brown
eecdc43ce7
Remove stray commas
2020-06-18 20:15:38 -04:00
Brown
49f0592794
Improve tracking of array taints
2020-06-18 18:48:19 -04:00
Brown
562a7c1ca4
Track taints from all tainted arrays
2020-06-18 13:45:58 -04:00
Brown
7d9a99a956
Fix #3609 - interpret strings as regular static calls
2020-06-18 11:56:08 -04:00
Brown
f609a01497
Move static property fetch analyzer to own class
2020-06-18 11:53:24 -04:00
Brown
98622783ec
Allow lists to have their types refined
...
Fixes #3605
2020-06-18 10:01:16 -04:00
Bruce Weirdan
6fb63903c1
Infer better types for magic constants used in const initializers ( #3602 )
...
Fixes vimeo/psalm#3464
2020-06-18 09:48:51 -04:00
Brown
137647a1a0
Fix #3603 - better typed value comparisons for loose equality
2020-06-18 09:31:38 -04:00
Brown
7fc1f50f54
Fix potential nullref
2020-06-17 16:40:35 -04:00
Brown
4870774ea4
Allow falsable issues on DateInterval::$days
2020-06-17 16:28:26 -04:00
Brown
0a8b9b56ab
Fix #3600 - conditional return should be removed before comparison
2020-06-17 12:57:50 -04:00
Jaik Dean
02b15b83ff
Fix argument types for Redis::zRevRangeByScore() and Redis::zRevRangeByLex() ( #3597 )
2020-06-17 11:50:03 -04:00
Teemu Koskinen
bfae4af030
tidyNode->child will be null if the node does not have any children ( #3599 )
...
https://github.com/php/php-src/blob/master/ext/tidy/tidy.c#L696
2020-06-17 09:29:23 -04:00
Olle Härstedt
e1cc27f7a2
Add new config: sealAllMethods ( #3578 )
...
* Add new config: sealAllMethods
* Add some more tests
* Fix codesniffer issue with preg_quote
* Fix missing method in test
Co-authored-by: Olle <noemail>
2020-06-15 22:36:42 -04:00
Brown
03e9649d49
Fix tainting of function calls absent taintable params
2020-06-15 20:59:48 -04:00
Brown
56ef220e49
Fix bugs in taint specialisation
2020-06-15 18:34:56 -04:00
Brown
bbada7ba8d
Ensure correct vars are used
2020-06-15 17:16:12 -04:00
Brown
05cb39814c
Improve performance of long switch checks
2020-06-15 16:23:19 -04:00
Brown
8c5a434dc8
Allow updating array by reference
2020-06-15 14:45:08 -04:00
Matthew Brown
081a284759
Fix #3567 - remember which variables a callable sets byref in use
2020-06-14 11:58:50 -04:00
Matthew Brown
a49a0e5650
Fix #3551 - count method can be impure
2020-06-14 11:06:53 -04:00
Matthew Brown
683bde9540
Fix #3573 - allow UnnecessaryVarAnnotation to be suppressed
2020-06-13 16:48:10 -04:00
Matthew Brown
19ba53f28c
Fix too-long line
2020-06-13 16:45:54 -04:00
Matthew Brown
427f470806
Fix #3586 - ensure templated trait params more accurate
2020-06-13 16:37:39 -04:00
Matthew Brown
edb2b4c5ef
Get type of requires
2020-06-13 15:48:12 -04:00
Gabriel Ostrolucký
8ca7a88c41
Mark fgetcsv impure ( #3582 )
...
fgetcsv standalone is used to skip current row for consecutive reads
2020-06-13 00:32:00 -04:00
Andrei Petre
3497ca07b6
Extending final class is prohibited #3037 ( #3576 )
2020-06-13 00:29:59 -04:00
Bruce Weirdan
a99f92ae3a
Fix vimeo/psalm#3572 ( #3575 )
...
session_decode has side effects
2020-06-13 00:28:56 -04:00
Brown
9bfe50b20a
Always analyse cast expressions
...
Fixes #3577
2020-06-12 17:25:46 -04:00
Brown
211f014356
Fix #3571 - make callable():void valid for callable():?Foo
2020-06-12 14:26:31 -04:00
Brown
45ea5d0bfe
Add a couple more shortcuts for common pattern
...
Fixes #3563
2020-06-12 11:18:34 -04:00
Brown
9ca6c868b7
Fix #3563 - add workaround for == true
2020-06-12 10:58:44 -04:00
Tim van Dijen
7fa48f3508
Fix return type for preg_grep ( #3565 )
2020-06-11 11:59:14 -04:00
Brown
f67b61f6cc
Fix reconciliation of template param to literal string
...
Fixes #3510
2020-06-11 11:58:31 -04:00
Brown
16189782ab
Inherit whether methods are sealed from parent
...
Ref #3561
2020-06-11 11:28:41 -04:00
Brown
ec0a4c7c96
Require ReflectionMethod get a class-string
2020-06-11 11:07:57 -04:00
Jáchym Toušek
c6611cfcd1
Update ext-ds stubs ( #3559 )
2020-06-10 17:27:39 -04:00
Gregor Harlan
235093ecc4
Add PharData::offsetGet/offsetExists to CallMap ( #3557 )
2020-06-10 17:26:22 -04:00
Brown
5617e9d7c9
Fix array_values call
2020-06-09 19:06:08 -04:00
Brown
286a8f911a
Add support for static mixin calls
...
Fixes #3552
2020-06-09 18:39:52 -04:00
Brown
a6c0991073
Fix #3532 - expand type alias types recursively
2020-06-07 12:01:04 -04:00
Matthew Brown
91e76f7173
Fix #3536 - Make method return type provider aware of original called method
2020-06-06 23:35:08 -04:00
Matthew Brown
0ac739fd48
Fix #3534 - allow magic method call on mixin
2020-06-06 23:28:32 -04:00
Matthew Brown
739d23e5f0
Use alias
2020-06-06 23:27:25 -04:00
Matthew Brown
3d7288afcb
Fix #3529 - static intersected with itself is static
2020-06-06 20:10:50 -04:00
Matthew Brown
ce445636e7
Fix #3535 - match template param class constants properly
2020-06-06 20:02:14 -04:00
Matthew Brown
74a34f066c
Don’t check classes if literal strings are allowed
...
Fixes #3538
2020-06-06 19:31:42 -04:00
Brown
4f87cca55b
Fix #3537 - improve parsing for @mixin annotations
2020-06-06 18:15:24 -04:00
Matthew Brown
243c09de37
Make property protected
2020-06-06 12:24:16 -04:00
Brown
fcf0a681d9
Fix #3531 - ignore mixed returns from template
2020-06-06 10:33:49 -04:00
Brown
438eb17e58
Fix #3367 - ensure --diff works after second run, not third
2020-06-05 12:09:38 -04:00
Brown
cf92361338
Fix #3522 - only use property pass-through when it’s visible
2020-06-04 16:15:07 -04:00
Brown
a4aa44494f
Fix #3519 - prevent empty callable string
2020-06-04 15:40:53 -04:00
Šimon Podlipský
596213c2c3
Make ext-ds to array return list<V> ( #3520 )
2020-06-04 09:56:00 -04:00
Matthew Brown
c9ee691595
Fix suppression
2020-06-04 09:55:32 -04:00
Brown
5c80dc3299
Fix #3515 - add merge method to Vector
2020-06-03 16:50:01 -04:00
Brown
fd74d3284d
Add support for PHPParser 4.5.0
2020-06-03 14:58:08 -04:00
LeSuisse
1f8dc26d1d
Fix signatures of stream_filter_append and stream_filter_prepend ( #3514 )
...
filterparams is not restricted to an array, it is perfectly to pass a
class or any other value.
See https://github.com/php/php-src/blob/php-7.4.6/ext/standard/streamsfuncs.c#L1171
2020-06-03 12:50:40 -04:00
Brown
7caaa64825
Fix #3418 - don’t override with send type when @psalm-yield is given
2020-06-02 13:27:17 -04:00
Brown
4d149de764
Fix #3506 - prevent black classes in throws check
2020-06-01 14:56:27 -04:00
Markus Staab
efcc28be02
Fixed mysql::$insert_id type ( #3496 )
...
* Fixed mysql::$insert_id type
* Update PropertyMap.php
* Update src/Psalm/Internal/PropertyMap.php
2020-05-31 18:53:30 -04:00
Brown
be8fd3ea19
Fix #3481 - treat an iterable like a Traversable when comparing to object
2020-05-31 01:22:43 -04:00
Brown
86b894eca5
Treat iterables as traversable when comparing to named object
2020-05-31 00:55:45 -04:00
Brown
c1d8912a9b
Bust cache more
2020-05-30 19:11:57 -04:00
Brown
4e21e54ee1
Fix #3491 - provide correct types for substitution
2020-05-30 19:11:41 -04:00
Markus Staab
0e298a6f13
Removed unexisting property mysqli::stat ( #3501 )
2020-05-30 17:03:04 -04:00
orklah
76f5def268
Use scandir and glob flags to reduce their performance impact ( #3499 )
...
* Use scandir and glob flags to reduce their performance impact
* Order seem to impact Tests here
2020-05-30 17:02:35 -04:00
Markus Staab
f24d7abcd9
Made mysqli_warning::$sqlstate a string ( #3497 )
2020-05-30 17:01:20 -04:00
orklah
428beb21fb
Improve stubs for str_replace and preg_replace ( #3495 )
...
* expand accepted values for str_replace and preg_replace. Make return conditional based on type of $subject
* Remove int|float from str_replace/preg_replace
Co-authored-by: Matthew Brown <github@muglug.com>
2020-05-30 16:59:18 -04:00
orklah
51bf7f38de
Fix #3438 ( #3494 )
2020-05-30 16:55:55 -04:00
El Azimov
bed5a74065
Add wildcard support for class constants in template. ( #3489 )
...
Co-authored-by: El Azimov <el.azimov@rocks>
2020-05-30 16:55:18 -04:00
orklah
1621a9f3ea
Add checks for duplicated params and returns ( #3487 )
2020-05-30 16:54:16 -04:00
orklah
062db0ffcf
Fix #3437 ( #3493 )
2020-05-30 14:38:12 -04:00
Brown
db67be5965
Fix #3483 - analyse variable static property access properly
2020-05-29 09:28:34 -04:00
Brown
235704ad49
Fix #3484 - use better method to determine constant existence in wildcard checks
2020-05-29 09:09:59 -04:00
Matthew Brown
73797f7498
Add more default sinks
2020-05-29 00:24:07 -04:00
Brown
30907f0269
Clean up comment parsing
2020-05-28 22:14:41 -04:00
Brown
b932163d5d
Make parser a little cleaner
2020-05-28 14:31:17 -04:00
feek
5330dcbd7a
fix: pass along final ( #3471 )
2020-05-28 01:59:24 -04:00
still-dreaming-1
1bb884bd84
__TRAIT__ can be string or non-empty-string ( #3469 )
...
depending on whether or not it is used from inside a __TRAIT__
2020-05-27 19:23:46 -04:00
still-dreaming-1
9189335715
Fixes #3464 by typing __DIR__, __TRAIT__, and __FILE__ as non-empty-s… ( #3468 )
...
* Fixes #3464 by typing __DIR__, __TRAIT__, and __FILE__ as non-empty-string
* __TRAIT__ should stay string in case used outside a trait
Co-authored-by: <jesse@LAPTOP-73CA4O5T.localdomain>
2020-05-27 18:21:26 -04:00
Brown
3c60609c21
Support better mixin handling
2020-05-27 11:12:09 -04:00
Brown
9b413cfccc
Improved understanding of array_key_exists
...
Fixes #3463
2020-05-27 09:03:36 -04:00
Brown
b9ea115487
Support string class_alias calls with leading backslash
...
Fixes #3465
2020-05-27 08:14:47 -04:00
Brown
ef53ee3a3b
Fix crash on aliased exception
...
Ref #3465
2020-05-27 08:09:58 -04:00
Brown
769ac5c052
Fix #3458 - scope templated mixin accurately
2020-05-26 23:32:07 -04:00
Brown
d04e21ee5a
Define mixin declaring classname
2020-05-26 23:32:07 -04:00
Brown
b4855b3ecd
Catch errors during yield annotation tokenisation
...
Fixes #3430
2020-05-26 17:57:55 -04:00
Brown
3da3d61270
Fix #3434 by removing extraneous call to simplifyType
2020-05-26 17:55:54 -04:00
Brown
0ef00f5756
Fix #3460 - allow isset checks on static properties
2020-05-26 17:40:27 -04:00
Brown
f0a5bd74b6
Detect never-return statement same as a throw
2020-05-26 15:02:23 -04:00
Brown
a2b6326a84
Change specialize-call to taint-specialize
2020-05-26 14:18:43 -04:00
Brown
ecb179c784
Migrate min/max function calls back to CallMap
2020-05-26 12:28:56 -04:00
Brown
a266d4748b
Fix build
2020-05-26 07:50:11 -04:00
Brown
953be61cf2
Allow limiting connected taint paths
2020-05-25 23:28:11 -04:00
Brown
7e7456c863
Make taint checks more thorough
2020-05-25 17:10:53 -04:00
Brown
2e6fc24867
Template callmap methods too
...
Fixes #3453
2020-05-25 14:21:06 -04:00
Brown
118b700436
Simplify sink mapping for internal calls
2020-05-25 13:10:06 -04:00
Brown
109920be88
Expand template param before comparison
2020-05-25 11:51:10 -04:00
Brown
be847472a2
Fix #3453 - allow conditional return types on instance methods
2020-05-25 09:39:30 -04:00
Brown
3416e33348
Fix indentation
2020-05-25 01:23:28 -04:00
Brown
240b2f898c
Add some negative test cases for @mixin
...
Also fix #3452
2020-05-25 00:19:52 -04:00
Matthew Brown
806db80d63
Fix #3440 - literal string doesn’t contain numeric-string
2020-05-24 22:42:08 -04:00
Brown
ff5c17c044
Switch subtype messagearg order
2020-05-24 09:43:54 -04:00
orklah
72435757ea
Add false to possible parse_url return types ( #3359 ) ( #3445 )
...
* Add false to possible parse_url return types (#3359 )
* fix test
2020-05-24 09:19:58 -04:00
Brown
92a9a7efdf
Handle flows into arguments a little better
2020-05-23 23:54:16 -04:00
Matthew Brown
1d17c02fba
Fix #3442 - support broader type after initial array assignment
2020-05-23 23:23:50 -04:00
Matthew Brown
15e753e279
Fix #3443 - add InvalidDocblock issue for @psalm-assert Foo|!Bar
2020-05-23 22:52:21 -04:00
Brown
a198b09eb7
Add intermediary concat op node
2020-05-23 21:38:09 -04:00
Brown
f5a0622ad2
Fix style
2020-05-23 08:06:31 -04:00
Matthew Brown
0dee85d0b7
Remove redundancy
2020-05-23 01:48:56 -04:00
Brown
16af6a5773
Improve concat taint propagation
2020-05-23 01:11:16 -04:00
Brown
ee493909d7
Fix bugs
2020-05-23 00:08:16 -04:00
Brown
10c106f7eb
Add eval sink
2020-05-23 00:03:29 -04:00
Brown
dc73e25157
Detect taints in include calls
2020-05-22 23:53:37 -04:00
Brown
e72288c85f
Don’t error on badly-formatted taint annotation
2020-05-22 22:38:03 -04:00
Brown
e82c317d53
Adjust tolerances
2020-05-22 21:37:18 -04:00
Brown
fb3cb2c4d1
Only use plain return type if we’re not memoizing
2020-05-22 17:05:39 -04:00
Brown
bbc30a1747
Only recreate taints if non-null
2020-05-22 16:55:36 -04:00
Brown
4b1c3db760
Don’t memoize method call where we have a getter standin
...
Fixes #3427
2020-05-22 15:54:32 -04:00
Brown
4010129e96
Fix #3420 - add ds\vector::toArray method
2020-05-22 15:26:19 -04:00
Brown
0cb211784d
Fix #3415 - flesh out Closure return type
2020-05-22 14:26:37 -04:00
Brown
27a009fd69
Fix #3417 - Treat $this as static-y
2020-05-22 13:32:26 -04:00
Brown
bebfac0ab6
Fix #3426 - allow falsy reconciliation for templated params
2020-05-22 13:16:48 -04:00
Brown
1b84fc2c12
Fix #3419 - don’t add null to return type when template/conditional return is used
2020-05-22 12:44:19 -04:00
Brown
8632cdb3cd
Improve taint tracking during scanning phase
2020-05-22 12:33:48 -04:00
Brown
63c3678ae5
Improve property location resolution
2020-05-22 12:33:38 -04:00
Matthew Brown
187b944680
Add faster taint analysis
2020-05-22 12:33:29 -04:00
Matthew Brown
6784a90b2f
Fix #3423 - allow conditional with func_num_args() in namespace
2020-05-21 11:29:54 -04:00
Joe Hoyle
6f28d741bc
Display variable assignment type in LSP hovers ( #3401 )
...
* Add node references for variable assignments
* Break up line
Co-authored-by: Matthew Brown <github@muglug.com>
2020-05-20 17:40:22 -04:00
Matthew Brown
3effdc5b69
Improve yield type substitution
2020-05-20 09:12:24 -04:00
Matthew Brown
2d02064962
Fix #3407 - allow multiple matching generic classes in union
2020-05-20 09:11:17 -04:00
Jáchym Toušek
8855b6c1d9
Fix Ds\Map methods ( #3412 )
2020-05-20 07:27:25 -04:00
Brown
2ec76f01c2
Fix redundant condition
2020-05-19 20:11:25 -04:00
Brown
27cb660377
Respect possibly-undefined array keys while merging
...
Fixes #3393
2020-05-19 20:10:01 -04:00
Brown
a4141a7581
Fix #3327 - convert void to null when comparing conditional type with nullable
2020-05-19 19:48:11 -04:00
Brown
f335560b69
Allow setting property on templated type
2020-05-19 17:31:05 -04:00
Brown
6ec5763847
Filter out traversable possibly-mixed too
2020-05-19 16:26:00 -04:00
Brown
a3214012a6
Only convert userland functions
2020-05-19 16:15:41 -04:00
Brown
baeb86ca8f
Fix #3403 - remove possibly-mixed key
2020-05-19 16:12:37 -04:00
Brown
4415e0f69c
Fix special case calling callable param with string non-global function
...
Fixes #3411
2020-05-19 15:48:31 -04:00
Matthew Brown
777b6e8d91
Simplify conditional
2020-05-19 15:07:30 -04:00
Brown
b5ae0167a2
Fix typo
2020-05-19 14:58:53 -04:00
Brown
b38d945b12
Cast null and false to empty string
...
Ref #3408
2020-05-19 14:53:06 -04:00
Brown
8becefda04
Forbid :: in object-like key name
...
Ref #3399
2020-05-19 14:38:46 -04:00
Šimon Podlipský
dc82243edc
Add RdKafka:flush() to CallMap ( #3410 )
2020-05-19 12:56:58 -04:00
Brown
0b2da18f1e
Break up StatementsAnalyzer
2020-05-19 12:56:30 -04:00
Šimon Podlipský
47cf69ded1
Fix RdKafka maps ( #3404 )
...
Resolves #3388
2020-05-19 10:13:25 -04:00
Brown
666cc3b4c9
Fix BinaryOp analysis
2020-05-18 23:00:53 -04:00
Brown
8e5b330c5a
Break apart CallAnalyzer
2020-05-18 22:57:00 -04:00
Brown
5b06c206e0
Move classes into deeper namespace
2020-05-18 22:52:33 -04:00
Brown
ace049a068
Beautify BinaryOpAnalyzer
2020-05-18 18:57:09 -04:00
orklah
478bb267d8
stubs for array_sum ( #3395 )
2020-05-18 17:23:21 -04:00
Brown
8c86d47eb7
Downgrade some PossiblyInvalidClone
issues
2020-05-18 17:18:13 -04:00
Brown
4ca83ca30d
Add slash
2020-05-18 17:05:47 -04:00
Brown
3a582dde8d
Allow merging of numeric-string and literal string
2020-05-18 16:57:16 -04:00
Brown
2312523318
Support merging of numeric-string with literal
2020-05-18 16:56:09 -04:00
Brown
b62f646388
Fix #3391 - move_uploaded_file mutates
2020-05-18 16:26:08 -04:00
Evgeniy
04a576708c
Correct analyze clone expression ( #3382 )
...
* Correct analyze clone, add PossibleInvalidClone issue type
* Infer mixed type when possible incorrect clone
* Remove unused variable
2020-05-18 16:22:50 -04:00
Brown
ea0a99d3a8
Fix bad merge
2020-05-18 16:02:10 -04:00
Brown
5ee1487a01
Make ExpressionAnalyzer more beautiful
2020-05-18 15:13:27 -04:00
SignpostMarv
911ac2d363
Infer numeric-string from (string)$numeric ( #3390 )
...
* adding test for vimeo/psalm#3370
* check if typecast will result in numeric-string
* int & float as per examples in vimeo/psalm#3370
* numeric & numeric-string because they shouldn't lose numericness.
* satisfy phpcs
* adjusting assertions to reflect typecasting change
2020-05-18 13:42:47 -04:00
Brown
21798efed2
Fix #3388 - eliminate null after < 0 check
2020-05-18 08:52:44 -04:00
Mark Sch
9aa46221f6
Use pretty print for JSON reporting. ( #3364 )
...
* Use pretty print for JSON reporting.
* Use pretty print for JSON reporting.
* Use pretty-print option on CLI for BC.
* Change static:: const to self::
Co-authored-by: Matthew Brown <github@muglug.com>
2020-05-18 08:40:20 -04:00
orklah
3e7f5df7e1
Solve more cases when docblock rendering is not needed ( #3387 )
2020-05-18 07:16:18 -04:00
Matthew Brown
b0ffaf0077
Fix type coercion
2020-05-17 22:51:48 -04:00
RJ Garcia
fd15bfc65d
Infer Return Types for Arrow Functions #3376 ( #3385 )
...
* Infer Return Types for Arrow Functions #3376
- Made a small patch to check for closure or arrow
function when attempting to infer the functions
params
- Added new isExprClosureLike to start to consolidate
all checks on closure/arrow fns
Signed-off-by: RJ Garcia <ragboyjr@icloud.com>
* Use better check
* Remove unused method
Co-authored-by: Matthew Brown <github@muglug.com>
2020-05-17 22:17:35 -04:00
orklah
dd4927a14c
Avoid regenerating docblock when no modification is made ( #3374 )
...
* Avoid regenerating docblock when no modification is made
* Generate empty docblock before, in case there was no docblock at all
2020-05-16 16:44:47 -04:00
Jefersson Nathan
f824cc380a
Add more test case scenario for @psalm-import-type ( #3375 )
...
* Add test case scenario for @psalm-import-type
Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
* Add fix for @psalm-import-type test
Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
* Add test for import ocross namespaces
Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
* Add tests for failing cases
Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
2020-05-16 16:43:35 -04:00
Matthew Brown
4dd0a2b775
Fix #3380 - allow comparisons between template param and empty array
2020-05-16 16:41:07 -04:00
Matthew Brown
f6342a40d9
Remove unnecesary conditional check for do
...
Fixes #3378
2020-05-16 16:32:36 -04:00
Nobu Funaki
abef8008bc
Fix InvalidCast after is_callable([$val, '__toString']) check ( #3372 )
...
Support is_callable() with an array argument similar to method_exists()
2020-05-16 08:50:43 -04:00
Brown
c62e08a88e
Support intersection of type aliases
2020-05-15 16:18:52 -04:00
Brown
111303d913
Add non-empty-lowercase-string type
2020-05-15 10:18:05 -04:00
Brown
013467dc0e
Add reference to ensure proper hydration
2020-05-15 00:31:55 -04:00
Brown
0086eb25a2
Remove duplicate types with @psalm-import-type
2020-05-15 00:16:20 -04:00
Brown
2d92943625
Add support for expansion of type aliases
2020-05-15 00:15:48 -04:00
Brown
9f3f7bb946
Consolidate ThreadData types
2020-05-14 23:44:22 -04:00
Brown
c212c03e40
Don’t stop analysing when encountering an UndefinedGlobalVariable
...
Fixes #3366
2020-05-14 22:51:51 -04:00
Brown
ae48c1895f
Fix #3365 - add support for negated empty string checks
2020-05-14 22:09:37 -04:00
Brown
48504aa88c
Pass through typa aliases where appropriate
2020-05-14 00:48:58 -04:00
Brown
006c6e09f1
Add more details to type alias creation
2020-05-14 00:41:50 -04:00
Brown
2327a0db6b
Add TTypeAlias object with a creation path
2020-05-13 19:49:03 -04:00
Brown
190c9ce27e
Use TypeAlias object to allow future extension
2020-05-13 19:29:59 -04:00
Brown
0fc3398631
Move parsing methods into internal namespace
2020-05-13 19:12:45 -04:00
Brown
2af0a17d03
Fix #3236 - allow use-checking of more methods starting with __
2020-05-12 22:39:26 -04:00
Matthew Brown
8c236f411a
Fix #3353 - allow extending nested when nested as type is mixed
2020-05-12 15:07:16 -04:00
Brown
3e58163180
Prevent empty function id
...
Ref #3354
2020-05-12 12:54:06 -04:00
Brown
d8cd30b34a
Fix #3340 - catch more errors in @method type parsing
2020-05-11 18:39:07 -04:00
Brown
0d5d7c8938
Add null check
2020-05-11 11:56:07 -04:00
Brown
291018034b
Remove unnecessary PHP code
2020-05-11 11:36:50 -04:00
Brown
3554aa4435
Fix crash newly introduced
2020-05-11 09:34:07 -04:00
Brown
eefd2e743b
Use generic function definition for sscanf
...
cc @villfa
2020-05-10 23:58:51 -04:00
Brown
8f2f2617d4
Improve refactor
2020-05-10 22:45:01 -04:00
Brown
5f4d162dd5
Break out type expander into separate class
2020-05-10 22:39:18 -04:00
sj-i
fa601f97d7
update proc_open() types for PHP 7.4 ( #3333 )
...
as of PHP 7.4, proc_open() accepts an array for its first argument.
https://www.php.net/manual/en/function.proc-open.php#refsect1-function.proc-open-parameters
2020-05-10 21:11:27 -04:00
Brown
48da7a4be8
Fix issues found with Vimeo’s code
2020-05-10 21:09:48 -04:00
Matthew Brown
733da0e539
Fix #3311 - don’t erroneously mark a class as undefined
...
As they can sometimes only be obvious once an autoloader has been registered
2020-05-10 15:55:44 -04:00
Matthew Brown
4b388a2951
Fix ref
2020-05-10 11:35:35 -04:00
Brown
55222573ea
Mark as possibly-undefined any variable that wasn’t present when the loop began
...
Fixes #3332
2020-05-10 11:17:50 -04:00
Brown
28349c6423
Remove mixin_fqcln hack
2020-05-10 09:04:30 -04:00
Brown
58c63bd1b2
Migrate generic param comparison method
2020-05-08 22:49:08 -04:00
Brown
75761647c2
Fix #3321 - allow interface methods to be mapped
2020-05-08 14:52:53 -04:00
Brown
640ffdb324
Fix #3323 - make short object-like arrays sealed tuples
2020-05-08 14:36:06 -04:00
Brown
2d5c2a9dd1
Fix #3324 - prevent crash asserting on possibly-undefined variable
2020-05-08 14:21:10 -04:00
Brown
65b4263315
Fix #3320 - add final flag to pseudo methods where appropriate
2020-05-08 07:28:12 -04:00
Brown
4295f9525f
Fix #3313 - add check for very specific pattern
2020-05-07 12:30:15 -04:00
Brad Kent
18ee440e3f
update mysqli_stmt::__construct signature ( #3315 )
2020-05-07 12:08:22 -04:00
Brown
20bcfb096a
Fix #3305 - use the same issue type for short closures as closures
2020-05-06 09:57:02 -04:00
Brown
a089d8bd58
Fix #3296 - propagate final flag to static calls in return types
2020-05-03 20:42:06 -04:00
Matthew Brown
dc64d4b1ca
Support evaluation of boolean conditionals in scanning stage
...
Fixes #3290
2020-05-03 10:44:00 -04:00
Matthew Brown
23b0a18632
Fix property type
2020-05-03 10:22:52 -04:00
Matthew Brown
b69c37acdf
Simplify logic around evaluating expressions a little
2020-05-03 10:19:15 -04:00
Brown
d99fbc0d4d
Remove blank line
2020-05-03 00:26:50 -04:00
Brown
b8a1f5d5c9
Allow destructuring on arrayaccess implementers
2020-05-03 00:08:03 -04:00
Brown
bf5e178d16
Fix #3289 - treat property on non-generic type like actual value
2020-05-02 23:37:59 -04:00
Brown
618a54ff41
Fix #3240 - check arguments when class cannot be found
2020-05-02 22:13:59 -04:00
Brown
aceaf6c356
Fix #3217 - don’t override abstract return type with parent one
2020-05-02 21:57:53 -04:00
Brown
d3fba74f75
Fix false-positive
2020-05-02 21:56:28 -04:00
Brown
3e0c4cfb75
Fix #3210 - prevent possibly-null array access from destructure
2020-05-02 20:36:41 -04:00
Brown
132b5c9358
Fix #3263 - inherit magic properties when using @mixin
2020-05-02 19:57:38 -04:00
Brown
29741cd76d
Remove earlier now-unnecessary fix
2020-05-02 19:24:48 -04:00
Matthew Brown
da5e8a4324
Increase type coverage for projects that use assert after mixed
2020-05-02 14:55:30 -04:00
feek
c5319fc379
fix: mixin parameter of self should be properly resolved ( #3280 )
...
Co-authored-by: Matthew Brown <github@muglug.com>
2020-05-02 14:32:43 -04:00
Brown
07e5250292
Fix #3273 - add support for func_num_args() in conditional type
2020-05-01 16:02:53 -04:00
Brown
0d8b56dc78
Fix return type coalescing for conditional return types
2020-05-01 13:04:48 -04:00
Brown
6024447ca0
Expand function-based template types before comparing against inherited
...
Fixes #3276
2020-05-01 12:40:10 -04:00
Brown
5e76467378
Fix #3279 - make sure self/parent references in mixin use existing class
2020-05-01 11:23:02 -04:00
Brown
117a4d4d40
Require callable() have a return type when in conditional
...
Fixes #3260
2020-04-30 23:35:13 -04:00
Brown
bb1c8a9d74
Don’t clobber intersection types after generic in union
...
Fixes #3274
2020-04-30 23:15:16 -04:00
Brown
470bf807b7
Add better handling of expression termination
2020-04-30 22:23:37 -04:00
Brown
9e6797d297
Add protection from ComplicatedExpression
2020-04-30 22:23:07 -04:00
Brown
ce8fb459e9
Allow complex types in conditional is expressions
...
Ref #3277
2020-04-30 22:02:37 -04:00
Brown
8ab5a0f504
Probably safe to un-negate a class string assertion without autoloader
2020-04-30 12:48:21 -04:00
Brown
21f4deed3b
Fix #3268 - infer generator return for closure
2020-04-29 16:52:37 -04:00
Brown
555f525038
Add type
2020-04-29 14:58:48 -04:00
Brown
891c66650b
Prevent unintersectable template lower bounds
...
Ref #3264
2020-04-29 14:57:57 -04:00
Andrii Dembitskyi
d3fd9a6acf
Fix #3265 ( #3267 )
...
We should add function body
2020-04-29 12:30:04 -04:00
Brown
e782329821
Add slashes
2020-04-28 23:42:53 -04:00
Brown
63c190ff83
Fix #3257 - refine as type and clone where necessary
2020-04-28 22:26:54 -04:00
orklah
8571746f8a
Add hook for plugins after FunctionLikeAnalysis ( #3258 )
2020-04-28 15:30:51 -04:00
Brown
a0667f1543
Remove accidentally-added interface
2020-04-28 15:27:09 -04:00
Brown
05ff8d0142
Prevent invalid [] brackets in tree
...
Fixes #3246
2020-04-28 15:18:50 -04:00
Brown
a402d4598b
Define with single argument should not trigger a notice
...
Fixes #3254
2020-04-28 14:43:12 -04:00
Brown
d56c5c9782
Fix #3256 - fix parsing of colons in callable inside conditional
2020-04-28 10:55:17 -04:00
Grégoire Paris
1fb1c2195d
Allow non-string keys ( #3221 )
...
Although it would be stupid to provide an array with exclusively
non-string keys, it's possible to have an array with a bit of both.
See for instance
155d028be0/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php (L263-L276)
2020-04-27 22:49:07 -04:00
Brown
f0487c216d
Add slash
2020-04-27 09:50:27 -04:00
Brown
95dbb93732
Fix #3237 - allow mixin to reference generic params
2020-04-27 09:10:24 -04:00
Brown
189cd2bdc8
Fix key stringg
2020-04-27 00:50:07 -04:00
Brown
755ada9114
Fix #3234 - infer iterator key types properly
2020-04-27 00:41:34 -04:00
Brown
f91e94b64e
Make sure to remember correct positions of @var references
2020-04-27 00:05:20 -04:00
Brown
10f3bef743
Fix type check
2020-04-26 20:21:24 -04:00
Brown
e65bffc94f
Support intersections with __toString
...
Fixes #3149
2020-04-26 20:04:41 -04:00
Fabien Villepinte
5087feff79
Fix #2845 - FunctionReturnTypeProvider for sscanf ( #3233 )
...
Co-authored-by: Fabien Villepinte <fabien.villepinte@displayce.com>
2020-04-26 17:36:44 -04:00
Brown
ebcb0b8cc4
Fix #3228 - support IteratorIterator wrapping
2020-04-26 16:59:03 -04:00
Brown
d88c31f461
Support templated @mixin
2020-04-26 16:49:52 -04:00
Brown
83fe3a2fd9
Complain about malformed @property annotation
2020-04-26 10:10:14 -04:00
Brown
e1c6fcc707
Fix #3215 - suppress PossiblyUndefinedMethod in synthetic call
2020-04-24 00:11:32 -04:00
Brown
e9666372d0
Fix coercion
2020-04-22 16:27:43 -04:00
Brown
507f5f4afa
Add context-sensitive conversion
2020-04-22 16:08:04 -04:00
Brown
a670aa7ddc
Fix #3214 - allow if/else branches of conditional to both be arrays
2020-04-22 16:07:13 -04:00
Brown
52c0346b65
Fix #3213 - make sure static is bound from a static call with set class
2020-04-22 11:34:46 -04:00
Fabien Villepinte
a93bf28532
Fix #3045 - ignore mixed assignments to variables named $_ ( #3211 )
2020-04-21 20:18:38 -04:00
still-dreaming-1
16fa208a60
Made compact's return array key type more specific ( #3209 )
2020-04-21 20:18:11 -04:00
Matthew Brown
1b752d06ab
Fix #3201 - add additional constraints on constructor initialisation
2020-04-21 00:04:47 -04:00
Brown
8f57d0c738
Fix #3204 - normalise function ids where possible
2020-04-20 21:38:35 -04:00
Grégoire Paris
e7b8983b7e
Make Throwable methods overridable ( #3203 )
...
Methods from \Exception cannot be overriden, but that does not mean
methods from \Throwable cannot be.
Closes #3202
2020-04-20 17:17:47 -04:00
Brown
6b42efed3f
Fix #3150 - only inherit docblock return when same type is returned
2020-04-20 09:22:58 -04:00
Brown
a3ae2a713b
Fix #3182 - don’t allow unnamespaced string references to functions in same context
2020-04-19 21:21:18 -04:00
Brown
6fc18af42e
Fix #3163 - map object-like arrays too
2020-04-19 18:46:24 -04:00
Brown
286c396498
Fix #3185 - allow ignore_user_abort calls
2020-04-19 13:19:18 -04:00
Brown
e55fe0a0e8
Fix #3188 - register global variables as by-reference ones
2020-04-19 13:15:04 -04:00
Brown
bb46c30e38
Fix #3191 - don’t generate complex assertion from class-string
2020-04-19 12:53:50 -04:00
Brown
2188b6736f
Fix #3162
...
Descend into inherited templates to prevent function-defined templates mapping inappopriately
2020-04-19 12:19:39 -04:00
Brown
3e07684855
Fix iterable coercion for Traversable-extending types
...
Fixes #3159
2020-04-19 09:15:20 -04:00
vladyslavstartsev
d8a4030a21
added right types for BCMath functions and GMP functions ( #3189 )
2020-04-19 08:04:11 -04:00
Brown
d2d795018f
Fix #3138 - fix inherited property template type inference
2020-04-18 16:57:13 -04:00
Brown
ddbc1d2763
Yet again fix handling of nested template resolution and comparison
2020-04-18 13:02:55 -04:00
Brown
edb07952fc
Static call inside throw does not violate purity
2020-04-18 12:43:51 -04:00
Brown
7af771a006
Fix #3132 - resolve array access in constant properly
2020-04-18 12:39:00 -04:00
Brown
61f5a06a7b
Fix #3174 - always scan @mixin classes
2020-04-18 11:57:25 -04:00
Brown
8ba642f408
Fix bad param
2020-04-18 11:54:17 -04:00
Brown
b0455adced
Fix #3177 - prevent crash by using inherited templates
2020-04-18 11:48:22 -04:00
Brown
5180ce1f54
Improve template assertion reconciliation
...
Fixes #3144
2020-04-18 11:22:06 -04:00
Grégoire Paris
b47306ad3b
Account for PDOException ( #3175 )
...
Probably for legacy reasons, PDOException::getCode() can return string (it's an
SQLSTATE code). Note that if you instantiate it yourself, you will get
an integer though.
I changed the signature of the Exception stub accordingly, and then
there were errors about incompatible signatures, so I had to change the
signature of Throwable too, which makes sense since a Throwable could be
a PDOException. The signature at
https://www.php.net/manual/en/throwable.getcode.php seems plain wrong,
and that same page of the docs warns about PDOException. Not sure what
are the plans for future versions of PHP.
2020-04-18 10:39:23 -04:00
Brown
e699004dab
Improve names a little
2020-04-18 00:59:16 -04:00
Valentin Udaltsov
9b8e8ab964
Support non-empty-arrays in array_keys ( #3168 )
...
Closes #3160
2020-04-18 00:56:54 -04:00
Brown
d54f9bca17
Allow nested template resolution
2020-04-18 00:56:24 -04:00
Grégoire Paris
bc91de015e
Mark throwable methods as pure ( #3171 )
...
* Write stub as valid PHP
This works probably because it is not parsed by PHP but by something
more tolerant, but let's make it more valid (the final access type in
the signature is not valid) PHP anyway, that will raise fewer eyebrows.
* Document actual return type
See ca006e54e3/Zend/zend_exceptions.stub.php (L8)
* Mark all methods from Throwable as mutation free
Exception is the only possible class implementation of Throwable, and
all of its methods except __toString() are final.
See ca006e54e3/Zend/zend_exceptions.stub.php (L3-L25)
Closes #3170
2020-04-17 22:08:26 -04:00
Matthew Brown
aa29c7fc9e
Revert "Support non-empty-arrays in array_keys ( #3168 )" ( #3172 )
...
This reverts commit a280e57ecf
.
2020-04-17 16:52:08 -04:00
Valentin Udaltsov
a280e57ecf
Support non-empty-arrays in array_keys ( #3168 )
...
Closes #3160
2020-04-17 15:07:41 -04:00
Jáchym Toušek
4aac3767f5
Update ext-ds.php ( #3165 )
2020-04-17 15:07:16 -04:00
Brown
7a759915ee
Add arg
2020-04-17 14:40:42 -04:00
Brown
b6fd821172
Fix broken build
2020-04-17 14:39:33 -04:00
Brown
aa3846758e
Fix #3153 - narrow template types in conditional branches
2020-04-17 09:53:58 -04:00
Brown
e53c79b66e
Break out SimpleNegatedAssertionReconciler
2020-04-17 09:28:42 -04:00
Brown
edc164c549
Simplify conditionals a little
2020-04-17 09:10:33 -04:00
Brown
239234e803
Migrate simple assertions to self-enclosed method
2020-04-17 08:59:15 -04:00
Brown
5ef82b53f6
Fix #3137 - support nested templates in class definitions
2020-04-17 01:16:15 -04:00
Brown
1309eece2e
At the very least interpret nested templates as templates
2020-04-17 00:56:11 -04:00
Anthony Rainer
6f36f33630
Added new language server options and functionality. ( #3161 )
...
* Added new language server options and functionality.
Added new extended diagnostic code information to the language server.
-- It must be enabled via a command line switch.
Added telemetry data for language server initialization and operation.
Added verbose log messages for language server.
-- It must be enabled via a command line switch.
* fixed phpcs issues
* fixed failing tests
* changed the language server reported error code to be the help link
Co-authored-by: Anthony Rainer <0@0ze.ro>
2020-04-17 00:47:18 -04:00
Brown
35d376cbe7
Fix #3164 - allow nested templates in conditional classes
2020-04-17 00:46:27 -04:00
Matthew Brown
6f28ee684a
Fix #3156 - only override existing property types with @property suggestions
2020-04-16 00:22:00 -04:00
Jáchym Toušek
7841581122
Update ext-ds.php ( #3146 )
2020-04-15 07:31:17 -04:00
Brown
2e4aaac5bb
Add better inference for date calls
2020-04-14 21:07:44 -04:00
Matthew Brown
e4bfe9e6be
Fix #3142 - array_unique should remove count info
2020-04-14 11:08:45 -04:00
Brown
8533b866ab
Simplify template bounds message
...
Ref #3126
2020-04-12 22:19:49 -04:00
Brown
e17cfd8dba
Fix #3125 - only apply clauses where applicable
2020-04-12 21:50:10 -04:00
Brown
633b210a32
Fix test
2020-04-12 21:47:50 -04:00
Brown
73f8f963fa
Expand out class constants as early as possible
...
Fixes #3128
2020-04-12 20:38:36 -04:00
Brown
15df39f72f
Fix #3127 - allow templated param to be accepted where static is expected
2020-04-12 20:09:49 -04:00
Brown
5988149272
Prevent checking assertions on $this-> types, always accessible
2020-04-12 14:13:42 -04:00
Brown
c733d6d373
Only perform assertions where the property type is known
...
cc @m0003r
2020-04-12 12:56:33 -04:00
Brown
95ec189e0b
Remove Amp stubs
2020-04-12 11:47:10 -04:00
Brown
370ffa28e4
Fix #3117 - invalidate all caches when composer lockfile changes
2020-04-12 11:41:37 -04:00
m0003r
77270dc9b7
Getters automagic ( #3122 )
...
* When method is a plain getter: (1) correct method return type if property type is known (2) auto assert-if-true that corresponding property is not falsy
* do not use getter automagic if getter is overridden somewhere
2020-04-12 08:40:24 -04:00
Brown
ee50542b8f
Allow users to disable caching full files
2020-04-12 08:34:57 -04:00
Brown
9d2957d339
Fix a few more edge-cases
2020-04-12 01:26:11 -04:00
Brown
7dfa37beb2
Improve ergonomics of array assignment
2020-04-11 17:50:24 -04:00
Brown
d530fce4b3
Fall through with PossiblyInvalidIterator issue
2020-04-11 11:17:54 -04:00
Brown
739f2c7faf
Fix array key type
2020-04-11 08:12:28 -04:00
Brown
db7447abd7
Make array coercion-to--mixed rules a little more lenient
2020-04-10 16:21:48 -04:00
Brown
672baea6fc
Fix #3116 - allow class to be compared to a templated class-string
2020-04-10 00:26:11 -04:00
Brown
556d5625b5
Prevent Throwable being intersected with itself
2020-04-10 00:10:31 -04:00
Brown
fea1310d67
Fix #3092 - round always returns a float
2020-04-09 23:31:26 -04:00
Brown
f4a6b24e34
Fix style errors
2020-04-09 23:24:52 -04:00
m0003r
1749c19a29
Fix $assertion_var_id calculation in method calls ( #3115 )
2020-04-09 23:03:53 -04:00
Brown
09663b5938
Fix #3095 - allow intersection of arrays after assertions
2020-04-09 23:02:28 -04:00
Brown
13d9354cde
Fix #3107 - prevent bad @method with dash
2020-04-09 12:16:58 -04:00
Brown
3a4dd70403
Prevent MixedMethodCall from generated array offsetGet calls
2020-04-09 11:45:15 -04:00
Brown
bd92ec6cd3
Detect nested issues
2020-04-09 10:42:54 -04:00
Brown
bd2104c5ba
Merge with mixed in nested arrays
2020-04-09 09:27:21 -04:00
m0003r
4d1be3f0c4
Allow plain assertions (@psalm-assert) about $this ( fixes #3105 ) ( #3108 )
...
* Allow plain assertions (@psalm-assert) about $this (fixes #3105 )
* Fix multiple assertion combining
* Fix multiple assertion combining for $this again
* Add test for multiple assertion combining for $this again
2020-04-09 08:15:07 -04:00
Mikko Pesari
184be78405
Update mysqli property maps ( #3114 )
...
From ca92e03c12/src/Phan/Language/Internal/PropertyMap.php
2020-04-09 08:14:09 -04:00
m0003r
28f740fddb
@psalm-trace is now a specific low-level issue, because plain debug print breaks structured output (after #3080 ) ( #3106 )
2020-04-08 21:03:05 -04:00