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

8048 Commits

Author SHA1 Message Date
Matt Brown
62a5a74640 Fix #5108 - prevent crash on 0 type 2021-01-26 14:06:43 -05:00
Matt Brown
0624098865 Ensure getId() output can always be parsed as a type
Ref #5105
2021-01-25 23:41:51 -05:00
Matthew Brown
0b2c62de50
Remove ProxyManager run 2021-01-25 22:04:29 -05:00
sji
f1123d0ccc
Fix wrong comments in CallMap_80_delta.php (#5104) 2021-01-25 11:05:13 -05:00
sji
4b9003ae9c
Bump the CURRENT PHP TARGET VERSION to 8.0 in CallMap.php (#5103) 2021-01-25 11:04:57 -05:00
sji
e61daf5c2f
Fix CallMap of PDOStatement for PHP8 (#5100)
The definitions are based on the php-src stub. 4bbb98c24f/ext/pdo/pdo_stmt.stub.php
2021-01-25 11:04:30 -05:00
Oliver Hader
546283b71a
Update documentation for taints and global configuration (#5098)
* [DOCS] Extend documentation on global variables configuration

* [DOCS] Synchronize meaning of @psalm-taint-source input with source code

* [DOCS] Add documentation for conditional @psalm-taint-escape

* [DOCS] Add documentation for @psalm-taint-unescape
2021-01-25 11:04:00 -05:00
Matt Brown
ae172b2c04 Removing proxymanager from test-with-real-projects for the time being 2021-01-24 15:00:21 -05:00
Matt Brown
1ea49e0544 Fix composer location 2021-01-24 14:42:36 -05:00
Matt Brown
34fe82caad Add intl extension for composer install 2021-01-24 14:14:19 -05:00
Matt Brown
dc7ffe2810 Fix long line 2021-01-24 14:02:55 -05:00
Bruce Weirdan
3209ef76fe
Remove ReflectionType::getName(), move ReflectionType::isBuiltin() (#5090)
* Remove ReflectionType::getName(), move ReflectionType::isBuiltin()

* `ReflectionType::getName()` was never there: https://3v4l.org/1iZt4
* `ReflectionType::isBuiltin()` was moved to
`ReflectionNamedType::isBuiltin()` in PHP 8

Fixes vimeo/psalm#5089

* Fix test

* Mark test as php 8.0 only
2021-01-24 13:31:10 -05:00
Bruce Weirdan
0489dd1fd8
Use separate exit code to indicate Psalm finding issues (#5087)
* Use separate exit code to indicate Psalm finding issues

This will allow to distinguish successful run that found some issues
from crashes.

* Fix e2e test expectations

* Documented exit statuses
2021-01-24 13:30:35 -05:00
Joe Hoyle
531cd36767
Support completions on class references (#5085)
* Support compleitions on class references

This provides completions on class references (as opposed to initiated objects via the type map), so you can do `MyClass::` and get completitions for static methods and constants etc.

* Only provide completions for references that don't exist
2021-01-24 13:29:21 -05:00
orklah
b61831345c
only transform a Keyed array into callable-array if there's two elements (#5086)
* only transform a Keyed array into callable-array if there's two elements in array

* add tests
2021-01-22 16:14:29 -05:00
Joe Hoyle
ba43e6d0f3
Remove file map cache when re-analyzing files (#5084)
* Remove file map cache when re-analyzing files

When the project is re-analyzed under the single thread condition (not using a process pool), the filemaps are not cleared before re-analyzing files. This means that file maps only get appended to. If you delete the contents of a file via the LSP, the file map will still be populated with all the old values for example.

In doing this I had to write a few more tests to check my assumptions too, so adding those additional tests.

* Rename test

* Formatting

* Formatting again!
2021-01-22 16:05:28 -05:00
Adrien LUCAS
6f1f680b2d
Add option to dump taint graph (#5080)
* Add option to dump taint graph

* Fix types

* Simplify types

Co-authored-by: Matthew Brown <github@muglug.com>
2021-01-22 16:04:15 -05:00
Matt Brown
d97db0471c Make complex method break the build 2021-01-22 09:58:25 -05:00
Matt Brown
6f30399189 Fix #5070 – fix static return type inference in static methods 2021-01-22 09:58:09 -05:00
Matthew Brown
28d2795e59 Fix #5078 - when unpacking with missing array item, Use the param’s default type if param has one 2021-01-22 00:20:51 -05:00
Bruce Weirdan
d659957b88
Resolve class aliases when accessing properties (#5068)
* Resolve class aliases when accessing properties

* Moved Properties::getClasslikeStorage() to ClassLikes::getStorageFor()
2021-01-21 19:38:17 -05:00
Vincent Langlet
c912b6c2b9
Catch InvalidArgumentException (#5061) 2021-01-20 17:42:45 -05:00
Bruce Weirdan
d296c4bb9a
Add missing dataflow population in array spreads (#5059)
Fixes vimeo/psalm#5057
2021-01-20 17:42:11 -05:00
orklah
592f6794a8
fix wrong order of types (#5058) 2021-01-20 17:41:41 -05:00
81b75a7884
Check iterator types on yield from (#5042)
* Check iterator types on yield from

* Switch to NodeAbstract

* Make Foo iterable
2021-01-20 17:41:15 -05:00
orklah
9e0525439d
add createFromInterface in PHP 8 (#5055) 2021-01-19 17:22:25 -05:00
Bruce Weirdan
c2a324e610
Use composer autoloader during init (#5054)
Fixes vimeo/psalm#5048

The issue was caused by missing dependency of a class that Psalm tried
to inspect through reflection. Fixed by using composer autoloader which
avoids the need to use reflection.
2021-01-19 17:21:33 -05:00
Matt Brown
f1107ab4d9 Fix #5049 - assertion of !empty on bool makes true 2021-01-19 17:19:47 -05:00
Matt Brown
2f58c6afc8 Fix #5020 - remove previous catch var assertions when assigning inside catch 2021-01-17 14:28:28 -05:00
Matt Brown
bca58863ad Fix #5017 - handle combining literal and non-empty strings 2021-01-17 12:22:29 -05:00
Matt Brown
4378bec917 Fix #5025 - prevent crash in assert function during reflection 2021-01-17 12:08:19 -05:00
Matt Brown
3049301da8 Fix #5028 - avoid false-positive on dynamic property fetch after ternary 2021-01-17 11:59:59 -05:00
Lukas Bestle
fdb181fe00
Stubs: Don't explicitly depend on \Stringable (#5037)
Fixes #5007.
2021-01-17 10:56:24 -05:00
orklah
72c21c5fa6
Calculate more literal values (#5032)
* try to calculate more literal values

* add test

* improve test
2021-01-17 10:55:32 -05:00
orklah
7997766e8b
use coherent annotations (#5031) 2021-01-17 10:54:45 -05:00
Matt Brown
ef0d19ed9f Fix #5029 - remember staticness of types when combining 2021-01-16 01:12:18 -05:00
Daniele Santini
df4a541c97
Add codeclimate.json report (#5030) 2021-01-16 00:48:35 -05:00
Matt Brown
9fd7a7d885 Only create after analysis event if they exist
Fixes #5008 - this does some git execing, so we don’t want it to always run
2021-01-14 16:44:29 -05:00
orklah
7a40443ffb
don't throw InvalidArrayOffset when dealing with templates (#5019) 2021-01-14 16:35:06 -05:00
orklah
26f756d244
remove signature return types in stubs (#5014)
* remove return types from signatures for some stubs

* fix duplicate type
2021-01-14 16:34:22 -05:00
Thomas Bley
080cf61064
fix #5010 function exec() is disabled (#5012)
* fix #5010 function exec() is disabled

* Improve error message

Co-authored-by: Thomas Bley <thomas.bley@bringmeister.de>
Co-authored-by: Matthew Brown <github@muglug.com>
2021-01-14 16:33:49 -05:00
Matt Brown
ef4afd72bc Unset should change array with keyed offsets 2021-01-13 18:10:59 -05:00
Matt Brown
d10a06837d Fix #5001 - update variables after context after type change from empty
Empty is the invalid state, and some old logic here was causing a bug
2021-01-13 11:35:52 -05:00
Marco Pivetta
a53cc23809
#4997 added more precise type inference for count() returning 0 or positive-int on known arrays (#4999)
* #4997 added more precise stub for `count()` returning `0` or `positive-int` on known types

* #4997 updated `count()` to support `\SimpleXmlElement` and `\ResourceBundle` counting, as well as handling hardcoded 2-element-arrays cases

This patch:

 * adds support for `count(\SimpleXmlElement)` (https://www.php.net/manual/en/simplexmlelement.count.php)
 * adds support for `count(\ResourceBundle)` (https://www.php.net/manual/en/resourcebundle.count.php)
 * removes usage of global constants from stub (not supported - see https://www.php.net/manual/en/function.count.php)
 * adds support for identifying fixed-element-count arrays, for example `count(callable&array)`, which is always `2`

* #4997 adapted `FunctionCallReturnTypeFetcher` to infer `TPositiveInt` for `count(TNonEmptyArray)` and `count(TNonEmptyList)`

* The `FunctionCallReturnTypeFetcher` is responsible for defining the precise type of a `\count(T)`
expression when given a `T`, so we baked the whole type resolution for `positive-int`, `0` and
`positive-int|0` directly in there.

While this complicates things, it is also true that it is not possible right now (for the stubs)
to provide the level of detail around `count()` that is required by the type inference system
for such a complex function with so many different semantics.
2021-01-13 09:48:38 -05:00
Matt Brown
1afce4d613 Improve treatment of strict equality 2021-01-12 12:07:36 -05:00
Matthew Brown
37fb081baa
Bump up to 8 concurrent builds 2021-01-11 18:19:11 -05:00
Matthew Brown
4e677c9cfb
So long Travis 2021-01-11 18:18:35 -05:00
Matt Brown
5beb3ad4b9 Simplify assertion when mixed 2021-01-11 17:45:03 -05:00
Ben Davies
53afd2857d
Split unit test over multiple jobs in GitHub Actions, lowering the total run time (#4985)
* Split unit test over multiple jobs in GitHub Actions, lowering the total run time

* rename FileManipulationTest to FileManipulationTestCase so it does not run as a standalone Test
2021-01-11 17:30:33 -05:00
Matt Brown
4faa6bb320 Fix #4976 - improve type narrowing 2021-01-11 17:14:23 -05:00