From 8f7757a25c963afaa0c366129e9812f04bed8853 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 16 Apr 2013 00:17:15 +0400 Subject: [PATCH 1/3] conditions cleanup --- framework/helpers/base/Html.php | 2 +- framework/widgets/ActiveForm.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/helpers/base/Html.php b/framework/helpers/base/Html.php index 5e7f4ad..bb1fed3 100644 --- a/framework/helpers/base/Html.php +++ b/framework/helpers/base/Html.php @@ -728,7 +728,7 @@ class Html if (!isset($options['size'])) { $options['size'] = 4; } - if (isset($options['multiple']) && $options['multiple'] && substr($name, -2) !== '[]') { + if (!empty($options['multiple']) && substr($name, -2) !== '[]') { $name .= '[]'; } $options['name'] = $name; diff --git a/framework/widgets/ActiveForm.php b/framework/widgets/ActiveForm.php index 48bc181..8192bc0 100644 --- a/framework/widgets/ActiveForm.php +++ b/framework/widgets/ActiveForm.php @@ -64,7 +64,7 @@ class ActiveForm extends Widget $models = array($models); } - $showAll = isset($options['showAll']) && $options['showAll']; + $showAll = !empty($options['showAll']); $lines = array(); /** @var $model Model */ foreach ($models as $model) { From ac5b25e3f7514763ff60edfff9bb23346f0ec509 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 16 Apr 2013 00:52:24 +0400 Subject: [PATCH 2/3] fixed typos --- framework/caching/ZendDataCache.php | 2 +- framework/console/controllers/AppController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/caching/ZendDataCache.php b/framework/caching/ZendDataCache.php index 669733d..5b41a8d 100644 --- a/framework/caching/ZendDataCache.php +++ b/framework/caching/ZendDataCache.php @@ -10,7 +10,7 @@ namespace yii\caching; /** * ZendDataCache provides Zend data caching in terms of an application component. * - * To use this application component, the [Zend Data Cache PHP extensionn](http://www.zend.com/en/products/server/) + * To use this application component, the [Zend Data Cache PHP extension](http://www.zend.com/en/products/server/) * must be loaded. * * See [[Cache]] for common cache operations that ZendDataCache supports. diff --git a/framework/console/controllers/AppController.php b/framework/console/controllers/AppController.php index 93ef5f5..2c32c54 100644 --- a/framework/console/controllers/AppController.php +++ b/framework/console/controllers/AppController.php @@ -159,7 +159,7 @@ class AppController extends Controller * @param string $pathTo path to file we want to get relative path for * @param string $varName variable name w/o $ to replace value with relative path for * - * @return string target file contetns + * @return string target file contents */ public function replaceRelativePath($source, $pathTo, $varName) { From 9f2b44fc21c0dc6572cdda930dae96276cd80426 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 16 Apr 2013 00:53:07 +0400 Subject: [PATCH 3/3] phpdoc --- framework/base/ErrorHandler.php | 14 ++++++++++++++ framework/base/Response.php | 18 ++++++++++++++++++ framework/caching/DbDependency.php | 1 + framework/caching/MemCache.php | 2 +- framework/helpers/base/VarDumper.php | 2 +- framework/validators/CaptchaValidator.php | 1 + framework/widgets/ActiveForm.php | 16 +++++++++++++++- 7 files changed, 51 insertions(+), 3 deletions(-) diff --git a/framework/base/ErrorHandler.php b/framework/base/ErrorHandler.php index a2f372c..dc83474 100644 --- a/framework/base/ErrorHandler.php +++ b/framework/base/ErrorHandler.php @@ -51,6 +51,7 @@ class ErrorHandler extends Component /** + * Handles exception * @param \Exception $exception */ public function handle($exception) @@ -64,6 +65,10 @@ class ErrorHandler extends Component $this->renderException($exception); } + /** + * Renders exception + * @param \Exception $exception + */ protected function renderException($exception) { if ($this->errorAction !== null) { @@ -196,6 +201,10 @@ class ErrorHandler extends Component echo '
' . $output . '
'; } + /** + * Renders calls stack trace + * @param array $trace + */ public function renderTrace($trace) { $count = 0; @@ -233,6 +242,11 @@ class ErrorHandler extends Component echo ''; } + /** + * Converts special characters to HTML entities + * @param string $text text to encode + * @return string + */ public function htmlEncode($text) { return htmlspecialchars($text, ENT_QUOTES, \Yii::$app->charset); diff --git a/framework/base/Response.php b/framework/base/Response.php index a53fd61..af91a20 100644 --- a/framework/base/Response.php +++ b/framework/base/Response.php @@ -13,27 +13,45 @@ namespace yii\base; */ class Response extends Component { + /** + * Starts output buffering + */ public function beginOutput() { ob_start(); ob_implicit_flush(false); } + /** + * Returns contents of the output buffer and discards it + * @return string output buffer contents + */ public function endOutput() { return ob_get_clean(); } + /** + * Returns contents of the output buffer + * @return string output buffer contents + */ public function getOutput() { return ob_get_contents(); } + /** + * Discards the output buffer + */ public function cleanOutput() { ob_clean(); } + /** + * Discards the output buffer + * @param boolean $all if true recursively discards all output buffers used + */ public function removeOutput($all = true) { if ($all) { diff --git a/framework/caching/DbDependency.php b/framework/caching/DbDependency.php index cbe0ae1..7d45223 100644 --- a/framework/caching/DbDependency.php +++ b/framework/caching/DbDependency.php @@ -52,6 +52,7 @@ class DbDependency extends Dependency /** * Generates the data needed to determine if dependency has been changed. * This method returns the value of the global state. + * @throws InvalidConfigException * @return mixed the data needed to determine if dependency has been changed. */ protected function generateDependencyData() diff --git a/framework/caching/MemCache.php b/framework/caching/MemCache.php index df07b8e..20aff21 100644 --- a/framework/caching/MemCache.php +++ b/framework/caching/MemCache.php @@ -106,7 +106,7 @@ class MemCache extends Cache /** * Returns the underlying memcache (or memcached) object. * @return \Memcache|\Memcached the memcache (or memcached) object used by this cache component. - * @throws Exception if memcache or memcached extension is not loaded + * @throws InvalidConfigException if memcache or memcached extension is not loaded */ public function getMemcache() { diff --git a/framework/helpers/base/VarDumper.php b/framework/helpers/base/VarDumper.php index 5942cd8..fe15d98 100644 --- a/framework/helpers/base/VarDumper.php +++ b/framework/helpers/base/VarDumper.php @@ -64,7 +64,7 @@ class VarDumper return self::$_output; } - /* + /** * @param mixed $var variable to be dumped * @param integer $level depth level */ diff --git a/framework/validators/CaptchaValidator.php b/framework/validators/CaptchaValidator.php index 3b4745b..ebb0039 100644 --- a/framework/validators/CaptchaValidator.php +++ b/framework/validators/CaptchaValidator.php @@ -68,6 +68,7 @@ class CaptchaValidator extends Validator /** * Returns the CAPTCHA action object. + * @throws InvalidConfigException * @return CaptchaAction the action object */ public function getCaptchaAction() diff --git a/framework/widgets/ActiveForm.php b/framework/widgets/ActiveForm.php index 8192bc0..83506dd 100644 --- a/framework/widgets/ActiveForm.php +++ b/framework/widgets/ActiveForm.php @@ -39,10 +39,16 @@ class ActiveForm extends Widget public $errorMessageClass = 'yii-error-message'; /** * @var string the default CSS class that indicates an input has error. - * This is */ public $errorClass = 'yii-error'; + /** + * @var string the default CSS class that indicates an input validated successfully. + */ public $successClass = 'yii-success'; + + /** + * @var string the default CSS class that indicates an input is currently being validated. + */ public $validatingClass = 'yii-validating'; /** * @var boolean whether to enable client-side data validation. Defaults to false. @@ -127,6 +133,14 @@ class ActiveForm extends Widget return Html::label($label, $for, $options); } + /** + * @param string $type + * @param Model $model + * @param string $attribute + * @param array $options + * + * @return string + */ public function input($type, $model, $attribute, $options = array()) { $value = $this->getAttributeValue($model, $attribute);