mirror of
https://github.com/danog/Valinor.git
synced 2025-01-10 06:38:24 +01:00
Daniil Gentili
afcedf9e56
Allows the usage of boolean values, as follows: ```php class Foo { /** @var int|false */ public readonly int|bool $value; } ```
55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace CuyZ\Valinor\Tests\Integration\Mapping\Fixture;
|
|
|
|
// @PHP8.0 move inside \CuyZ\Valinor\Tests\Integration\Mapping\UnionValuesMappingTest
|
|
class NativeUnionValues
|
|
{
|
|
public bool|float|int|string $scalarWithBoolean = 'Schwifty!';
|
|
|
|
public bool|float|int|string $scalarWithFloat = 'Schwifty!';
|
|
|
|
public bool|float|int|string $scalarWithInteger = 'Schwifty!';
|
|
|
|
public bool|float|int|string $scalarWithString = 'Schwifty!';
|
|
|
|
public string|null $nullableWithString = 'Schwifty!';
|
|
|
|
public string|null $nullableWithNull = 'Schwifty!';
|
|
|
|
/** @var int|true */
|
|
public int|bool $intOrLiteralTrue = 42;
|
|
|
|
/** @var int|false */
|
|
public int|bool $intOrLiteralFalse = 42;
|
|
}
|
|
|
|
class NativeUnionValuesWithConstructor extends NativeUnionValues
|
|
{
|
|
/**
|
|
* @param int|true $intOrLiteralTrue
|
|
* @param int|false $intOrLiteralFalse
|
|
*/
|
|
public function __construct(
|
|
bool|float|int|string $scalarWithBoolean = 'Schwifty!',
|
|
bool|float|int|string $scalarWithFloat = 'Schwifty!',
|
|
bool|float|int|string $scalarWithInteger = 'Schwifty!',
|
|
bool|float|int|string $scalarWithString = 'Schwifty!',
|
|
string|null $nullableWithString = 'Schwifty!',
|
|
string|null $nullableWithNull = 'Schwifty!',
|
|
int|bool $intOrLiteralTrue = 42,
|
|
int|bool $intOrLiteralFalse = 42
|
|
) {
|
|
$this->scalarWithBoolean = $scalarWithBoolean;
|
|
$this->scalarWithFloat = $scalarWithFloat;
|
|
$this->scalarWithInteger = $scalarWithInteger;
|
|
$this->scalarWithString = $scalarWithString;
|
|
$this->nullableWithString = $nullableWithString;
|
|
$this->nullableWithNull = $nullableWithNull;
|
|
$this->intOrLiteralTrue = $intOrLiteralTrue;
|
|
$this->intOrLiteralFalse = $intOrLiteralFalse;
|
|
}
|
|
}
|