Skip to content

Instantly share code, notes, and snippets.

@iluuu1994
Created January 19, 2023 17:31
Show Gist options
  • Save iluuu1994/c7950245c13c21f559c81776100b09e0 to your computer and use it in GitHub Desktop.
Save iluuu1994/c7950245c13c21f559c81776100b09e0 to your computer and use it in GitHub Desktop.
<?php
class Foo {
public function __get($name, $scope) {
var_dump($scope);
return '';
}
}
$foo = new Foo();
$foo->bar; // null, called from global scope
function test() {
$foo = new Foo();
$foo->bar; // null, called from non-class scope
}
class Test {
public static function staticTest() {
$foo = new Foo();
$foo->bar; // Test
}
public function test() {
$foo = new Foo();
$foo->bar; // Test
}
}
(function () {
$foo = new Foo();
$foo->bar; // Test
})->bindTo(null, Test::class)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment