mirror of
https://github.com/danog/Valinor.git
synced 2024-12-12 09:09:38 +01:00
897ca9b65e
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
30 lines
743 B
PHP
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
|
|
{
|
|
}
|
|
}
|