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

7126 Commits

Author SHA1 Message Date
Matthew Brown
43cff22b25 Add support for native PHP readonly 2021-07-21 13:29:07 -04:00
Bruce Weirdan
052c7478cc
Unary plus and minus mark operand as used
Fixes vimeo/psalm#6145
2021-07-21 01:15:51 +03:00
orklah
58dd3f6f94 change wording 2021-07-20 23:53:04 +02:00
orklah
9ff0fceb71 CS changes 2021-07-20 23:41:11 +02:00
orklah
9160a4e8a6 review 2021-07-20 23:37:34 +02:00
orklah
acfdb82856 Basic implementation 2021-07-20 23:34:38 +02:00
Bruce Weirdan
b149097086
Replace array cast with get_object_vars() which Psalm understands 2021-07-20 23:26:15 +03:00
Nathan Dench
39555a2df8 add type signature in XmlReport 2021-07-20 21:54:44 +10:00
Nathan Dench
ca2c125218 fix: Handle DataFlowNodeData in XmlReport 2021-07-20 21:39:09 +10:00
Bruce Weirdan
7bcefb783a
Simplify InstancePropertyAssignmentAnalyzer::analyzeAtomicAssignment()
... to fix build issues.
2021-07-20 00:08:49 +03:00
Bruce Weirdan
0317f1dbec
Merge pull request #6130 from weirdan/forbid-dynamic-access-to-static-props 2021-07-19 16:11:29 +03:00
Bruce Weirdan
d992331125
Expand magic properties
Fixes vimeo/psalm#4344
Fixes vimeo/psalm#5663
Fixes vimeo/psalm#5639
Fixes vimeo/psalm#5955
Fixes vimeo/psalm#3272
2021-07-18 23:43:33 +03:00
Bruce Weirdan
b589525eb1
Merge pull request #6131 from orklah/bindtextdomain
makes bindtextdomain impure
2021-07-18 16:53:59 +03:00
Bruce Weirdan
7418e6e167
grammar 2021-07-18 16:52:00 +03:00
orklah
f1269d2425 makesbindtextdomain impure 2021-07-18 14:24:43 +02:00
Bruce Weirdan
a180dc6099
Flag staticness mismatch
This handles two new cases:
1. Accessing static property with `->` (produces notices and warnings: https://3v4l.org/TiGan)
2. Accessing non-static property with `::` (causes fatal error: https://3v4l.org/IdYSh)

Fixes vimeo/psalm#6117
2021-07-18 02:51:33 +03:00
Bruce Weirdan
53ae7764e9
Merge pull request #6129 from orklah/unused-global 2021-07-18 02:33:50 +03:00
orklah
fcbd443bc8 initialize array 2021-07-17 22:04:22 +02:00
orklah
79d0647d19 fix issue when setting a value to a global is considered unused 2021-07-17 22:00:54 +02:00
Bruce Weirdan
2127da387b
Merge pull request #3903 from greg0ire/redundant-not-identical-with-false
Add negated identity with false case
2021-07-17 04:07:40 +03: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
Bruce Weirdan
4c197afc09
Merge pull request #5512 from ngmy/shepherd-envvar
Add the environment variable for using Shepherd
2021-07-17 02:50:15 +03:00
Yuta Nagamiya
bcd5fc4b6a
Add the environment variable for using Shepherd 2021-07-17 02:26:13 +03:00
Joshua Behrens
0c6031f7f2
Use same working directory for preparing cache directory as it used in running analysis 2021-07-17 01:55:41 +03:00
Bruce Weirdan
c9f52c449b
Merge pull request #6127 from weirdan/deprecated-properties
Check deprecated properties on $this->prop reads
2021-07-17 01:43:08 +03:00
Matthew Brown
88c4e2468e
Support interface-string<Foo> as temporary alias of class-string<Foo> (#6106) 2021-07-16 18:38:39 -04:00
Bruce Weirdan
a6a261b537
Merge pull request #6123 from caugner/codeclimate-relative-paths
fix(CodeClimateReport): use relative path
2021-07-17 01:29:26 +03:00
Bruce Weirdan
af5cdb4dd4
Check deprecated properties on $this->prop reads
Fixes vimeo/psalm#6118
2021-07-17 01:20:35 +03:00
Claas Augner
d0df69afb5 Fix CodeClimateReport to use relative paths
Both GitLab and the Code Climate Engine Specification require the code
climate report to contain the *relative* path to the source code file.
2021-07-16 22:39:47 +02:00
Bruce Weirdan
4a516005a3
Allow 0 for all bitmask types
Fixes vimeo/psalm#6119
2021-07-16 23:20:33 +03:00
orklah
0bd8b03f7a Fix usage of gettype in a switch with closed resource 2021-07-14 12:49:46 +02:00
Bruce Weirdan
601c8cac5b
Merge pull request #6086 from orklah/cleanup 2021-07-14 09:08:18 +03:00
orklah
c3a4e513f9 add more detailed phpdoc for $conditional and remove unused code 2021-07-14 00:02:36 +02:00
orklah
bcd22335b6 add some detailed phpdoc for $conditional 2021-07-13 22:35:57 +02:00
orklah
874b8ed7ae fix doc 2021-07-13 22:29:27 +02:00
orklah
647b9b78dc cleanup and refactor AssertionFinder 2021-07-13 20:54:47 +02:00
Ruslan Karimov
8a08489dcc Merge branch 'master' into fix-5957
# Conflicts:
#	tests/UnusedVariableTest.php
2021-07-13 10:15:35 +05:00
Ruslan Karimov
cfaca07c6d added dataflow to stringy bitwise op, bitwise not op (fix 5957) 2021-07-13 10:05:21 +05:00
Bruce Weirdan
6729f4db01
Merge pull request #6083 from orklah/falsable-argument 2021-07-13 02:13:39 +03:00
orklah
52033f4b69 fix condition when scalar is allowed 2021-07-13 00:34:22 +02:00
orklah
1fc8982ca9 fix condition when bool is allowed 2021-07-13 00:19:13 +02:00
orklah
688367de38 Always emit InvalidArgument when the parameter is always false and not accepted 2021-07-13 00:06:36 +02:00
Matthew Brown
f2bc6913db
Fix #6061 — delay analysis of array value except when unpacking (#6081) 2021-07-12 17:05:33 -04:00
Bruce Weirdan
e93b37a225
Merge pull request #6060 from VincentLanglet/statement 2021-07-11 22:12:10 +03:00
Matthew Brown
acc7ee261c
Fix #6066 - introduce more robust system for capturing template constraints (#6072)
* Fix #6066 - add better system for capturing template constraints

* Fix comment
2021-07-11 12:03:21 -04:00
Vincent Langlet
3339ce1379 Use stmt instead of args 2021-07-11 11:22:13 +02:00
Bruce Weirdan
83bf9b8ed9
Merge pull request #5608 from paxal/patch/preg_replace_callback
Allow to use string key for preg_replace_callback callable argument
2021-07-11 04:55:03 +03:00
Bruce Weirdan
d1f894a5a0
Merge pull request #6068 from caugner/make-ClassLikeNodeScanner-resilient-against-missing-class-storage
Make ClassLikeNodeScanner resilient against missing class storage
2021-07-11 03:18:31 +03:00
Matthew Brown
d883d73991 Fix template bound terminology
I had this flipped by mistake
2021-07-10 14:08:09 -04:00
Claas Augner
c6ccf61a5c Make ClassLikeNodeScanner resilient against missing class storage 2021-07-09 16:56:45 +02:00
Bruce Weirdan
f94f3b8691
Merge pull request #6054 from caugner/6050-FunctionLikeAnalyzer-extract-setParams-addParam 2021-07-09 08:21:36 +03:00
Claas Augner
9a78b2fbc8
Mark FunctionLikeStorage::setParams()/addParam() as internal 2021-07-09 00:58:29 +02:00
ElisDN
61b78e117f Fix negative numbers 2021-07-08 19:17:31 +03:00
Simon Podlipsky
8568798747
Skip argv when --config file.xml is passed 2021-07-08 10:19:58 +02:00
Vincent Langlet
49ed7b045f Pass statement to MethodReturnTypeProviderEvent 2021-07-08 00:02:36 +02:00
Andrew Nagy
81bd44b714
didChangeWatchedFiles should continue not return
didChangeWatchedFiles should continue not return per each watched file in the $changes array
2021-07-06 16:52:46 -07:00
Claas Augner
b91e00b03f Always keep FunctionLikeStorage->param_lookup in sync 2021-07-06 11:58:58 +02:00
Claas Augner
601a981898 Extract FunctionLikeStorage::setParams()/addParam() 2021-07-06 11:52:42 +02:00
Bruce Weirdan
e8f1acb9b6 Revert "Don't attempt to read baseline before it was generated (#5961)"
This reverts commit 52d2692497.
2021-07-06 09:54:00 +03:00
orklah
f8644fb508 Improve resolution of __METHOD__ and __FUNCTION__ 2021-07-03 10:01:53 +02:00
Bruce Weirdan
6db79be207
Keep generic part of shape on array_map return type
Fixes vimeo/psalm#6038
2021-07-03 06:33:37 +03:00
Bruce Weirdan
4b31058234
Separate memory limit formatting from retrieval
This addresses https://github.com/vimeo/psalm/pull/6030#issuecomment-872611832

Previously PHP would allow to set memory limit to be below current
memory usage, and the test changed in this PR abused that. As we
actually don't need to test `ini_get()` value decoding was split into
its own method, and we're testing that decoding instead.
2021-07-02 02:59:43 +03:00
Bruce Weirdan
248a07fd35
Ship FakeFileProvider even with dist dev releases
Refs psalm/psalm.dev#60
2021-07-02 00:26:20 +03:00
Matt Brown
667dcc2e49 No false-positives for tainting through array keys 2021-06-29 17:05:39 -04:00
Ruslan Karimov
79b61c3b61 Added support for self & static keywords in array_reduce callables 2021-06-29 22:27:50 +05:00
Bruce Weirdan
0196afc758
Merge pull request #6014 from tm1000/feature/6013-1 2021-06-29 05:39:16 +03:00
Andrew Nagy
468e474f44
Update src/Psalm/Internal/LanguageServer/Server/Workspace.php
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2021-06-28 19:08:02 -07:00
Bruce Weirdan
5ea98d6324
Merge pull request #6010 from tm1000/feature/6008 2021-06-29 04:40:00 +03:00
Your Name
79fbaa2252 Fixes #6013, implement workspace/didChangeWatchedFiles 2021-06-28 17:34:43 -07:00
Bruce Weirdan
3080140061
Drop superfluous docblock types 2021-06-29 03:10:19 +03:00
Bruce Weirdan
63286714e6
Merge pull request #6012 from tm1000/bugfix/6011
Fixes #6011, move placement of version call
2021-06-29 03:00:03 +03:00
Your Name
4d91c6ecc5 Fixes # 6011, move placement of version call 2021-06-28 15:09:50 -07:00
Your Name
46c3f1cbf3 fix styling issues 2021-06-28 14:31:48 -07:00
Your Name
4ae5d50f56 Fixes #6008, Enabled onSave and onOpen textDocument 2021-06-28 14:23:43 -07:00
Bruce Weirdan
9e9413da6d
Merge pull request #6007 from tm1000/bugfix/5997-1
Fixes #5997 by intentionally sending Success responses from shutdown method
2021-06-28 23:12:29 +03:00
Matt Brown
d18a4f4ccc Don’t stop scanning loop contents due to possibly-null iterator 2021-06-28 13:13:12 -04:00
Your Name
2e05377323 Fixes #5997 by intentionally sending Success response from shutdown method 2021-06-28 10:02:18 -07:00
Barney Laurance
140cf01a91 Trim issue snippet at time of comparison with baseline, not in IssueData constructor 2021-06-27 10:36:33 +01:00
Barney Laurance
097ccf16b4
Mention Psalm 5 in comment
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2021-06-27 10:18:42 +01:00
Barney Laurance
0722401aaf Trim code snippets on both sides when comparing current issues against baseline
Should fix issue #5979

We could also trim code issues when writing to baseline, but I think
that's a minor BC break, so probably shouldn't happen until Psalm 9.
2021-06-26 22:37:29 +01:00
Matt Brown
19cc4cb4ee Simplify lots of usage checks 2021-06-25 10:14:49 -04:00
Matt Brown
67d68a5dc0 Use more accurate variable name 2021-06-25 09:54:39 -04:00
Bruce Weirdan
6d4262edbd
Mark return values in as throw argument as used (#5989)
Fixes vimeo/psalm#5975
2021-06-25 09:11:27 -04:00
Abdul Malik Ikhsan
3376f3cdfa
Add ob_get_clean to impure function 2021-06-24 20:34:38 +07:00
Oliver Hader
38d3b15f8d
[BUGFIX] Specialize TaintSink in IncludeAnalyzer (#5986)
* [TEST] Assert more details in TaintTest

* [TEST] Add test for multiple tainted includes

* [BUGFIX] Specialize TaintSink in IncludeAnalyzer

Fixes: #5986
2021-06-23 08:27:03 -04:00
Oliver Hader
b07de1fefd
[BUGFIX] Avoid crash during interface checks on non-existing classes (#5984)
`ClassLikes::classImplements(NonExisting::class, WellKnown::class)`
now returns `false` instead of throwing an exception for non-existing
classes.

Fixes: #5983
2021-06-22 18:04:47 -04:00
Bruce Weirdan
260faee29e
Mark set_include_path() as impure 2021-06-22 22:00:05 +03:00
Matt Brown
d8f4eb2d6d Restrict type of implode to prevent Array-to-string conversion; 2021-06-21 19:55:27 -04:00
Bruce Weirdan
52d2692497
Don't attempt to read baseline before it was generated (#5961)
Fixes vimeo/psalm#5960
2021-06-20 21:59:54 -04:00
Matt Brown
f73f2299db Fix #5960 - catch exception when baseline cannot be located 2021-06-20 19:03:20 -04:00
Bruce Weirdan
0a57c86549
Announce removal of deprecated methods (#5956)
Refs vimeo/psalm#4700
2021-06-20 14:12:20 -04:00
orklah
3c9476bdf6
Prevent infinite loop in case a TClassConstant is expanded to itself (#5951) 2021-06-18 08:51:19 -04:00
orklah
79478a60b1
Allow class constant as offset key (#5943)
* allow class-constant as an array offset when the type match

* remove object with __toString as a possible offset as it's not valid
2021-06-17 18:15:57 -04:00
orklah
872f1c232c
allow Psalter to fix RedundantCast (#5948)
* allow Psalter to fix RedundantCast

* fix test
2021-06-17 18:15:45 -04:00
Matthew Brown
c2f7422e80
Prevent crash with non-UTF-8 string
Fixes #5945
2021-06-17 12:26:18 -04:00
Bruce Weirdan
e552925af6
Emit separate type of issue when foreach value is unused (#5932)
* Emit separate type of issue when foreach value is unused

Fixes vimeo/psalm#5929

* Fixed var name case sensitivity
2021-06-17 00:40:24 -04:00
orklah
cfa5492286
Remove redundant namespaced phpdoc (#5936)
* remove array-key from generated phpdoc

* remove mixed value too

* fix tests

* fix mixed suppression

* revert back to array to prevent breaking refactoring
2021-06-16 11:16:20 -04: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
4941b9e5d2 Rename class and make it type-hintable 2021-06-14 16:02:59 -04:00
Matt Brown
5ae8b2a23f Add preliminary support for literal-string 2021-06-14 15:30:25 -04:00
Bruce Weirdan
24d45a50de
Merge pull request #5924 from BafS/fix-type-error-patch-1 2021-06-13 21:19:43 +03:00
BafS
d395e00f18
Add assertion 2021-06-13 12:07:34 +02:00
Matt Brown
aade5d0def Add slash 2021-06-12 17:17:27 -04:00
Matt Brown
b678461f5c Improve detection of fluent methods 2021-06-12 17:09:42 -04:00
Matt Brown
23b7ff86b7 Mark interface methods as unused even when inherited 2021-06-12 16:13:29 -04:00
BafS
eb4ecc20d4
Fix style 2021-06-11 20:11:21 +02:00
BafS
07cf6012f7
Use assert() instead of phpdoc 2021-06-11 20:07:59 +02:00
BafS
dde0f1fb06
Fix Uncaught TypeError with some shifts 2021-06-11 20:03:23 +02:00
Matt Brown
884043b47b Fix style 2021-06-10 18:29:08 -04:00
Matt Brown
f2f5f1eaa2 Revert fix and tests 2021-06-10 17:44:34 -04:00
Matt Brown
47bf5ed567 Fix #5918 - add new issue to detect unquoted strings 2021-06-10 17:43:04 -04:00
Matt Brown
e661c5fb55 Fix erroneous use when comparing methods 2021-06-10 14:39:01 -04:00
Matthew Brown
6d09418a23
Detect unused return values (#5917)
* Detect unused return values

* Allow static-returning instance methods (presumed to be fluent)

* Make $is_used the default for Codebase::methodExists
2021-06-10 14:18:15 -04:00
Matt Brown
542fa77896 Remove unused use 2021-06-10 12:59:37 -04:00
Matt Brown
34c1f9dccf Nest conditional for more accurate flow 2021-06-10 12:52:23 -04:00
Matt Brown
a6d79fd409 Clean up more unused return values 2021-06-10 12:23:53 -04:00
Matt Brown
8509999f3f Remove some unused return values 2021-06-10 12:09:46 -04:00
Matthew Brown
e5a7478b38 Fix order 2021-06-10 09:07:15 -04:00
Matt Brown
f5bc841295 Prevent nested literal coercion 2021-06-09 16:01:45 -04:00
Matthew Brown
d12cf88e83 Add back supported for templated index assignment 2021-06-09 12:55:37 -04:00
Matthew Brown
0a7d254689 Fix #5911 - improve non-terminating switch type inference 2021-06-09 09:06:23 -04:00
Bruce Weirdan
6abce3525a
Enforce use sort (#5900) 2021-06-07 22:55:21 -04:00
Bruce Weirdan
5bfb841072
Prevent crashes when class constant references missing class (#5902)
Fixes vimeo/psalm#5861
2021-06-07 13:20:07 -04:00
Matthew Brown
7301e3a35f Fix redundant cast 2021-06-07 13:19:00 -04:00
Bruce Weirdan
80e8d40013
Deprecate legacy hook interfaces (#5898)
Refs vimeo/psalm#4700
2021-06-07 10:46:56 -04:00
Bruce Weirdan
86050df4d0
Formally deprecate allowCoercionFromStringToClassConst (#5897)
* Mark allowCoercionFromStringToClassConst as deprecated in xml schema

* Emit deprecation warning for `allowCoercionFromStringToClassConst`
2021-06-07 10:46:26 -04:00
Bruce Weirdan
a5080f2cf6
Do not provide mixed return type on unrelated methods (#5895)
Fixes vimeo/psalm#5894
2021-06-07 10:45:43 -04:00
Andrey Klimenko
3ad3375777
Fix generic destruction in assertion (#5888) 2021-06-04 15:33:37 -04:00
Oliver Hader
e457a7d5af
[FEATURE] Allow plugins to declare their custom scanner or analyzer (#5883)
* [FEATURE] Allow plugins to declare their custom scanner or analyzer

Related: #5882

* [TEST] Check plugin declaring own scanner/analyzer

* [TASK] Document plugins declaring scanner or analyzer

* [TEST] Clean up code

* [!!!][TASK] Extend Psalm\Plugin\RegistrationInterface

* add method `addFileTypeScanner(string $fileExtension, string $className): void`
* add method `addFileTypeAnalyzer(string $fileExtension, string $className): void`

* [TASK] Ignore IntelliJ/PhpStorm workspace folder in VCS

* [TASK] Remove superfluous class import
2021-06-04 15:32:53 -04:00
Matt Brown
b33f87f68d Treat all assignment operations as equivalent binary ops 2021-06-04 14:39:38 -04:00
Andrey Klimenko
e5e397a6c5
Type negation in generic context (#5879)
* Type negation in generic context

* Fix cs
2021-06-03 01:06:25 -04:00
Matthew Brown
1a2e761918 Remove incorrectly-committed code 2021-06-02 17:26:40 -04:00
Matthew Brown
577ae090c4 Bump LS memory to Psalm’s 2021-06-02 10:49:04 -04:00
Barney Laurance
e0eb8f88e5
Apply De Morgan's to output copy (#5872) 2021-06-02 06:32:50 -04:00
Matt Brown
f3fc112bae Fix #4523 - fix short-circuiting for properties and method calls 2021-06-01 16:06:12 -04:00
Bruce Weirdan
448534fd7c
Cli command classes (#5858)
* Move psalm entry-point to a Cli command class

* Moved psalter to the CLI command class

* Moved psalm-language-server to the CLI command class

* Moved psalm-refactor to the CLI command class

* Moved psalm_plugin to the CLI command class

* Use CLI commands directly and deprecate trampolines

* Require CLI commands directly and don't use trampolines

* Announce isAbsolutePath() removal

* Deprecate \Psalm\requireAutoloaders() function

* Deprecate \Psalm\getVendorDir() function

* Deprecate Psalm\getArguments() function

* Deprecate \Psalm\getPathsToCheck() function

* Deprecate \Psalm\getPsalmHelpText() function

* Deprecate \Psalm\initialiseConfig() function

* Deprecate Psalm\update_config_file() function

* Deprecate \Psalm\get_path_to_config() function

* Deprecate Psalm\getMemoryLimitInBytes() function

* CS fix

* Untangle Psalm entrypoint

* Untangle Psalter entrypoint

* Drop command_functions.php references

* Adjust phar build
2021-05-31 22:23:54 -04:00
orklah
0e8ca1d852
fix wrong version used in psalter (#5855) 2021-05-28 18:49:12 -04:00
Bruce Weirdan
e6607935a9
Encode control characters in literal strings (#5846)
Fixes vimeo/psalm#5733
2021-05-28 09:48:04 -04:00
Bruce Weirdan
c98b20247b
Flag unexpected tags on function docblocks (#5845)
* Flag unexpected tags on function docblocks

Fixes vimeo/psalm#5782

* Document new issue

* Fix spacing

Co-authored-by: Matthew Brown <github@muglug.com>
2021-05-28 09:47:39 -04:00
orklah
3bcfd2e726
allow psalter to add literal string/int in psalm phpdoc (#5844)
* allow psalter to add literal string/int in psalm phpdoc

* fix CS
2021-05-28 09:46:11 -04:00
Bruce Weirdan
0c77ccc238
Check whether constructor is internal on new call (#5843)
Fixes vimeo/psalm#5841
2021-05-28 09:44:07 -04:00
orklah
276d355ebb
fix issue reporting when baseline already exists (#5838) 2021-05-28 09:43:15 -04:00
Oliver Hader
b259296457
[BUGFIX] Continue processing psalm-flow graph after first taint sink (#5832)
Related: #5830
2021-05-26 16:04:22 -04:00
Matt Brown
38c452ae58 Add example given in ticket and ensure that works too 2021-05-24 00:09:51 -04:00
Matt Brown
c258303f78 Fix test 2021-05-23 22:03:43 -04:00
Matt Brown
8f333337cb Fix #5804 - don’t choke on conditional return types when converting to callables 2021-05-23 21:41:07 -04:00
orklah
aaab522a98
update baseline and fix issues (#5821) 2021-05-23 16:49:46 -04:00
orklah
de1bb954cf
Handle the case where a switch return on each case (#5819)
* Handle the case where a switch return on each case

* introduce a "hybrid" case exit type for cases where there's both "none" and something else
2021-05-23 16:24:29 -04:00
Matt Brown
7354ec9903 Fix #5298 - improve handling of method that may write properties 2021-05-23 16:22:52 -04:00