- Updated swoole/phpx from ~2.4.3 to ~2.4.5 in composer.json - Added new test case for static::class runtime called scope behavior - Added new test case for magic method indirect property update using __get by reference - Extended existing magic method tests with isset true scenario that skips readingpull/45/head
parent
a7b16dc1be
commit
6d7e68a9ff
4 changed files with 91 additions and 1 deletions
@ -0,0 +1,27 @@ |
|||||||
|
--TEST-- |
||||||
|
static::class uses the runtime called scope |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
class CalledClassParent |
||||||
|
{ |
||||||
|
public static function name(): string |
||||||
|
{ |
||||||
|
return static::class; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class CalledClassChild extends CalledClassParent |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
var_dump(CalledClassParent::name()); |
||||||
|
var_dump(CalledClassChild::name()); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
string(17) "CalledClassParent" |
||||||
|
string(16) "CalledClassChild" |
||||||
@ -0,0 +1,41 @@ |
|||||||
|
--TEST-- |
||||||
|
Magic Methods - indirect property update uses __get by reference |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
class MagicUpdateTest |
||||||
|
{ |
||||||
|
private array $values = []; |
||||||
|
|
||||||
|
public function __isset(string $name): bool |
||||||
|
{ |
||||||
|
echo "__isset($name)\n"; |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public function &__get(string $name): mixed |
||||||
|
{ |
||||||
|
echo "__get($name)\n"; |
||||||
|
return $this->values[$name]; |
||||||
|
} |
||||||
|
|
||||||
|
public function value(string $name): mixed |
||||||
|
{ |
||||||
|
return $this->values[$name] ?? null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$probe = new MagicUpdateTest(); |
||||||
|
$probe->value[] = 42; |
||||||
|
var_dump($probe->value('value')); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
__get(value) |
||||||
|
array(1) { |
||||||
|
[0]=> |
||||||
|
int(42) |
||||||
|
} |
||||||
Loading…
Reference in new issue