1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00
Commit Graph

84 Commits

Author SHA1 Message Date
AndrolGenhald
3aea0987ef Fix non-empty encapsed string check. 2022-06-24 20:28:04 -05:00
AndrolGenhald
2559222f67 More interpolation and concatenation improvements. 2022-06-24 19:22:59 -05:00
rarila
97e6511fab Set number of lines before and after namespace. 2021-12-15 04:58:32 +01:00
AndrolGenhald
b29fc6ad3c Allow operator overloading for Decimal extension (fixes #3938). 2021-12-08 10:59:37 -06:00
ralila
8fb2e0f885 Handle some partials 2021-12-04 21:55:53 +01:00
ralila
711be643c6 Import instead of using fqn exceptions 2021-12-03 20:29:06 +01:00
ralila
245920e53c Import instead of using fqn 2021-12-03 20:11:20 +01:00
ralila
fdaed941ad use return type hints instead of php doc "@return void" 2021-11-26 20:59:41 +01:00
orklah
ad57516765 create a temporary var for coalescing ternaries 2021-11-05 20:07:35 +01:00
orklah
e2bb9859e4 fix tests 2021-11-01 22:27:43 +01:00
orklah
85d65d35e9 restrict the test because int size is fixed on runtime environment 2021-09-23 21:24:17 +02:00
Bruce Weirdan
82dfbbc12e
Merge pull request #6167 from orklah/non-div-with-numeric-and-int 2021-07-25 13:56:48 +03:00
orklah
55245cf558 Arithmetic operation between numeric and int or float gives int|float 2021-07-25 12:29:11 +02:00
orklah
9189fa1745 add tests and code for handling LiteralString that are Numeric 2021-07-24 21:21:50 +02:00
orklah
c225281d22 add test 2021-07-23 21:22:00 +02:00
Grégoire Paris
26f8e5b333
Add negated identity with false case
This is the opposite of === true and works the same.
2021-07-17 03:20:23 +03:00
Matt Brown
9dde8eed9d Add support for literal-int annotations as well 2021-06-14 23:24:09 -04:00
Matt Brown
c3fdfc5795 Support literal ints in encapsed strings 2021-06-14 16:30:45 -04:00
Matt Brown
5ae8b2a23f Add preliminary support for literal-string 2021-06-14 15:30:25 -04:00
Bruce Weirdan
a97bc06e6b
Test for boundary conditions 2021-06-13 13:40:54 +03:00
BafS
d395e00f18
Add assertion 2021-06-13 12:07:34 +02:00
BafS
dde0f1fb06
Fix Uncaught TypeError with some shifts 2021-06-11 20:03:23 +02:00
Bruce Weirdan
6abce3525a
Enforce use sort (#5900) 2021-06-07 22:55:21 -04:00
orklah
4c4d574bed
better inference of string increment (#5777)
* better inference of string increment

* fix combination
2021-05-17 07:44:53 -05:00
orklah
6501ca7b95
Redundant cast to Int preserve type (#5773)
* Redundant cast to Int preserve type

* add test
2021-05-15 07:19:18 -04:00
AndrolGenhald
d022910599
ConcatAnalyzer improvements and non-falsy-string fixes. (#5544)
* ConcatAnalyzer improvements.

Deduplicate code.
Improve type inference.
Allow literal type inference when only one side has multiple types (fixes #5483).
Fix invalid type inference with negative int as right operand.

* Fix inference to be lowercase-string when concatenating int.

* Fix TNonEmptyLowercaseString to not be subtype of TNonFalsyString.

'0' is a non-empty-lowercase-string that is falsy.

* Fix other issues with non-falsy-string.

* Nest ands and ors

Co-authored-by: Matthew Brown <github@muglug.com>
2021-03-31 23:16:21 -04:00
orklah
adc5368b97
fix Int overflow for pow (#5510) 2021-03-29 15:09:44 -04:00
AndrolGenhald
d4590711d6
Fix object-like array keys when combining string and automatic keys (fixes #5427). (#5428)
* Fix object-like array keys (fixes #5427).

* Fix incorrect return types for tests.

* Fix false positive list with literal int key.
2021-03-19 21:44:44 -04:00
orklah
cddef00692
fix int overflow (#5369) 2021-03-12 13:24:00 -05:00
orklah
7b24552534
Fix not always positive bit operations (#5233)
* Fix not always positive bit operations

* Fix not always positive bit operations

* add test
2021-02-15 23:10:42 -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
bcc378bd20
handle concatenation with int parts (#4938) 2021-01-06 09:01:53 -05:00
orklah
c47230c690
Infer result of modulo 1 operation statically (#4926) 2021-01-03 16:56:04 +00:00
orklah
a760a2418a
support shift and bitwise operations in constants (#4740) 2020-11-29 21:43:49 -05:00
erikjwaxx
25d8c6d21e
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
2020-11-23 13:10:51 -05:00
Matt Brown
5ad1e80e99 Fix #4527 - improve interpolated string types 2020-11-11 00:38:26 -05:00
Matt Brown
be1cd5275e Fix #4349 - improve types for suggested unions 2020-10-16 17:56:31 -04:00
Matt Brown
bb7d7132f7 Do arithmetic for preg_split arguments 2020-10-12 20:26:02 -04:00
Matt Brown
443025eab8 Fix addition of int and string type 2020-10-07 18:01:41 -04:00
Matt Brown
14efde286f 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
2020-09-30 12:28:13 -04:00
orklah
ead107fa9e
More return types (#4173)
* add native return types

* redundant phpdoc
2020-09-12 11:24:05 -04:00
Brown
f9815d6e83 Fix modulo test 2020-08-29 11:47:34 -04:00
Brown
df0d426f61 Fix #4081 - better inference of positive ints 2020-08-28 16:38:50 -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
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