hiqdev /
hidev
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * Task runner, code generator and build tool for easier continuos integration |
||
| 5 | * |
||
| 6 | * @link https://github.com/hiqdev/hidev |
||
| 7 | * @package hidev |
||
| 8 | * @license BSD-3-Clause |
||
| 9 | * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/) |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace hidev\controllers; |
||
| 13 | |||
| 14 | use hidev\helpers\Helper; |
||
| 15 | use yii\base\InvalidParamException; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Init controller. |
||
| 19 | * Builds .hidev/config.yml by template and params. |
||
| 20 | */ |
||
| 21 | class InitController extends TemplateController |
||
| 22 | { |
||
| 23 | use \hiqdev\yii2\collection\ObjectTrait; |
||
| 24 | |||
| 25 | protected $_file = '.hidev/config.yml'; |
||
| 26 | |||
| 27 | public $vendor; |
||
| 28 | public $package; |
||
| 29 | |||
| 30 | public function actionPerform($name = null, $template = '.hidev/config') |
||
| 31 | { |
||
| 32 | list($vendor, $package) = explode('/', $name, 2); |
||
| 33 | if ($vendor) { |
||
| 34 | $this->vendor = $vendor; |
||
| 35 | } |
||
| 36 | if ($package) { |
||
| 37 | $this->package = $package; |
||
| 38 | } |
||
| 39 | if (!$this->package || !$this->vendor) { |
||
| 40 | throw new InvalidParamException('Wrong vendor/package given: ' . $name); |
||
| 41 | } |
||
| 42 | $this->template = $template; |
||
| 43 | |||
| 44 | if (!file_exists($this->dirname)) { |
||
|
0 ignored issues
–
show
|
|||
| 45 | mkdir($this->dirname); |
||
|
0 ignored issues
–
show
The property
dirname does not exist on object<hidev\controllers\InitController>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 46 | } |
||
| 47 | |||
| 48 | return parent::actionPerform(); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function options($actionId) |
||
| 52 | { |
||
| 53 | return array_merge(parent::options($actionId), explode(',', 'namespace,headline,title,type,license,keywords,description,year,nick,author,email,novendor,norequire')); |
||
| 54 | } |
||
| 55 | |||
| 56 | public function getType() |
||
| 57 | { |
||
| 58 | return $this->getItem('type') ?: 'project'; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function getTitle() |
||
| 62 | { |
||
| 63 | return $this->getItem('title') ?: Helper::titleize($this->package); |
||
| 64 | } |
||
| 65 | |||
| 66 | public function getKeywords() |
||
| 67 | { |
||
| 68 | return $this->getItem('keywords') ?: implode(', ', explode('-', $this->package)); |
||
| 69 | } |
||
| 70 | |||
| 71 | /// TODO think of better getting nick |
||
| 72 | public function getNick() |
||
| 73 | { |
||
| 74 | return $this->getItem('nick') ?: preg_replace('/[^a-zA-Z_0-9]+/', '', `id -un`); |
||
| 75 | } |
||
| 76 | |||
| 77 | public function getAuthor() |
||
| 78 | { |
||
| 79 | return $this->getItem('author') ?: $this->getVcs()->getUserName(); |
||
|
0 ignored issues
–
show
The method
getVcs does not exist on object<hidev\controllers\InitController>? Since you implemented __call, maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
| 80 | } |
||
| 81 | |||
| 82 | public function getEmail() |
||
| 83 | { |
||
| 84 | return $this->getItem('email') ?: $this->getVcs()->getUserEmail(); |
||
|
0 ignored issues
–
show
The method
getVcs does not exist on object<hidev\controllers\InitController>? Since you implemented __call, maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
Loading history...
|
|||
| 85 | } |
||
| 86 | } |
||
| 87 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.