class myClass { protected function myProtectedMethod() { // code } } $reflectionMethod = new ReflectionMethod('myClass', 'myProtectedMethod'); if ($reflectionMethod->isProtected()) { echo "The method myProtectedMethod is protected."; } else { echo "The method myProtectedMethod is not protected."; }
class myClass { protected function myProtectedMethod() { // code } public function myPublicMethod() { // code } } $reflectionClass = new ReflectionClass('myClass'); $methods = $reflectionClass->getMethods(); foreach ($methods as $method) { if ($method->isProtected()) { echo "{$method->getName()} is protected. "; } else { echo "{$method->getName()} is not protected. "; } }Package/library: `php-reflect`.