Created
April 27, 2015 19:46
-
-
Save shadowhand/915ff25729b038577475 to your computer and use it in GitHub Desktop.
Check if a class implements all methods of an interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Created for https://github.com/facebook/hhvm/issues/5170 | |
require 'vendor/autoload.php'; | |
$i = new ReflectionClass('League\OAuth2\Client\Provider\ProviderInterface'); | |
$c = new ReflectionClass('League\OAuth2\Client\Provider\AbstractProvider'); | |
$r = []; | |
$h = []; | |
foreach ($i->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { | |
$r[] = $method->getName(); | |
} | |
foreach ($c->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { | |
if ($method->getDeclaringClass() == $c) { | |
$h[] = $method->getName(); | |
} | |
} | |
$missing = array_diff($r, $h); | |
if (empty($missing)) { | |
printf("OKAY: %s implements all methods of %s\n", | |
$c->getName(), | |
$i->getName() | |
); | |
} else { | |
printf("ERROR: %s is missing some methods of %s:\n- %s\n", | |
$c->getName(), | |
$i->getName(), | |
implode("\n- ", $missing) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment