Valinor/tests/Fixture/Object/ObjectWithAttributes.php
Radhi Guennichi 897ca9b65e
fix: handle native attribute on promoted parameter
Handles race condition when the attribute is affected to a property or 
parameter that was promoted, in this case the attribute will be applied
to both `ParameterReflection` and `PropertyReflection`, but the target
argument inside the attribute class is configured to support only one of
them (parameter or property).

More details: https://wiki.php.net/rfc/constructor_promotion#attributes
2022-07-31 15:42:58 +02:00

30 lines
743 B
PHP

<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\Fixture\Object;
use CuyZ\Valinor\Tests\Fixture\Attribute\AttributeWithArguments;
use CuyZ\Valinor\Tests\Fixture\Attribute\BasicAttribute;
use CuyZ\Valinor\Tests\Fixture\Attribute\PropertyTargetAttribute;
#[BasicAttribute]
#[AttributeWithArguments('foo', 'bar')]
// @PHP8.0 move to anonymous class
final class ObjectWithAttributes
{
#[BasicAttribute]
#[AttributeWithArguments('foo', 'bar')]
public bool $property;
public function __construct(#[PropertyTargetAttribute] public bool $promotedProperty)
{
}
#[BasicAttribute]
#[AttributeWithArguments('foo', 'bar')]
public function method(#[BasicAttribute] string $parameter): void
{
}
}