You are here

class RuntimeReflectionService in Plug 7

PHP Runtime Reflection Service.

@author Benjamin Eberlei <kontakt@beberlei.de>

Hierarchy

Expanded class hierarchy of RuntimeReflectionService

1 file declares its use of RuntimeReflectionService
RuntimeReflectionServiceTest.php in lib/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php

File

lib/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php, line 33

Namespace

Doctrine\Common\Persistence\Mapping
View source
class RuntimeReflectionService implements ReflectionService {

  /**
   * {@inheritDoc}
   */
  public function getParentClasses($class) {
    if (!class_exists($class)) {
      throw MappingException::nonExistingClass($class);
    }
    return class_parents($class);
  }

  /**
   * {@inheritDoc}
   */
  public function getClassShortName($class) {
    $reflectionClass = new ReflectionClass($class);
    return $reflectionClass
      ->getShortName();
  }

  /**
   * {@inheritDoc}
   */
  public function getClassNamespace($class) {
    $reflectionClass = new ReflectionClass($class);
    return $reflectionClass
      ->getNamespaceName();
  }

  /**
   * {@inheritDoc}
   */
  public function getClass($class) {
    return new ReflectionClass($class);
  }

  /**
   * {@inheritDoc}
   */
  public function getAccessibleProperty($class, $property) {
    $reflectionProperty = new ReflectionProperty($class, $property);
    if ($reflectionProperty
      ->isPublic()) {
      $reflectionProperty = new RuntimePublicReflectionProperty($class, $property);
    }
    $reflectionProperty
      ->setAccessible(true);
    return $reflectionProperty;
  }

  /**
   * {@inheritDoc}
   */
  public function hasPublicMethod($class, $method) {
    try {
      $reflectionMethod = new ReflectionMethod($class, $method);
    } catch (ReflectionException $e) {
      return false;
    }
    return $reflectionMethod
      ->isPublic();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RuntimeReflectionService::getAccessibleProperty public function Returns an accessible property (setAccessible(true)) or null. Overrides ReflectionService::getAccessibleProperty
RuntimeReflectionService::getClass public function Returns a reflection class instance or null. Overrides ReflectionService::getClass
RuntimeReflectionService::getClassNamespace public function Overrides ReflectionService::getClassNamespace
RuntimeReflectionService::getClassShortName public function Returns the shortname of a class. Overrides ReflectionService::getClassShortName
RuntimeReflectionService::getParentClasses public function Returns an array of the parent classes (not interfaces) for the given class. Overrides ReflectionService::getParentClasses
RuntimeReflectionService::hasPublicMethod public function Checks if the class have a public method with the given name. Overrides ReflectionService::hasPublicMethod