Created
January 31, 2013 18:29
-
-
Save bobmagicii/4685064 to your computer and use it in GitHub Desktop.
testing how good is_callable is about method accessibility.
This file contains hidden or 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 | |
class BobTest { | |
public function PublicMethod() { return; } | |
protected function ProtectedMethod() { return; } | |
private function PrivateMethod() { return; } | |
public function TestCallables() { | |
echo "testing myself...", PHP_EOL; | |
foreach((new ReflectionClass(__CLASS__))->getMethods() as $m) { | |
if(is_callable([$this,$m->name])) | |
echo "->{$m->name} yep", PHP_EOL; | |
else | |
echo "->{$m->name} nope", PHP_EOL; | |
} | |
} | |
} | |
$test = new BobTest; | |
$test->TestCallables(); | |
echo "testing publicly...", PHP_EOL; | |
foreach((new ReflectionClass($test))->getMethods() as $m) { | |
if(is_callable([$test,$m->name])) | |
echo "->{$m->name} yep", PHP_EOL; | |
else | |
echo "->{$m->name} nope", PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment