|
|
@ -7,6 +7,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace yii\build\controllers; |
|
|
|
namespace yii\build\controllers; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Yii; |
|
|
|
use yii\console\Controller; |
|
|
|
use yii\console\Controller; |
|
|
|
use yii\helpers\Console; |
|
|
|
use yii\helpers\Console; |
|
|
|
use yii\helpers\FileHelper; |
|
|
|
use yii\helpers\FileHelper; |
|
|
@ -38,10 +39,30 @@ class PhpDocController extends Controller |
|
|
|
* |
|
|
|
* |
|
|
|
* @param null $root the directory to parse files from. Defaults to YII_PATH. |
|
|
|
* @param null $root the directory to parse files from. Defaults to YII_PATH. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function actionProperty($root=null) |
|
|
|
public function actionProperty($root = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$except = []; |
|
|
|
if ($root === null) { |
|
|
|
if ($root === null) { |
|
|
|
$root = YII_PATH; |
|
|
|
$root = dirname(dirname(YII_PATH)); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/bootstrap', $root . '/extensions/bootstrap'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/debug', $root . '/extensions/debug'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/elasticsearch', $root . '/extensions/elasticsearch'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/gii', $root . '/extensions/gii'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/jui', $root . '/extensions/jui'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/redis', $root . '/extensions/redis'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/smarty', $root . '/extensions/smarty'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/sphinx', $root . '/extensions/sphinx'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/swiftmailer', $root . '/extensions/swiftmailer'); |
|
|
|
|
|
|
|
Yii::setAlias('@yii/twig', $root . '/extensions/twig'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$except = [ |
|
|
|
|
|
|
|
'/apps/', |
|
|
|
|
|
|
|
'/build/', |
|
|
|
|
|
|
|
'/docs/', |
|
|
|
|
|
|
|
'/extensions/composer/', |
|
|
|
|
|
|
|
'/tests/', |
|
|
|
|
|
|
|
'/vendor/', |
|
|
|
|
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
$root = FileHelper::normalizePath($root); |
|
|
|
$root = FileHelper::normalizePath($root); |
|
|
|
$options = [ |
|
|
|
$options = [ |
|
|
@ -55,14 +76,13 @@ class PhpDocController extends Controller |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
}, |
|
|
|
}, |
|
|
|
'only' => ['.php'], |
|
|
|
'only' => ['.php'], |
|
|
|
'except' => [ |
|
|
|
'except' => array_merge($except, [ |
|
|
|
'BaseYii.php', |
|
|
|
'BaseYii.php', |
|
|
|
'Yii.php', |
|
|
|
'Yii.php', |
|
|
|
'/debug/views/', |
|
|
|
'/views/', |
|
|
|
'/requirements/', |
|
|
|
'/requirements/', |
|
|
|
'/gii/views/', |
|
|
|
|
|
|
|
'/gii/generators/', |
|
|
|
'/gii/generators/', |
|
|
|
], |
|
|
|
]), |
|
|
|
]; |
|
|
|
]; |
|
|
|
$files = FileHelper::findFiles($root, $options); |
|
|
|
$files = FileHelper::findFiles($root, $options); |
|
|
|
$nFilesTotal = 0; |
|
|
|
$nFilesTotal = 0; |
|
|
@ -216,21 +236,28 @@ class PhpDocController extends Controller |
|
|
|
$ns = $this->match('#\nnamespace (?<name>[\w\\\\]+);\n#', $file); |
|
|
|
$ns = $this->match('#\nnamespace (?<name>[\w\\\\]+);\n#', $file); |
|
|
|
$namespace = reset($ns); |
|
|
|
$namespace = reset($ns); |
|
|
|
$namespace = $namespace['name']; |
|
|
|
$namespace = $namespace['name']; |
|
|
|
$classes = $this->match('#\n(?:abstract )?class (?<name>\w+)( |\n)(extends )?.+\{(?<content>.*)\n\}(\n|$)#', $file); |
|
|
|
$classes = $this->match('#\n(?:abstract )?class (?<name>\w+)( extends .+)?( implements .+)?\n\{(?<content>.*)\n\}(\n|$)#', $file); |
|
|
|
|
|
|
|
|
|
|
|
if (count($classes) > 1) { |
|
|
|
if (count($classes) > 1) { |
|
|
|
$this->stderr("[ERR] There should be only one class in a file: $fileName\n", Console::FG_RED); |
|
|
|
$this->stderr("[ERR] There should be only one class in a file: $fileName\n", Console::FG_RED); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (count($classes) < 1) { |
|
|
|
if (count($classes) < 1) { |
|
|
|
$interfaces = $this->match('#\ninterface (?<name>\w+)\n\{(?<content>.+)\n\}(\n|$)#', $file); |
|
|
|
$interfaces = $this->match('#\ninterface (?<name>\w+)( extends .+)?\n\{(?<content>.+)\n\}(\n|$)#', $file); |
|
|
|
if (count($interfaces) == 1) { |
|
|
|
if (count($interfaces) == 1) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} elseif (count($interfaces) > 1) { |
|
|
|
} elseif (count($interfaces) > 1) { |
|
|
|
$this->stderr("[ERR] There should be only one interface in a file: $fileName\n", Console::FG_RED); |
|
|
|
$this->stderr("[ERR] There should be only one interface in a file: $fileName\n", Console::FG_RED); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
$traits = $this->match('#\ntrait (?<name>\w+)\n\{(?<content>.+)\n\}(\n|$)#', $file); |
|
|
|
|
|
|
|
if (count($traits) == 1) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} elseif (count($traits) > 1) { |
|
|
|
|
|
|
|
$this->stderr("[ERR] There should be only one class/trait/interface in a file: $fileName\n", Console::FG_RED); |
|
|
|
|
|
|
|
} else { |
|
|
|
$this->stderr("[ERR] No class in file: $fileName\n", Console::FG_RED); |
|
|
|
$this->stderr("[ERR] No class in file: $fileName\n", Console::FG_RED); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|