mirror of
https://github.com/danog/Valinor.git
synced 2024-11-27 04:34:48 +01:00
b6b3296638
Using variadic parameters is now handled properly by the library, meaning the following example will run: ```php final class SomeClass { /** @var string[] */ private array $values; public function __construct(string ...$values) { $this->values = $values; } } (new \CuyZ\Valinor\MapperBuilder()) ->mapper() ->map(SomeClass::class, ['foo', 'bar', 'baz']); ```
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace CuyZ\Valinor\Tests\Unit\Definition;
|
|
|
|
use CuyZ\Valinor\Definition\ParameterDefinition;
|
|
use CuyZ\Valinor\Tests\Fake\Definition\FakeAttributes;
|
|
use CuyZ\Valinor\Tests\Fake\Type\FakeType;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ParameterDefinitionTest extends TestCase
|
|
{
|
|
public function test_parameter_data_can_be_retrieved(): void
|
|
{
|
|
$name = 'someParameter';
|
|
$signature = 'someParameterSignature';
|
|
$type = new FakeType();
|
|
$isOptional = true;
|
|
$isVariadic = true;
|
|
$defaultValue = 'Some parameter default value';
|
|
$attributes = new FakeAttributes();
|
|
|
|
$parameter = new ParameterDefinition(
|
|
$name,
|
|
$signature,
|
|
$type,
|
|
$isOptional,
|
|
$isVariadic,
|
|
$defaultValue,
|
|
$attributes
|
|
);
|
|
|
|
self::assertSame($name, $parameter->name());
|
|
self::assertSame($signature, $parameter->signature());
|
|
self::assertSame($type, $parameter->type());
|
|
self::assertSame($isOptional, $parameter->isOptional());
|
|
self::assertSame($isVariadic, $parameter->isVariadic());
|
|
self::assertSame($defaultValue, $parameter->defaultValue());
|
|
self::assertSame($attributes, $parameter->attributes());
|
|
}
|
|
}
|