2020-03-10 20:12:55 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class DateTimeImmutable implements DateTimeInterface
|
|
|
|
{
|
2021-02-14 18:07:39 +01:00
|
|
|
public function __construct(string $datetime = "now", DateTimeZone $timezone = null) {}
|
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
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
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
|
|
|
* @return static|false
|
|
|
|
*/
|
|
|
|
public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
2022-08-05 12:24:35 +02:00
|
|
|
*
|
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
|
|
|
* @param string $format
|
2022-08-05 12:24:35 +02:00
|
|
|
*
|
2022-08-05 13:21:28 +02:00
|
|
|
* @return ($format is non-empty-string ? non-empty-string : string)
|
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
|
|
|
*/
|
|
|
|
public function format($format) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
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
|
|
|
* @return DateTimeZone
|
|
|
|
*/
|
|
|
|
public function getTimezone() {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
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
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getOffset() {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
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
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getTimestamp() {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
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
|
|
|
* @param bool $absolute
|
|
|
|
* @return DateInterval
|
|
|
|
*/
|
|
|
|
public function diff(DateTimeInterface $targetObject, $absolute = false) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
2022-08-05 12:37:24 +02:00
|
|
|
* @return static|false
|
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
|
|
|
*/
|
|
|
|
public function modify(string $modifier) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
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
|
|
|
* @return static
|
|
|
|
*/
|
|
|
|
public function add(DateInterval $interval) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
2022-10-14 01:49:57 +02:00
|
|
|
* @return static
|
2022-10-14 01:56:20 +02:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
public function sub(DateInterval $interval) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
2022-08-05 12:42:45 +02:00
|
|
|
* @return static
|
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
|
|
|
*/
|
|
|
|
public function setTimezone(DateTimeZone $timezone) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
2022-08-05 12:47:04 +02:00
|
|
|
* @return static
|
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
|
|
|
*/
|
|
|
|
public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
2022-08-05 12:48:29 +02:00
|
|
|
* @return static
|
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
|
|
|
*/
|
|
|
|
public function setDate(int $year, int $month, int $day) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
2022-08-05 12:49:45 +02:00
|
|
|
* @return static
|
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
|
|
|
*/
|
|
|
|
public function setISODate(int $year, int $week, int $dayOfWeek = 1) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
2022-08-05 12:50:51 +02:00
|
|
|
* @return static
|
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
|
|
|
*/
|
|
|
|
public function setTimestamp(int $unixtimestamp) {}
|
|
|
|
|
|
|
|
/**
|
2022-08-01 10:08:35 +02:00
|
|
|
* @psalm-mutation-free
|
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
|
|
|
* @return static
|
|
|
|
*/
|
|
|
|
public static function createFromMutable(DateTime $object) {}
|
2020-03-10 20:12:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-immutable
|
|
|
|
*/
|
|
|
|
class DateTimeZone
|
|
|
|
{
|
2021-02-14 18:07:39 +01:00
|
|
|
public function __construct(string $timezone) {}
|
2020-03-10 20:12:55 +01:00
|
|
|
}
|
|
|
|
|
2022-07-22 15:03:45 +02:00
|
|
|
/**
|
|
|
|
* @psalm-immutable
|
|
|
|
*
|
2022-07-25 15:37:49 +02:00
|
|
|
* @template-covariant Start of string|DateTimeInterface
|
|
|
|
* @implements Traversable<int, DateTimeInterface>
|
2022-07-22 15:03:45 +02:00
|
|
|
*/
|
2022-07-25 15:37:49 +02:00
|
|
|
class DatePeriod implements Traversable
|
2022-07-22 15:03:45 +02:00
|
|
|
{
|
|
|
|
const EXCLUDE_START_DATE = 1;
|
|
|
|
/**
|
2022-07-25 15:37:49 +02:00
|
|
|
* @param Start $start
|
|
|
|
* @param (Start is string ? 0|self::EXCLUDE_START_DATE : DateInterval) $interval
|
|
|
|
* @param (Start is string ? never : DateTimeInterface|positive-int) $end
|
|
|
|
* @param (Start is string ? never : 0|self::EXCLUDE_START_DATE) $options
|
2022-07-22 15:03:45 +02:00
|
|
|
*/
|
2022-07-25 15:37:49 +02:00
|
|
|
public function __construct($start, $interval = 0, $end = 1, $options = 0) {}
|
2022-07-22 15:03:45 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 17:51:24 +02:00
|
|
|
/**
|
|
|
|
* @psalm-taint-specialize
|
|
|
|
*/
|
2020-03-10 20:12:55 +01:00
|
|
|
interface Throwable
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
2020-04-20 23:17:47 +02:00
|
|
|
public function getMessage() : string;
|
2020-04-18 04:08:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
2020-04-18 16:39:23 +02:00
|
|
|
*
|
|
|
|
* @return int|string https://www.php.net/manual/en/throwable.getcode.php
|
2020-04-18 04:08:26 +02:00
|
|
|
*/
|
2020-04-20 23:17:47 +02:00
|
|
|
public function getCode();
|
2020-04-18 04:08:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
2020-04-20 23:17:47 +02:00
|
|
|
public function getFile() : string;
|
2020-04-18 04:08:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
2020-04-20 23:17:47 +02:00
|
|
|
public function getLine() : int;
|
2020-04-18 04:08:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
2022-11-05 22:34:42 +01:00
|
|
|
* @return list<strict-array{file?:string,line?:int,function?:string,class?:class-string,type?:'::'|'->',args?:array<mixed>}>
|
2020-04-18 04:08:26 +02:00
|
|
|
*/
|
2020-04-20 23:17:47 +02:00
|
|
|
public function getTrace() : array;
|
2020-04-18 04:08:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
2020-04-20 23:17:47 +02:00
|
|
|
public function getPrevious() : ?Throwable;
|
2020-04-18 04:08:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
2020-07-02 03:27:40 +02:00
|
|
|
* @psalm-taint-source input
|
2020-04-18 04:08:26 +02:00
|
|
|
*/
|
2020-04-20 23:17:47 +02:00
|
|
|
public function getTraceAsString() : string;
|
2020-07-02 03:27:40 +02:00
|
|
|
|
|
|
|
/**
|
2020-07-02 20:09:56 +02:00
|
|
|
* @return string
|
2020-07-02 03:27:40 +02:00
|
|
|
* @psalm-taint-source input
|
|
|
|
*/
|
2020-07-02 20:09:56 +02:00
|
|
|
public function __toString();
|
2020-03-10 20:12:55 +01:00
|
|
|
}
|
|
|
|
|
2020-06-24 17:51:24 +02:00
|
|
|
/**
|
|
|
|
* @psalm-taint-specialize
|
|
|
|
*/
|
2020-03-10 20:12:55 +01:00
|
|
|
class Exception implements Throwable
|
|
|
|
{
|
2020-03-11 20:43:15 +01:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2020-03-11 22:41:05 +01:00
|
|
|
protected $message = '';
|
2020-03-11 20:43:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
2020-03-11 22:41:05 +01:00
|
|
|
protected $code = 0;
|
2020-03-11 20:43:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2020-03-11 22:41:05 +01:00
|
|
|
protected $file = '';
|
2020-03-11 20:43:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
2020-03-11 22:41:05 +01:00
|
|
|
protected $line = 0;
|
2020-03-11 20:43:15 +01:00
|
|
|
|
2020-03-10 20:12:55 +01:00
|
|
|
/**
|
|
|
|
* @psalm-external-mutation-free
|
|
|
|
* @param string $message
|
|
|
|
* @param int $code
|
|
|
|
* @param Throwable $previous
|
|
|
|
*/
|
2020-03-11 22:41:05 +01:00
|
|
|
public function __construct($message = "", $code = 0, Throwable $previous = null) {}
|
2020-03-10 20:12:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
|
|
|
public final function getMessage() : string {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
2020-04-18 16:39:23 +02:00
|
|
|
*
|
|
|
|
* @return int|string https://www.php.net/manual/en/throwable.getcode.php
|
2020-03-10 20:12:55 +01:00
|
|
|
*/
|
2020-04-18 16:39:23 +02:00
|
|
|
public final function getCode() {}
|
2020-03-10 20:12:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
2020-04-18 04:08:26 +02:00
|
|
|
public final function getFile(): string {}
|
2020-03-10 20:12:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
2020-04-18 04:08:26 +02:00
|
|
|
public final function getLine(): int {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
2022-11-05 22:34:42 +01:00
|
|
|
* @return list<strict-array{file?:string,line?:int,function?:string,class?:class-string,type?:'::'|'->',args?:array<mixed>}>
|
2020-04-18 04:08:26 +02:00
|
|
|
*/
|
|
|
|
public final function getTrace() : array {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
|
|
|
public final function getPrevious() : ?Throwable {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
2020-07-02 03:27:40 +02:00
|
|
|
* @psalm-taint-source input
|
2020-04-18 04:08:26 +02:00
|
|
|
*/
|
|
|
|
public final function getTraceAsString() : string {}
|
2020-07-02 03:27:40 +02:00
|
|
|
|
|
|
|
/**
|
2020-07-02 20:09:56 +02:00
|
|
|
* @return string
|
2020-07-02 03:27:40 +02:00
|
|
|
* @psalm-taint-source input
|
|
|
|
*/
|
2020-07-02 20:09:56 +02:00
|
|
|
public function __toString() {}
|
2020-03-10 20:12:55 +01:00
|
|
|
}
|
2020-03-22 00:11:23 +01:00
|
|
|
|
2020-06-24 17:51:24 +02:00
|
|
|
/**
|
|
|
|
* @psalm-taint-specialize
|
|
|
|
*/
|
2020-03-22 00:11:23 +01:00
|
|
|
class Error implements Throwable
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $message = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $code = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $file = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $line = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-external-mutation-free
|
|
|
|
* @param string $message
|
|
|
|
* @param int $code
|
|
|
|
* @param Throwable $previous
|
|
|
|
*/
|
|
|
|
public function __construct($message = "", $code = 0, Throwable $previous = null) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
|
|
|
public final function getMessage() : string {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
2020-04-18 04:08:26 +02:00
|
|
|
public final function getCode(): int {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
|
|
|
public final function getFile(): string {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
|
|
|
public final function getLine(): int{}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
2022-11-05 22:34:42 +01:00
|
|
|
* @return list<strict-array{file?:string,line?:int,function?:string,class?:class-string,type?:'::'|'->',args?:array<mixed>}>
|
2020-04-18 04:08:26 +02:00
|
|
|
*/
|
|
|
|
public final function getTrace() : array {}
|
2020-03-22 00:11:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
|
|
|
*/
|
2020-04-18 04:08:26 +02:00
|
|
|
public final function getPrevious() : ?Throwable {}
|
2020-03-22 00:11:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-mutation-free
|
2020-07-02 03:27:40 +02:00
|
|
|
* @psalm-taint-source input
|
2020-03-22 00:11:23 +01:00
|
|
|
*/
|
2020-04-18 04:08:26 +02:00
|
|
|
public final function getTraceAsString() : string {}
|
2020-07-02 03:27:40 +02:00
|
|
|
|
|
|
|
/**
|
2020-07-02 20:09:56 +02:00
|
|
|
* @return string
|
2020-07-02 03:27:40 +02:00
|
|
|
* @psalm-taint-source input
|
|
|
|
*/
|
2020-07-02 20:09:56 +02:00
|
|
|
public function __toString() {}
|
2020-03-22 00:11:23 +01:00
|
|
|
}
|