Skip to content

Instantly share code, notes, and snippets.

@telless
Last active September 5, 2018 11:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save telless/fe942e202b408b1b614faf638d7aea30 to your computer and use it in GitHub Desktop.
<?php
class A
{
public $prop;
public function __construct()
{
$this->prop = 'prop';
}
public function method()
{
return 'method';
}
}
class B extends A
{
}
print_r((new ReflectionMethod(B::class, 'method'))->invoke(new A()).PHP_EOL);
print_r((new ReflectionProperty(B::class, 'prop'))->getValue(new A()).PHP_EOL);
@telless
Copy link
Author

telless commented Sep 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment