获取类的构造函数的参数，以及reflections对象

@param $class
@return array
@throws \ReflectionException
160153
private function getDependencies($class)
    {
        if (isset($this->_reflections[$class])) {
            return [$this->_reflections[$class], $this->_dependencies[$class], $this->_defaultProperties[$class]];
        }

        $dependencies = [];
        $reflection = new \ReflectionClass($class);

        //获取类的公共public属性
        $props = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);

        //获取构造器的参数
        $constructor = $reflection->getConstructor();
        if ($constructor !== null) {
            foreach ($constructor->getParameters() as $param) {
                $name = $param->getName();
                if ($param->isDefaultValueAvailable()) {
                    $dependencies[$name] = $param->getDefaultValue();
                } else {
                    $dependencies[$name] = '';
                }
            }
        }

        $this->_reflections[$class] = $reflection;
        $this->_dependencies[$class] = $dependencies;
        $this->_defaultProperties[$class] = $props;

        unset($reflection);
        unset($defaultProperties);
        unset($dependencies);
        unset($constructor);

        return [$this->_reflections[$class], $this->_dependencies[$class], $this->_defaultProperties[$class]];
    }
80809
public static function getClassProperties($class)
    {
        if (is_string($class)) {
            if (isset(self::$classPropertyes[$class])) {
                return self::$classPropertyes[$class];
            }

            $class = new \ReflectionClass($class);
        }

        if (!$class instanceof \ReflectionClass) {
            throw new \InvalidArgumentException('The arguments must be a valid class name or reflection');
        }

        if (isset(self::$classPropertyes[$class->getName()])) {
            return self::$classPropertyes[$class->getName()];
        }

        $props = $class->getProperties();
        $props_arr = [];
        foreach ($props as $prop) {
            $f = $prop->getName();

            $props_arr[$f] = $prop;
        }
        if ($parentClass = $class->getParentClass()) {
            $parent_props_arr = static::getClassProperties($parentClass);//RECURSION
            if (count($parent_props_arr) > 0) {
                $props_arr = array_merge($parent_props_arr, $props_arr);
            }
        }

        self::$classPropertyes[$class->getName()] = $props_arr;

        return $props_arr;
    }
253839
public static function getClass($class) {
        $cache = null;

        if (is_object($class)) {
            $cache = new Cache('gcs_cache_annotation_' . strtolower(str_replace('\\', '-', get_class($class))), 0);
        }
        else {
            $cache = new Cache('gcs_cache_annotation_' . strtolower(str_replace('\\', '-', $class)), 0);
        }

        if ($cache->isExist() && Config::config()['user']['debug']['environment'] != 'development') {
            return $cache->getCache();
        }

        $data = ['class' => [], 'methods' => [], 'properties' => []];

        $reflectionClass = new \ReflectionClass($class);

        //Class annotations
        $parser = new Parser($reflectionClass->getDocComment());
        $dataClasses = $parser->parse();

        foreach ($dataClasses as $key => $dataClass) {
            $processorClass = new Processor($dataClass);
            array_push($data['class'], [0 => ['annotation' => $dataClass['type'], 'instance' => $processorClass->process()]]);
        }

        //Method annotations
        $methodsName = $reflectionClass->getMethods();

        foreach ($methodsName as $methodName) {
            $method = new \ReflectionMethod($class, $methodName->getName());

            $parser = new Parser($method->getDocComment());
            $dataMethods = $parser->parse();

            if (count($dataMethods) > 0) {
                $data['methods'][$methodName->getName()] = [];

                foreach ($dataMethods as $key => $dataMethod) {
                    $processorMethods = new Processor($dataMethod);
                    array_push($data['methods'][$methodName->getName()], ['annotation' => $dataMethod['type'], 'instance' => $processorMethods->process()]);
                }
            }
        }

        //Properties annotations
        $propertiesNames = $reflectionClass->getProperties();

        foreach ($propertiesNames as $propertyName) {
            $property = new \ReflectionProperty($class, $propertyName->getName());

            $parser = new Parser($property->getDocComment());
            $dataProperties = $parser->parse();

            if (count($dataProperties) > 0) {
                $data['properties'][$propertyName->getName()] = [];

                foreach ($dataProperties as $key => $dataProperty) {
                    $processorProperties = new Processor($dataProperty);
                    array_push($data['properties'][$propertyName->getName()], ['annotation' => $dataProperty['type'], 'instance' => $processorProperties->process()]);
                }
            }
        }

        $cache->setContent($data);
        $cache->setCache();

        return $data;
    }
495264
public function forClass(string $class): array
    {
        if (!class_exists($class)) {
            throw new InvalidArgumentException("Cannot get meta for non-exist class '$class'");
        }

        $reflection = $this->factory->reflectClass($class);

        $meta = $this->getClassMeta($reflection);
        $meta['@properties'] = $this->getPropertiesMeta($reflection);

        return $meta;
    }
239001
public function getTypesForClass(string $class): array
    {
        $types = array_filter(
            $this->typeMap,
            function ($val) use ($class) {
                return $val === $class;
            }
        );

        if (empty($types)) {
            $error = sprintf('Does not exist any valid type for class "%s"', $class);
            throw new \UnexpectedValueException($error);
        }

        return array_keys($types);
    }
856562
public static function getClassProperties($class)
    {
        $properties = [];
        Logger::log('Extracting annotations properties from class ' . $class);
        $selfReflector = new \ReflectionClass($class);
        if (false !== $selfReflector->getParentClass()) {
            $properties = self::getClassProperties($selfReflector->getParentClass()->getName());
        }
        $properties = array_merge($properties, self::extractProperties($selfReflector));
        return $properties;
    }
1124919
public static function getAllChildClasses($class): array
    {
        $type = gettype($class);
        $className = '';

        /* If input an object */
        if ($type == 'object') {
            $className = get_class($class);
        }

        /* If input a string */
        elseif ($type == 'string') {
            $className = $class;
        }

        $classes = [];

        /* Go through all classes */
        foreach (get_declared_classes() as $class) {
            if (is_subclass_of($class, $className)) {
                $classes[] = $class;
            }
        }

        return $classes;
    }
287750
public function parseClass(\ReflectionClass $class)
    {
        if (false === $filename = $class->getFilename()) {
            return array();
        }

        $content = $this->getFileContent($filename, $class->getStartLine());
        $namespace = str_replace('\\', '\\\\', $class->getNamespaceName());
        $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
        $this->tokens = token_get_all('<?php ' . $content);
        $this->numTokens = count($this->tokens);
        $this->pointer = 0;

        $statements = $this->parseUseStatements($class->getNamespaceName());

        return $statements;
    }
743807
protected function getReflectionMethod($class, $method)
    {
        if (!isset($this->methodReflectors[$class])) {
            $this->methodReflectors[$class] = [];
        }
        if (!isset($this->methodReflectors[$class][$method])) {
            $this->methodReflectors[$class][$method] = new \ReflectionMethod($class, $method);
        }

        return $this->methodReflectors[$class][$method];
    }
1084969
public function get($class = null)
        {
            $class = $this->getClass($class);

            if (Arrays::exists($class, $this->reflections)) {
                return $this->reflections[$class];
            }

            throw new Exception("Class not found: $class");
        }
658219
public function parseEntity($class)
    {
        $reflectionClass = new ReflectionClass($class);

        // scan class annotations
        $classAnnotations = $this->reader->getClassAnnotations($reflectionClass);

        // init class metadata
        $entityMetadata = new EntityDefinition([
            'class' => $class,
            'morphClass' => $this->generateMorphClass($class),
            'table' => new TableDefinition([
                'name' => $this->generateTableName($class),
                'columns' => [],
            ]),
            'versionTable' => false,
        
            'softDeletes' => false,
            'timestamps' => false,
            
            'touches' => [],
            'with' => [],

            'columns' => [],
            'attributes' => [],
            'embeddeds' => [],
            'relations' => [],
        ]);

        // find entity parameters and plugins
        foreach ($classAnnotations as $annotation) {
            // entity parameters
            if ($annotation instanceof \ProAI\Datamapper\Annotations\Entity) {
                if (! empty($annotation->morphClass)) {
                    $entityMetadata['morphClass'] = $annotation->morphClass;
                }
                if (! empty($annotation->touches)) {
                    $entityMetadata['touches'] = $annotation->touches;
                }
                if (! empty($annotation->with)) {
                    $entityMetadata['with'] = $annotation->with;
                }
            }

            // softdeletes
            if ($annotation instanceof \ProAI\Datamapper\Annotations\SoftDeletes) {
                $entityMetadata['softDeletes'] = true;
            }

            // table name
            if ($annotation instanceof \ProAI\Datamapper\Annotations\Table) {
                $entityMetadata['table']['name'] = $annotation->name;
            }

            // timestamps
            if ($annotation instanceof \ProAI\Datamapper\Annotations\Timestamps) {
                $entityMetadata['timestamps'] = true;
            }
        }

        // find versionable annotation (2nd loop, because table name is required)
        foreach ($classAnnotations as $annotation) {
            if ($annotation instanceof \ProAI\Datamapper\Annotations\Versionable) {
                $entityMetadata['versionTable'] = new TableDefinition([
                    'name' => $entityMetadata['table']['name'] . '_version',
                    'columns' => [],
                ]);
            }
        }

        // find columns and embedded classes
        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            $name = $this->getSanitizedName($reflectionProperty->getName(), $entityMetadata['class']);
            $propertyAnnotations = $this->reader->getPropertyAnnotations($reflectionProperty);

            foreach ($propertyAnnotations as $annotation) {
                // column
                if ($annotation instanceof \ProAI\Datamapper\Annotations\Column) {
                    $this->setAdditionalColumnProperties($name, $annotation, $propertyAnnotations);

                    $this->parseColumn($name, $annotation, $entityMetadata, false, true);
                }

                // embedded class
                if ($annotation instanceof \ProAI\Datamapper\Annotations\Embedded) {
                    $this->parseEmbeddedClass($name, $annotation, $entityMetadata, true);
                }
            }
        }

        // check primary key
        $this->validator->validatePrimaryKey($entityMetadata);

        // find relationships (2nd loop, because primary key column is required for foreign keys)
        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            $name = $this->getSanitizedName($reflectionProperty->getName(), $entityMetadata['class']);
            $propertyAnnotations = $this->reader->getPropertyAnnotations($reflectionProperty);

            foreach ($propertyAnnotations as $annotation) {
                // column
                if ($annotation instanceof \ProAI\Datamapper\Annotations\Column) {
                    $this->setAdditionalColumnProperties($name, $annotation, $propertyAnnotations);

                    $entityMetadata['attributes'][] = $this->parseColumn($name, $annotation, $entityMetadata);
                }

                // embedded class
                if ($annotation instanceof \ProAI\Datamapper\Annotations\Embedded) {
                    $entityMetadata['embeddeds'][] = $this->parseEmbeddedClass($name, $annotation, $entityMetadata);
                }

                // relation
                if ($annotation instanceof \ProAI\Datamapper\Annotations\Relation) {
                    $entityMetadata['relations'][] = $this->parseRelation($name, $annotation, $entityMetadata);
                }
            }
        }

        // check timestamps extension
        if (! empty($entityMetadata['timestamps'])) {
            $this->validator->validateTimestamps($entityMetadata);
        }

        // check softDeletes extension
        if (! empty($entityMetadata['softDeletes'])) {
            $this->validator->validateSoftDeletes($entityMetadata);
        }

        // check version extension
        if (! empty($entityMetadata['versionTable'])) {
            $this->validator->validateVersionTable($entityMetadata);
        }

        return $entityMetadata;
    }
23287
function classGetReflection($class) {
    if (array_key_exists($class, $this->classLikesByQcn)) {
      return $this->classLikesByQcn[$class];
    }
    if (class_exists($class, FALSE) || interface_exists($class, FALSE) || trait_exists($class, FALSE)) {
      $reflectionClass = new \ReflectionClass($class);
      $this->initKnownClass($class, $reflectionClass);
    }
    else {
      $this->triggerAutoload($class);
    }
    if (isset($this->classLikesByQcn[$class])) {
      return $this->classLikesByQcn[$class];
    }
    if (array_key_exists($class, $this->classLikesByQcn)) {
      return $this->classLikesByQcn[$class];
    }
    return NULL;
  }
776405
private function getPhpFileStmt(\ReflectionClass $class) : array
    {
        $traverser = new NodeTraverser();
        $visitor = new CodeGenVisitor();
        $traverser->addVisitor($visitor);
        $fileName = $class->getFileName();
        if (is_bool($fileName)) {
            throw new InvalidSourceClassException(get_class($class));
        }
        $file = file_get_contents($fileName);
        if ($file === false) {
            throw new \RuntimeException($fileName); // @codeCoverageIgnore
        }
        $stmts = $this->parser->parse($file);
        if (is_array($stmts)) {
            $traverser->traverse($stmts);
        }

        return $visitor();
    }
224804
public function loadMetadataForClass(\ReflectionClass $class)
    {
        foreach ($this->drivers as $driver) {
            if (null !== $metadata = $driver->loadMetadataForClass($class)) {
                return $metadata;
            }
        }
    }
1038970
public static function getByClass( $class )
	{
		$results = [];
		foreach ( static::$globals as $k => $v )
			if ( $v instanceof $class )
				$results[$k] = $v;
		return $results;
	}
497103
private function getModel($class)
    {
        $reflectionClass = new \ReflectionClass($class);
        $instance = $reflectionClass->newInstance();
        if (!($instance instanceof ModelInterface)) {
            throw new \Exception('This class is not supported');
        }

        return $instance;
    }
565415
public static function newInstance($class) {
		$className = str_replace(':', '\\', $class);
		$reflectedClass = new ReflectionClass($className);

		if ($reflectedClass->isInstantiable()) {
			$constructor = $reflectedClass->getConstructor();

			if ($constructor) {
				$parameters = $constructor->getParameters();
				$constructorParameters = array();

				foreach ($parameters as $parameter) {
					if ($parameter->getClass()) {
						$constructorParameters[] = self::newInstance($parameter->getClass()->getName());
					} else {
						$constructorParameters[] = $parameter->getDefaultValue();
					}
				}

				return $reflectedClass->newInstanceArgs($constructorParameters);
			} else {
				return $reflectedClass->newInstance();
			}

		} else {
			throw new Exception($class." is not instantiable Class");
		}
	}