Skip to content

Instantly share code, notes, and snippets.

@hnw
Created March 2, 2018 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnw/141c1af2f0641b3696c474ad0dae8056 to your computer and use it in GitHub Desktop.
Save hnw/141c1af2f0641b3696c474ad0dae8056 to your computer and use it in GitHub Desktop.
<?php
abstract class Foo {
abstract public function func(int $y);
}
class Bar extends Foo {
public function func(int $y) {
return 1;
}
}
class Baz extends Bar {
public function func(int $y) {
}
}
$cl = new ReflectionClass(new Baz());
$methods = $cl->getMethods();
foreach ($methods as $mt) {
printf("method: class=%s, name=%s\n", $mt->getDeclaringClass()->getName(), $mt->getName());
$proto = $mt->getPrototype();
printf("prototype: class=%s name=%s\n", $proto->getDeclaringClass()->getName(), $proto->getName());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment