You are here

class ClassNode in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/css-selector/Node/ClassNode.php \Symfony\Component\CssSelector\Node\ClassNode
  2. 8 vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/Node/ClassNode.php \Prophecy\Doubler\Generator\Node\ClassNode
Same name and namespace in other branches
  1. 8.0 vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/Node/ClassNode.php \Prophecy\Doubler\Generator\Node\ClassNode

Class node.

@author Konstantin Kudryashov <ever.zet@gmail.com>

Hierarchy

  • class \Prophecy\Doubler\Generator\Node\ClassNode

Expanded class hierarchy of ClassNode

10 files declare their use of ClassNode
ClassCreatorException.php in vendor/phpspec/prophecy/src/Prophecy/Exception/Doubler/ClassCreatorException.php
ClassPatchInterface.php in vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ClassPatchInterface.php
DisableConstructorPatch.php in vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/DisableConstructorPatch.php
HhvmExceptionPatch.php in vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/HhvmExceptionPatch.php
KeywordPatch.php in vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/KeywordPatch.php

... See full list

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/Node/ClassNode.php, line 21

Namespace

Prophecy\Doubler\Generator\Node
View source
class ClassNode {
  private $parentClass = 'stdClass';
  private $interfaces = array();
  private $properties = array();

  /**
   * @var MethodNode[]
   */
  private $methods = array();
  public function getParentClass() {
    return $this->parentClass;
  }

  /**
   * @param string $class
   */
  public function setParentClass($class) {
    $this->parentClass = $class ?: 'stdClass';
  }

  /**
   * @return string[]
   */
  public function getInterfaces() {
    return $this->interfaces;
  }

  /**
   * @param string $interface
   */
  public function addInterface($interface) {
    if ($this
      ->hasInterface($interface)) {
      return;
    }
    array_unshift($this->interfaces, $interface);
  }

  /**
   * @param string $interface
   *
   * @return bool
   */
  public function hasInterface($interface) {
    return in_array($interface, $this->interfaces);
  }
  public function getProperties() {
    return $this->properties;
  }
  public function addProperty($name, $visibility = 'public') {
    $visibility = strtolower($visibility);
    if (!in_array($visibility, array(
      'public',
      'private',
      'protected',
    ))) {
      throw new InvalidArgumentException(sprintf('`%s` property visibility is not supported.', $visibility));
    }
    $this->properties[$name] = $visibility;
  }

  /**
   * @return MethodNode[]
   */
  public function getMethods() {
    return $this->methods;
  }
  public function addMethod(MethodNode $method) {
    $this->methods[$method
      ->getName()] = $method;
  }
  public function removeMethod($name) {
    unset($this->methods[$name]);
  }

  /**
   * @param string $name
   *
   * @return MethodNode|null
   */
  public function getMethod($name) {
    return $this
      ->hasMethod($name) ? $this->methods[$name] : null;
  }

  /**
   * @param string $name
   *
   * @return bool
   */
  public function hasMethod($name) {
    return isset($this->methods[$name]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ClassNode::$interfaces private property
ClassNode::$methods private property
ClassNode::$parentClass private property
ClassNode::$properties private property
ClassNode::addInterface public function
ClassNode::addMethod public function
ClassNode::addProperty public function
ClassNode::getInterfaces public function
ClassNode::getMethod public function
ClassNode::getMethods public function
ClassNode::getParentClass public function
ClassNode::getProperties public function
ClassNode::hasInterface public function
ClassNode::hasMethod public function
ClassNode::removeMethod public function
ClassNode::setParentClass public function