Valinor/tests/Fake/Definition/Repository/FakeFunctionDefinitionRepository.php
Romain Canon b6b3296638 feat: handle variadic parameters in constructors
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']);
```
2022-02-19 20:17:03 +01:00

36 lines
1016 B
PHP

<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\Fake\Definition\Repository;
use CuyZ\Valinor\Definition\EmptyAttributes;
use CuyZ\Valinor\Definition\FunctionDefinition;
use CuyZ\Valinor\Definition\ParameterDefinition;
use CuyZ\Valinor\Definition\Parameters;
use CuyZ\Valinor\Definition\Repository\FunctionDefinitionRepository;
use CuyZ\Valinor\Type\Types\NativeStringType;
final class FakeFunctionDefinitionRepository implements FunctionDefinitionRepository
{
public function for(callable $function): FunctionDefinition
{
return new FunctionDefinition(
'foo',
'foo:42-1337',
new Parameters(
new ParameterDefinition(
'bar',
'foo::bar',
NativeStringType::get(),
false,
false,
'foo',
EmptyAttributes::get()
)
),
NativeStringType::get()
);
}
}