-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
SplType.php
61 lines (55 loc) · 1.58 KB
/
SplType.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Part of SplTypes package.
*
* (c) Adrien Loyant <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Ducks\Component\SplTypes;
/**
* Parent class for all SPL types.
*
* @template T
*
* @psalm-api
*/
abstract class SplType implements
\JsonSerializable,
\Stringable
{
/** @use SplTypeTrait<T> */
use SplTypeTrait;
/**
* Default value.
*
* @var mixed
*/
// phpcs:ignore Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
protected const __default = null;
/**
* Creates a new value of some type.
*
* @param mixed $initial_value Type and default value depends on the extension class.
* @param bool $strict Whether to set the object's sctrictness.
*
* @return void
*
* @phpstan-param T|null $initial_value Type and default value depends on the extension class.
* @phpstan-param bool $strict Whether to set the object's sctrictness.
* @phpstan-ignore-next-line
*
* @psalm-suppress PossiblyUnusedParam
*
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct($initial_value = self::__default, /** @scrutinizer ignore-unused */ bool $strict = true)
{
/** @var T $this->__default */
$this->__default = $initial_value ?? static::__default;
}
}