| @@ -55,9 +55,15 @@ | ||
| 55 | 55 | // property getter |
| 56 | 56 | if (!($prop & 0b1)) { |
| 57 | 57 | throw new MemberAccessException("Cannot read a write-only property {$class}::\${$name}."); |
| 58 | 58 | } |
| 59 | - $m = ($prop & 0b10 ? 'get' : 'is') . $name; | |
| 59 | + $m = ($prop & 0b10 ? 'get' : 'is') . \ucfirst($name); | |
| 60 | + if ($prop & 0b10000) { | |
| 61 | + $trace = \debug_backtrace(0, 1)[0]; | |
| 62 | + // suppose this method is called from __call() | |
| 63 | + $loc = isset($trace['file'], $trace['line']) ? " in {$trace['file']} on line {$trace['line']}" : ''; | |
| 64 | + \trigger_error("Property {$class}::\${$name} is deprecated, use {$class}::{$m}() method{$loc}.", \E_USER_DEPRECATED); | |
| 65 | + } | |
| 60 | 66 | if ($prop & 0b100) { |
| 61 | 67 | // return by reference |
| 62 | 68 | return $this->{$m}(); |
| 63 | 69 | } else { |
| @@ -83,9 +89,16 @@ | ||
| 83 | 89 | // property setter |
| 84 | 90 | if (!($prop & 0b1000)) { |
| 85 | 91 | throw new MemberAccessException("Cannot write to a read-only property {$class}::\${$name}."); |
| 86 | 92 | } |
| 87 | - $this->{'set' . $name}($value); | |
| 93 | + $m = 'set' . \ucfirst($name); | |
| 94 | + if ($prop & 0b10000) { | |
| 95 | + $trace = \debug_backtrace(0, 1)[0]; | |
| 96 | + // suppose this method is called from __call() | |
| 97 | + $loc = isset($trace['file'], $trace['line']) ? " in {$trace['file']} on line {$trace['line']}" : ''; | |
| 98 | + \trigger_error("Property {$class}::\${$name} is deprecated, use {$class}::{$m}() method{$loc}.", \E_USER_DEPRECATED); | |
| 99 | + } | |
| 100 | + $this->{$m}($value); | |
| 88 | 101 | } else { |
| 89 | 102 | ObjectHelpers::strictSet($class, $name); |
| 90 | 103 | } |
| 91 | 104 | } |