From 8a6eceb8523ad22ae5d84080f79f31f6c3c3ac7e Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 26 Mar 2014 15:13:11 +0100 Subject: [PATCH 1/5] phpdoc fixes --- extensions/apidoc/models/TypeDoc.php | 4 ++-- extensions/apidoc/renderers/BaseRenderer.php | 8 ++++---- framework/db/BaseActiveRecord.php | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/extensions/apidoc/models/TypeDoc.php b/extensions/apidoc/models/TypeDoc.php index 77a56de928..c5be79c65f 100644 --- a/extensions/apidoc/models/TypeDoc.php +++ b/extensions/apidoc/models/TypeDoc.php @@ -86,8 +86,8 @@ class TypeDoc extends BaseDoc } /** - * @param null $visibility - * @param null $definedBy + * @param string|null $visibility + * @param string|null $definedBy * @return MethodDoc[] */ private function getFilteredMethods($visibility = null, $definedBy = null) diff --git a/extensions/apidoc/renderers/BaseRenderer.php b/extensions/apidoc/renderers/BaseRenderer.php index 90ea56a63e..eb0ceb7ec5 100644 --- a/extensions/apidoc/renderers/BaseRenderer.php +++ b/extensions/apidoc/renderers/BaseRenderer.php @@ -53,10 +53,10 @@ abstract class BaseRenderer extends Component /** * creates a link to a type (class, interface or trait) - * @param ClassDoc|InterfaceDoc|TraitDoc|ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types - * @param string $title a title to be used for the link TODO check whether [[yii\...|Class]] is supported - * @param BaseDoc $context - * @param array $options additional HTML attributes for the link. + * @param ClassDoc|InterfaceDoc|TraitDoc|ClassDoc[]|InterfaceDoc[]|TraitDoc[]|string|string[] $types + * @param string $title a title to be used for the link TODO check whether [[yii\...|Class]] is supported + * @param BaseDoc $context + * @param array $options additional HTML attributes for the link. * @return string */ public function createTypeLink($types, $context = null, $title = null, $options = []) diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index 3ac93e35eb..a62308cbd1 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -81,7 +81,8 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface */ private $_attributes = []; /** - * @var array old attribute values indexed by attribute names. + * @var array|null old attribute values indexed by attribute names. + * This is `null` if the record [[isNewRecord|is new]]. */ private $_oldAttributes; /** @@ -475,7 +476,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface /** * Sets the old attribute values. * All existing old attribute values will be discarded. - * @param array $values old attribute values to be set. + * @param array|null $values old attribute values to be set. */ public function setOldAttributes($values) { @@ -1304,8 +1305,8 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface /** * @param array $link - * @param BaseActiveRecord $foreignModel - * @param BaseActiveRecord $primaryModel + * @param ActiveRecordInterface $foreignModel + * @param ActiveRecordInterface $primaryModel * @throws InvalidCallException */ private function bindModels($link, $foreignModel, $primaryModel) From d774e7f1272c3086292c2efa02f97f595ab97950 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 26 Mar 2014 15:13:26 +0100 Subject: [PATCH 2/5] fixed recursive call of ArrayHelper::toArray() --- framework/helpers/BaseArrayHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/helpers/BaseArrayHelper.php b/framework/helpers/BaseArrayHelper.php index 8ead84f93f..4172688300 100644 --- a/framework/helpers/BaseArrayHelper.php +++ b/framework/helpers/BaseArrayHelper.php @@ -62,7 +62,7 @@ class BaseArrayHelper if ($recursive) { foreach ($object as $key => $value) { if (is_array($value) || is_object($value)) { - $object[$key] = static::toArray($value, true); + $object[$key] = static::toArray($value, $properties, true); } } } From 0b2aafc780a4a20315b085cd366816b15ea5dfe0 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 26 Mar 2014 16:03:42 +0100 Subject: [PATCH 3/5] fixed private / self in helpers fixes #2886 --- framework/helpers/BaseMarkdown.php | 2 +- framework/helpers/BaseUrl.php | 2 +- framework/rest/RateLimiter.php | 3 +-- framework/web/UploadedFile.php | 11 +++-------- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/framework/helpers/BaseMarkdown.php b/framework/helpers/BaseMarkdown.php index 59bb3ecfbd..6d8ee39e92 100644 --- a/framework/helpers/BaseMarkdown.php +++ b/framework/helpers/BaseMarkdown.php @@ -82,7 +82,7 @@ class BaseMarkdown * @return \cebe\markdown\Parser * @throws \yii\base\InvalidParamException when an undefined flavor is given. */ - private static function getParser($flavor) + protected static function getParser($flavor) { /** @var \cebe\markdown\Markdown $parser */ if (!isset(static::$flavors[$flavor])) { diff --git a/framework/helpers/BaseUrl.php b/framework/helpers/BaseUrl.php index d43882ff8d..eb97526174 100644 --- a/framework/helpers/BaseUrl.php +++ b/framework/helpers/BaseUrl.php @@ -108,7 +108,7 @@ class BaseUrl * @return string normalized route suitable for UrlManager * @throws InvalidParamException a relative route is given while there is no active controller */ - private static function normalizeRoute($route) + protected static function normalizeRoute($route) { $route = (string) $route; if (strncmp($route, '/', 1) === 0) { diff --git a/framework/rest/RateLimiter.php b/framework/rest/RateLimiter.php index d668e6d576..8226f59871 100644 --- a/framework/rest/RateLimiter.php +++ b/framework/rest/RateLimiter.php @@ -8,7 +8,6 @@ namespace yii\rest; use yii\base\Component; -use yii\base\Action; use yii\web\Request; use yii\web\Response; use yii\web\TooManyRequestsHttpException; @@ -37,7 +36,7 @@ class RateLimiter extends Component * @param RateLimitInterface $user the current user * @param Request $request * @param Response $response - * @param Action $action the action to be executed + * @param \yii\base\Action $action the action to be executed * @throws TooManyRequestsHttpException if rate limit exceeds */ public function check($user, $request, $response, $action) diff --git a/framework/web/UploadedFile.php b/framework/web/UploadedFile.php index c7648c1b73..bcfb989310 100644 --- a/framework/web/UploadedFile.php +++ b/framework/web/UploadedFile.php @@ -56,6 +56,7 @@ class UploadedFile extends Object */ public $error; + /** * String output. * This is PHP magic method that returns string representation of an object. @@ -80,7 +81,6 @@ class UploadedFile extends Object public static function getInstance($model, $attribute) { $name = Html::getInputName($model, $attribute); - return static::getInstanceByName($name); } @@ -95,7 +95,6 @@ class UploadedFile extends Object public static function getInstances($model, $attribute) { $name = Html::getInputName($model, $attribute); - return static::getInstancesByName($name); } @@ -108,8 +107,7 @@ class UploadedFile extends Object */ public static function getInstanceByName($name) { - $files = static::loadFiles(); - + $files = self::loadFiles(); return isset($files[$name]) ? $files[$name] : null; } @@ -124,7 +122,7 @@ class UploadedFile extends Object */ public static function getInstancesByName($name) { - $files = static::loadFiles(); + $files = self::loadFiles(); if (isset($files[$name])) { return [$files[$name]]; } @@ -134,7 +132,6 @@ class UploadedFile extends Object $results[] = self::$_files[$key]; } } - return $results; } @@ -166,7 +163,6 @@ class UploadedFile extends Object return copy($this->tempName, $file); } } - return false; } @@ -209,7 +205,6 @@ class UploadedFile extends Object } } } - return self::$_files; } From cc4d4933d437950fd24a818c3518d46118d37abc Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 26 Mar 2014 16:04:49 +0100 Subject: [PATCH 4/5] fixed undefined variable problem in AccessControl --- framework/web/AccessControl.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/web/AccessControl.php b/framework/web/AccessControl.php index 077f9bd15d..da3d63b11f 100644 --- a/framework/web/AccessControl.php +++ b/framework/web/AccessControl.php @@ -64,6 +64,7 @@ class AccessControl extends ActionFilter * ~~~ * * where `$rule` is this rule, and `$action` is the current [[Action|action]] object. + * `$rule` will be `null` if access is denied because none of the rules matched. */ public $denyCallback; /** @@ -79,6 +80,7 @@ class AccessControl extends ActionFilter */ public $rules = []; + /** * Initializes the [[rules]] array by instantiating rule objects from configurations. */ @@ -114,16 +116,14 @@ class AccessControl extends ActionFilter } else { $this->denyAccess($user); } - return false; } } if (isset($this->denyCallback)) { - call_user_func($this->denyCallback, $rule, $action); + call_user_func($this->denyCallback, null, $action); } else { $this->denyAccess($user); } - return false; } From f93d871cd601b8b92f9d8179171ebb8964f40dc1 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 26 Mar 2014 16:18:28 +0100 Subject: [PATCH 5/5] fixed wrong method calls in elasticsearch Command --- extensions/apidoc/templates/bootstrap/layouts/api.php | 1 + extensions/elasticsearch/Command.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/apidoc/templates/bootstrap/layouts/api.php b/extensions/apidoc/templates/bootstrap/layouts/api.php index b76d4ab069..b5242d35bc 100644 --- a/extensions/apidoc/templates/bootstrap/layouts/api.php +++ b/extensions/apidoc/templates/bootstrap/layouts/api.php @@ -6,6 +6,7 @@ use yii\helpers\StringHelper; /** * @var yii\web\View $this + * @var array $types * @var string $content */ diff --git a/extensions/elasticsearch/Command.php b/extensions/elasticsearch/Command.php index db2b62b8b2..fa4defb463 100644 --- a/extensions/elasticsearch/Command.php +++ b/extensions/elasticsearch/Command.php @@ -95,7 +95,7 @@ class Command extends Component */ public function get($index, $type, $id, $options = []) { - return $this->db->get([$index, $type, $id], $options, null); + return $this->db->get([$index, $type, $id], $options); } /** @@ -184,7 +184,7 @@ class Command extends Component { $body = $configuration !== null ? Json::encode($configuration) : null; - return $this->db->put([$index], $body); + return $this->db->put([$index], [], $body); } /** @@ -381,7 +381,7 @@ class Command extends Component 'mappings' => (object) $mappings, ]); - return $this->db->put(['_template', $name], $body); + return $this->db->put(['_template', $name], [], $body); }