Matthew Brown
8d36bdc3ed
Make array shapes strict by default ( #8701 )
...
* Make array shapes strict by default
* Fix PSL tests
2022-11-11 20:14:21 -05:00
68a5511057
Merge remote-tracking branch 'origin/4.x' into HEAD
2022-11-08 10:25:04 +01:00
Marco Pivetta
5e9b921fc6
Making json_encode()
always produce a non-empty-string
, when successful
...
`json_encode()` never produces `''` as a value: that would be invalid JSON anyway
2022-11-07 20:42:47 +01: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
Alies Lapatsin
d9a08ec047
Add stubs for ext-random (PHP 8.2)
2022-11-02 15:59:56 +03:00
William Owen O. Ponce
77b3962b94
Fix typo
2022-10-31 23:09:07 +08:00
Thomas Gerbet
62e92fb0cf
Add stubs for ext-ffi
...
See #8612
2022-10-25 19:59:44 +02:00
orklah
e8e8777561
Merge pull request #8592 from gphargreaves/#7810/improve-reflection-stubs
...
#7810/improve reflection stubs
2022-10-18 00:09:06 +02:00
orklah
48b8efde99
Merge pull request #8584 from boesing/feature/8521
...
Enhance type detection for internal php functions `key`, `current`, `end` and `reset`
2022-10-18 00:07:13 +02:00
Maximilian Bösing
7f35bff0d9
feature: enhance type detection for internal php functions key
, current
, end
and reset
...
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-10-17 20:24:40 +02:00
Greg Hargreaves
45bb58ebfa
Add stub for reflection property isReadOnly
2022-10-17 00:46:19 +01:00
Greg Hargreaves
ea39a6e674
Fixes #7810
2022-10-17 00:33:26 +01:00
cbd1a27ea7
Merge branch 'master' into merge_4.x
2022-10-16 13:49:21 +02:00
b79c43a288
Merge remote-tracking branch 'origin/4.x' into merge_4.x
2022-10-16 13:42:43 +02:00
748a74bb2c
Merge remote-tracking branch 'origin/4.x' into HEAD
2022-10-16 13:41:27 +02:00
ADmad
9bd4d7a740
Fix template param for SplDoublyLinkedList.
...
It's key is always an integer.
2022-10-14 11:54:53 +05:30
Greg Hargreaves
ef0d2256a6
Remove link to php-src as was part of the documented reason for the return type false
2022-10-14 00:56:20 +01:00
Greg Hargreaves
f573ef5163
Correct return type of DateTimeImmutable sub method stub
2022-10-14 00:49:57 +01:00
kkmuffme
88ba8452c4
some more string values
2022-10-09 17:01:38 +02:00
kkmuffme
5bfc0f960b
force $value to be string
...
technically all stringable types work https://github.com/phpredis/phpredis/issues/1735#event-7529843256 however they're all cast to string implicitly, which unevitably leads to unexpected results (see riskyCast,...)
2022-10-09 16:53:30 +02:00
kkmuffme
47317205c1
small improvement for return type of mGet
2022-10-09 16:51:26 +02:00
kkmuffme
dfa82366d7
add false return type to additional phpredis functions
...
address https://github.com/phpredis/phpredis/pull/2120#issuecomment-1166644919 - weedwacker method, as I don't have time to check it all one by one
2022-10-09 16:46:43 +02:00
orklah
5108834088
Merge pull request #8136 from sergkash7/patch-1
...
Update phpredis.phpstub
2022-09-09 07:47:53 +02:00
Aleksandr Zhuravlev
d7097281ba
trim(), ltrim(), rtrim() now keep lowercase string attribute
2022-08-31 21:02:20 +12:00
Tim Düsterhus
3c2018a1e0
Configure a correct attribute target in stubs/CoreGenericClasses.phpstub
2022-08-24 21:32:26 +02:00
Thomas Gerbet
4b1adaafec
Allow *bin2hex and *bin2base64 functions to keep non-empty-string type
...
Those functions should not return a string when they receive a
non-empty-string in input.
The following example is expected to work:
```php
<?php
/**
* @param non-empty-string $i
*/
function takesNonEmptyString(string $i): void {
echo $i;
}
takesNonEmptyString(bin2hex("a"));
takesNonEmptyString(base64_encode("a"));
```
2022-08-23 16:38:17 +02:00
Markus Staab
63915d1e2c
added SensitiveParameter, AllowDynamicProperties php 8.2 attributes
2022-08-22 16:44:55 +02:00
Marco Pivetta
13828771c7
Removed DateTimeImmutable::createFromInterface()
from stubs
...
While there is value in declaring `DateTimeImmutable::createFromInterface()` as mutation-free in
a stub, this method was introduced in PHP 8.0, so we cannot really declare it in a stub.
For now, we drop it, as the value of its stub declaration is much lower than the problems it
introduces through its conditional existence.
2022-08-05 13:28:53 +02:00
Marco Pivetta
68ffae097e
Simplified DateTimeImmutable::format()
: always returns a string
...
Also:
* a non-empty format string will always lead to `non-empty-string`
* it seems that you can throw **everything** at `DateTimeInterface#format()`, even null bytes,
and it will always produce a `string`
2022-08-05 13:21:28 +02:00
Marco Pivetta
aaac9ccb90
Removed DateTimeImmutable::setTimestamp()
from the CallMap: fully covered by stub
...
Also simplified the return type from `static|false` to `static`, since
the method throws at all times, on failure.
On PHP 7.x, it could only fail if an invalid type was passed in, which is
not really valid anyway, from a type perspective.
Ref (PHP 8.1.x): 32d55f7422/ext/date/php_date.c (L3353-L3369)
Ref (PHP 7.0.33): bf574c2b67/ext/date/php_date.c (L3596-L3612)
2022-08-05 12:50:51 +02:00
Marco Pivetta
964f64a500
Removed DateTimeImmutable::setISODate()
from the CallMap: fully covered by stub
...
Also simplified the return type from `static|false` to `static`, since
the method throws at all times, on failure.
On PHP 7.x, it could only fail if an invalid type was passed in, which is
not really valid anyway, from a type perspective.
Ref (PHP 8.1.x): 32d55f7422/ext/date/php_date.c (L3308-L3324)
Ref (PHP 7.0.33): bf574c2b67/ext/date/php_date.c (L3549-L3565)
2022-08-05 12:49:45 +02:00
Marco Pivetta
0a6c9d0177
Removed DateTimeImmutable::setDate()
from the CallMap: fully covered by stub
...
Also simplified the return type from `static|false` to `static`, since
the method throws at all times, on failure.
On PHP 7.x, it could only fail if an invalid type was passed in, which is
not really valid anyway, from a type perspective.
Ref (PHP 8.1.x): 32d55f7422/ext/date/php_date.c (L3258-L3274)
Ref (PHP 7.0.33): bf574c2b67/ext/date/php_date.c (L3496-L3512)
2022-08-05 12:48:29 +02:00
Marco Pivetta
e61c593a2c
Removed DateTimeImmutable::setTime()
from the CallMap: fully covered by stub
...
Also simplified the return type from `static|false` to `static`, since
the method throws at all times, on failure.
On PHP 7.x, it could only fail if an invalid type was passed in, which is
not really valid anyway, from a type perspective.
Ref (PHP 8.1.x): 32d55f7422/ext/date/php_date.c (L3212-L3228)
Ref (PHP 7.0.33): bf574c2b67/ext/date/php_date.c (L3447-L3463)
2022-08-05 12:47:04 +02:00
Marco Pivetta
4fe554d6d2
Removed DateTimeImmutable::setTimezone()
from the CallMap: fully covered by stub
...
Also simplified the return type from `static|false` to `static`, since
the method throws at all times, on failure.
On PHP 7.x, it could only fail if an invalid type was passed in, which is
not really valid anyway, from a type perspective.
Ref (PHP 8.2.x): 534127d3b2/ext/date/php_date.c (L3291-L3307)
Ref (PHP 8.2.x): 534127d3b2/ext/date/php_date.stub.php (L517-L518)
Ref (PHP 7.0.33): bf574c2b67/ext/date/php_date.c (L3363-L3379)
2022-08-05 12:42:45 +02:00
Marco Pivetta
7cd3d49dc4
Removed DateTimeImmutable::modify()
from the CallMap: fully covered by stub
...
Also expanded the return type from `static` to `static|false`, since the
operation can fail (with a warning too), such as in following example:
https://3v4l.org/Xrjlc
```php
<?php
var_dump(
(new DateTimeImmutable())
->modify('potato')
);
```
Produces
```
Warning: DateTimeImmutable::modify(): Failed to parse time string (potato) at position 0 (p): The timezone could not be found in the database in /in/Xrjlc on line 6
bool(false)
```
Ref: 534127d3b2/ext/date/php_date.stub.php (L508-L509)
2022-08-05 12:37:24 +02:00
Marco Pivetta
7ee12c7493
Removed DateTimeImmutable::format()
from the CallMap: fully covered by stub
...
Note: some conditional return type magic was required here.
See: https://github.com/vimeo/psalm/pull/8350#discussion_r937089212
2022-08-05 12:24:35 +02:00
Marco Pivetta
267d76088d
Removed DateTimeImmutable::sub()
from the CallMap: fully covered by stub
2022-08-05 12:23:00 +02:00
Marco Pivetta
68978b9e19
s/psalm-pure/psalm-mutation-free, since psalm-mutation-free is safer to use
...
Ref: c205d652d1 (r934032422)
The idea is that `@psalm-pure` disallows `$this` usage in child classes,
which is not wanted, while `@psalm-mutation-free` allows it.
By using `@psalm-mutation-free`, we don't completely destroy inheritance
use-cases based on internal (immutable) state.
2022-08-01 10:08:35 +02:00
Marco Pivetta
b4b2bc66c7
Added better stubs for DateTimeImmutable
, highlighting how the constructor is **NOT** immutable
...
`DateTimeImmutable` is **almost** immutable: `DateTimeImmutable::__construct()` is in fact not a pure
method, since `new DateTimeImmutable('now')` produces a different value at each instantiation (by design).
This change makes sure that `DateTimeImmutable` loses its `@psalm-immutable` class-level marker,
preventing downstream misuse of the constructor inside otherwise referentially transparent code.
Note: only pure methods are stubbed here: all other methods declared by `DateTimeImmutable` (parent interface)
are NOT present here, and are either inferred from runtime reflection, or `CallMap*.php` definitions.
Methods are sorted in the order defined by reflection on PHP 8.1.8, at the time of writing this ( https://3v4l.org/3TGg8 ).
Following simplistic snippet was used to infer the current signature:
```php
<?php
$c = new \ReflectionClass(\DateTimeImmutable::class);
$methods = array_map(function ($m) {
return $m->getName()
. '(' . implode(',', array_map(function ($p) {
return $p->getType()
. ' $' . $p->getName()
. ($p->isOptional() ? ' = ' . var_export($p->getDefaultValue(), true) : '');
}, $m->getParameters())) . ')' . ($m->getReturnType() ? (': ' . $m->getReturnType()) : '');
}, $c->getMethods());
$properties = array_map(function ($m) {
return $m->getName();
}, $c->getProperties());
var_dump($methods, $properties);
```
2022-07-31 18:02:30 +02:00
Semyon
b1295d6894
Code style
2022-07-25 17:15:28 +03:00
Semyon
462ce7138a
Make DatePeriod implement Traversable oh PHP 7, rename constructor params
2022-07-25 17:11:36 +03:00
Semyon
9d3253482d
Add stub for DatePeriod
2022-07-25 17:11:36 +03:00
Pol Dellaiera
63b64532d6
Update CachingIterator
, use int-mask-of
.
2022-07-22 18:38:12 +02:00
Pol Dellaiera
3e0f0b6173
Update CachingIterator
, remove newly added @template
.
...
Also update `RecursiveCachingIterator`, remove extended methods and constructor that are the same.
2022-07-21 08:22:02 +02:00
Pol Dellaiera
f4da6aafaa
Update stub based on PR feedback.
2022-07-18 18:13:08 +02:00
Pol Dellaiera
2747f028c9
Update CachingIterator::getCache
stub.
2022-07-18 16:24:10 +02:00
Corey Taylor
f28ac73777
Fix nullable return types for CallMap functions
2022-07-13 22:44:38 -05:00
AndrolGenhald
285740a753
Merge branch '4.x'
2022-07-07 15:01:38 -05:00
Adrien Foulon
6c49dad38c
fix: ltrim may return class-string #8218
...
Fixes #8218
2022-07-06 02:36:20 +02:00
Christian Schiffler
ce4ba69e70
Add missing properties to stubs/Reflection.phpstub
...
This should fix the now failing tests as the properties got removed from
the autogenerated property map.
2022-07-04 11:14:34 +02:00
Benjamin Morel
df6fdb99d7
Fix return type of ReflectionNamedType::getName()
...
Fixes #8167
2022-06-29 18:22:46 +02:00
AndrolGenhald
79603820d8
Fix SimpleXMLIterator::current() return type.
2022-06-22 01:38:58 -05:00
AndrolGenhald
c0de59c943
Add simplexml stub.
2022-06-22 01:15:43 -05:00
AndrolGenhald
ea987697dc
Update DOM stub.
2022-06-22 00:44:19 -05:00
sergkash7
ffe18296b0
Update phpredis.phpstub
2022-06-21 22:03:11 +03:00
Bruce Weirdan
e0acf22e40
Merge branch '4.x' into update-master
2022-05-28 14:49:12 -04:00
Kevin van Sonsbeek
23eff58a09
bugfix/#7912: Add Iterator implements to stub
2022-05-17 23:55:44 +02:00
Kevin van Sonsbeek
f86b599878
bugfix/#7912: Added stub for the APCu extension
2022-05-17 23:45:08 +02:00
hirokinoue
4fc34d998b
improve @return annotation of join()
2022-05-14 23:47:46 +09:00
hirokinoue
91640e7e90
improve @return annotation of implode()
2022-05-14 23:44:43 +09:00
Markus Staab
3c837e5d9a
fix missing is_a() parameter type
2022-05-12 15:37:29 +02:00
hirokinoue
2b34b1228b
handle the non-empty case for usort()
2022-04-29 00:36:28 +09:00
hirokinoue
8c64bddf29
handle the non-empty case for uksort()
2022-04-29 00:23:57 +09:00
hirokinoue
37bf36d475
handle the non-empty case for uasort()
2022-04-28 23:49:32 +09:00
hirokinoue
95b5e8cb56
handle the non-empty case for shuffle()
2022-04-28 23:07:43 +09:00
hirokinoue
1605b18678
handle the non-empty case for rsort()
2022-04-28 23:01:17 +09:00
hirokinoue
0770f0128c
improve syntax
2022-04-28 22:44:39 +09:00
Matt Brown
5b91506926
cache statements even without persistent parser cache
2022-04-27 01:50:13 -04:00
Matt Brown
a9e3c1fdc1
Fix namespaced min/max int range keyword issue introduced in #7775 .
2022-04-27 01:44:57 -04:00
Matt Brown
043bbfbbb4
Remove useless array casting as CallMap for stream_select is reset.
2022-04-27 01:40:51 -04:00
Matt Brown
0c65a19554
Allow null to ArrayAccess::offsetSet $offset param
2022-04-27 01:34:09 -04:00
Matt Brown
d58736a550
fix #7747 : DateInterval::createFromDateString can be false
2022-04-27 01:32:38 -04:00
hirokinoue
37c53ee783
handle the non-empty case for sort()
2022-04-23 22:51:50 +09:00
hirokinoue
c6d7bc0d19
Improve Throwable::getTrace() return type
2022-04-12 23:42:37 +09:00
Ciaran McNulty
ca185d7f28
Update Throwable::getTrace in stubs
2022-03-18 09:14:37 +00:00
orklah
7cfb601ab8
Merge pull request #7718 from niconoe-/fix-3036
...
Fix #3036 : make argument $read of internal PHP function stream_socket nullable.
2022-03-13 16:16:35 +01:00
Nicolas Giraud
0dc435409c
Replace changes in the CallMap for stream_select by a stub.
2022-03-11 08:52:36 +01:00
Fran Moreno
ff195e76c9
Allow null to ArrayAccess::offsetSet $offset param
2022-03-06 13:47:32 +01:00
kkmuffme
8fc41e6907
update phpredis stubs
...
* fixes feedback for setOption of https://github.com/vimeo/psalm/issues/7709
* latest WIP stubs with additional changes from upstream phpredis master and other additions
From https://raw.githubusercontent.com/phpredis/phpredis/77334ecbf2c06ea1ff18ea5e3ecc168cb1897a8b/redis.stub.php via https://github.com/phpredis/phpredis/pull/2015
2022-03-04 12:56:30 +01:00
orklah
0fe6eaf5d9
Merge remote-tracking branch 'upstream/4.x' into upstream-master13
2022-02-26 21:26:59 +01:00
AndrolGenhald
1387f94324
Attribute analysis improvements.
2022-02-23 22:12:32 -06:00
Bei Xiao
40cc346991
Update stub
2022-02-23 00:52:53 +02:00
Mark McEver
828b093964
Prevent unnecessary filter_var() warnings on primitive types
2022-02-15 14:13:44 -06:00
orklah
fac55576ab
Merge remote-tracking branch 'upstream/4.x' into upstream-master7
2022-02-12 09:59:55 +01:00
orklah
c13a536386
Merge pull request #7614 from kkmuffme/add-phpredis-stubs
...
add phpredis stubs
2022-02-11 23:15:48 +01:00
Bruce Weirdan
11e60fa261
Merge branch '4.x' into upstream-master
2022-02-11 03:51:48 +02:00
orklah
0702a0b3e7
add ReflectionIntersectionType stub
2022-02-09 19:32:17 +01:00
Office
9d120896d5
add phpredis stubs
2022-02-09 08:14:58 +01:00
orklah
2e01e9b7cd
Merge pull request #7396 from Patrick-Remy/feat/key-of-value-of-improvements
...
feat: make key-of/value-of usable with non-const arrays
2022-01-31 21:39:01 +01:00
orklah
1220320e0b
fix some iterator stubs ( #6970 )
...
* fix some iterator stubs
* fix iterators
* update stubs
* fix a test
* fixes
* fixes
* fix a test
* fix
2022-01-30 01:18:05 +01:00
AndrolGenhald
653d17ff81
Add stub for PDOException.
2022-01-27 17:05:48 -06:00
AndrolGenhald
02cd7bbbba
Add SoapHeader stub.
2022-01-27 16:30:14 -06:00
AndrolGenhald
63cd3f3b95
Add SoapFault stub.
2022-01-27 16:30:14 -06:00
AndrolGenhald
2fe4fc397c
Enable extensions based on composer.json instead of those loaded at runtime ( fixes #5482 ).
2022-01-27 16:30:14 -06:00
Patrick Remy
8cd5ccd076
feat: make value-of<T>
capable for template types
2022-01-27 22:28:40 +01:00
Patrick Remy
2880d046ce
feat: make key-of/value-of usable with non-const arrays
2022-01-27 22:22:14 +01:00
orklah
841d4f4429
improve support for enum_exists
2022-01-22 18:27:24 +01:00
Bruce Weirdan
3fb3db3516
Merge branch '4.x' into upstream-master
2022-01-06 10:05:53 +02:00
Andreas Hennings
9da6b3f094
Issue #6618 : All reflection classes should implement Reflector.
2022-01-06 01:55:55 +01:00
Bruce Weirdan
c1acab4606
Merge branch '4.x' into upstream-master
2022-01-03 22:06:12 +02:00