From 913eb62294f084b3d085127d31b25505b84c2c67 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Fri, 8 Nov 2013 12:24:03 +0100 Subject: [PATCH] updated phpdoc and fixed generator read/write-only annotation --- build/controllers/PhpDocController.php | 32 ++++++++++++++++++++++++++++---- framework/yii/base/Application.php | 2 ++ framework/yii/db/ActiveRecord.php | 2 ++ framework/yii/mail/BaseMailer.php | 3 ++- framework/yii/mail/BaseMessage.php | 2 +- framework/yii/web/Controller.php | 2 ++ framework/yii/web/Request.php | 20 +++++++++++++++++++- 7 files changed, 56 insertions(+), 7 deletions(-) diff --git a/build/controllers/PhpDocController.php b/build/controllers/PhpDocController.php index 760cb05..c7a2fa7 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -278,11 +278,35 @@ class PhpDocController extends Controller . ' See [[get'.ucfirst($propName).'()]] and [[set'.ucfirst($propName).'()]] for details.'; } } elseif (isset($prop['get'])) { - $note = ' This property is read-only.'; -// $docline .= '-read'; + // check if parent class has setter defined + $c = $className; + $parentSetter = false; + while($parent = get_parent_class($c)) { + if (method_exists($parent, 'set' . ucfirst($propName))) { + $parentSetter = true; + break; + } + $c = $parent; + } + if (!$parentSetter) { + $note = ' This property is read-only.'; +// $docline .= '-read'; + } } elseif (isset($prop['set'])) { - $note = ' This property is write-only.'; -// $docline .= '-write'; + // check if parent class has getter defined + $c = $className; + $parentGetter = false; + while($parent = get_parent_class($c)) { + if (method_exists($parent, 'set' . ucfirst($propName))) { + $parentGetter = true; + break; + } + $c = $parent; + } + if (!$parentGetter) { + $note = ' This property is write-only.'; +// $docline .= '-write'; + } } else { continue; } diff --git a/framework/yii/base/Application.php b/framework/yii/base/Application.php index 8826d5a..70eaca3 100644 --- a/framework/yii/base/Application.php +++ b/framework/yii/base/Application.php @@ -15,6 +15,7 @@ use yii\web\HttpException; * Application is the base class for all application classes. * * @property \yii\rbac\Manager $authManager The auth manager for this application. This property is read-only. + * @property string $basePath The root directory of the application. * @property \yii\caching\Cache $cache The cache application component. Null if the component is not enabled. * This property is read-only. * @property \yii\db\Connection $db The database connection. This property is read-only. @@ -261,6 +262,7 @@ abstract class Application extends Module * Sets the root directory of the applicaition and the @app alias. * This method can only be invoked at the beginning of the constructor. * @param string $path the root directory of the application. + * @property string the root directory of the application. * @throws InvalidParamException if the directory does not exist. */ public function setBasePath($path) diff --git a/framework/yii/db/ActiveRecord.php b/framework/yii/db/ActiveRecord.php index 830bf40..380eb03 100644 --- a/framework/yii/db/ActiveRecord.php +++ b/framework/yii/db/ActiveRecord.php @@ -29,6 +29,8 @@ use yii\helpers\Inflector; * @property mixed $oldPrimaryKey The old primary key value. An array (column name => column value) is * returned if the primary key is composite or `$asArray` is true. A string is returned otherwise (null will be * returned if the key value is null). This property is read-only. + * @property array $populatedRelations An array of relation data indexed by relation names. This property is + * read-only. * @property mixed $primaryKey The primary key value. An array (column name => column value) is returned if * the primary key is composite or `$asArray` is true. A string is returned otherwise (null will be returned if * the key value is null). This property is read-only. diff --git a/framework/yii/mail/BaseMailer.php b/framework/yii/mail/BaseMailer.php index 2b6918a..52f31ce 100644 --- a/framework/yii/mail/BaseMailer.php +++ b/framework/yii/mail/BaseMailer.php @@ -20,7 +20,8 @@ use yii\web\View; * * @see BaseMessage * - * @property View|array $view view instance or its array configuration. + * @property View $view View instance. Note that the type of this property differs in getter and setter. See + * [[getView()]] and [[setView()]] for details. * * @author Paul Klimov * @since 2.0 diff --git a/framework/yii/mail/BaseMessage.php b/framework/yii/mail/BaseMessage.php index 04b7200..01b671c 100644 --- a/framework/yii/mail/BaseMessage.php +++ b/framework/yii/mail/BaseMessage.php @@ -18,7 +18,7 @@ use Yii; * * @see BaseMailer * - * @property BaseMailer $mailer mailer component instance. This property is read-only. + * @property MailerInterface $mailer The mailer component. This property is read-only. * * @author Paul Klimov * @since 2.0 diff --git a/framework/yii/web/Controller.php b/framework/yii/web/Controller.php index 6927893..01794ed 100644 --- a/framework/yii/web/Controller.php +++ b/framework/yii/web/Controller.php @@ -14,6 +14,8 @@ use yii\helpers\Html; /** * Controller is the base class of web controllers. * + * @property string $canonicalUrl This property is read-only. + * * @author Qiang Xue * @since 2.0 */ diff --git a/framework/yii/web/Request.php b/framework/yii/web/Request.php index a6a92fa..6bede5e 100644 --- a/framework/yii/web/Request.php +++ b/framework/yii/web/Request.php @@ -31,6 +31,8 @@ use yii\helpers\Security; * @property string $csrfToken The random token for CSRF validation. This property is read-only. * @property string $csrfTokenFromHeader The CSRF token sent via [[CSRF_HEADER]] by browser. Null is returned * if no such header is sent. This property is read-only. + * @property array $delete The DELETE request parameter values. This property is read-only. + * @property array $get The GET request parameter values. This property is read-only. * @property string $hostInfo Schema and hostname part (with port number if needed) of the request URL (e.g. * `http://www.yiiframework.com`). * @property boolean $isAjax Whether this is an AJAX (XMLHttpRequest) request. This property is read-only. @@ -47,11 +49,14 @@ use yii\helpers\Security; * read-only. * @property string $method Request method, such as GET, POST, HEAD, PUT, PATCH, DELETE. The value returned is * turned into upper case. This property is read-only. + * @property array $patch The PATCH request parameter values. This property is read-only. * @property string $pathInfo Part of the request URL that is after the entry script and before the question * mark. Note, the returned path info is already URL-decoded. * @property integer $port Port number for insecure requests. + * @property array $post The POST request parameter values. This property is read-only. * @property string $preferredLanguage The language that the application should use. Null is returned if both * [[getAcceptedLanguages()]] and `$languages` are empty. This property is read-only. + * @property array $put The PUT request parameter values. This property is read-only. * @property string $queryString Part of the request URL that is after the question mark. This property is * read-only. * @property string $rawBody The request body. This property is read-only. @@ -304,12 +309,22 @@ class Request extends \yii\base\Request } /** + * Returns the GET request parameter values. + * @return array the GET request parameter values + */ + public function getGet() + { + return $_GET; + } + + /** * Returns the named POST parameter value. * If the POST parameter does not exist, the second parameter to this method will be returned. * @param string $name the POST parameter name. If not specified, whole $_POST is returned. * @param mixed $defaultValue the default parameter value if the POST parameter does not exist. + * @property array the POST request parameter values * @return mixed the POST parameter value - * @see getParam + * @see get */ public function getPost($name = null, $defaultValue = null) { @@ -323,6 +338,7 @@ class Request extends \yii\base\Request * Returns the named DELETE parameter value. * @param string $name the DELETE parameter name. If not specified, an array of DELETE parameters is returned. * @param mixed $defaultValue the default parameter value if the DELETE parameter does not exist. + * @property array the DELETE request parameter values * @return mixed the DELETE parameter value */ public function getDelete($name = null, $defaultValue = null) @@ -337,6 +353,7 @@ class Request extends \yii\base\Request * Returns the named PUT parameter value. * @param string $name the PUT parameter name. If not specified, an array of PUT parameters is returned. * @param mixed $defaultValue the default parameter value if the PUT parameter does not exist. + * @property array the PUT request parameter values * @return mixed the PUT parameter value */ public function getPut($name = null, $defaultValue = null) @@ -351,6 +368,7 @@ class Request extends \yii\base\Request * Returns the named PATCH parameter value. * @param string $name the PATCH parameter name. If not specified, an array of PATCH parameters is returned. * @param mixed $defaultValue the default parameter value if the PATCH parameter does not exist. + * @property array the PATCH request parameter values * @return mixed the PATCH parameter value */ public function getPatch($name = null, $defaultValue = null)