Skip to content

Commit

Permalink
Simplified DateTimeImmutable::format(): always returns a string
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
Ocramius committed Aug 5, 2022
1 parent a1ed84f commit 68ffae0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion stubs/CoreImmutableClasses.phpstub
Expand Up @@ -15,7 +15,7 @@ class DateTimeImmutable implements DateTimeInterface
*
* @param string $format
*
* @return (\PHP_MAJOR_VERSION is int<0, 7> ? string|false : string)
* @return ($format is non-empty-string ? non-empty-string : string)
*/
public function format($format) {}

Expand Down
4 changes: 2 additions & 2 deletions tests/MethodCallTest.php
Expand Up @@ -271,8 +271,8 @@ final class MyDate extends DateTimeImmutable {}
$b = (new DateTimeImmutable())->modify("+3 hours");',
'assertions' => [
'$yesterday' => 'MyDate',
'$b' => 'DateTimeImmutable',
'$yesterday' => 'MyDate|false',
'$b' => 'DateTimeImmutable|false',
],
],
'magicCall' => [
Expand Down

0 comments on commit 68ffae0

Please sign in to comment.