|
| 1 | +--TEST-- |
| 2 | +Using ReflectionClass::__toString() with hooked properties (GH-17927) |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +interface IHookedDemo { |
| 7 | + public mixed $getOnly { get; } |
| 8 | + public mixed $setOnly { set; } |
| 9 | + public mixed $both { get; set; } |
| 10 | +} |
| 11 | +abstract class HookedDemo { |
| 12 | + abstract public mixed $getOnly { get; } |
| 13 | + abstract public mixed $setOnly { set; } |
| 14 | + abstract public mixed $both { get; set; } |
| 15 | +} |
| 16 | +class WithHooks { |
| 17 | + public mixed $getOnly { |
| 18 | + get => "always this string"; |
| 19 | + } |
| 20 | + public mixed $setOnly { |
| 21 | + set => strtolower($value); |
| 22 | + } |
| 23 | + public mixed $both { |
| 24 | + get => $this->prop3; |
| 25 | + set => strtolower($value); |
| 26 | + } |
| 27 | +} |
| 28 | +class WithFinalHooks { |
| 29 | + public mixed $getOnly { |
| 30 | + final get => "always this string"; |
| 31 | + } |
| 32 | + public mixed $setOnly { |
| 33 | + final set => strtolower($value); |
| 34 | + } |
| 35 | + public mixed $both { |
| 36 | + final get => $this->prop3; |
| 37 | + final set => strtolower($value); |
| 38 | + } |
| 39 | +} |
| 40 | +class WithMixedHooks { |
| 41 | + public mixed $getIsFinal { |
| 42 | + final get => "always this string"; |
| 43 | + set => strtolower($value); |
| 44 | + } |
| 45 | + public mixed $setIsFinal { |
| 46 | + get => $this->setIsFinal; |
| 47 | + final set => strtolower($value); |
| 48 | + } |
| 49 | +} |
| 50 | +$classes = [ |
| 51 | + IHookedDemo::class, |
| 52 | + HookedDemo::class, |
| 53 | + WithHooks::class, |
| 54 | + WithFinalHooks::class, |
| 55 | + WithMixedHooks::class, |
| 56 | +]; |
| 57 | +foreach ( $classes as $clazz ) { |
| 58 | + echo new ReflectionClass( $clazz ); |
| 59 | +} |
| 60 | +?> |
| 61 | +--EXPECTF-- |
| 62 | +Interface [ <user> <iterateable> interface IHookedDemo ] { |
| 63 | + @@ %s %d-%d |
| 64 | + |
| 65 | + - Constants [0] { |
| 66 | + } |
| 67 | + |
| 68 | + - Static properties [0] { |
| 69 | + } |
| 70 | + |
| 71 | + - Static methods [0] { |
| 72 | + } |
| 73 | + |
| 74 | + - Properties [3] { |
| 75 | + Property [ abstract public virtual mixed $getOnly { get; } ] |
| 76 | + Property [ abstract public virtual mixed $setOnly { set; } ] |
| 77 | + Property [ abstract public virtual mixed $both { get; set; } ] |
| 78 | + } |
| 79 | + |
| 80 | + - Methods [0] { |
| 81 | + } |
| 82 | +} |
| 83 | +Class [ <user> <iterateable> abstract class HookedDemo ] { |
| 84 | + @@ %s %d-%d |
| 85 | + |
| 86 | + - Constants [0] { |
| 87 | + } |
| 88 | + |
| 89 | + - Static properties [0] { |
| 90 | + } |
| 91 | + |
| 92 | + - Static methods [0] { |
| 93 | + } |
| 94 | + |
| 95 | + - Properties [3] { |
| 96 | + Property [ abstract public virtual mixed $getOnly { get; } ] |
| 97 | + Property [ abstract public virtual mixed $setOnly { set; } ] |
| 98 | + Property [ abstract public virtual mixed $both { get; set; } ] |
| 99 | + } |
| 100 | + |
| 101 | + - Methods [0] { |
| 102 | + } |
| 103 | +} |
| 104 | +Class [ <user> <iterateable> class WithHooks ] { |
| 105 | + @@ %s %d-%d |
| 106 | + |
| 107 | + - Constants [0] { |
| 108 | + } |
| 109 | + |
| 110 | + - Static properties [0] { |
| 111 | + } |
| 112 | + |
| 113 | + - Static methods [0] { |
| 114 | + } |
| 115 | + |
| 116 | + - Properties [3] { |
| 117 | + Property [ public virtual mixed $getOnly { get; } ] |
| 118 | + Property [ public mixed $setOnly { set; } ] |
| 119 | + Property [ public mixed $both { get; set; } ] |
| 120 | + } |
| 121 | + |
| 122 | + - Methods [0] { |
| 123 | + } |
| 124 | +} |
| 125 | +Class [ <user> <iterateable> class WithFinalHooks ] { |
| 126 | + @@ %s %d-%d |
| 127 | + |
| 128 | + - Constants [0] { |
| 129 | + } |
| 130 | + |
| 131 | + - Static properties [0] { |
| 132 | + } |
| 133 | + |
| 134 | + - Static methods [0] { |
| 135 | + } |
| 136 | + |
| 137 | + - Properties [3] { |
| 138 | + Property [ public virtual mixed $getOnly { final get; } ] |
| 139 | + Property [ public mixed $setOnly { final set; } ] |
| 140 | + Property [ public mixed $both { final get; final set; } ] |
| 141 | + } |
| 142 | + |
| 143 | + - Methods [0] { |
| 144 | + } |
| 145 | +} |
| 146 | +Class [ <user> <iterateable> class WithMixedHooks ] { |
| 147 | + @@ %s %d-%d |
| 148 | + |
| 149 | + - Constants [0] { |
| 150 | + } |
| 151 | + |
| 152 | + - Static properties [0] { |
| 153 | + } |
| 154 | + |
| 155 | + - Static methods [0] { |
| 156 | + } |
| 157 | + |
| 158 | + - Properties [2] { |
| 159 | + Property [ public mixed $getIsFinal { final get; set; } ] |
| 160 | + Property [ public mixed $setIsFinal { get; final set; } ] |
| 161 | + } |
| 162 | + |
| 163 | + - Methods [0] { |
| 164 | + } |
| 165 | +} |
0 commit comments