Parse a class variable given $class_name::
@param $class_name
@param $colon_node
@return Node
171704
private function classVariable($class_name, $colon_node) {
    if ($this->currentType === '{') {
      // Must be $class_name::{expr()}().
      return $this->classMethodCall($class_name, $colon_node, $this->bracesExpr());
    }

    /*
     * Note $var_node contains possible array lookup, eg. $a[0]. This must
     * happen cause $class::$var[0]() is treated as $class::($var[0])();
     * However $class::$var[0] is treated as ($class::$var)[0], but in order
     * to determine between these two cases, the [0] has to be matched.
     */
    $var_node = $this->indirectReference();
    if ($this->currentType === '(') {
      return $this->classMethodCall($class_name, $colon_node, $var_node);
    }
    else {
      /*
       * Since $class::$var[0] is treated as ($class::$var)[0] then have
       * to replace the $var in $var[0] with $class::$var.
       */
      if ($var_node instanceof ArrayLookupNode) {
        // Find the member name, eg. $var
        $member_name = $var_node;
        while ($member_name instanceof ArrayLookupNode) {
          $member_name = $member_name->getArray();
        }
        // Replace the member name with ClassMemberLookupNode, eg. $class::$var
        $node = new ClassMemberLookupNode();
        $node->addChild($class_name, 'className');
        $node->mergeNode($colon_node);
        $node->addChild(clone $member_name, 'memberName');
        $member_name->replaceWith($node);
        return $this->objectDereference($var_node);
      }
      else {
        $node = new ClassMemberLookupNode();
        $node->addChild($class_name, 'className');
        $node->mergeNode($colon_node);
        $node->addChild($var_node, 'memberName');
        return $this->objectDereference($node);
      }
    }
  }
939667
public function get(string $class_name, array $args = [])
    {
        $class_name = ltrim($class_name, '\\');
        $class_key  = strtolower($class_name);

        if (isset($this->instances[$class_key])) {
            return $this->instances[$class_key];
        }
        if (!isset($this->closures[$class_key])) {
            $this->closures[$class_key] = $this->getClosure($class_name, $class_key);
        }
        return $this->closures[$class_key]($args);
    }
1059497
private function parseClassCode(string $code, string $className):array
    {
        $codeSansComments = $this->stripComments($code);
        $lines = array_map("trim", explode("\n", $codeSansComments));
        preg_match_all("/p[a-zA-Z]*\sfunction\s+([a-zA-Z\_]*)\(.*?\).*/ui", $code, $matches);

        if (!empty($matches[0])) {

            $functions = array_map(function ($item, $key) use ($lines, $matches, $className) {

                $startLineNumber = array_search($item, $lines);
                if ($startLineNumber) {
                    if (isset($matches[0][$key+1])) {
                        $endLineNumber =  array_search($matches[0][$key+1], $lines);
                    }
                    if (isset($endLineNumber) && is_int($endLineNumber)) {
                        $code = trim(implode("\n", array_slice( $lines, $startLineNumber, $endLineNumber - $startLineNumber )));
                    } else {
                        $code = trim(implode("\n", array_slice( $lines, $startLineNumber )));
                    }
                }

                return array(
                    "className" => $className,
                    "name" => $matches[1][$key],
                    "code" => isset($code)?$code:""
                );

            }, $matches[0], array_keys($matches[0]));

            return $functions;

        }

        return array();

    }
824831
public function load($classname, $name = null) {

		if(false === is_string($classname)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($classname)), E_USER_ERROR);
		}

		if(null !== $name && false === is_string($name)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR);
		}

		$directories 	= explode('.', $classname); //Convert dots to directory seperators
		$amount 		= count($directories) - 1;
		$namespace 		= Router :: getRoute() -> getModule() . '\\' . str_replace(DIRECTORY_SEPARATOR, '\\', Application :: get(['directory', 'validator']));

		foreach($directories as $index => $directory) {

			if($amount === $index) {
				
				$namespace .= Application :: get(['prefix', 'validator']) . ucfirst($directory);
				break;
			}

			$namespace 	.= $directory . '\\';
		}

		if(false === class_exists($namespace)) {
			return trigger_error(sprintf('Class "%s" does not exists or is not a valid validator rule', $namespace), E_USER_ERROR);
		}

		$name = (null !== $name ? $name : $directory);
		$this -> custom[$name] = $namespace;

		$instance = $this -> getMessageInstance();
		$instance :: loadCustom($directory, $namespace, $name);

		return $this;
	}
946483
protected function childrenByInstance($class_name) {
    $matches = [];
    $child = $this->head;
    while ($child) {
      if ($child instanceof $class_name) {
        $matches[] = $child;
      }
      $child = $child->next;
    }
    return $matches;
  }
548407
public function getJavaClass(string $class_name): Interfaces\JavaClass
    {
        try {
            $class = $this->pjbProxyClient->getJavaClass($class_name);
        } catch (Pjb62BrokenConnectionException | Exception\InvalidUsageException $e) {
            PjbProxyClient::unregisterInstance();
            throw new BrokenConnectionException($e->getMessage(), $e->getCode(), $e);
        }

        return $class;
    }
1202063
public function getRowsByClass($class_name)
    {
        $rows = array();
        foreach ($this->extra_rows as $row) {
            if ($row instanceof $class_name) {
                $rows[] = $row;
            }
        }

        return $rows;
    }
1305827
protected function formatClass($class_name, $ctor_args)
    {
        $r = new ReflectionClass($class_name);
        $data = $r->newInstanceArgs((array) $ctor_args);

        foreach ($this->getData() as $key => $value) {
            $data->$key = $value;
        }

        return $data;
    }
744490
public static function getAnonymousClassName(PhpParser\Node\Stmt\Class_ $class, $file_path)
    {
        return preg_replace('/[^A-Za-z0-9]/', '_', $file_path)
            . '_' . $class->getLine() . '_' . (int)$class->getAttribute('startFilePos');
    }
317648
protected function getClosure(string $class_name, string $class_key): callable
    {
        $parent_class_names = class_parents($class_name);
        $all_class_names    = $parent_class_names;
        $all_class_names[]  = $class_name;

        $class                      = new \ReflectionClass($class_name);
        $constructor                = $class->getConstructor(); // Null if no constructor.
        $class_rule                 = $this->getRule($class_name, $class_key, $parent_class_names);
        $constructor_params_closure = $constructor ? $this->getParamsClosure($constructor, $class_rule) : null;

        if (!$this->rules['*']['new_instances'] || !array_intersect($all_class_names, $this->rules['*']['new_instances'])) {
            return function (array $args) use ($class, $class_key, $constructor, $constructor_params_closure) {
                if ($constructor && $constructor_params_closure) {
                    return $this->instances[$class_key] = $class->newInstanceArgs($constructor_params_closure($args));
                } else {
                    return $this->instances[$class_key] = $class->newInstanceWithoutConstructor();
                }
            };
        } elseif ($constructor && $constructor_params_closure) {
            return function (array $args) use ($class, $constructor_params_closure) {
                return $class->newInstanceArgs($constructor_params_closure($args));
            };
        } else {
            return function (array $args) use ($class) {
                return $class->newInstanceWithoutConstructor();
            };
        }
    }
1235848
public static function create(Node $object, $method_name) {
    /** @var ObjectMethodCallNode $node */
    $node = new static();
    $node->addChild($object, 'object');
    $node->addChild(Token::objectOperator(), 'operator');
    $node->addChild(Token::identifier($method_name), 'methodName');
    $node->addChild(Token::openParen(), 'openParen');
    $node->addChild(new CommaListNode(), 'arguments');
    $node->addChild(Token::closeParen(), 'closeParen');
    return $node;
  }
1215032
public function loadObject($class_name = "stdClass")
    {
        if ($this->stmt === null) {
            return null;
        }

        return $this->stmt->fetchObject($class_name);
    }
1176882
public function getNamespace($class_name)
	{
		$class_name = trim($class_name, '\\');
		if ($last_separator = strrpos($class_name, '\\'))
		{
			return substr($class_name, 0, $last_separator + 1);
		}
		return '';
	}
932009
public function importsClass($class_name = NULL) {
    if ($this->useFunction || $this->useConst) {
      return FALSE;
    }
    if ($class_name) {
      foreach ($this->getDeclarations() as $declaration) {
        if ($declaration->getName()->getPath() === $class_name) {
          return TRUE;
        }
      }
      return FALSE;
    }
    else {
      return TRUE;
    }
  }
957905
public function loadObjectList($class_name = "stdClass")
    {
        if ($this->stmt === null) {
            return null;
        }

        $objectList = array();
        while ($object = $this->stmt->fetchObject($class_name)) {
            $objectList[] = $object;
        }
        return $objectList;
    }
25848
protected function _findClasses($class_names)
    {
        if (!is_array($class_names)) {
            $class_names = array($class_names);
        }
        foreach ($class_names as $_cls) {
            if (true===class_exists($_cls)) {
                return $_cls;
            }
        }
        return false;
    }
891798
public static function isClass($class_name) {
    $class_names = func_get_args();

    return function ($node) use ($class_names) {
      if ($node instanceof ClassNode) {
        return in_array($node->getName()->getText(), $class_names, TRUE);
      }
      return FALSE;
    };
  }