php-src/Zend/tests/magic_methods/overloaded_prop_assign_op_refs.phpt
DanielEScherzer 674663464e
Zend/tests: organize some tests with sub directories (9) (#17897)
Add directories for tests relating to
- calling user functions (`call_user_func()` and `call_user_func_array()`)
- using `::class` to access class names
- null coalescing with `??`
- concatenation with `.`
- indirect function calls (e.g. by calling a variable with a function name)
- reporting of line numbers
- static variables in functions
- type casts

As well as organizing a couple of tests into existing sub directories along the
way

Work towards GH-15631
2025-02-23 14:41:49 +00:00

47 lines
673 B
PHP

--TEST--
Handling of assign-ops and incdecs on overloaded properties using &__get()
--FILE--
<?php
class Test {
protected $a = 0;
protected $b = 0;
protected $c = 0;
public function &__get($name) {
echo "get($name)\n";
return $this->$name;
}
public function __set($name, $value) {
echo "set($name, $value)\n";
}
}
$test = new Test;
var_dump($test->a += 1);
var_dump($test->b++);
var_dump(++$test->c);
var_dump($test);
?>
--EXPECT--
get(a)
set(a, 1)
int(1)
get(b)
set(b, 1)
int(0)
get(c)
set(c, 1)
int(1)
object(Test)#1 (3) {
["a":protected]=>
int(0)
["b":protected]=>
int(0)
["c":protected]=>
int(0)
}