1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
Commit Graph

54 Commits

Author SHA1 Message Date
orklah
61b7975850
Calculate more literal values (#5032)
* try to calculate more literal values

* add test

* improve test
2021-01-29 11:47:32 +01:00
orklah
a17e403270
handle concatenation with int parts (#4938) 2021-01-29 11:47:27 +01:00
orklah
e949ed68ac
Infer result of modulo 1 operation statically (#4926) 2021-01-29 11:47:25 +01:00
orklah
5f9aff5734
support shift and bitwise operations in constants (#4740) 2021-01-29 11:47:07 +01:00
erikjwaxx
62ca9f42bc
Narrow inference of $a <=> $b from "int" to "-1|0|1" (#4680)
* A <=> operator has a literal type of -1|0|1 and not simply int

* Test to verify inferred type of $a <=> $b is -1|0|1
2021-01-29 11:46:23 +01:00
Matt Brown
f3b6846c70
Fix #4527 - improve interpolated string types 2021-01-29 11:46:08 +01:00
Matt Brown
da79106a6a
Fix #4349 - improve types for suggested unions 2021-01-29 11:39:57 +01:00
Matt Brown
278a306681
Do arithmetic for preg_split arguments 2021-01-29 11:39:53 +01:00
Matt Brown
f1be27b18a
Fix addition of int and string type 2021-01-29 11:39:50 +01:00
Matt Brown
63953d5676
4.x - refactor unused variable detection
This turns unused variable detection into an explicit control-flow problem, where before we had a more simplistic mark-and-sweep algorithm
2021-01-29 11:39:44 +01:00
orklah
db45ff1ba4
More return types (#4173)
* add native return types

* redundant phpdoc
2021-01-29 11:38:57 +01:00
Brown
38cd48657f
Fix modulo test 2021-01-29 11:38:48 +01:00
Brown
9f246938ba
Fix #4081 - better inference of positive ints 2021-01-29 11:38:48 +01:00
Bruce Weirdan
dabfb16e34
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
2021-01-29 11:38:04 +01:00
Brown
6949a34ded Put RedundantIdentityWithTrue behind a flag cc @greg0ire 2020-07-30 10:25:59 -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
84945a7d1b Fix #3877 - prevent impossible subtr comparisons 2020-07-24 10:08:57 -04:00
Brown
27cb660377 Respect possibly-undefined array keys while merging
Fixes #3393
2020-05-19 20:10:01 -04:00
Brown
04bcc32efb Fix #2940 - fix array offset assignment under ??= 2020-03-09 14:09:41 -04:00
Matthew Brown
c75f7dc4d5 Fix #2339 - add support for null coalescing operator 2019-11-27 00:34:23 -05:00
Matthew Brown
51e552665e Fix #2061 - add config to allow suppression of string increment issues 2019-09-01 17:49:37 -04:00
LeSuisse
f29826b958 Fully qualify constants and function calls (#1849)
This should give a small performance boost.
Part of #1837.

The change is enforced via phpcs and can be autofixed
with phpcbf.
2019-06-26 16:52:29 -04:00
bugreportuser
8454c0db39 Support for bitwise not 2019-04-14 10:16:38 -04:00
Bruce Weirdan
9bdc9f774f More provider typing 2019-03-02 08:43:19 -05:00
Brown
601f303de2 Fix position of invalid param 2019-02-27 16:00:44 -05:00
SignpostMarv
4a56688800 adding DIRECTORY_SEPARATOR to tests that fail under windows 2019-02-06 14:29:10 -05:00
Matthew Brown
7e0928d775 Fix #833 - warn on some invalid operands 2019-01-13 10:15:15 -05:00
Matthew Brown
4688b25fd9 Move internal classes to own namespace 2018-11-12 11:20:59 -05:00
Matthew Brown
2065e0129e Fix #1069 - module arithmetic always returns ints 2018-11-07 08:45:26 -05:00
Matt Brown
dce8d14e1b Fix syntax errors in tests 2018-09-17 12:15:45 -04:00
Matthew Brown
6f96c661ef Fix #881 - skip tests if necessary test classes are missing 2018-07-16 20:52:58 -04:00
Matthew Brown
7d747be5d5 Fix checks for possibly null right part of binary op 2018-07-03 19:52:40 -04:00
Matt Brown
11240eb193 Fix #826 allow better template replacements 2018-06-19 13:19:41 -04:00
Matt Brown
2be0f68d87 Add better checks on increment/decrement operators 2018-06-18 13:16:51 -04:00
Matt Brown
5819ba2b67 Fix #801 - bust assertions on assignment in || op 2018-06-07 15:04:22 -04:00
Matthew Brown
dda9b4e48c Fix #783 - allow ternarys to declare vars 2018-05-31 22:00:11 -04:00
Matthew Brown
aac01f0670 Fix #766 and fix #765 - improve handling of ^ and xor 2018-05-28 20:31:20 +01:00
Matthew Brown
85c69f1335 Make sure div operations return GMP too 2018-05-05 13:14:59 -04:00
Matthew Brown
c39af03a01 Allow GMP to be converted to string 2018-05-05 13:04:27 -04:00
Matthew Brown
3718bd5c61 Fix GMP arithmetic operations 2018-05-05 12:59:30 -04:00
Matt Brown
b28cc19fd2 Fix bitwise operations on strings 2018-04-16 18:19:18 -04:00
Matt Brown
55153f9542 Fix #676 - bitwise operators didn’t have int return type 2018-04-16 16:36:06 -04:00
Matthew Brown
80cf80dbda Reduce number of InvalidOperand issues further 2018-03-18 16:58:54 -04:00
Matthew Brown
d7a585160f Add more granular error messages for invalid operands 2018-03-18 16:39:34 -04:00
Matt Brown
19ee843d6c Emit InvalidOperand if both sides are not numeric 2018-03-08 14:30:40 -05:00
Matthew Brown
d6909193ea Add additional formatting changes 2017-05-26 20:05:57 -04:00
Jon Ursenbach
11bc153deb Rewriting and streamlining every unit test with data providers. (#147)
* Rewriting and streamlining every unit test with data providers.

All unit tests have been rewritten into PHPUnit data providers
to reduce the amount of unnecessary code-reuse through out the
test suite.
2017-04-24 23:45:02 -04:00
Matt Brown
a7872472be Add stubbing tests and modify config initialisation 2017-01-31 19:22:05 -05:00
Matthew Brown
b3726c9de5 Use getcwd() for the project’s base, not the config file parent directory 2017-01-16 18:33:04 -05:00
Matt Brown
6e6106c080 Add docblocks to tests 2017-01-13 14:07:23 -05:00