1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/Zend/tests/closures/closure_037.phpt
DanielEScherzer 8475d5fea1 Zend/tests: organize some tests with subdirectories (#15638)
Move some low-hanging fruit, creating new directories for the tests for

* access modifiers
* `class_alias()`
* constant expressions
* constructor property promotion
* `__debugInfo()`
* dereferencing
* first class callable syntax

Additionally, move some tests into the existing subdirectory for
closure-related tests

Work towards GH-15631
2024-10-13 14:21:07 +01:00

48 lines
668 B
PHP

--TEST--
Closure 037: self:: and static:: within closures
--FILE--
<?php
class A {
private $x = 0;
function getClosure () {
return function () {
$this->x++;
self::printX();
self::print42();
static::print42();
};
}
function printX () {
echo $this->x."\n";
}
function print42() {
echo "42\n";
}
}
class B extends A {
function print42() {
echo "forty two\n";
}
}
$a = new A;
$closure = $a->getClosure();
$closure();
$b = new B;
$closure = $b->getClosure();
$closure();
?>
Done.
--EXPECT--
1
42
42
1
42
forty two
Done.