|
| 1 | +--TEST-- |
| 2 | +#[\DelayedTargetValidation] with #[\Deprecated]: validator errors delayed |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +#[DelayedTargetValidation] |
| 7 | +#[Deprecated] |
| 8 | +interface DemoInterface {} |
| 9 | + |
| 10 | +#[DelayedTargetValidation] |
| 11 | +#[Deprecated] |
| 12 | +class DemoClass {} |
| 13 | + |
| 14 | +#[DelayedTargetValidation] |
| 15 | +#[Deprecated] |
| 16 | +enum DemoEnum {} |
| 17 | + |
| 18 | +$cases = [ |
| 19 | +new ReflectionClass('DemoInterface'), |
| 20 | +new ReflectionClass('DemoClass'), |
| 21 | +new ReflectionClass('DemoEnum'), |
| 22 | +]; |
| 23 | +foreach ($cases as $r) { |
| 24 | +echo str_repeat("*", 20) . "\n"; |
| 25 | +echo $r . "\n"; |
| 26 | +$attributes = $r->getAttributes(); |
| 27 | +var_dump($attributes); |
| 28 | +try { |
| 29 | +$attributes[1]->newInstance(); |
| 30 | +} catch (Error $e) { |
| 31 | +echo get_class($e) . ": " . $e->getMessage() . "\n"; |
| 32 | +} |
| 33 | +} |
| 34 | + |
| 35 | +?> |
| 36 | +--EXPECTF-- |
| 37 | +******************** |
| 38 | +Interface [ <user> interface DemoInterface ] { |
| 39 | + @@ %s %d-%d |
| 40 | + |
| 41 | + - Constants [0] { |
| 42 | + } |
| 43 | + |
| 44 | + - Static properties [0] { |
| 45 | + } |
| 46 | + |
| 47 | + - Static methods [0] { |
| 48 | + } |
| 49 | + |
| 50 | + - Properties [0] { |
| 51 | + } |
| 52 | + |
| 53 | + - Methods [0] { |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +array(2) { |
| 58 | + [0]=> |
| 59 | + object(ReflectionAttribute)#%d (1) { |
| 60 | + ["name"]=> |
| 61 | + string(23) "DelayedTargetValidation" |
| 62 | + } |
| 63 | + [1]=> |
| 64 | + object(ReflectionAttribute)#%d (1) { |
| 65 | + ["name"]=> |
| 66 | + string(10) "Deprecated" |
| 67 | + } |
| 68 | +} |
| 69 | +Error: Cannot apply #[\Deprecated] to interface DemoInterface |
| 70 | +******************** |
| 71 | +Class [ <user> class DemoClass ] { |
| 72 | + @@ %s %d-%d |
| 73 | + |
| 74 | + - Constants [0] { |
| 75 | + } |
| 76 | + |
| 77 | + - Static properties [0] { |
| 78 | + } |
| 79 | + |
| 80 | + - Static methods [0] { |
| 81 | + } |
| 82 | + |
| 83 | + - Properties [0] { |
| 84 | + } |
| 85 | + |
| 86 | + - Methods [0] { |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +array(2) { |
| 91 | + [0]=> |
| 92 | + object(ReflectionAttribute)#%d (1) { |
| 93 | + ["name"]=> |
| 94 | + string(23) "DelayedTargetValidation" |
| 95 | + } |
| 96 | + [1]=> |
| 97 | + object(ReflectionAttribute)#%d (1) { |
| 98 | + ["name"]=> |
| 99 | + string(10) "Deprecated" |
| 100 | + } |
| 101 | +} |
| 102 | +Error: Cannot apply #[\Deprecated] to class DemoClass |
| 103 | +******************** |
| 104 | +Enum [ <user> enum DemoEnum implements UnitEnum ] { |
| 105 | + @@ %s %d-%d |
| 106 | + |
| 107 | + - Constants [0] { |
| 108 | + } |
| 109 | + |
| 110 | + - Static properties [0] { |
| 111 | + } |
| 112 | + |
| 113 | + - Static methods [1] { |
| 114 | + Method [ <internal, prototype UnitEnum> static public method cases ] { |
| 115 | + |
| 116 | + - Parameters [0] { |
| 117 | + } |
| 118 | + - Return [ array ] |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + - Properties [1] { |
| 123 | + Property [ public protected(set) readonly string $name ] |
| 124 | + } |
| 125 | + |
| 126 | + - Methods [0] { |
| 127 | + } |
| 128 | +} |
| 129 | + |
| 130 | +array(2) { |
| 131 | + [0]=> |
| 132 | + object(ReflectionAttribute)#%d (1) { |
| 133 | + ["name"]=> |
| 134 | + string(23) "DelayedTargetValidation" |
| 135 | + } |
| 136 | + [1]=> |
| 137 | + object(ReflectionAttribute)#%d (1) { |
| 138 | + ["name"]=> |
| 139 | + string(10) "Deprecated" |
| 140 | + } |
| 141 | +} |
| 142 | +Error: Cannot apply #[\Deprecated] to enum DemoEnum |
0 commit comments