1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 08:49:52 +01:00
Commit Graph

8006 Commits

Author SHA1 Message Date
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
Matthew Brown
d8e815ef6b
Limit to releases again 2021-01-11 15:51:26 -05:00
Matt Brown
ca2e51b3a9 Fix case for echo 2021-01-11 15:19:37 -05:00
Matthew Brown
51f0c58f3b Fix signing 2021-01-11 15:15:14 -05:00
Matt Brown
74c0bd3c19 Try siginig again 2021-01-11 15:05:16 -05:00
Matt Brown
e176786882 Use expliit key id 2021-01-11 14:58:30 -05:00
Matt Brown
00f3ccbb3a Maybe fix signing 2021-01-11 14:37:17 -05:00
Matt Brown
08f6a5c26d Don’t try to import local keys 2021-01-11 13:52:14 -05:00
Matthew Brown
076bf57c2a Change GPG key 2021-01-11 13:36:23 -05:00
Matthew Brown
0e8e44a986
Also push signed phar for master commits 2021-01-11 13:27:58 -05:00
Bruce Weirdan
7f9712dc92
Added GHA workflow to build phars (#4974) 2021-01-11 13:16:44 -05:00
Matt Brown
951afcf4af Fix #4982 - ensure destructuring assignments are seen inside a loop 2021-01-11 12:46:02 -05:00
Matt Brown
104647745b Fix #4955 - catch invalid passing class constant where templated class string expected 2021-01-11 00:28:44 -05:00
Bruce Weirdan
7007000a68
Allow Attribute::IS_REPEATABLE (#4971)
This allows Attribute::IS_REPEATABLE to be specified as attribute flag.

Fixes vimeo/psalm#4892, vimeo/psalm#4970
2021-01-10 21:55:06 -05:00
Matt Brown
59bea26bb8 Add non-emptiness check 2021-01-10 21:54:49 -05:00
Matt Brown
e299e914f8 Fix #4958 - honour template as inheritance when comparing template types 2021-01-09 18:58:29 -05:00
Matt Brown
6ef0f2e63e Fix #4943
Prevent input types becoming part of the inferred generic params when a match is found
2021-01-09 18:08:02 -05:00
Bruce Weirdan
c1a710999c
Skip conditional includes when registering autoload files (#4967)
This should allow analysis of forward-compatible polyfills used in
codebases targeting older PHP versions.

The following previously problematic polyfills should now emit no parse
errors:

* `symfony/polyfill-ctype`
* `symfony/polyfill-intl-grapheme`
* `symfony/polyfill-intl-normalizer`
* `symfony/polyfill-mbstring`

The pattern that is now works as intended looks like this:
```php
if (\PHP_VERSION_ID >= 80000) {
    require __DIR__ . '/bootstrap80.php';
    return;
}
```

Previously Psalm would scan the required file even when codebase
targeted older PHP versions, and would emit parse errors when that file
contained PHP 8 syntax.

Fixes #4961 and #4965
2021-01-09 16:14:58 -05:00
Bruce Weirdan
f795906187
Removed misc files from dist archives (#4968) 2021-01-09 16:14:08 -05:00
Adrien LUCAS
493c57eedf
Trigger dispatch even when only legacy hooks (#4962) 2021-01-08 19:51:26 -05:00
Bruce Weirdan
fac9e46ba8
Correct gzread signature (#4960)
Fixes vimeo/psalm#4959
2021-01-08 19:50:10 -05:00
Adrien LUCAS
d1398f2b12
Avoid false positives for taint specialized calls even when not using a variable (#4948) 2021-01-07 16:39:51 -05:00
Matthew Brown
ec4c7bde73
Fix #4951 - add Traversable interface to PDOStatement 2021-01-07 15:53:19 -05:00
Matt Brown
603ecadbb7 Fix #4945 - use assertion string for scalar templated assertions 2021-01-07 10:27:35 -05:00
orklah
0e17a3354f
add stubs for standard iterators (#4725)
* add stubs for standard iterators

* Apply suggestions from code review cc @weirdan

Co-authored-by: Bruce Weirdan <weirdan@gmail.com>

* complete stub + delete code made redundant by stubs + fix some syntax in stubs

* fix parse error

Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2021-01-07 10:07:07 -05:00
orklah
81e557e3a8
adds statements list in the event (#4835) 2021-01-07 09:04:50 -05:00
orklah
1bbcbddfcf
pass args through event (#4864) 2021-01-07 09:02:05 -05:00
Matthew Brown
e1c8050850
Update language_server.md 2021-01-07 08:48:33 -05:00
Adrien LUCAS
0f5886746f
Taint specialized calls even when not using a variable (#4940) 2021-01-06 14:14:52 -05:00
Matt Brown
7ffea7c425 Fix #4917 - allow array_reduce to be called with a single arg 2021-01-06 12:59:51 -05:00
orklah
665170eadb
add ArrayAccess to SimpleXmlElement (#4934)
* add ArrayAccess to SimpleXmlElement

* add test
2021-01-06 09:44:12 -05:00
orklah
f9fccb2b2d
implement DTO for plugins (#4881)
* implement DTO for plugins

* introduce EventHandler + reintroduce legacy API for plugins
2021-01-06 09:05:53 -05:00
orklah
bcc378bd20
handle concatenation with int parts (#4938) 2021-01-06 09:01:53 -05:00
Matthew Brown
3fd47f9e10 Add comments to AtomicMethodCallAnalyzer and suppress ComplexMethod 2021-01-05 19:03:50 -05:00
Matthew Brown
0533ce61cb Break apart type combiner 2021-01-05 18:33:33 -05:00
Matthew Brown
b1028adc5a Break out large chunk to simplify function 2021-01-05 17:50:23 -05:00
Matthew Brown
13497b8d2b Break out parent and implemented class checks 2021-01-05 17:49:55 -05:00
Matthew Brown
e4b1a4fa55 Uncomment erroneously-commented return 2021-01-05 17:49:17 -05:00
Matthew Brown
630f646bd4 Break out large chunk 2021-01-05 17:47:15 -05:00
Matthew Brown
b3b2389aff Ignore recently-deleted files for scanning 2021-01-04 19:00:44 +00:00
orklah
c47230c690
Infer result of modulo 1 operation statically (#4926) 2021-01-03 16:56:04 +00:00
Lukas Bestle
0397564f6b
PHAR: Include issue docs for SARIF output (#4925)
The SARIF report uses the Markdown files inside `docs/running_psalm/issues` for its output, so the files should be included in the PHAR.
2021-01-03 16:54:52 +00:00
Lukas Bestle
2d17b744ce
SARIF report: Include help links (#4924) 2021-01-03 01:45:21 +00:00