Bruce Weirdan
007ffaecd8
array_pop
is impure
...
Fixes vimeo/psalm#9429
2023-02-28 18:53:36 -04:00
Jack Worman
1c19260cdd
Require trailing commas
2022-12-18 13:20:31 -06:00
Jack Worman
643542346b
Add codesniffer rules and expand php-cs-fixer to bin and test
2022-12-14 13:29:09 -06:00
1986c8b4a8
Add support for strict arrays, fix type alias intersection, fix array_is_list assertion on non-lists ( #8395 )
...
* Immutable CodeLocation
* Remove excess clones
* Remove external clones
* Remove leftover clones
* Fix final clone issue
* Immutable storages
* Refactoring
* Fixes
* Fixes
* Fix
* Fix
* Fixes
* Simplify
* Fixes
* Fix
* Fixes
* Update
* Fix
* Cache global types
* Fix
* Update
* Update
* Fixes
* Fixes
* Refactor
* Fixes
* Fix
* Fix
* More caching
* Fix
* Fix
* Update
* Update
* Fix
* Fixes
* Update
* Refactor
* Update
* Fixes
* Break one more test
* Fix
* FIx
* Fix
* Fix
* Fix
* Fix
* Improve performance and readability
* Equivalent logic
* Fixes
* Revert
* Revert "Revert"
This reverts commit f9175100c8452c80559234200663fd4c4f4dd889.
* Fix
* Fix reference bug
* Make default TypeVisitor immutable
* Bugfix
* Remove clones
* Partial refactoring
* Refactoring
* Fixes
* Fix
* Fixes
* Fixes
* cs-fix
* Fix final bugs
* Add test
* Misc fixes
* Update
* Fixes
* Experiment with removing different property
* revert "Experiment with removing different property"
This reverts commit ac1156e077fc4ea633530d51096d27b6e88bfdf9.
* Uniform naming
* Uniform naming
* Hack hotfix
* Clean up $_FILES ref #8621
* Undo hack, try fixing properly
* Helper method
* Remove redundant call
* Partially fix bugs
* Cleanup
* Change defaults
* Fix bug
* Fix (?, hope this doesn't break anything else)
* cs-fix
* Review fixes
* Bugfix
* Bugfix
* Improve logic
* Add support for list{} and callable-list{} types, properly implement array_is_list assertions (fixes #8389 )
* Default to sealed arrays
* Fix array_merge bug
* Fixes
* Fix
* Sealed type checks
* Properly infer properties-of and get_object_vars on final classes
* Fix array_map zipping
* Fix tests
* Fixes
* Fixes
* Fix more stuff
* Recursively resolve type aliases
* Fix typo
* Fixes
* Fix array_is_list assertion on keyed array
* Add BC docs
* Fixes
* fix
* Update
* Update
* Update
* Update
* Seal arrays with count assertions
* Fix #8528
* Fix
* Update
* Improve sealed array foreach logic
* get_object_vars on template properties
* Fix sealed array assertion reconciler logic
* Improved reconciler
* Add tests
* Single source of truth for test types
* Fix tests
* Fixup tests
* Fixup tests
* Fixup tests
* Update
* Fix tests
* Fix tests
* Final fixes
* Fixes
* Use list syntax only when needed
* Fix tests
* Cs-fix
* Update docs
* Update docs
* Update docs
* Update docs
* Update docs
* Document missing types
* Update docs
* Improve class-string-map docs
* Update
* Update
* I love working on psalm :)
* Keep arrays unsealed by default
* Fixup tests
* Fix syntax mistake
* cs-fix
* Fix typo
* Re-import missing types
* Keep strict types only in return types
* argc/argv fixes
* argc/argv fixes
* Fix test
* Comment-out valinor code, pinging @romm pls merge https://github.com/CuyZ/Valinor/pull/246 so we can add valinor to the psalm docs :)
2022-11-05 22:34:42 +01:00
Matthew Brown
b49682a485
Simplify issue suppression in tests
2022-01-13 14:38:17 -05:00
Matthew Brown
f439d6550b
Ensure that all entries in test arrays have explicit keys ( #7386 )
...
* Transformation that updates assertions
* Simplify transformation
* Ensure that all tests have keys
* Fix a few remaining keys
2022-01-13 13:49:37 -05:00
orklah
5ce626fcdf
fix test
2022-01-07 19:39:24 +01:00
orklah
8049438408
forbid calling impure callable in immutable context
2022-01-01 11:13:45 +01:00
rarila
97e6511fab
Set number of lines before and after namespace.
2021-12-15 04:58:32 +01:00
orklah
75312d93b1
Don't crash when checking purity of __callStatic in a trait
2021-12-06 19:00:37 +01:00
ralila
8fb2e0f885
Handle some partials
2021-12-04 21:55:53 +01:00
orklah
41fd460db5
check __callStatic purity instead of the pseudoMethod purity
2021-11-21 13:51:19 +01:00
orklah
a0681a4498
flag impure calls made through __callstatic
2021-10-24 09:55:40 +02:00
Jack Robertson
f0193f20fa
Consider print, and conditionally exit / die impure
2021-07-27 13:26:54 +01:00
Matt Brown
b33f87f68d
Treat all assignment operations as equivalent binary ops
2021-06-04 14:39:38 -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
Matt Brown
524084a64c
Tighten up rules arouund when mutation-free methods get memoised
2020-12-08 16:39:06 -05:00
orklah
37a2f8a33d
unused use statements ( #4228 )
2020-09-22 01:10:46 -04:00
orklah
ead107fa9e
More return types ( #4173 )
...
* add native return types
* redundant phpdoc
2020-09-12 11:24:05 -04:00
Brown
f4c2edf40b
Fix #4132 - ignore purity of $this when checking for initialisation
2020-09-04 16:46:20 -04:00
Brown
efe143a396
Fix #4077 - always track closure purity
2020-08-28 12:42:55 -04:00
Brown
2b060b75d3
Fix #4052 - foreach over an iterable is impure
2020-08-25 11:24:57 -04:00
Matthew Brown
c8ecee109c
Fix immutable tests
2020-08-24 00:35:59 -04:00
Brown
6103cf0f51
Fix ImpureVariable test
2020-08-23 22:07:02 -04:00
Brown
140d37c7ef
Prevent isset on uknown property in pure function
2020-08-23 18:50:17 -04:00
Brown
39cc96a9d6
Allow modification after clone in pure context
2020-08-23 10:58:43 -04:00
Brown
c8ea4b4e8b
Prohibit property fetches from pure contexts except when they’re on immutable objects
2020-08-23 10:57:24 -04:00
Brown
8fbc8de98a
Fix #3820 - don’t treat a method call as memoisable if it has assertions
2020-07-15 15:09:19 -04:00
Matthew Brown
a49a0e5650
Fix #3551 - count method can be impure
2020-06-14 11:06:53 -04:00
Matthew Brown
1b752d06ab
Fix #3201 - add additional constraints on constructor initialisation
2020-04-21 00:04:47 -04:00
Brown
edb07952fc
Static call inside throw does not violate purity
2020-04-18 12:43:51 -04:00
Grégoire Paris
b47306ad3b
Account for PDOException ( #3175 )
...
Probably for legacy reasons, PDOException::getCode() can return string (it's an
SQLSTATE code). Note that if you instantiate it yourself, you will get
an integer though.
I changed the signature of the Exception stub accordingly, and then
there were errors about incompatible signatures, so I had to change the
signature of Throwable too, which makes sense since a Throwable could be
a PDOException. The signature at
https://www.php.net/manual/en/throwable.getcode.php seems plain wrong,
and that same page of the docs warns about PDOException. Not sure what
are the plans for future versions of PHP.
2020-04-18 10:39:23 -04:00
Grégoire Paris
bc91de015e
Mark throwable methods as pure ( #3171 )
...
* Write stub as valid PHP
This works probably because it is not parsed by PHP but by something
more tolerant, but let's make it more valid (the final access type in
the signature is not valid) PHP anyway, that will raise fewer eyebrows.
* Document actual return type
See ca006e54e3/Zend/zend_exceptions.stub.php (L8)
* Mark all methods from Throwable as mutation free
Exception is the only possible class implementation of Throwable, and
all of its methods except __toString() are final.
See ca006e54e3/Zend/zend_exceptions.stub.php (L3-L25)
Closes #3170
2020-04-17 22:08:26 -04:00
Brown
d1fcbf38ae
Fix #2956 - treat Exception::getMessage as final and mutation-free
2020-03-10 15:12:55 -04:00
Brown
0a8bb32115
Fix #2866 - prevent use of impure __toString via concatenation in pure contexts
2020-02-24 14:50:34 -05:00
Matthew Brown
618ae77846
Prevent implicit __toString method calls in a pure context
2020-02-23 18:18:25 -05:00
Matthew Brown
5c3ec7a531
Fix #2696 - make sure static property references are prevented in pure functions
2020-01-27 22:55:20 -05:00
Brown
da43b8188f
Fix #2632 - detect invalid by-ref assignments in pure functions
2020-01-23 14:21:34 -05:00
Brown
0ac20e76c4
Fix #2631 - evaluate purity of uasort closure
2020-01-23 13:49:15 -05:00
Matthew Brown
ae46c9e132
Fix #2114 - make builtin constructors mutation free
2019-09-21 21:07:27 -04:00
Brown
a6baa2d04c
Allow callables to be understood as pure
...
Fixes #2112
2019-09-09 12:11:04 -04:00
Brown
3c7fd94503
Add more test cases for @psalm-external-mutation-free
2019-09-09 11:23:51 -04:00
Brown
21aa162d0a
Make assert() pure
...
Fixes #2113
2019-09-09 10:43:10 -04:00
Matthew Brown
dee2cf3281
Detect use of static inside pure function
2019-08-31 21:31:53 -04:00
Matthew Brown
dcc4de59df
Change @immutable to @psalm-immutable
2019-08-31 18:43:45 -04:00
Matthew Brown
f20dc16295
Make @immutable work properly
2019-08-31 10:07:23 -04:00
Matthew Brown
900cfc0f05
Improve handling of external-mutation-free objects created in pure functions
2019-08-31 09:49:32 -04:00
Matthew Brown
f096c3d29c
Don’t identify impurity when checking property initialisation
2019-08-31 09:07:00 -04:00
Brown
55cfbdcd5f
Fix erroneous complaint for str_replace
2019-08-13 14:26:25 -04:00
Brown
955899ade0
Builtin functions are assumed to be pure
2019-08-07 15:21:15 -04:00