- Check for readonly property when calling unset on object properties - Throw fatal error when attempting to unset readonly properties - Add proper error message with property display name - Include tests for unset operations on readonly properties - Support both regular readonly properties and readonly class properties - Ensure consistent error handling for readonly property access violationspull/48/head
parent
3b51eaa6d0
commit
a3ea91918d
4 changed files with 54 additions and 0 deletions
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
readonly class ReadonlyClassPropertyUnset |
||||||
|
{ |
||||||
|
public int $value; |
||||||
|
|
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$this->value = 1; |
||||||
|
} |
||||||
|
|
||||||
|
public function clear(): void |
||||||
|
{ |
||||||
|
unset($this->value); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class ReadonlyPropertyUnset |
||||||
|
{ |
||||||
|
public readonly int $value; |
||||||
|
|
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$this->value = 1; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$object = new ReadonlyPropertyUnset(); |
||||||
|
unset($object->value); |
||||||
|
} |
||||||
Loading…
Reference in new issue