1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 18:48:03 +01:00
Commit Graph

10965 Commits

Author SHA1 Message Date
AndrolGenhald
faf106e717
Merge pull request #8444 from SCIF/bugfix-8439
trim(), ltrim(), rtrim() now keep lowercase string attribute
2022-08-31 08:47:09 -05:00
Aleksandr Zhuravlev
d7097281ba trim(), ltrim(), rtrim() now keep lowercase string attribute 2022-08-31 21:02:20 +12:00
orklah
1eeea7c21d
Merge pull request #8428 from den-kuz/4.x
Allow any attribute for complex types in schema
2022-08-28 14:04:10 +02:00
AndrolGenhald
2fdcd5a5fc
Merge pull request #8436 from TimWolla/attribute-target
Configure a correct attribute target in stubs/CoreGenericClasses.phpstub
2022-08-24 16:59:40 -05:00
Tim Düsterhus
3c2018a1e0 Configure a correct attribute target in stubs/CoreGenericClasses.phpstub 2022-08-24 21:32:26 +02:00
AndrolGenhald
88d33828d8
Merge pull request #8435 from VincentLanglet/arrayReduce
Add support for callable in array_reduce
2022-08-24 09:44:08 -05:00
Vincent Langlet
6bc714c867 Add support for callable in array_reduce 2022-08-24 16:04:22 +02:00
AndrolGenhald
034a796f84
Merge pull request #8431 from LeSuisse/bin2hex-base64-stub
Allow *bin2hex and *bin2base64 functions to keep non-empty-string type
2022-08-23 09:47:18 -05: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
Denis Kuznetsov
93a293c673 Allow any attribute for complex types in schema 2022-08-23 04:19:02 +03:00
orklah
0b790e0982
Merge pull request #8427 from staabm/attr
added SensitiveParameter, AllowDynamicProperties php 8.2 attributes
2022-08-22 19:15:07 +02:00
Markus Staab
72a1c05717
Restore CliUtils.php 2022-08-22 16:59:27 +02:00
Markus Staab
198347fac7 fix test 2022-08-22 16:58:23 +02:00
Markus Staab
8407cacc02 improve CI error message 2022-08-22 16:55:32 +02:00
Markus Staab
a3d58cf2fd imports 2022-08-22 16:55:26 +02:00
Markus Staab
63915d1e2c added SensitiveParameter, AllowDynamicProperties php 8.2 attributes 2022-08-22 16:44:55 +02:00
orklah
91705722ff
Merge pull request #8424 from krsriq/fix_typo
Fix doc typos
2022-08-21 00:13:55 +02:00
Daniel Schmelz
9c67b85f39
Fix typos 2022-08-20 23:29:03 +02:00
orklah
7ee3a81bce
Merge pull request #8370 from someniatko/issue-8363
Ensure we recognize inherited static methods for the first-class callables
2022-08-18 21:50:20 +02:00
orklah
0d0a049eb2
Merge pull request #8405 from vjik/get-modifiers-name
Clarification of `Reflection::getModifierNames()` result type
2022-08-12 18:53:47 +02:00
orklah
24b8b8e6ce
Merge pull request #8403 from paulfedorow/imageinterlace-callmap-fix-4.x
Fix `imageinterlace` function signature
2022-08-12 18:29:19 +02:00
Sergei Predvoditelev
4498a523b9
fix 2022-08-12 16:12:36 +03:00
Sergei Predvoditelev
ffe4375a60
Clarification of Reflection::getModifierNames() result type 2022-08-12 16:03:56 +03:00
Paul Fedorow
8908638219 Fix imageinterlace function signature 2022-08-12 11:22:45 +02:00
orklah
7e010a7a4f
Merge pull request #8372 from kkmuffme/safely-read-write-cache-data
always use lock when writing/reading cache data to/from file
2022-08-11 18:06:56 +02:00
orklah
28f22c7b57
Merge pull request #8400 from staabm/truthy
added truthy-string alias for non-falsy-string
2022-08-11 17:35:58 +02:00
Markus Staab
8f6e16add6 added truthy-string alias for non-falsy-string 2022-08-11 16:49:58 +02:00
kkmuffme
8ca594a34d always use lock when writing/reading cache data to/from file 2022-08-11 13:12:47 +02:00
AndrolGenhald
aae539560b
Merge pull request #8376 from Daeroni/fix-8373
Use classlike_storage_provider only if it has the required data
2022-08-08 16:01:49 -05:00
Teemu Koskinen
89b7b3234b
Add test for #8373
Undefined classes in function dockblocks should not crash psalm.
Test provided by @AndrolGenhald
2022-08-08 23:49:14 +03:00
Teemu Koskinen
fefd4861d6
Use $codebase->classlike_storage_provider only if it has the required data. Fixes #8373 2022-08-08 23:49:14 +03:00
orklah
57fcc3968e
Merge pull request #8350 from Ocramius/fix/datetime-constructor-is-not-immutable
Added better stubs for `DateTimeImmutable`, highlighting how the constructor is **NOT** immutable
2022-08-07 22:57:43 +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
a1ed84f1ed Removed DateTimeImmutable::createFromMutable() from the CallMap: fully covered by stub 2022-08-05 12:52:32 +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
cb9939cbd3 Removed DateTimeImmutable::add() from the CallMap: fully covered by stub
Ref: 534127d3b2/ext/date/php_date.stub.php (L511-L512)
Ref: 534127d3b2/ext/date/php_date.c (L3129-L3144)
2022-08-05 12:39:16 +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
18557b8c70 Removed DateTimeImmutable::diff() from the CallMap: fully covered by stub 2022-08-05 12:34:31 +02:00
Marco Pivetta
002585b57e Removed DateTimeImmutable::getTimestamp() from the CallMap: fully covered by stub
This also simplifies the return type from `int|false` to always `int`,
since a timestamp can always be produced.

Ref: eff9aed159/ext/date/php_date.stub.php (L496-L500)
2022-08-05 12:32:26 +02:00
Marco Pivetta
1be04e0988 Removed DateTimeImmutable::getOffset() from the CallMap: fully covered by stub 2022-08-05 12:27:29 +02:00
Marco Pivetta
2b6fddf88d Removed DateTimeImmutable::getTimezone() from the CallMap: fully covered by stub
Note: also verified that a `DateTimeImmutable#getTimezone()` always returns
a default timezone (initialized internally), and therefore restricted the
type a bit.
2022-08-05 12:26:59 +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
58ca4e0b73 Removed DateTimeImmutable::createFromFormat() from the CallMap: fully covered by stub 2022-08-05 12:23:43 +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
dc7d26abb1 Removed DateTimeImmutable::__construct from the CallMap: fully covered by stub 2022-08-05 12:22:27 +02:00