File.php 1.12 KB
Newer Older
1
<?php
2 3 4 5 6
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */
7

8
namespace yii\apidoc\models;
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

use phpDocumentor\Reflection\FileReflector;
use yii\base\Object;

class File extends Object
{
	public $name;

	public $namespaces = [];
	/**
	 * @var ClassDoc[]
	 */
	public $classes = [];
	/**
	 * @var InterfaceDoc[]
	 */
	public $interfaces = [];
	/**
	 * @var TraitDoc[]
	 */
	public $traits = [];

	private $_reflection;

	public function __construct($fileName, $context, $config = [])
	{
		$this->name = $fileName;
		$this->_reflection = new FileReflector($fileName, true);
		$this->_reflection->process();

		foreach($this->_reflection->getClasses() as $class) {
			$class = new ClassDoc($class, $context);
			$class->sourceFile = $fileName;
			$this->classes[] = $class;
		}
		foreach($this->_reflection->getInterfaces() as $interface) {
			$this->interfaces[] = new InterfaceDoc($interface, $context);
		}
		foreach($this->_reflection->getTraits() as $trait) {
			$this->traits[] = new TraitDoc($trait, $context);
		}

		parent::__construct($config);
	}
}