1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 09:47:29 +01:00
Commit Graph

4584 Commits

Author SHA1 Message Date
Maximilian Bösing
62b0a09741
qa: remove useless var annotation and the psalm suppression
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2021-11-15 19:06:33 +01:00
Maximilian Bösing
dac82e95dc
qa: re-enable skipped test for class constant assertions
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2021-11-15 18:49:51 +01:00
Maximilian Bösing
665cea7fbf
bugfix: prevent psalm from yelling about docblock type contradiction
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2021-11-15 18:36:04 +01:00
Maximilian Bösing
a2bf87b1fc
qa: ensure psalm is able to understand already verified types
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2021-11-15 18:31:28 +01:00
Maximilian Bösing
68abcaab5c
feature: extract class constant by wildcard detection into dedicated resolver
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2021-11-15 18:27:19 +01:00
Maximilian Bösing
3e1be794c4
refactor: expand test cases and optimize handling of invalid class-constant references
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2021-11-15 17:56:39 +01:00
Maximilian Bösing
1a543aecb9
qa: add namespace to test asset
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2021-11-15 17:56:04 +01:00
Maximilian Bösing
49624169a5
bugfix: reconcile class-constant
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2021-11-15 17:53:26 +01:00
Bruce Weirdan
608e8d11fa
Merge pull request #6922 from weirdan/cases-references 2021-11-15 11:49:47 +02:00
Bruce Weirdan
0a9154b8bb
Allow references to enum cases in class constants 2021-11-15 05:56:09 +02:00
ralila
2e1b7b4c70 Add some tests 2021-11-15 03:09:37 +01:00
Bruce Weirdan
45e1a1c69a
Merge pull request #6850 from gharlan/hyperlink 2021-11-14 23:20:09 +02:00
Bruce Weirdan
db181bfc08
Test links output 2021-11-14 23:07:00 +02:00
Bruce Weirdan
d61e31bbaf
Merge pull request #6912 from weirdan/mbstrotolower-produces-nonlowercase-strings-sometimes 2021-11-14 21:03:24 +02:00
Bruce Weirdan
58f60b4be0
Use correct constant in tests 2021-11-14 05:23:12 +02:00
Bruce Weirdan
f5b71a3a5f
Infer mb_strtolower() result as string when encoding is specified
`mb_strtolower()` may return characters we generally consider uppercase
when it's given the encoding argument. This PR makes Psalm to err on the
side of caution and treat the return type as `string` rather than
`lowercase-string` in this case

Refs vimeo/psalm#6908
2021-11-14 03:57:10 +02:00
Aaron Piotrowski
1bb204db76
Fix detecting readonly promoted property visibility 2021-11-13 12:54:15 -06:00
Aaron Piotrowski
d06510833b
Fix detection of readonly on promoted properties 2021-11-13 12:37:08 -06:00
Jonathan Vollebregt
f5d7f6c405 SimpleXMLIterator is not always truthy
Fixes #6865
2021-11-12 13:49:31 +01:00
orklah
2d0758ab10
Merge pull request #6899 from pilif/fix-6887
don't stop processing for class usage after raising an issue
2021-11-12 09:42:49 +01:00
Philip Hofstetter
ece2bccf76
don't stop processing for class usage after raising an issue
this fixes #6887
2021-11-12 09:24:39 +01:00
Bruce Weirdan
85f2083acb
Flag duplicate constants
Fixes vimeo/psalm#6882
Addresses p1 from vimeo/psalm#6471
2021-11-11 00:44:17 +02:00
Philip Hofstetter
038df9cebe
detect unevaluated inline-html code after an rearly return
this is a followup after #6876

this fixes #6877
2021-11-10 13:11:50 +01:00
Philip Hofstetter
f407ac846a
do not treat __halt_compiler() as an expression being executed
this fixes #6875
2021-11-10 12:45:12 +01:00
orklah
a193ec4573
Merge pull request #6874 from orklah/fix-never-combination
fix never combination
2021-11-09 23:18:58 +01:00
orklah
de443192c7
Merge pull request #6873 from orklah/ReturnTypeWillChange3
load the ReturnTypeWillChange stubs for all versions to allow using it on every PHP version
2021-11-09 23:18:07 +01:00
orklah
830c898fec
Merge pull request #6872 from orklah/InvalidDocblockPromotedProperties
allow signature type for promoted property as well as property docblock
2021-11-09 23:17:43 +01:00
orklah
db05dfeb4c fix never combination 2021-11-09 20:59:49 +01:00
orklah
b7e70f3cd7 load the ReturnTypeWillChange stubs for all versions to allow using it on every PHP version 2021-11-09 19:57:03 +01:00
orklah
d409c063f3 allow signature type for promoted property as well as property docblock (that will be used for param as well) 2021-11-09 19:38:18 +01:00
Thomas Bley
ca2fe166ee Added option to forbid eval() in codebase #6855 2021-11-07 21:06:22 +01:00
Bruce Weirdan
756be3b80c
Merge pull request #6843 from weirdan/enums-as-attributes 2021-11-07 17:53:19 +02:00
Bruce Weirdan
17ef25acd8
Merge pull request #6845 from sasezaki/cs_SelfMemberReference 2021-11-07 17:41:45 +02:00
orklah
4e6cb75094
Merge pull request #6848 from orklah/taint-comments
Taint comments
2021-11-07 15:55:37 +01:00
orklah
39dc7608ef ignore comments after taint-sink 2021-11-07 10:29:08 +01:00
orklah
3322801903 ignore comments after taint-sink 2021-11-07 10:17:25 +01:00
sasezaki
5a01c8d601 Added phpcs SelfMemberReference rule, and applied 2021-11-07 15:47:39 +09:00
Bruce Weirdan
68495be147
Forbid declaring enums as attributes
This is in line with current Psalm behavior. We forbid non-instantiable
classlikes as attributes, including abstract classes and classes with
non-public constructors.

Refs vimeo/psalm#6841
2021-11-07 01:47:11 +02:00
Bruce Weirdan
9210bbcdd4
Forbid enum instantiation
Fixes vimeo/psalm#6837
2021-11-07 00:14:37 +02:00
Bruce Weirdan
59e63c3235
Merge pull request #6839 from weirdan/forbid-enum-properties 2021-11-06 23:15:09 +02:00
orklah
b08d39e567
Merge pull request #6834 from orklah/unused-in-assert
don't consider calls to methods with assertions as Unused
2021-11-06 22:05:34 +01:00
orklah
e28659eb6c
Merge pull request #6838 from orklah/value_and_name_enum
better understands value and name properties for enum
2021-11-06 22:05:04 +01:00
Bruce Weirdan
f0f085e084
Add test for NoEnumProperties
This was somehow missed from vimeo/psalm#6836
2021-11-06 22:52:17 +02:00
orklah
18677bb108 better understands value and name properties for enum 2021-11-06 21:49:42 +01:00
Bruce Weirdan
b49c25ae76
Fixed tests
* Added new issue to the config.xsd
* Marked NoEnumProperties as PHP 8.1 issue
2021-11-06 22:22:38 +02:00
orklah
65c41e7543 don't consider calls to methods with assertions as Unused 2021-11-06 20:00:31 +01:00
orklah
9c9669ea44 don't consider calls to methods with assertions as Unused 2021-11-06 19:54:17 +01:00
orklah
ad57516765 create a temporary var for coalescing ternaries 2021-11-05 20:07:35 +01:00
orklah
f4f9bd6711 allow declaring functions and classLikes after a never-returning call 2021-11-05 18:34:59 +01:00
orklah
6e8bd2b207 allow declaring functions and classLikes after a never-returning call 2021-11-05 18:18:34 +01:00
orklah
33aab6cc40 allow declaring functions and classLikes after a never-returning call 2021-11-05 18:09:40 +01:00
orklah
915278e253
Merge pull request #6823 from orklah/variable_class
allow assertion to work on $var::class
2021-11-04 20:54:59 +01:00
orklah
5282e4728b allow assertion to work on $var::class 2021-11-04 20:33:30 +01:00
orklah
cd74f665dc
Merge pull request #6813 from orklah/intTaint
don't register taints for numeric variables
2021-11-04 15:30:52 +01:00
orklah
e6dccaa07c
Merge pull request #6809 from orklah/binaryOpTaint
don't taint the result of most binary operations
2021-11-04 13:18:07 +01:00
orklah
bf993452a8
Merge pull request #6810 from orklah/castArrayTaints
Array cast pass taints
2021-11-04 13:17:20 +01:00
orklah
c2b14e2f39
Merge pull request #6812 from orklah/shell_exec_taint
backticks shell_exec taint
2021-11-04 13:16:53 +01:00
Bruce Weirdan
6610a2f918
Improve Github Actions output
* Use issue type in title
* Also provide issue type and location in the (use-visible) error message

Fixes vimeo/psalm#6817
2021-11-04 03:03:25 +02:00
orklah
9fb74a4f28 exclude Plus on arrays too 2021-11-04 00:30:09 +01:00
orklah
3b01713257 don't taint the result of most binary operations 2021-11-04 00:30:09 +01:00
orklah
24137bdbad Array cast pass taints 2021-11-04 00:29:36 +01:00
orklah
eca530d792 don't register taints for numeric variables 2021-11-04 00:29:07 +01:00
orklah
fbe305e5bb detect taint in backticks 2021-11-04 00:28:40 +01:00
sasezaki
e3c6464a91 accept ::class constant strings for literal argument 2021-11-03 13:44:14 +09:00
Bruce Weirdan
0cdb0dc04a
Merge pull request #6768 from zoonru/psalm-self-out-templates 2021-11-02 21:41:16 +02:00
orklah
96ae8e7600
Merge pull request #6793 from orklah/unevaluatedCode
emit UnevaluatedCode after exit or never returning functionlike
2021-11-01 23:41:36 +01:00
orklah
500571b9da move tests to enable config 2021-11-01 22:45:17 +01:00
orklah
e2bb9859e4 fix tests 2021-11-01 22:27:43 +01:00
orklah
68a4f9e930 emit UnevaluatedCode after exit or never returning functionlike 2021-11-01 22:13:29 +01:00
Bruce Weirdan
81ca05f3ab
Merge pull request #6790 from orklah/fix_yield 2021-11-01 20:25:54 +02:00
orklah
c5c779c4a9 detect yield in new 2021-11-01 19:04:49 +01:00
orklah
af129f8851 detect yield in new 2021-11-01 19:04:37 +01:00
Bruce Weirdan
ac098a52da
Allow to forbid exit() and die() 2021-10-31 03:02:16 +03:00
Bruce Weirdan
f660ff4f83
Move ForbiddenCode-related tests to the corresponding test file 2021-10-31 02:43:17 +03:00
Alexey Borzov
136624e817 Add another check to a PHP_VERSION_ID condition test 2021-10-30 01:13:28 +03:00
Alexey Borzov
91ec5712ad Add a means to switch return types based on PHP_VERSION_ID
As suggested in vimeo/psalm#6755
2021-10-29 22:19:38 +03:00
orklah
61a7cbe9c5
Merge pull request #6764 from orklah/promoted-property-docblock
allow documenting promoted properties with @var
2021-10-28 22:19:42 +02:00
orklah
b53138ebde fix CS 2021-10-28 22:10:22 +02:00
orklah
067f8375cf replace exception by InvalidDocblock 2021-10-28 22:05:43 +02:00
orklah
d19018b3fa
Merge pull request #6775 from orklah/is_a
fix is_a when used with Stringable classes
2021-10-28 21:47:27 +02:00
orklah
9823e87b80
Merge pull request #6774 from orklah/reconcileFalsyOrEmpty
fix local variable defined too early
2021-10-28 21:47:17 +02:00
orklah
ce87fc4882 fix is_a when used with Stringable classes 2021-10-28 20:08:43 +02:00
orklah
b9effdb28a
Merge pull request #6742 from zoonru/fix_fewer_template_parameters
Fix template parameter collection for child classes with fewer parameters (fixes #6734)
2021-10-28 20:06:11 +02:00
orklah
a7c44a1a19 fix local variable defined too early 2021-10-28 19:33:27 +02:00
5fae548e62
Add template support to @psalm-self-out 2021-10-28 10:44:37 +02:00
orklah
e17ca1ba10 fix CS/test 2021-10-27 22:45:16 +02:00
orklah
9b7eabe17f allow documenting promoted properties with @var 2021-10-27 22:35:21 +02:00
02e293bc07
Improve test 2021-10-27 11:02:35 +02:00
9c59550e15
Fully fix recursive template parameter resolution 2021-10-27 10:58:33 +02:00
orklah
dc2ac427ca Don't remove a type because they have a common parent 2021-10-26 22:54:55 +02:00
3f1fef1fce
Fix tests 2021-10-26 13:38:06 +02:00
6fe44b3374
Add tests 2021-10-26 13:26:36 +02:00
Bruce Weirdan
4b0c8806a7
Merge pull request #6739 from orklah/instanceof_notliteral 2021-10-25 23:45:17 +03:00
orklah
8e0cf0e74b add test 2021-10-25 20:16:58 +02:00
orklah
9fb959150a
Merge pull request #6730 from orklah/int-template-arithmetics
don't emit issues when doing arithmetics on int templates
2021-10-24 20:39:54 +02:00
orklah
af918a95a2 don't emit issues when doing arithmetics on int templates 2021-10-24 19:30:39 +02:00
orklah
90d6239d74 strlen of strtolower of string is not always true 2021-10-24 18:40:13 +02:00
orklah
e33492398b
Merge pull request #6726 from orklah/crash_intrange
Don't crash on falsy with int ranges
2021-10-24 14:29:22 +02:00
orklah
c38139a87c Don't crash on falsy with int ranges 2021-10-24 13:59:21 +02:00
orklah
68528985d6
Merge pull request #6724 from orklah/impure_callstatic
flag impure calls made through __callstatic
2021-10-24 10:30:56 +02:00
orklah
a0681a4498 flag impure calls made through __callstatic 2021-10-24 09:55:40 +02:00
orklah
0339815070 fix type leaking when using ternaries 2021-10-23 18:58:05 +02:00
orklah
b63d877f48
Merge pull request #6720 from orklah/loop-template-regression
Don't refine empty/falsy assertions on templates inside loops
2021-10-23 14:31:10 +02:00
orklah
78a4c78187
Merge pull request #6718 from orklah/5651
fix literal string access on a non empty array
2021-10-23 12:11:39 +02:00
orklah
fb5a652e18 Don't refine empty/falsy assertions on templates inside loops 2021-10-23 11:17:47 +02:00
orklah
2cc5c555c2 fix literal string access on a non empty array 2021-10-22 18:17:08 +02:00
orklah
2d90631c87
Merge pull request #6689 from orklah/traversable&array
only fuse array & Traversable with phpstorm generics
2021-10-21 22:38:59 +02:00
orklah
1c0b802abb fix regression 2021-10-21 21:10:12 +02:00
orklah
f0f0b4a8a8
Merge pull request #6708 from orklah/skipped
skipped tests
2021-10-21 13:17:03 +02:00
orklah
8b98e645eb skipped tests 2021-10-20 23:37:52 +02:00
orklah
31bbd5a967
Merge pull request #6707 from orklah/!falsy_on_empty-string
improve falsy on non-empty-string
2021-10-20 23:18:12 +02:00
orklah
7ce0c3a6e3 improve falsy on non-empty-string 2021-10-20 22:31:03 +02:00
orklah
1f02795e42 fix missing implicit __toString 2021-10-20 19:54:32 +02:00
orklah
4755131585 more consistency 2021-10-20 07:32:04 +02:00
orklah
5d154e1bda fix test 2021-10-18 22:00:51 +02:00
orklah
a9e2284e79 add test 2021-10-18 21:51:36 +02:00
orklah
f7a63361ad
Merge pull request #6679 from SCIF/bugfix-5694-arrayfilter
Improve handling of positive ints by array_filter()
2021-10-17 23:20:26 +02:00
Aleksandr Zhuravlev
b664850cdc Added support of asserting properties of objects out of scope 2021-10-17 21:29:25 +13:00
Aleksandr Zhuravlev
978d9ec774 Improve handling of positive ints by array_filter() 2021-10-16 20:47:22 +13:00
orklah
56c73142d6 don't emit InvalidReturnType when return type was inferred to never 2021-10-16 00:15:17 +02:00
orklah
1aad830392
Merge pull request #6654 from zoonru/fixes
Fix manipulation of intersection types, arrow functions, foreign static types, parameter static types, T|false|null unions.
2021-10-15 23:41:24 +02:00
ElisDN
7b47063585 Add array typed tests 2021-10-15 14:30:20 +03:00
ElisDN
f26e9ae3b1 Add array replace tests 2021-10-15 14:30:20 +03:00
orklah
b8a2ba251f
Merge pull request #6672 from orklah/phpstorm-generics
prevent phpstorm generics from touching to signature types
2021-10-14 21:25:36 +02:00
orklah
a1b1080c4e prevent phpstorm generics from touching to signature types 2021-10-14 21:04:53 +02:00
orklah
110f2b4822
Merge pull request #6658 from fluffycondor/method-annotation-parsing-fix
Fix @psalm-method annotation parsing
2021-10-14 17:36:42 +02:00
Semyon
28385dc526 Fix failed test 2021-10-14 18:00:32 +03:00
Bruce Weirdan
6abdb092bc
Merge pull request #6667 from SCIF/bugfix-5135-reflectionnamedtype-stub 2021-10-14 13:26:50 +03:00
Aleksandr Zhuravlev
657f8e22ed Made the test marked 7.4 2021-10-14 22:05:40 +13:00
244a90ca4f
Fix #6665 2021-10-14 10:56:54 +02:00
orklah
75c3f8716a
Merge pull request #6652 from orklah/is_a_stub
stub for is_a
2021-10-14 00:13:13 +02:00
Aleksandr Zhuravlev
cbb67c0672 Stubbed RelfectionNamedType 2021-10-14 11:09:52 +13:00
orklah
e17290a9bc
Merge pull request #6613 from orklah/string-unpacking
String unpacking
2021-10-13 15:18:11 +02:00
24f1b60e53
Fix nullable unions 2021-10-13 14:05:48 +02:00
orklah
c96be1f68e fix tests 2021-10-13 11:47:57 +02:00
orklah
758acccb91 fix tests 2021-10-13 11:43:17 +02:00
ce60fa2151
Cleanup 2021-10-13 11:26:01 +02:00
orklah
c4eb548603 more precise type 2021-10-13 11:22:40 +02:00
orklah
83f2cf2eac switch the test from invalid to valid 2021-10-13 11:22:40 +02:00
orklah
690c24f824 array unpacking with strings 2021-10-13 11:22:40 +02:00
b6e7201b5a
Forbid static in parameter typehint 2021-10-13 11:22:33 +02:00
1c99af205b
Fix manipulation of intersection types, arrow functions, foreign static types, T|false|null unions. 2021-10-13 11:13:43 +02:00
orklah
e7cd2eac0a
Merge pull request #6641 from orklah/weird-assertion-count
Union::getAssertionString with multiple types
2021-10-13 08:15:28 +02:00
orklah
1efe272aed stub for is_a 2021-10-12 22:12:51 +02:00
orklah
04813bf556 fix test 2021-10-12 15:58:06 +02:00
orklah
233fe11d12 SimpleXMLElement is not always truthy 2021-10-12 15:46:02 +02:00
orklah
c6fb81007c
Merge pull request #6629 from orklah/loops-tweaking
tweaking with loops
2021-10-11 20:45:54 +02:00
orklah
af414ffe59
Merge pull request #6642 from orklah/inside-conditional
Inside conditional
2021-10-11 20:45:14 +02:00
orklah
b54dddf484
Merge pull request #6643 from orklah/never-closure
infer never on closures(and more?)
2021-10-11 20:42:02 +02:00
orklah
29966b38bd fix test 2021-10-11 19:23:56 +02:00