diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000000..e345af329a7 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,4 @@ +# Reformat code to be PSR-2 compatible +b5f8a4dc22d5f8188405a2099d85fc154226c9b2 +# Added php-cs-fixer coding standards validation to Travis CI +ba0ab403b52124c941dbeb46fbd9efdc12252a5d diff --git a/.gitattributes b/.gitattributes index 1d3d767fd32..0a94a07283b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,15 +22,16 @@ *.ttf binary # Ignore some meta files when creating an archive of this repository -# We do not ignore any content, because this repo represents the +# We do not ignore any content, because this repo represents the # `yiisoft/yii2-dev` package, which is expected to ship all tests and docs. -/.appveyor.yml export-ignore -/.github export-ignore -/.editorconfig export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.scrutinizer.yml export-ignore -/.travis.yml export-ignore +/.appveyor.yml export-ignore +/.github export-ignore +/.editorconfig export-ignore +/.git-blame-ignore-revs export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore # Avoid merge conflicts in CHANGELOG # https://about.gitlab.com/2015/02/10/gitlab-reduced-merge-conflicts-by-90-percent-with-changelog-placeholders/ diff --git a/build/controllers/MimeTypeController.php b/build/controllers/MimeTypeController.php index b2c51098a49..82a8164c0dd 100644 --- a/build/controllers/MimeTypeController.php +++ b/build/controllers/MimeTypeController.php @@ -122,7 +122,7 @@ private function generateMimeTypesFile($outFile, $content) * https://raw.githubusercontent.com/apache/httpd/refs/heads/trunk/docs/conf/mime.types * This file has been placed in the public domain for unlimited redistribution. * - * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * All extra changes made to this file must be committed to /build/controllers/MimeTypeController.php * otherwise they will be lost on next build. */ \$mimeTypes = $array; @@ -153,7 +153,7 @@ private function generateMimeAliasesFile($outFile) * * This file contains aliases for MIME types. * - * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * All extra changes made to this file must be committed to /build/controllers/MimeTypeController.php * otherwise they will be lost on next build. */ return $array; @@ -217,7 +217,7 @@ private function generateMimeExtensionsFile($outFile, $content) * https://raw.githubusercontent.com/apache/httpd/refs/heads/trunk/docs/conf/mime.types * This file has been placed in the public domain for unlimited redistribution. * - * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * All extra changes made to this file must be committed to /build/controllers/MimeTypeController.php * otherwise they will be lost on next build. */ return $array; diff --git a/build/controllers/PhpDocController.php b/build/controllers/PhpDocController.php index 1b12eb3fa94..47f71892f72 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -8,11 +8,17 @@ namespace yii\build\controllers; use Yii; -use yii\console\Controller; +use yii\base\Model; +use yii\base\Module; +use yii\console\Controller as ConsoleController; +use yii\db\QueryBuilder; use yii\helpers\Console; use yii\helpers\FileHelper; use yii\helpers\Json; +use yii\log\Dispatcher; +use yii\log\Target; use yii\web\Controller as WebController; +use yii\web\Request as WebRequest; /** * PhpDocController is there to help to maintain PHPDoc annotation in class files. @@ -21,10 +27,10 @@ * @author Alexander Makarov * @since 2.0 */ -class PhpDocController extends Controller +class PhpDocController extends ConsoleController { /** - * Manually added PHPDoc properties that do not need to be removed. + * Manually added PHPDoc properties that do not need to be removed or changed. * * @phpstan-var array */ @@ -34,8 +40,33 @@ class PhpDocController extends Controller 'response', 'view', ], + ConsoleController::class => [ + 'request', + 'response', + ], + Model::class => [ + 'errors', + ], + Module::class => [ + 'aliases', + ], + Dispatcher::class => [ + 'flushInterval', + 'logger', + ], + Target::class => [ + 'enabled', + ], + WebRequest::class => [ + 'hostInfo', + ], + QueryBuilder::class => [ + 'conditionClasses', + ], ]; + private const PROPERTIES_ENCLOSURE = " *\n"; + /** * {@inheritdoc} */ @@ -634,6 +665,9 @@ protected function updateDocComment($doc, $properties, $className) $lines = explode("\n", $doc); $propertyPart = false; $propertyPosition = false; + $lastPropertyName = null; + $hasManuallyAddedProperties = false; + foreach ($lines as $i => $line) { $line = trim($line); if (strncmp($line, '* @property', 11) === 0) { @@ -647,21 +681,44 @@ protected function updateDocComment($doc, $properties, $className) $propertyPart = false; } if ($propertyPart) { - preg_match('/@property\s+\w+\s+\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/', $line, $matches); - if (!isset($matches[1]) || !in_array($matches[1], $manuallyAddedProperties)) { + preg_match( + '/@property(?:-read|-write)?\s+([\\\\\w\|\[\]]+)\s+\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/', + $line, + $matches + ); + + if (isset($matches[2])) { + $lastPropertyName = $matches[2]; + } + + if (in_array($lastPropertyName, $manuallyAddedProperties)) { + $hasManuallyAddedProperties = true; + } else { unset($lines[$i]); } } } + if ($properties === '') { + return implode("\n", $lines); + } + // if no properties or other tags were present add properties at the end if ($propertyPosition === false) { $propertyPosition = \count($lines) - 2; } + // if there are properties that were added manually, remove start enclosure + if ($hasManuallyAddedProperties) { + $properties = substr($properties, strlen(self::PROPERTIES_ENCLOSURE)); + } + $finalDoc = ''; foreach ($lines as $i => $line) { - $finalDoc .= $line . "\n"; + if (!$hasManuallyAddedProperties || $i !== $propertyPosition) { + $finalDoc .= $line . "\n"; + } + if ($i == $propertyPosition) { $finalDoc .= $properties; } @@ -717,23 +774,33 @@ protected function generateClassPropertyDocs($fileName) $className = $namespace . '\\' . $class['name']; $gets = $this->match( - '#\* @return (?[\w\\|\\\\\\[\\]]+)(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' . - '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function (?get)(?\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)#', - $class['content'], true); - $sets = $this->match( - '#\* @param (?[\w\\|\\\\\\[\\]]+) \$\w+(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' . - '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function (?set)(?\w+)\(\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)#', - $class['content'], true); - // check for @property annotations in getter and setter - $properties = $this->match( - '#\* @(?property) (?[\w\\|\\\\\\[\\]]+)(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' . - '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function [g|s]et(?\w+)\(((?:,? ?\$\w+ ?= ?[^,]+)*|\$\w+(?:, ?\$\w+ ?= ?[^,]+)*)\)#', - $class['content']); - $acrs = array_merge($properties, $gets, $sets); + '#\* @return (?[\w\\|\\\\\\[\\]]+)' + . '(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/' + . '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}' + . 'public function (?get)(?\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#', + $class['content'], + true + ); + $sets = $this->match( + '#\* @param (?[\w\\|\\\\\\[\\]]+) \$\w+' + . '(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/' + . '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}' + . 'public function (?set)(?\w+)\(([\w\\|\\\\\\[\\]]+\s*)?\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#', + $class['content'], + true + ); + + $acrs = array_merge($gets, $sets); + $manuallyAddedProperties = self::MANUALLY_ADDED_PROPERTIES[$className] ?? []; $props = []; + foreach ($acrs as &$acr) { $acr['name'] = lcfirst($acr['name']); + if (in_array($acr['name'], $manuallyAddedProperties)) { + continue; + } + $acr['comment'] = trim(preg_replace('#(^|\n)\s+\*\s?#', '$1 * ', $acr['comment'])); $props[$acr['name']][$acr['kind']] = [ 'type' => $acr['type'], @@ -747,7 +814,6 @@ protected function generateClassPropertyDocs($fileName) ksort($props); - $phpdoc .= " *\n"; foreach ($props as $propName => &$prop) { $docLine = ' * @property'; $note = ''; @@ -777,7 +843,10 @@ protected function generateClassPropertyDocs($fileName) $phpdoc .= $docLine; } - $phpdoc .= " *\n"; + } + + if ($phpdoc !== '') { + $phpdoc = self::PROPERTIES_ENCLOSURE . $phpdoc . self::PROPERTIES_ENCLOSURE; } return [$className, $phpdoc]; diff --git a/build/controllers/ReleaseController.php b/build/controllers/ReleaseController.php index cec8456309c..1e6168a186e 100644 --- a/build/controllers/ReleaseController.php +++ b/build/controllers/ReleaseController.php @@ -436,7 +436,7 @@ protected function releaseFramework($frameworkPath, $version) $this->stdout("done.\n", Console::FG_GREEN, Console::BOLD); $this->stdout('updating mimetype magic file and mime aliases...', Console::BOLD); - $this->dryRun || Yii::$app->runAction('mime-type', ["$frameworkPath/helpers/mimeTypes.php"], ["$frameworkPath/helpers/mimeAliases.php"]); + $this->dryRun || Yii::$app->runAction('mime-type', ["$frameworkPath/helpers/mimeTypes.php"]); $this->stdout("done.\n", Console::FG_GREEN, Console::BOLD); $this->stdout("fixing various PHPDoc style issues...\n", Console::BOLD); diff --git a/build/controllers/views/translation/report_html.php b/build/controllers/views/translation/report_html.php index 302361d23bc..17d0a89cda3 100644 --- a/build/controllers/views/translation/report_html.php +++ b/build/controllers/views/translation/report_html.php @@ -8,6 +8,10 @@ * @var string $sourcePath * @var string $translationPath * @var array $results + * + * @phpstan-var \yii\web\View&object{ + * context: \yii\build\controllers\TranslationController, + * } $this */ ?> diff --git a/docs/internals-ru/core-code-style.md b/docs/internals-ru/core-code-style.md index 94e344ea4cf..09aaded9add 100644 --- a/docs/internals-ru/core-code-style.md +++ b/docs/internals-ru/core-code-style.md @@ -437,6 +437,35 @@ public function getEventHandlers($name) [Раздел руководства](guide:file-name.md#subsection) ``` +##### Примеры кода + +В примерах кода должен использоваться синтаксис Markdown, но не должен указываться язык. +Указание языка в примерах кода может привести к нарушению их отображения в некоторых IDE. Пример: + +```php +/** + * Correct code example: + * + * ``` + * $object->doMagic(); + * ``` + */ +public function doMagic() +{ +} + +/** + * Incorrect code example: + * + * ```php + * $object->doMagic(); + * ``` + */ +public function doMagic() +{ +} +``` + #### Комментарии diff --git a/docs/internals/core-code-style.md b/docs/internals/core-code-style.md index 0396b28b703..1937eae8c21 100644 --- a/docs/internals/core-code-style.md +++ b/docs/internals/core-code-style.md @@ -468,6 +468,35 @@ It is also possible to link to the Guide using the following syntax: [link to guide](guide:file-name.md#subsection) ``` +##### Code examples + +Code examples should use Markdown syntax, but they should not specify the language. +Specifying a language in code examples may break their display in some IDEs. Here is an example: + +```php +/** + * Correct code example: + * + * ``` + * $object->doMagic(); + * ``` + */ +function doMagic() +{ +} + +/** + * Incorrect code example: + * + * ```php + * $object->doMagic(); + * ``` + */ +function doMagic() +{ +} +``` + #### Comments diff --git a/framework/BaseYii.php b/framework/BaseYii.php index 253205bba7d..8732fcaccde 100644 --- a/framework/BaseYii.php +++ b/framework/BaseYii.php @@ -309,7 +309,7 @@ public static function autoload($className) * * Below are some usage examples: * - * ```php + * ``` * // create an object using a class name * $object = Yii::createObject('yii\db\Connection'); * @@ -343,8 +343,8 @@ public static function autoload($className) * @see \yii\di\Container * * @template T - * @phpstan-param class-string|array{class: class-string, ...}|callable(): T $type - * @psalm-param class-string|array{class: class-string, ...}|callable(): T $type + * @phpstan-param class-string|array{class?: class-string, __class?: class-string, ...}|callable(): T $type + * @psalm-param class-string|array{class?: class-string, __class?: class-string, ...}|callable(): T $type * @phpstan-return T * @psalm-return T */ @@ -462,7 +462,7 @@ public static function info($message, $category = 'application') * This has to be matched with a call to [[endProfile]] with the same category name. * The begin- and end- calls must also be properly nested. For example, * - * ```php + * ``` * \Yii::beginProfile('block1'); * // some code to be profiled * \Yii::beginProfile('block2'); @@ -501,7 +501,7 @@ public static function endProfile($token, $category = 'application') * You can add parameters to a translation message that will be substituted with the corresponding value after * translation. The format for this is to use curly brackets around the parameter name as you can see in the following example: * - * ```php + * ``` * $username = 'Alexander'; * echo \Yii::t('app', 'Hello, {username}!', ['username' => $username]); * ``` diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 320f5959f49..33b0ede40f2 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -51,6 +51,15 @@ Yii Framework 2 Change Log - Bug #20485: Fix error `Cannot unset string offsets` in `yii\di\Instance:ensure(['__class' => ...], 'some\class\name')` (max-s-lab) - Enh #20505: `ArrayDataProvider` key handling with flexible path support (fetus-hina) - Bug #20508: Fix PHPDoc, add PHPStan/Psalm annotations for `yii\web\CookieCollection::getIterator`. Add missing `@property` annotation in `yii\base\Model` (max-s-lab) +- Bug #20513: Fix code examples in PHPDoc (max-s-lab) +- Enh #20514: Add `@property` annotations for `yii\console\Controller` (max-s-lab) +- Bug #20515: Fix `@param` annotations in `BetweenColumnsCondition`, `InCondition` and `LikeCondition` (max-s-lab) +- Bug #20516: Fix `@template` annotations in `ActiveRecord` (max-s-lab) +- Bug #19506: Fix `@property` annotations in `yii\console\widgets\Table`, `yii\di\Container` and `yii\web\Session` (max-s-lab) +- Enh #20525: Add `@template` annotations for all actions (max-s-lab) +- Bug #20524: Fix PHPStan/Psalm annotations in `Yii::createObject` (max-s-lab) +- Bug #20530: Fix notice "Object of class DateTimeImmutable could not be converted to int" in `CookieCollection::has` (max-s-lab) + 2.0.53 June 27, 2025 -------------------- diff --git a/framework/base/Action.php b/framework/base/Action.php index 3aa20608cd3..fed9245e048 100644 --- a/framework/base/Action.php +++ b/framework/base/Action.php @@ -21,7 +21,7 @@ * with user input values automatically according to their names. * For example, if the `run()` method is declared as follows: * - * ```php + * ``` * public function run($id, $type = 'book') { ... } * ``` * diff --git a/framework/base/Application.php b/framework/base/Application.php index 98e652a437f..8890f0c6388 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -137,7 +137,7 @@ abstract class Application extends Module * @var array|null list of installed Yii extensions. Each array element represents a single extension * with the following structure: * - * ```php + * ``` * [ * 'name' => 'extension name', * 'version' => 'version number', diff --git a/framework/base/Arrayable.php b/framework/base/Arrayable.php index c278f61ee16..8b8d8a60c8d 100644 --- a/framework/base/Arrayable.php +++ b/framework/base/Arrayable.php @@ -33,7 +33,7 @@ interface Arrayable * the corresponding field definition which can be either an object property name or a PHP callable * returning the corresponding field value. The signature of the callable should be: * - * ```php + * ``` * function ($model, $field) { * // return field value * } @@ -47,7 +47,7 @@ interface Arrayable * - `fullName`: the field name is `fullName`. Its value is obtained by concatenating `first_name` * and `last_name`. * - * ```php + * ``` * return [ * 'email', * 'firstName' => 'first_name', diff --git a/framework/base/ArrayableTrait.php b/framework/base/ArrayableTrait.php index 3f18171aa90..08bc85834ff 100644 --- a/framework/base/ArrayableTrait.php +++ b/framework/base/ArrayableTrait.php @@ -34,7 +34,7 @@ trait ArrayableTrait * the corresponding field definition which can be either an object property name or a PHP callable * returning the corresponding field value. The signature of the callable should be: * - * ```php + * ``` * function ($model, $field) { * // return field value * } @@ -48,7 +48,7 @@ trait ArrayableTrait * - `fullName`: the field name is `fullName`. Its value is obtained by concatenating `first_name` * and `last_name`. * - * ```php + * ``` * return [ * 'email', * 'firstName' => 'first_name', diff --git a/framework/base/BaseObject.php b/framework/base/BaseObject.php index 6a87b4aed51..d14f1dbb91c 100644 --- a/framework/base/BaseObject.php +++ b/framework/base/BaseObject.php @@ -15,7 +15,7 @@ * A property is defined by a getter method (e.g. `getLabel`), and/or a setter method (e.g. `setLabel`). For example, * the following getter and setter methods define a property named `label`: * - * ```php + * ``` * private $_label; * * public function getLabel() @@ -34,7 +34,7 @@ * A property can be accessed like a member variable of an object. Reading or writing a property will cause the invocation * of the corresponding getter or setter method. For example, * - * ```php + * ``` * // equivalent to $label = $object->getLabel(); * $label = $object->label; * // equivalent to $object->setLabel('abc'); @@ -60,7 +60,7 @@ * In order to ensure the above life cycles, if a child class of BaseObject needs to override the constructor, * it should be done like the following: * - * ```php + * ``` * public function __construct($param1, $param2, ..., $config = []) * { * ... diff --git a/framework/base/Behavior.php b/framework/base/Behavior.php index b005a3de945..53fa8309f94 100644 --- a/framework/base/Behavior.php +++ b/framework/base/Behavior.php @@ -60,7 +60,7 @@ class Behavior extends BaseObject * * The following is an example: * - * ```php + * ``` * [ * Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate', * Model::EVENT_AFTER_VALIDATE => 'myAfterValidate', diff --git a/framework/base/BootstrapInterface.php b/framework/base/BootstrapInterface.php index 3775fcac9fd..ca3cfb6ad07 100644 --- a/framework/base/BootstrapInterface.php +++ b/framework/base/BootstrapInterface.php @@ -17,7 +17,7 @@ * The first approach is mainly used by extensions and is managed by the Composer installation process. * You mainly need to list the bootstrapping class of your extension in the `composer.json` file like following, * - * ```json + * ``` * { * // ... * "extra": { @@ -31,7 +31,7 @@ * The second approach is used by application code which needs to register some code to be run during * the bootstrap process. This is done by configuring the [[Application::bootstrap]] property: * - * ```php + * ``` * return [ * // ... * 'bootstrap' => [ diff --git a/framework/base/Component.php b/framework/base/Component.php index bfccadbd603..44c86645408 100644 --- a/framework/base/Component.php +++ b/framework/base/Component.php @@ -28,7 +28,7 @@ * * To attach an event handler to an event, call [[on()]]: * - * ```php + * ``` * $post->on('update', function ($event) { * // send email notification * }); @@ -44,7 +44,7 @@ * * The signature of an event handler should be like the following: * - * ```php + * ``` * function foo($event) * ``` * @@ -53,7 +53,7 @@ * You can also attach a handler to an event when configuring a component with a configuration array. * The syntax is like the following: * - * ```php + * ``` * [ * 'on add' => function ($event) { ... } * ] @@ -64,7 +64,7 @@ * Sometimes, you may want to associate extra data with an event handler when you attach it to an event * and then access it when the handler is invoked. You may do so by * - * ```php + * ``` * $post->on('update', function ($event) { * // the data can be accessed via $event->data * }, $data); @@ -80,7 +80,7 @@ * One can also attach a behavior to a component when configuring it with a configuration array. The syntax is like the * following: * - * ```php + * ``` * [ * 'as tree' => [ * 'class' => 'Tree', @@ -446,7 +446,7 @@ public function hasMethod($name, $checkBehaviors = true) * indexed by behavior names. A behavior configuration can be either a string specifying * the behavior class or an array of the following structure: * - * ```php + * ``` * 'behaviorName' => [ * 'class' => 'BehaviorClass', * 'property1' => 'value1', @@ -515,7 +515,7 @@ public function hasEventHandlers($name) * * Since 2.0.14 you can specify event name as a wildcard pattern: * - * ```php + * ``` * $component->on('event.group.*', function ($event) { * Yii::trace($event->name . ' is triggered.'); * }); diff --git a/framework/base/Configurable.php b/framework/base/Configurable.php index b44a082841e..4acbd3f0b74 100644 --- a/framework/base/Configurable.php +++ b/framework/base/Configurable.php @@ -14,7 +14,7 @@ * The interface does not declare any method. Classes implementing this interface must declare their constructors * like the following: * - * ```php + * ``` * public function __construct($param1, $param2, ..., $config = []) * ``` * diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 0eec3adb4a3..b2be42650c6 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -116,7 +116,7 @@ public function init() * It should return an array, with array keys being action IDs, and array values the corresponding * action class names or action configuration arrays. For example, * - * ```php + * ``` * return [ * 'action1' => 'app\components\Action1', * 'action2' => [ @@ -293,7 +293,7 @@ public function createAction($id) * * If you override this method, your code should look like the following: * - * ```php + * ``` * public function beforeAction($action) * { * // your custom code here, if you want the code to run before action filters, @@ -330,7 +330,7 @@ public function beforeAction($action) * * If you override this method, your code should look like the following: * - * ```php + * ``` * public function afterAction($action, $result) * { * $result = parent::afterAction($action, $result); diff --git a/framework/base/DynamicModel.php b/framework/base/DynamicModel.php index a7288a997f4..219ddc916ca 100644 --- a/framework/base/DynamicModel.php +++ b/framework/base/DynamicModel.php @@ -16,7 +16,7 @@ * * The typical usage of DynamicModel is as follows, * - * ```php + * ``` * public function actionSearch($name, $email) * { * $model = DynamicModel::validateData(compact('name', 'email'), [ @@ -41,7 +41,7 @@ * * Alternatively, you may use the following more "classic" syntax to perform ad-hoc data validation: * - * ```php + * ``` * $model = new DynamicModel(compact('name', 'email')); * $model->addRule(['name', 'email'], 'string', ['max' => 128]) * ->addRule('email', 'email') diff --git a/framework/base/Event.php b/framework/base/Event.php index ac2fdc43466..abafc37814a 100644 --- a/framework/base/Event.php +++ b/framework/base/Event.php @@ -72,7 +72,7 @@ class Event extends BaseObject * For example, the following code attaches an event handler to `ActiveRecord`'s * `afterInsert` event: * - * ```php + * ``` * Event::on(ActiveRecord::class, ActiveRecord::EVENT_AFTER_INSERT, function ($event) { * Yii::trace(get_class($event->sender) . ' is inserted.'); * }); @@ -82,7 +82,7 @@ class Event extends BaseObject * * Since 2.0.14 you can specify either class name or event name as a wildcard pattern: * - * ```php + * ``` * Event::on('app\models\db\*', '*Insert', function ($event) { * Yii::trace(get_class($event->sender) . ' is inserted.'); * }); diff --git a/framework/base/InlineAction.php b/framework/base/InlineAction.php index 6e6b1be02f9..13f57ad7249 100644 --- a/framework/base/InlineAction.php +++ b/framework/base/InlineAction.php @@ -19,6 +19,9 @@ * * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends Action */ class InlineAction extends Action { diff --git a/framework/base/Model.php b/framework/base/Model.php index 83488c0a66a..bf76013ca33 100644 --- a/framework/base/Model.php +++ b/framework/base/Model.php @@ -37,13 +37,25 @@ * * For more details and usage information on Model, see the [guide article on models](guide:structure-models). * + * @property-read array $errors Errors for all attributes. This is a two-dimensional + * array of errors for all attributes, similar to the following: + * + * ``` + * [ + * 'username' => [ + * 'Username is required.', + * 'Username must contain only word characters.', + * ], + * 'email' => [ + * 'Email address is invalid.', + * ] + * ] + * ``` + * + * Empty array if no errors. * @property-read \yii\validators\Validator[] $activeValidators The validators applicable to the current * [[scenario]]. * @property array $attributes Attribute values (name => value). - * @property-read array $errors Errors for all attributes or the specified attribute. Empty array is returned - * if no error. See [[getErrors()]] for detailed description. Note that when returning errors for all attributes, - * the result is a two-dimensional array, like the following: ```php [ 'username' => [ 'Username is required.', - * 'Username must contain only word characters.', ], 'email' => [ 'Email address is invalid.', ] ] ```. * @property-read array $firstErrors The first errors. The array keys are the attribute names, and the array * values are the corresponding error messages. An empty array will be returned if there is no error. * @property-read ArrayIterator $iterator An iterator for traversing the items in the list. @@ -104,7 +116,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg * * Each rule is an array with the following structure: * - * ```php + * ``` * [ * ['attribute1', 'attribute2'], * 'validator type', @@ -126,7 +138,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg * A validator can be either an object of a class extending [[Validator]], or a model class method * (called *inline validator*) that has the following signature: * - * ```php + * ``` * // $params refers to validation parameters given in the rule * function validatorName($attribute, $params) * ``` @@ -141,7 +153,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg * * Below are some examples: * - * ```php + * ``` * [ * // built-in "required" validator * [['username', 'password'], 'required'], @@ -176,7 +188,7 @@ public function rules() * An active attribute is one that is subject to validation in the current scenario. * The returned array should be in the following format: * - * ```php + * ``` * [ * 'scenario1' => ['attribute11', 'attribute12', ...], * 'scenario2' => ['attribute21', 'attribute22', ...], @@ -433,7 +445,7 @@ public function afterValidate() * manipulate it by inserting or removing validators (useful in model behaviors). * For example, * - * ```php + * ``` * $model->validators[] = $newValidator; * ``` * @@ -587,10 +599,9 @@ public function hasErrors($attribute = null) * Returns the errors for all attributes or a single attribute. * @param string|null $attribute attribute name. Use null to retrieve errors for all attributes. * @return array errors for all attributes or the specified attribute. Empty array is returned if no error. - * See [[getErrors()]] for detailed description. * Note that when returning errors for all attributes, the result is a two-dimensional array, like the following: * - * ```php + * ``` * [ * 'username' => [ * 'Username is required.', @@ -873,7 +884,7 @@ public function activeAttributes() * * This method provides a convenient shortcut for: * - * ```php + * ``` * if (isset($_POST['FormName'])) { * $model->attributes = $_POST['FormName']; * if ($model->save()) { @@ -884,7 +895,7 @@ public function activeAttributes() * * which, with `load()` can be written as: * - * ```php + * ``` * if ($model->load($_POST) && $model->save()) { * // handle success * } @@ -991,7 +1002,7 @@ public static function validateMultiple($models, $attributeNames = null) * the corresponding field definition which can be either an object property name or a PHP callable * returning the corresponding field value. The signature of the callable should be: * - * ```php + * ``` * function ($model, $field) { * // return field value * } @@ -1005,7 +1016,7 @@ public static function validateMultiple($models, $attributeNames = null) * - `fullName`: the field name is `fullName`. Its value is obtained by concatenating `first_name` * and `last_name`. * - * ```php + * ``` * return [ * 'email', * 'firstName' => 'first_name', diff --git a/framework/base/Module.php b/framework/base/Module.php index d730d915108..8a7b0b6e642 100644 --- a/framework/base/Module.php +++ b/framework/base/Module.php @@ -77,7 +77,7 @@ class Module extends ServiceLocator * the controller's fully qualified class name, and the rest of the name-value pairs * in the array are used to initialize the corresponding controller properties. For example, * - * ```php + * ``` * [ * 'account' => 'app\controllers\UserController', * 'article' => [ @@ -135,7 +135,7 @@ class Module extends ServiceLocator * Version can be specified as a PHP callback, which can accept module instance as an argument and should * return the actual version. For example: * - * ```php + * ``` * function (Module $module) { * //return string|int * } @@ -349,7 +349,7 @@ public function getVersion() * Version can be specified as a PHP callback, which can accept module instance as an argument and should * return the actual version. For example: * - * ```php + * ``` * function (Module $module) { * //return string * } @@ -381,14 +381,11 @@ protected function defaultVersion() * Defines path aliases. * This method calls [[Yii::setAlias()]] to register the path aliases. * This method is provided so that you can define path aliases when configuring a module. - * @property array list of path aliases to be defined. The array keys are alias names - * (must start with `@`) and the array values are the corresponding paths or aliases. - * See [[setAliases()]] for an example. * @param array $aliases list of path aliases to be defined. The array keys are alias names * (must start with `@`) and the array values are the corresponding paths or aliases. * For example, * - * ```php + * ``` * [ * '@models' => '@app/models', // an existing alias * '@backend' => __DIR__ . '/../backend', // a directory @@ -512,7 +509,7 @@ public function getModules($loadedOnly = false) * * The following is an example for registering two sub-modules: * - * ```php + * ``` * [ * 'comment' => [ * 'class' => 'app\modules\comment\CommentModule', @@ -705,7 +702,7 @@ private function isIncorrectClassNameOrPrefix($className, $prefix) * * If you override this method, your code should look like the following: * - * ```php + * ``` * public function beforeAction($action) * { * if (!parent::beforeAction($action)) { @@ -736,7 +733,7 @@ public function beforeAction($action) * * If you override this method, your code should look like the following: * - * ```php + * ``` * public function afterAction($action, $result) * { * $result = parent::afterAction($action, $result); diff --git a/framework/base/Security.php b/framework/base/Security.php index 63e7e951644..41554f124da 100644 --- a/framework/base/Security.php +++ b/framework/base/Security.php @@ -504,7 +504,7 @@ public function generateRandomString($length = 32) * Later when a password needs to be validated, the hash can be fetched and passed * to [[validatePassword()]]. For example, * - * ```php + * ``` * // generates the hash (usually done during user registration or when the password is changed) * $hash = Yii::$app->getSecurity()->generatePasswordHash($password); * // ...save $hash in database... diff --git a/framework/base/Theme.php b/framework/base/Theme.php index 2f9669071eb..5ea4c085ef0 100644 --- a/framework/base/Theme.php +++ b/framework/base/Theme.php @@ -33,7 +33,7 @@ * * It is possible to map a single path to multiple paths. For example, * - * ```php + * ``` * 'pathMap' => [ * '@app/views' => [ * '@app/themes/christmas', @@ -48,7 +48,7 @@ * To use a theme, you should configure the [[View::theme|theme]] property of the "view" application * component like the following: * - * ```php + * ``` * 'view' => [ * 'theme' => [ * 'basePath' => '@app/themes/basic', diff --git a/framework/base/View.php b/framework/base/View.php index 81d1acfa849..93b14a2dc60 100644 --- a/framework/base/View.php +++ b/framework/base/View.php @@ -59,7 +59,7 @@ class View extends Component implements DynamicContentAwareInterface * Each renderer may be a view renderer object or the configuration for creating the renderer object. * For example, the following configuration enables both Smarty and Twig view renderers: * - * ```php + * ``` * [ * 'tpl' => ['class' => 'yii\smarty\ViewRenderer'], * 'twig' => ['class' => 'yii\twig\ViewRenderer'], @@ -497,7 +497,7 @@ public function endBlock() * This method can be used to implement nested layout. For example, a layout can be embedded * in another layout file specified as '@app/views/layouts/base.php' like the following: * - * ```php + * ``` * beginContent('@app/views/layouts/base.php'); ?> * //...layout content here... * endContent(); ?> @@ -534,7 +534,7 @@ public function endContent() * call to end the cache and save the content into cache. * A typical usage of fragment caching is as follows, * - * ```php + * ``` * if ($this->beginCache($id)) { * // ...generate content here * $this->endCache(); diff --git a/framework/base/Widget.php b/framework/base/Widget.php index 1baaa42b681..f02d4a2b2dd 100644 --- a/framework/base/Widget.php +++ b/framework/base/Widget.php @@ -284,7 +284,7 @@ public function getViewPath() * * When overriding this method, make sure you call the parent implementation like the following: * - * ```php + * ``` * public function beforeRun() * { * if (!parent::beforeRun()) { @@ -315,7 +315,7 @@ public function beforeRun() * * If you override this method, your code should look like the following: * - * ```php + * ``` * public function afterRun($result) * { * $result = parent::afterRun($result); diff --git a/framework/behaviors/AttributeBehavior.php b/framework/behaviors/AttributeBehavior.php index 36b360658a7..c90a8d4d51e 100644 --- a/framework/behaviors/AttributeBehavior.php +++ b/framework/behaviors/AttributeBehavior.php @@ -21,7 +21,7 @@ * [[value]] property with a PHP callable whose return value will be used to assign to the current attribute(s). * For example, * - * ```php + * ``` * use yii\behaviors\AttributeBehavior; * * public function behaviors() @@ -56,7 +56,7 @@ class AttributeBehavior extends Behavior * and the array values are the corresponding attribute(s) to be updated. You can use a string to represent * a single attribute, or an array to represent a list of attributes. For example, * - * ```php + * ``` * [ * ActiveRecord::EVENT_BEFORE_INSERT => ['attribute1', 'attribute2'], * ActiveRecord::EVENT_BEFORE_UPDATE => 'attribute2', @@ -71,7 +71,7 @@ class AttributeBehavior extends Behavior * function will be assigned to the attributes. * The signature of the function should be as follows, * - * ```php + * ``` * function ($event) * { * // return value will be assigned to the attribute diff --git a/framework/behaviors/AttributeTypecastBehavior.php b/framework/behaviors/AttributeTypecastBehavior.php index 3d55d7ba777..96504e067b4 100644 --- a/framework/behaviors/AttributeTypecastBehavior.php +++ b/framework/behaviors/AttributeTypecastBehavior.php @@ -28,7 +28,7 @@ * * For example: * - * ```php + * ``` * use yii\behaviors\AttributeTypecastBehavior; * * class Item extends \yii\db\ActiveRecord @@ -58,7 +58,7 @@ * automatically based on owner validation rules. * Following example will automatically create same [[attributeTypes]] value as it was configured at the above one: * - * ```php + * ``` * use yii\behaviors\AttributeTypecastBehavior; * * class Item extends \yii\db\ActiveRecord @@ -99,7 +99,7 @@ * * Note: you can manually trigger attribute typecasting anytime invoking [[typecastAttributes()]] method: * - * ```php + * ``` * $model = new Item(); * $model->price = '38.5'; * $model->is_active = 1; @@ -126,7 +126,7 @@ class AttributeTypecastBehavior extends Behavior * typecast result. * For example: * - * ```php + * ``` * [ * 'amount' => 'integer', * 'price' => 'float', diff --git a/framework/behaviors/AttributesBehavior.php b/framework/behaviors/AttributesBehavior.php index 529c72db1f0..c3117d883a2 100644 --- a/framework/behaviors/AttributesBehavior.php +++ b/framework/behaviors/AttributesBehavior.php @@ -21,7 +21,7 @@ * value of enclosed arrays with a PHP callable whose return value will be used to assign to the current attribute. * For example, * - * ```php + * ``` * use yii\behaviors\AttributesBehavior; * * public function behaviors() @@ -73,7 +73,7 @@ class AttributesBehavior extends Behavior * (e.g. `new Expression('NOW()')`), scalar, string or an arbitrary value. If the former, the return value of the * function will be assigned to the attributes. * - * ```php + * ``` * [ * 'attribute1' => [ * ActiveRecord::EVENT_BEFORE_INSERT => new Expression('NOW()'), @@ -103,7 +103,7 @@ class AttributesBehavior extends Behavior * The rest of the attributes are processed at the end. * If the [[attributes]] for this attribute do not specify this event, it is ignored * - * ```php + * ``` * [ * ActiveRecord::EVENT_BEFORE_VALIDATE => ['attribute1', 'attribute2'], * ActiveRecord::EVENT_AFTER_VALIDATE => ['attribute2', 'attribute1'], diff --git a/framework/behaviors/BlameableBehavior.php b/framework/behaviors/BlameableBehavior.php index f83b8b3f28c..5976b6e2196 100755 --- a/framework/behaviors/BlameableBehavior.php +++ b/framework/behaviors/BlameableBehavior.php @@ -15,7 +15,7 @@ * * To use BlameableBehavior, insert the following code to your ActiveRecord class: * - * ```php + * ``` * use yii\behaviors\BlameableBehavior; * * public function behaviors() @@ -36,7 +36,7 @@ * If your attribute names are different, you may configure the [[createdByAttribute]] and [[updatedByAttribute]] * properties like the following: * - * ```php + * ``` * public function behaviors() * { * return [ diff --git a/framework/behaviors/CacheableWidgetBehavior.php b/framework/behaviors/CacheableWidgetBehavior.php index 2ac37517c5a..47015849d6f 100644 --- a/framework/behaviors/CacheableWidgetBehavior.php +++ b/framework/behaviors/CacheableWidgetBehavior.php @@ -23,7 +23,7 @@ * * The following example will cache the posts widget for an indefinite duration until any post is modified. * - * ```php + * ``` * use yii\behaviors\CacheableWidgetBehavior; * * public function behaviors() @@ -64,7 +64,7 @@ class CacheableWidgetBehavior extends Behavior * * For example, * - * ```php + * ``` * [ * 'class' => 'yii\caching\DbDependency', * 'sql' => 'SELECT MAX(updated_at) FROM posts', @@ -82,7 +82,7 @@ class CacheableWidgetBehavior extends Behavior * The following variation setting will cause the content to be cached in different versions * according to the current application language: * - * ```php + * ``` * [ * Yii::$app->language, * ] @@ -94,7 +94,7 @@ class CacheableWidgetBehavior extends Behavior * on and off according to specific conditions. * The following configuration will disable caching when a special GET parameter is passed: * - * ```php + * ``` * empty(Yii::$app->request->get('disable-caching')) * ``` */ diff --git a/framework/behaviors/OptimisticLockBehavior.php b/framework/behaviors/OptimisticLockBehavior.php index 18d80bd48db..aaaa0ed0bcc 100644 --- a/framework/behaviors/OptimisticLockBehavior.php +++ b/framework/behaviors/OptimisticLockBehavior.php @@ -27,7 +27,7 @@ * holding the lock version from the [[\yii\base\Model::rules()|rules()]] method of your * ActiveRecord class, then add the following code to it: * - * ```php + * ``` * use yii\behaviors\OptimisticLockBehavior; * * public function behaviors() @@ -54,7 +54,7 @@ * version by one, that may be useful when you need to mark an entity as stale among connected clients * and avoid any change to it until they load it again: * - * ```php + * ``` * $model->upgrade(); * ``` * @@ -151,7 +151,7 @@ protected function getValue($event) /** * Upgrades the version value by one and stores it to database. * - * ```php + * ``` * $model->upgrade(); * ``` * @throws InvalidCallException if owner is a new record. diff --git a/framework/behaviors/SluggableBehavior.php b/framework/behaviors/SluggableBehavior.php index 4b9ec90a7c7..582d1551454 100644 --- a/framework/behaviors/SluggableBehavior.php +++ b/framework/behaviors/SluggableBehavior.php @@ -22,7 +22,7 @@ * * To use SluggableBehavior, insert the following code to your ActiveRecord class: * - * ```php + * ``` * use yii\behaviors\SluggableBehavior; * * public function behaviors() @@ -45,7 +45,7 @@ * * If your attribute name is different, you may configure the [[slugAttribute]] property like the following: * - * ```php + * ``` * public function behaviors() * { * return [ @@ -78,7 +78,7 @@ class SluggableBehavior extends AttributeBehavior * If `null` then the `$attribute` property will be used to generate a slug. * The signature of the function should be as follows, * - * ```php + * ``` * function ($event) * { * // return slug @@ -114,7 +114,7 @@ class SluggableBehavior extends AttributeBehavior * @var callable|null slug unique value generator. It is used in case [[ensureUnique]] enabled and generated * slug is not unique. This should be a PHP callable with following signature: * - * ```php + * ``` * function ($baseSlug, $iteration, $model) * { * // return uniqueSlug diff --git a/framework/behaviors/TimestampBehavior.php b/framework/behaviors/TimestampBehavior.php index ef927b1d659..6c5de96b7ed 100644 --- a/framework/behaviors/TimestampBehavior.php +++ b/framework/behaviors/TimestampBehavior.php @@ -15,7 +15,7 @@ * * To use TimestampBehavior, insert the following code to your ActiveRecord class: * - * ```php + * ``` * use yii\behaviors\TimestampBehavior; * * public function behaviors() @@ -38,7 +38,7 @@ * If your attribute names are different or you want to use a different way of calculating the timestamp, * you may configure the [[createdAtAttribute]], [[updatedAtAttribute]] and [[value]] properties like the following: * - * ```php + * ``` * use yii\db\Expression; * * public function behaviors() @@ -61,7 +61,7 @@ * TimestampBehavior also provides a method named [[touch()]] that allows you to assign the current * timestamp to the specified attribute(s) and save them to the database. For example, * - * ```php + * ``` * $model->touch('creation_time'); * ``` * @@ -123,7 +123,7 @@ protected function getValue($event) /** * Updates a timestamp attribute to the current timestamp. * - * ```php + * ``` * $model->touch('lastVisit'); * ``` * @param string $attribute the name of the attribute to update. diff --git a/framework/caching/Cache.php b/framework/caching/Cache.php index 390494271fd..b4badc55413 100644 --- a/framework/caching/Cache.php +++ b/framework/caching/Cache.php @@ -22,7 +22,7 @@ * * A typical usage pattern of cache is like the following: * - * ```php + * ``` * $key = 'demo'; * $data = $cache->get($key); * if ($data === false) { @@ -33,7 +33,7 @@ * * Because Cache implements the [[\ArrayAccess]] interface, it can be used like an array. For example, * - * ```php + * ``` * $cache['foo'] = 'some data'; * echo $cache['foo']; * ``` @@ -523,7 +523,7 @@ public function offsetUnset($key) * * Usage example: * - * ```php + * ``` * public function getTopProducts($count = 10) { * $cache = $this->cache; // Could be Yii::$app->cache * return $cache->getOrSet(['top-n-products', 'n' => $count], function () use ($count) { diff --git a/framework/caching/CacheInterface.php b/framework/caching/CacheInterface.php index b9e8035a348..51aabf1813a 100644 --- a/framework/caching/CacheInterface.php +++ b/framework/caching/CacheInterface.php @@ -18,7 +18,7 @@ * * A typical usage pattern of cache is like the following: * - * ```php + * ``` * $key = 'demo'; * $data = $cache->get($key); * if ($data === false) { @@ -29,7 +29,7 @@ * * Because CacheInterface extends the [[\ArrayAccess]] interface, it can be used like an array. For example, * - * ```php + * ``` * $cache['foo'] = 'some data'; * echo $cache['foo']; * ``` @@ -169,7 +169,7 @@ public function flush(); * * Usage example: * - * ```php + * ``` * public function getTopProducts($count = 10) { * $cache = $this->cache; // Could be Yii::$app->cache * return $cache->getOrSet(['top-n-products', 'n' => $count], function ($cache) use ($count) { diff --git a/framework/caching/DbCache.php b/framework/caching/DbCache.php index 45f17296904..2f131268eff 100644 --- a/framework/caching/DbCache.php +++ b/framework/caching/DbCache.php @@ -24,7 +24,7 @@ * * The following example shows how you can configure the application to use DbCache: * - * ```php + * ``` * 'cache' => [ * 'class' => 'yii\caching\DbCache', * // 'db' => 'mydb', @@ -50,7 +50,7 @@ class DbCache extends Cache * @var string name of the DB table to store cache content. * The table should be pre-created as follows: * - * ```php + * ``` * CREATE TABLE cache ( * id char(128) NOT NULL PRIMARY KEY, * expire int(11), @@ -59,7 +59,7 @@ class DbCache extends Cache * ``` * * For MSSQL: - * ```php + * ``` * CREATE TABLE cache ( * id VARCHAR(128) NOT NULL PRIMARY KEY, * expire INT(11), diff --git a/framework/caching/DbQueryDependency.php b/framework/caching/DbQueryDependency.php index ac358292809..1c172615878 100644 --- a/framework/caching/DbQueryDependency.php +++ b/framework/caching/DbQueryDependency.php @@ -48,7 +48,7 @@ class DbQueryDependency extends Dependency * * This field can be specified as a PHP callback of following signature: * - * ```php + * ``` * function (QueryInterface $query, mixed $db) { * //return mixed; * } diff --git a/framework/caching/MemCache.php b/framework/caching/MemCache.php index a1918c90f58..80242c7dfbd 100644 --- a/framework/caching/MemCache.php +++ b/framework/caching/MemCache.php @@ -28,7 +28,7 @@ * * To use MemCache as the cache application component, configure the application as follows, * - * ```php + * ``` * [ * 'components' => [ * 'cache' => [ diff --git a/framework/caching/TagDependency.php b/framework/caching/TagDependency.php index 99dae2fb670..ccdb657401f 100644 --- a/framework/caching/TagDependency.php +++ b/framework/caching/TagDependency.php @@ -12,7 +12,7 @@ * * By calling [[invalidate()]], you can invalidate all cached data items that are associated with the specified tag name(s). * - * ```php + * ``` * // setting multiple cache keys to store data forever and tagging them with "user-123" * Yii::$app->cache->set('user_42_profile', '', 0, new TagDependency(['tags' => 'user-123'])); * Yii::$app->cache->set('user_42_stats', '', 0, new TagDependency(['tags' => 'user-123'])); diff --git a/framework/captcha/Captcha.php b/framework/captcha/Captcha.php index a86fd188ec1..065c171a610 100644 --- a/framework/captcha/Captcha.php +++ b/framework/captcha/Captcha.php @@ -31,7 +31,7 @@ * * The following example shows how to use this widget with a model attribute: * - * ```php + * ``` * echo Captcha::widget([ * 'model' => $model, * 'attribute' => 'captcha', @@ -40,7 +40,7 @@ * * The following example will use the name property instead: * - * ```php + * ``` * echo Captcha::widget([ * 'name' => 'captcha', * ]); @@ -49,7 +49,7 @@ * You can also use this widget in an [[\yii\widgets\ActiveForm|ActiveForm]] using the [[\yii\widgets\ActiveField::widget()|widget()]] * method, for example like this: * - * ```php + * ``` * field($model, 'captcha')->widget(\yii\captcha\Captcha::classname(), [ * // configure additional widget properties here * ]) ?> diff --git a/framework/captcha/CaptchaAction.php b/framework/captcha/CaptchaAction.php index 1518d0904d1..79086e05359 100644 --- a/framework/captcha/CaptchaAction.php +++ b/framework/captcha/CaptchaAction.php @@ -11,6 +11,7 @@ use yii\base\Action; use yii\base\InvalidConfigException; use yii\helpers\Url; +use yii\web\Controller; use yii\web\Response; /** @@ -35,6 +36,9 @@ * * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends Action */ class CaptchaAction extends Action { diff --git a/framework/console/Application.php b/framework/console/Application.php index 1ec070a55d2..8b85d0fb4bc 100644 --- a/framework/console/Application.php +++ b/framework/console/Application.php @@ -164,7 +164,7 @@ public function handleRequest($request) * For example, to run `public function actionTest($a, $b)` assuming that the controller has options the following * code should be used: * - * ```php + * ``` * \Yii::$app->runAction('controller/test', ['option' => 'value', $a, $b]); * ``` * diff --git a/framework/console/Controller.php b/framework/console/Controller.php index 5599dfffb4d..0be388c8b2a 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -28,6 +28,8 @@ * where `` is a route to a controller action and the params will be populated as properties of a command. * See [[options()]] for details. * + * @property Request $request The request object. + * @property Response $response The response object. * @property-read string $help The help information for this controller. * @property-read string $helpSummary The one-line short summary describing this controller. * @property-read array $passedOptionValues The properties corresponding to the passed options. @@ -353,7 +355,7 @@ public function stderr($string) * * An example of how to use the prompt method with a validator function. * - * ```php + * ``` * $code = $this->prompt('Enter 4-Chars-Pin', ['required' => true, 'validator' => function($input, &$error) { * if (strlen($input) !== 4) { * $error = 'The Pin must be exactly 4 chars!'; @@ -379,7 +381,7 @@ public function prompt($text, $options = []) * * A typical usage looks like the following: * - * ```php + * ``` * if ($this->confirm("Are you sure?")) { * echo "user typed yes\n"; * } else { diff --git a/framework/console/ExitCode.php b/framework/console/ExitCode.php index 311f5027d54..471f5953f71 100644 --- a/framework/console/ExitCode.php +++ b/framework/console/ExitCode.php @@ -14,7 +14,7 @@ * * These constants can be used in console controllers for example like this: * - * ```php + * ``` * public function actionIndex() * { * if (!$this->isAllowedToPerformAction()) { diff --git a/framework/console/controllers/AssetController.php b/framework/console/controllers/AssetController.php index 8b9d5a3fc27..7b451cb4e33 100644 --- a/framework/console/controllers/AssetController.php +++ b/framework/console/controllers/AssetController.php @@ -60,7 +60,7 @@ class AssetController extends Controller * You can specify the name of the output compressed file using 'css' and 'js' keys: * For example: * - * ```php + * ``` * 'app\config\AllAsset' => [ * 'js' => 'js/all-{hash}.js', * 'css' => 'css/all-{hash}.css', @@ -76,7 +76,7 @@ class AssetController extends Controller * bundles in this case. * For example: * - * ```php + * ``` * 'allShared' => [ * 'js' => 'js/all-shared-{hash}.js', * 'css' => 'css/all-shared-{hash}.css', diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 88792516a27..9400c04a37e 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -67,7 +67,7 @@ abstract class BaseMigrateController extends Controller * * For example: * - * ```php + * ``` * [ * 'app\migrations', * 'some\extension\migrations', diff --git a/framework/console/controllers/FixtureController.php b/framework/console/controllers/FixtureController.php index 8ad98f217c2..031e54d23e1 100644 --- a/framework/console/controllers/FixtureController.php +++ b/framework/console/controllers/FixtureController.php @@ -493,7 +493,7 @@ private function getFixturesConfig($fixtures) * If fixture is prefixed with "-", for example "-User", that means that fixture should not be loaded, * if it is not prefixed it is considered as one to be loaded. Returns array: * - * ```php + * ``` * [ * 'apply' => [ * 'User', diff --git a/framework/console/controllers/MigrateController.php b/framework/console/controllers/MigrateController.php index 2f2d1dd1740..8fea062ed75 100644 --- a/framework/console/controllers/MigrateController.php +++ b/framework/console/controllers/MigrateController.php @@ -31,7 +31,7 @@ * this command is executed, if it does not exist. You may also manually * create it as follows: * - * ```sql + * ``` * CREATE TABLE migration ( * version varchar(180) PRIMARY KEY, * apply_time integer @@ -54,7 +54,7 @@ * Since 2.0.10 you can use namespaced migrations. In order to enable this feature you should configure [[migrationNamespaces]] * property for the controller at application configuration: * - * ```php + * ``` * return [ * 'controllerMap' => [ * 'migrate' => [ diff --git a/framework/console/widgets/Table.php b/framework/console/widgets/Table.php index be223f1a23b..2e4de8f8001 100644 --- a/framework/console/widgets/Table.php +++ b/framework/console/widgets/Table.php @@ -17,7 +17,7 @@ * * For example, * - * ```php + * ``` * $table = new Table(); * * echo $table @@ -31,7 +31,7 @@ * * or * - * ```php + * ``` * echo Table::widget([ * 'headers' => ['test1', 'test2', 'test3'], * 'rows' => [ @@ -40,7 +40,10 @@ * ], * ]); * + * @property-write array $chars Table chars. + * @property-write array $headers Table headers. * @property-write string $listPrefix List prefix. + * @property-write array $rows Table rows. * @property-write int $screenWidth Screen width. * * @author Daniel Gomez Pan diff --git a/framework/data/ActiveDataFilter.php b/framework/data/ActiveDataFilter.php index be5704aa675..36b62176e9d 100644 --- a/framework/data/ActiveDataFilter.php +++ b/framework/data/ActiveDataFilter.php @@ -22,7 +22,7 @@ class ActiveDataFilter extends DataFilter * These methods are used by [[buildCondition()]] to build the actual filtering conditions. * Particular condition builder can be specified using a PHP callback. For example: * - * ```php + * ``` * [ * 'XOR' => function (string $operator, mixed $condition) { * //return array; @@ -56,7 +56,7 @@ class ActiveDataFilter extends DataFilter * used in [[\yii\db\QueryInterface::where()]]. However, you may want to adjust it in some special cases. * For example, when using PostgreSQL you may want to setup the following map: * - * ```php + * ``` * [ * 'LIKE' => 'ILIKE' * ] diff --git a/framework/data/ActiveDataProvider.php b/framework/data/ActiveDataProvider.php index 47555c326af..9190daaed28 100644 --- a/framework/data/ActiveDataProvider.php +++ b/framework/data/ActiveDataProvider.php @@ -21,7 +21,7 @@ * * The following is an example of using ActiveDataProvider to provide ActiveRecord instances: * - * ```php + * ``` * $provider = new ActiveDataProvider([ * 'query' => Post::find(), * 'pagination' => [ @@ -35,7 +35,7 @@ * * And the following example shows how to use ActiveDataProvider without ActiveRecord: * - * ```php + * ``` * $query = new Query(); * $provider = new ActiveDataProvider([ * 'query' => $query->from('post'), diff --git a/framework/data/ArrayDataProvider.php b/framework/data/ArrayDataProvider.php index a89cf56eb14..2a08ea06d8d 100644 --- a/framework/data/ArrayDataProvider.php +++ b/framework/data/ArrayDataProvider.php @@ -27,7 +27,7 @@ * * ArrayDataProvider may be used in the following way: * - * ```php + * ``` * $query = new Query; * $provider = new ArrayDataProvider([ * 'allModels' => $query->from('post')->all(), diff --git a/framework/data/DataFilter.php b/framework/data/DataFilter.php index 587b7b10a58..5be021266a0 100644 --- a/framework/data/DataFilter.php +++ b/framework/data/DataFilter.php @@ -24,7 +24,7 @@ * * Filter example: * - * ```json + * ``` * { * "or": [ * { @@ -51,7 +51,7 @@ * In the request the filter should be specified using a key name equal to [[filterAttributeName]]. Thus actual HTTP request body * will look like following: * - * ```json + * ``` * { * "filter": {"or": {...}}, * "page": 2, @@ -62,7 +62,7 @@ * Raw filter value should be assigned to [[filter]] property of the model. * You may populate it from request data via [[load()]] method: * - * ```php + * ``` * use yii\data\DataFilter; * * $dataFilter = new DataFilter(); @@ -72,7 +72,7 @@ * In order to function this class requires a search model specified via [[searchModel]]. This search model should declare * all available search attributes and their validation rules. For example: * - * ```php + * ``` * class SearchModel extends \yii\base\Model * { * public $id; @@ -92,7 +92,7 @@ * In order to reduce amount of classes, you may use [[\yii\base\DynamicModel]] instance as a [[searchModel]]. * In this case you should specify [[searchModel]] using a PHP callable: * - * ```php + * ``` * function () { * return (new \yii\base\DynamicModel(['id' => null, 'name' => null])) * ->addRule(['id', 'name'], 'trim') @@ -156,7 +156,7 @@ class DataFilter extends Model * * You may specify several keywords for the same filter build key, creating multiple aliases. For example: * - * ```php + * ``` * [ * 'eq' => '=', * '=' => '=', @@ -230,7 +230,7 @@ class DataFilter extends Model * @var array actual attribute names to be used in searched condition, in format: [filterAttribute => actualAttribute]. * For example, in case of using table joins in the search query, attribute map may look like the following: * - * ```php + * ``` * [ * 'authorName' => '{{author}}.[[name]]' * ] @@ -387,6 +387,8 @@ protected function detectSearchAttributeType(Validator $validator) } return self::TYPE_DATE; } + + return null; } /** diff --git a/framework/data/Pagination.php b/framework/data/Pagination.php index a928681c4da..d4e76a2a76c 100644 --- a/framework/data/Pagination.php +++ b/framework/data/Pagination.php @@ -26,7 +26,7 @@ * * Controller action: * - * ```php + * ``` * public function actionIndex() * { * $query = Article::find()->where(['status' => 1]); @@ -45,7 +45,7 @@ * * View: * - * ```php + * ``` * foreach ($models as $model) { * // display $model here * } diff --git a/framework/data/Sort.php b/framework/data/Sort.php index 0c0abc8b606..4f64f571f67 100644 --- a/framework/data/Sort.php +++ b/framework/data/Sort.php @@ -23,7 +23,7 @@ * * A typical usage example is as follows, * - * ```php + * ``` * public function actionIndex() * { * $sort = new Sort([ @@ -52,7 +52,7 @@ * * View: * - * ```php + * ``` * // display links leading to sort actions * echo $sort->link('name') . ' | ' . $sort->link('age'); * @@ -88,7 +88,7 @@ class Sort extends BaseObject * @var array list of attributes that are allowed to be sorted. Its syntax can be * described using the following example: * - * ```php + * ``` * [ * 'age', * 'name' => [ @@ -103,7 +103,7 @@ class Sort extends BaseObject * In the above, two attributes are declared: `age` and `name`. The `age` attribute is * a simple attribute which is equivalent to the following: * - * ```php + * ``` * 'age' => [ * 'asc' => ['age' => SORT_ASC], * 'desc' => ['age' => SORT_DESC], @@ -114,7 +114,7 @@ class Sort extends BaseObject * * Since 2.0.12 particular sort direction can be also specified as direct sort expression, like following: * - * ```php + * ``` * 'name' => [ * 'asc' => '[[last_name]] ASC NULLS FIRST', // PostgreSQL specific feature * 'desc' => '[[last_name]] DESC NULLS LAST', @@ -148,7 +148,7 @@ class Sort extends BaseObject * @var array|null the order that should be used when the current request does not specify any order. * The array keys are attribute names and the array values are the corresponding sort directions. For example, * - * ```php + * ``` * [ * 'name' => SORT_ASC, * 'created_at' => SORT_DESC, @@ -303,7 +303,7 @@ public function getAttributeOrders($recalculate = false) * For example the following return value will result in ascending sort by * `category` and descending sort by `created_at`: * - * ```php + * ``` * [ * 'category', * '-created_at' diff --git a/framework/data/SqlDataProvider.php b/framework/data/SqlDataProvider.php index e8620ff3455..e467f302639 100644 --- a/framework/data/SqlDataProvider.php +++ b/framework/data/SqlDataProvider.php @@ -25,7 +25,7 @@ * * SqlDataProvider may be used in the following way: * - * ```php + * ``` * $count = Yii::$app->db->createCommand(' * SELECT COUNT(*) FROM user WHERE status=:status * ', [':status' => 1])->queryScalar(); diff --git a/framework/db/ActiveQuery.php b/framework/db/ActiveQuery.php index 0d9cc0a83c7..1bebd99863d 100644 --- a/framework/db/ActiveQuery.php +++ b/framework/db/ActiveQuery.php @@ -45,7 +45,7 @@ * * These options can be configured using methods of the same name. For example: * - * ```php + * ``` * $customers = Customer::find()->with('orders')->asArray()->all(); * ``` * @@ -266,7 +266,10 @@ public function populate($rows) private function removeDuplicatedModels($models) { $hash = []; - /** @var ActiveRecord $class */ + /** + * @var ActiveRecord + * @phpstan-var class-string + */ $class = $this->modelClass; $pks = $class::primaryKey(); @@ -411,7 +414,7 @@ protected function queryScalar($selectExpression, $db) * * In the following you find some examples: * - * ```php + * ``` * // find all orders that contain books, and eager loading "books" * Order::find()->joinWith('books', true, 'INNER JOIN')->all(); * // find all orders, eager loading "books", and sort the orders and books by the book names. @@ -717,7 +720,7 @@ private function joinWithRelation($parent, $child, $joinType) * * Use this method to specify additional conditions when declaring a relation in the [[ActiveRecord]] class: * - * ```php + * ``` * public function getActiveUsers() * { * return $this->hasMany(User::class, ['id' => 'user_id']) @@ -787,7 +790,7 @@ public function orOnCondition($condition, $params = []) * * Use this method to specify a junction table when declaring a relation in the [[ActiveRecord]] class: * - * ```php + * ``` * public function getItems() * { * return $this->hasMany(Item::class, ['id' => 'item_id']) diff --git a/framework/db/ActiveQueryInterface.php b/framework/db/ActiveQueryInterface.php index 55e648cd4e7..d0588710eed 100644 --- a/framework/db/ActiveQueryInterface.php +++ b/framework/db/ActiveQueryInterface.php @@ -45,7 +45,7 @@ public function one($db = null); * This can also be a callable (e.g. anonymous function) that returns the index value based on the given * row or model data. The signature of the callable should be: * - * ```php + * ``` * // $model is an AR instance when `asArray` is false, * // or an array of column values when `asArray` is true. * function ($model) @@ -71,7 +71,7 @@ public function indexBy($column); * * The following are some usage examples: * - * ```php + * ``` * // find customers together with their orders and country * Customer::find()->with('orders', 'country')->all(); * // find customers together with their orders and the orders' shipping address diff --git a/framework/db/ActiveQueryTrait.php b/framework/db/ActiveQueryTrait.php index d8cb893ee95..73692d9b06e 100644 --- a/framework/db/ActiveQueryTrait.php +++ b/framework/db/ActiveQueryTrait.php @@ -55,7 +55,7 @@ public function asArray($value = true) * * The following are some usage examples: * - * ```php + * ``` * // find customers together with their orders and country * Customer::find()->with('orders', 'country')->all(); * // find customers together with their orders and the orders' shipping address @@ -72,7 +72,7 @@ public function asArray($value = true) * You can call `with()` multiple times. Each call will add relations to the existing ones. * For example, the following two statements are equivalent: * - * ```php + * ``` * Customer::find()->with('orders', 'country')->all(); * Customer::find()->with('orders')->with('country')->all(); * ``` diff --git a/framework/db/ActiveRecord.php b/framework/db/ActiveRecord.php index 5e195a9d0f5..9873312ab59 100644 --- a/framework/db/ActiveRecord.php +++ b/framework/db/ActiveRecord.php @@ -32,7 +32,7 @@ * To declare an ActiveRecord class you need to extend [[\yii\db\ActiveRecord]] and * implement the `tableName` method: * - * ```php + * ``` * name = 'Qiang'; * $user->save(); // a new row is inserted into user table @@ -100,7 +100,7 @@ class ActiveRecord extends BaseActiveRecord * * You may call this method to load default values after creating a new instance: * - * ```php + * ``` * // class Customer extends \yii\db\ActiveRecord * $customer = new Customer(); * $customer->loadDefaultValues(); @@ -146,7 +146,7 @@ public static function getDb() * * Below is an example: * - * ```php + * ``` * $customers = Customer::findBySql('SELECT * FROM customer')->all(); * ``` * @@ -302,7 +302,7 @@ public function refresh() * * For example, to change the status to be 1 for all customers whose status is 2: * - * ```php + * ``` * Customer::updateAll(['status' => 1], 'status = 2'); * ``` * @@ -312,7 +312,7 @@ public function refresh() * [[EVENT_AFTER_UPDATE]] to be triggered, you need to [[find()|find]] the models first and then * call [[update()]] on each of them. For example an equivalent of the example above would be: * - * ```php + * ``` * $models = Customer::find()->where('status = 2')->all(); * foreach ($models as $model) { * $model->status = 1; @@ -341,7 +341,7 @@ public static function updateAll($attributes, $condition = '', $params = []) * * For example, to increment all customers' age by 1, * - * ```php + * ``` * Customer::updateAllCounters(['age' => 1]); * ``` * @@ -373,7 +373,7 @@ public static function updateAllCounters($counters, $condition = '', $params = [ * * For example, to delete all customers whose status is 3: * - * ```php + * ``` * Customer::deleteAll('status = 3'); * ``` * @@ -383,7 +383,7 @@ public static function updateAllCounters($counters, $condition = '', $params = [ * [[EVENT_AFTER_DELETE]] to be triggered, you need to [[find()|find]] the models first and then * call [[delete()]] on each of them. For example an equivalent of the example above would be: * - * ```php + * ``` * $models = Customer::find()->where('status = 3')->all(); * foreach ($models as $model) { * $model->delete(); @@ -486,7 +486,7 @@ public function attributes() * in transactions. You can do so by overriding this method and returning the operations * that need to be transactional. For example, * - * ```php + * ``` * return [ * 'admin' => self::OP_INSERT, * 'api' => self::OP_INSERT | self::OP_UPDATE | self::OP_DELETE, @@ -547,7 +547,7 @@ public static function populateRecord($record, $row) * * For example, to insert a customer record: * - * ```php + * ``` * $customer = new Customer; * $customer->name = $name; * $customer->email = $email; @@ -597,7 +597,7 @@ public function insert($runValidation = true, $attributes = null) * * @return ActiveQuery * - * @template T + * @template T of self * * @phpstan-param class-string $class * @psalm-param class-string $class @@ -615,7 +615,7 @@ public function hasMany($class, $link) * * @return ActiveQuery * - * @template T + * @template T of self * * @phpstan-param class-string $class * @psalm-param class-string $class @@ -678,7 +678,7 @@ protected function insertInternal($attributes = null) * * For example, to update a customer record: * - * ```php + * ``` * $customer = Customer::findOne($id); * $customer->name = $name; * $customer->email = $email; @@ -689,7 +689,7 @@ protected function insertInternal($attributes = null) * In this case, this method will return 0. For this reason, you should use the following * code to check if update() is successful or not: * - * ```php + * ``` * if ($customer->update() !== false) { * // update successful * } else { diff --git a/framework/db/ActiveRecordInterface.php b/framework/db/ActiveRecordInterface.php index 441001a99ff..18a50000567 100644 --- a/framework/db/ActiveRecordInterface.php +++ b/framework/db/ActiveRecordInterface.php @@ -99,7 +99,7 @@ public static function isPrimaryKey($keys); * methods defined in [[ActiveQueryInterface]] before `one()` or `all()` is called to return * populated ActiveRecord instances. For example, * - * ```php + * ``` * // find the customer whose ID is 1 * $customer = Customer::find()->where(['id' => 1])->one(); * @@ -115,7 +115,7 @@ public static function isPrimaryKey($keys); * * You may override this method to return a customized query. For example, * - * ```php + * ``` * class Customer extends ActiveRecord * { * public static function find() @@ -128,7 +128,7 @@ public static function isPrimaryKey($keys); * * The following code shows how to apply a default condition for all queries: * - * ```php + * ``` * class Customer extends ActiveRecord * { * public static function find() @@ -172,7 +172,7 @@ public static function find(); * * See the following code for usage examples: * - * ```php + * ``` * // find a single customer whose primary key value is 10 * $customer = Customer::findOne(10); * @@ -195,7 +195,7 @@ public static function find(); * If you need to pass user input to this method, make sure the input value is scalar or in case of * array condition, make sure the array structure can not be changed from the outside: * - * ```php + * ``` * // yii\web\Controller ensures that $id is scalar * public function actionView($id) * { @@ -240,7 +240,7 @@ public static function findOne($condition); * * See the following code for usage examples: * - * ```php + * ``` * // find the customers whose primary key value is 10 * $customers = Customer::findAll(10); * @@ -263,7 +263,7 @@ public static function findOne($condition); * If you need to pass user input to this method, make sure the input value is scalar or in case of * array condition, make sure the array structure can not be changed from the outside: * - * ```php + * ``` * // yii\web\Controller ensures that $id is scalar * public function actionView($id) * { @@ -288,7 +288,7 @@ public static function findAll($condition); * * For example, to change the status to be 1 for all customers whose status is 2: * - * ```php + * ``` * Customer::updateAll(['status' => 1], ['status' => '2']); * ``` * @@ -307,7 +307,7 @@ public static function updateAll($attributes, $condition = null); * * For example, to delete all customers whose status is 3: * - * ```php + * ``` * Customer::deleteAll([status = 3]); * ``` * @@ -326,7 +326,7 @@ public static function deleteAll($condition = null); * * For example, to save a customer record: * - * ```php + * ``` * $customer = new Customer; // or $customer = Customer::findOne($id); * $customer->name = $name; * $customer->email = $email; @@ -347,7 +347,7 @@ public function save($runValidation = true, $attributeNames = null); * * Usage example: * - * ```php + * ``` * $customer = new Customer; * $customer->name = $name; * $customer->email = $email; @@ -368,7 +368,7 @@ public function insert($runValidation = true, $attributes = null); * * Usage example: * - * ```php + * ``` * $customer = Customer::findOne($id); * $customer->name = $name; * $customer->email = $email; diff --git a/framework/db/ActiveRelationTrait.php b/framework/db/ActiveRelationTrait.php index 0a4f903ce07..53addd17ef4 100644 --- a/framework/db/ActiveRelationTrait.php +++ b/framework/db/ActiveRelationTrait.php @@ -84,7 +84,7 @@ public function __clone() * * Use this method to specify a pivot record/table when declaring a relation in the [[ActiveRecord]] class: * - * ```php + * ``` * class Order extends ActiveRecord * { * public function getOrderItems() { @@ -124,7 +124,7 @@ public function via($relationName, ?callable $callable = null) * * Use this method when declaring a relation in the [[ActiveRecord]] class, e.g. in Customer model: * - * ```php + * ``` * public function getOrders() * { * return $this->hasMany(Order::class, ['customer_id' => 'id'])->inverseOf('customer'); @@ -133,7 +133,7 @@ public function via($relationName, ?callable $callable = null) * * This also may be used for Order model, but with caution: * - * ```php + * ``` * public function getCustomer() * { * return $this->hasOne(Customer::class, ['id' => 'customer_id'])->inverseOf('orders'); @@ -143,14 +143,14 @@ public function via($relationName, ?callable $callable = null) * in this case result will depend on how order(s) was loaded. * Let's suppose customer has several orders. If only one order was loaded: * - * ```php + * ``` * $orders = Order::find()->where(['id' => 1])->all(); * $customerOrders = $orders[0]->customer->orders; * ``` * * variable `$customerOrders` will contain only one order. If orders was loaded like this: * - * ```php + * ``` * $orders = Order::find()->with('customer')->where(['customer_id' => 1])->all(); * $customerOrders = $orders[0]->customer->orders; * ``` @@ -339,7 +339,6 @@ private function populateInverseRelation(&$primaryModels, $models, $primaryName, return; } $model = reset($models); - /** @var ActiveQueryInterface|ActiveQuery $relation */ if ($model instanceof ActiveRecordInterface) { $relation = $model->getRelation($name); } else { @@ -348,6 +347,7 @@ private function populateInverseRelation(&$primaryModels, $models, $primaryName, $relation = $modelClass::instance()->getRelation($name); } + /** @var ActiveQueryInterface|ActiveQuery $relation */ if ($relation->multiple) { $buckets = $this->buildBuckets($primaryModels, $relation->link, null, null, false); if ($model instanceof ActiveRecordInterface) { diff --git a/framework/db/ArrayExpression.php b/framework/db/ArrayExpression.php index 935f979dd6b..3f091786776 100644 --- a/framework/db/ArrayExpression.php +++ b/framework/db/ArrayExpression.php @@ -15,7 +15,7 @@ * * Expressions of this type can be used in conditions as well: * - * ```php + * ``` * $query->andWhere(['@>', 'items', new ArrayExpression([1, 2, 3], 'integer')]) * ``` * diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index 6ecad432a1e..e60bd35542f 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -149,7 +149,7 @@ protected static function findByCondition($condition) * * For example, to change the status to be 1 for all customers whose status is 2: * - * ```php + * ``` * Customer::updateAll(['status' => 1], 'status = 2'); * ``` * @@ -169,7 +169,7 @@ public static function updateAll($attributes, $condition = '') * * For example, to increment all customers' age by 1, * - * ```php + * ``` * Customer::updateAllCounters(['age' => 1]); * ``` * @@ -191,7 +191,7 @@ public static function updateAllCounters($counters, $condition = '') * * For example, to delete all customers whose status is 3: * - * ```php + * ``` * Customer::deleteAll('status = 3'); * ``` * @@ -370,7 +370,7 @@ public function __unset($name) * For example, to declare the `country` relation for `Customer` class, we can write * the following code in the `Customer` class: * - * ```php + * ``` * public function getCountry() * { * return $this->hasOne(Country::class, ['id' => 'country_id']); @@ -411,7 +411,7 @@ public function hasOne($class, $link) * For example, to declare the `orders` relation for `Customer` class, we can write * the following code in the `Customer` class: * - * ```php + * ``` * public function getOrders() * { * return $this->hasMany(Order::class, ['customer_id' => 'id']); @@ -678,7 +678,7 @@ public function getDirtyAttributes($names = null) * * For example, to save a customer record: * - * ```php + * ``` * $customer = new Customer; // or $customer = Customer::findOne($id); * $customer->name = $name; * $customer->email = $email; @@ -724,7 +724,7 @@ public function save($runValidation = true, $attributeNames = null) * * For example, to update a customer record: * - * ```php + * ``` * $customer = Customer::findOne($id); * $customer->name = $name; * $customer->email = $email; @@ -735,7 +735,7 @@ public function save($runValidation = true, $attributeNames = null) * In this case, this method will return 0. For this reason, you should use the following * code to check if update() is successful or not: * - * ```php + * ``` * if ($customer->update() !== false) { * // update successful * } else { @@ -855,7 +855,7 @@ protected function updateInternal($attributes = null) * * An example usage is as follows: * - * ```php + * ``` * $post = Post::findOne($id); * $post->updateCounters(['view_count' => 1]); * ``` @@ -972,7 +972,7 @@ public function afterFind() * or an [[EVENT_BEFORE_UPDATE]] event if `$insert` is `false`. * When overriding this method, make sure you call the parent implementation like the following: * - * ```php + * ``` * public function beforeSave($insert) * { * if (!parent::beforeSave($insert)) { @@ -1028,7 +1028,7 @@ public function afterSave($insert, $changedAttributes) * The default implementation raises the [[EVENT_BEFORE_DELETE]] event. * When overriding this method, make sure you call the parent implementation like the following: * - * ```php + * ``` * public function beforeDelete() * { * if (!parent::beforeDelete()) { @@ -1812,7 +1812,7 @@ private function isValueDifferent($newValue, $oldValue) * Helps to reduce the number of queries performed against database if some related models are only used * when a specific condition is met. For example: * - * ```php + * ``` * $customers = Customer::find()->where(['country_id' => 123])->all(); * if (Yii:app()->getUser()->getIdentity()->canAccessOrders()) { * Customer::loadRelationsFor($customers, 'orders.items'); @@ -1842,7 +1842,7 @@ public static function loadRelationsFor(&$models, $relationNames, $asArray = fal * Helps to reduce the number of queries performed against database if some related models are only used * when a specific condition is met. For example: * - * ```php + * ``` * $customer = Customer::find()->where(['id' => 123])->one(); * if (Yii:app()->getUser()->getIdentity()->canAccessOrders()) { * $customer->loadRelations('orders.items'); diff --git a/framework/db/BatchQueryResult.php b/framework/db/BatchQueryResult.php index a188d10b710..260324a0033 100644 --- a/framework/db/BatchQueryResult.php +++ b/framework/db/BatchQueryResult.php @@ -16,7 +16,7 @@ * calling [[Query::batch()]] or [[Query::each()]]. Because BatchQueryResult implements the [[\Iterator]] interface, * you can iterate it to obtain a batch of data in each iteration. For example, * - * ```php + * ``` * $query = (new Query)->from('user'); * foreach ($query->batch() as $i => $users) { * // $users represents the rows in the $i-th batch diff --git a/framework/db/Command.php b/framework/db/Command.php index 3595509509e..7b81f5d8b4c 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -23,7 +23,7 @@ * * For example, * - * ```php + * ``` * $users = $connection->createCommand('SELECT * FROM user')->queryAll(); * ``` * @@ -36,7 +36,7 @@ * Command also supports building SQL statements by providing methods such as [[insert()]], * [[update()]], etc. For example, the following code will create and execute an INSERT SQL statement: * - * ```php + * ``` * $connection->createCommand()->insert('user', [ * 'name' => 'Sam', * 'age' => 30, @@ -465,7 +465,7 @@ public function queryColumn() * * For example, * - * ```php + * ``` * $connection->createCommand()->insert('user', [ * 'name' => 'Sam', * 'age' => 30, @@ -495,7 +495,7 @@ public function insert($table, $columns) * * For example, * - * ```php + * ``` * $connection->createCommand()->batchInsert('user', ['name', 'age'], [ * ['Tom', 30], * ['Jane', 20], @@ -537,7 +537,7 @@ public function batchInsert($table, $columns, $rows) * * For example, * - * ```php + * ``` * $sql = $queryBuilder->upsert('pages', [ * 'name' => 'Front page', * 'url' => 'https://example.com/', // url is unique @@ -571,13 +571,13 @@ public function upsert($table, $insertColumns, $updateColumns = true, $params = * * For example, * - * ```php + * ``` * $connection->createCommand()->update('user', ['status' => 1], 'age > 30')->execute(); * ``` * * or with using parameter binding for the condition: * - * ```php + * ``` * $minAge = 30; * $connection->createCommand()->update('user', ['status' => 1], 'age > :minAge', [':minAge' => $minAge])->execute(); * ``` @@ -605,13 +605,13 @@ public function update($table, $columns, $condition = '', $params = []) * * For example, * - * ```php + * ``` * $connection->createCommand()->delete('user', 'status = 0')->execute(); * ``` * * or with using parameter binding for the condition: * - * ```php + * ``` * $status = 0; * $connection->createCommand()->delete('user', 'status = :status', [':status' => $status])->execute(); * ``` @@ -648,7 +648,7 @@ public function delete($table, $condition = '', $params = []) * inserted into the generated SQL. * * Example usage: - * ```php + * ``` * Yii::$app->db->createCommand()->createTable('post', [ * 'id' => 'pk', * 'title' => 'string', @@ -1273,7 +1273,7 @@ protected function requireTransaction($isolationLevel = null) * Sets a callable (e.g. anonymous function) that is called when [[Exception]] is thrown * when executing the command. The signature of the callable should be: * - * ```php + * ``` * function (\yii\db\Exception $e, $attempt) * { * // return true or false (whether to retry the command or rethrow $e) diff --git a/framework/db/Connection.php b/framework/db/Connection.php index 7457c7dd25a..b0cb2b84a3f 100644 --- a/framework/db/Connection.php +++ b/framework/db/Connection.php @@ -32,7 +32,7 @@ * The following example shows how to create a Connection instance and establish * the DB connection: * - * ```php + * ``` * $connection = new \yii\db\Connection([ * 'dsn' => $dsn, * 'username' => $username, @@ -43,7 +43,7 @@ * * After the DB connection is established, one can execute SQL statements like the following: * - * ```php + * ``` * $command = $connection->createCommand('SELECT * FROM post'); * $posts = $command->queryAll(); * $command = $connection->createCommand('UPDATE post SET status=1'); @@ -54,7 +54,7 @@ * When the parameters are coming from user input, you should use this approach * to prevent SQL injection attacks. The following is an example: * - * ```php + * ``` * $command = $connection->createCommand('SELECT * FROM post WHERE id=:id'); * $command->bindValue(':id', $_GET['id']); * $post = $command->query(); @@ -65,7 +65,7 @@ * If the underlying DBMS supports transactions, you can perform transactional SQL queries * like the following: * - * ```php + * ``` * $transaction = $connection->beginTransaction(); * try { * $connection->createCommand($sql1)->execute(); @@ -79,7 +79,7 @@ * * You also can use shortcut for the above like the following: * - * ```php + * ``` * $connection->transaction(function () { * $order = new Order($customer); * $order->save(); @@ -89,7 +89,7 @@ * * If needed you can pass transaction isolation level as a second parameter: * - * ```php + * ``` * $connection->transaction(function (Connection $db) { * //return $db->... * }, Transaction::READ_UNCOMMITTED); @@ -98,7 +98,7 @@ * Connection is often used as an application component and configured in the application * configuration like the following: * - * ```php + * ``` * 'components' => [ * 'db' => [ * 'class' => '\yii\db\Connection', @@ -346,7 +346,7 @@ class Connection extends Component * @var array the configuration that should be merged with every slave configuration listed in [[slaves]]. * For example, * - * ```php + * ``` * [ * 'username' => 'slave', * 'password' => 'slave', @@ -372,7 +372,7 @@ class Connection extends Component * @var array the configuration that should be merged with every master configuration listed in [[masters]]. * For example, * - * ```php + * ``` * [ * 'username' => 'master', * 'password' => 'master', @@ -469,7 +469,7 @@ public function getIsActive() * queries performed within the callable will be cached and their results will be fetched from cache if available. * For example, * - * ```php + * ``` * // The customer will be fetched from cache if available. * // If not, the query will be made against DB and cached for use next time. * $customer = $db->cache(function (Connection $db) { @@ -513,7 +513,7 @@ public function cache(callable $callable, $duration = null, $dependency = null) * * Queries performed within the callable will not use query cache at all. For example, * - * ```php + * ``` * $db->cache(function (Connection $db) { * * // ... queries that use query cache ... @@ -1098,7 +1098,7 @@ public function getMaster() * This method is provided so that you can temporarily force using the master connection to perform * DB operations even if they are read queries. For example, * - * ```php + * ``` * $result = $db->useMaster(function ($db) { * return $db->createCommand('SELECT * FROM user LIMIT 1')->queryOne(); * }); diff --git a/framework/db/DataReader.php b/framework/db/DataReader.php index 3d2973d8621..3da0e1a13f8 100644 --- a/framework/db/DataReader.php +++ b/framework/db/DataReader.php @@ -16,7 +16,7 @@ * returns all the rows in a single array. Rows of data can also be read by * iterating through the reader. For example, * - * ```php + * ``` * $command = $connection->createCommand('SELECT * FROM post'); * $reader = $command->query(); * diff --git a/framework/db/Expression.php b/framework/db/Expression.php index f9aec92ff40..5116bb77020 100644 --- a/framework/db/Expression.php +++ b/framework/db/Expression.php @@ -14,7 +14,7 @@ * it will be replaced with the [[expression]] property value without any * DB escaping or quoting. For example, * - * ```php + * ``` * $expression = new Expression('NOW()'); * $now = (new \yii\db\Query)->select($expression)->scalar(); // SELECT NOW(); * echo $now; // prints the current date diff --git a/framework/db/JsonExpression.php b/framework/db/JsonExpression.php index 601c279004b..7c7e3bd8559 100644 --- a/framework/db/JsonExpression.php +++ b/framework/db/JsonExpression.php @@ -14,7 +14,7 @@ * * For example: * - * ```php + * ``` * new JsonExpression(['a' => 1, 'b' => 2]); // will be encoded to '{"a": 1, "b": 2}' * ``` * diff --git a/framework/db/Migration.php b/framework/db/Migration.php index 5b864f225d0..5881acc9812 100644 --- a/framework/db/Migration.php +++ b/framework/db/Migration.php @@ -56,7 +56,7 @@ class Migration extends Component implements MigrationInterface * by the command. If you do not want to use the DB connection provided by the command, you may override * the [[init()]] method like the following: * - * ```php + * ``` * public function init() * { * $this->db = 'db2'; @@ -313,7 +313,7 @@ public function delete($table, $condition = '', $params = []) * put into the generated SQL. * * Example usage: - * ```php + * ``` * class m200000_000000_create_table_fruits extends \yii\db\Migration * { * public function safeUp() diff --git a/framework/db/PdoValue.php b/framework/db/PdoValue.php index 0713774c0a1..29dc7f5c7ea 100644 --- a/framework/db/PdoValue.php +++ b/framework/db/PdoValue.php @@ -12,7 +12,7 @@ * * For example, it will be useful when you need to bind binary data to BLOB column in DBMS: * - * ```php + * ``` * [':name' => 'John', ':profile' => new PdoValue($profile, \PDO::PARAM_LOB)]`. * ``` * diff --git a/framework/db/Query.php b/framework/db/Query.php index f44a1c44743..8a9d30cd279 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -24,7 +24,7 @@ * * For example, * - * ```php + * ``` * $query = new Query; * // compose the query * $query->select('id, name') @@ -83,13 +83,13 @@ class Query extends Component implements QueryInterface, ExpressionInterface * @var array|null how to join with other tables. Each array element represents the specification * of one join which has the following structure: * - * ```php + * ``` * [$joinType, $tableName, $joinCondition] * ``` * * For example, * - * ```php + * ``` * [ * ['INNER JOIN', 'user', 'user.id = author_id'], * ['LEFT JOIN', 'team', 'team.id = team_id'], @@ -183,7 +183,7 @@ public function prepare($builder) * * For example, * - * ```php + * ``` * $query = (new Query)->from('user'); * foreach ($query->batch() as $rows) { * // $rows is an array of 100 or fewer rows from user table @@ -212,7 +212,7 @@ public function batch($batchSize = 100, $db = null) * This method is similar to [[batch()]] except that in each iteration of the result, * only one row of data is returned. For example, * - * ```php + * ``` * $query = (new Query)->from('user'); * foreach ($query->each() as $row) { * } @@ -650,7 +650,7 @@ public function select($columns, $option = null) * Note, that if [[select]] has not been specified before, you should include `*` explicitly * if you want to select all remaining columns too: * - * ```php + * ``` * $query->addSelect(["*", "CONCAT(first_name, ' ', last_name) AS full_name"])->one(); * ``` * @@ -744,7 +744,7 @@ public function distinct($value = true) * * Here are some examples: * - * ```php + * ``` * // SELECT * FROM `user` `u`, `profile`; * $query = (new \yii\db\Query)->from(['u' => 'user', 'profile']); * @@ -903,7 +903,7 @@ public function andFilterCompare($name, $value, $defaultOperator = '=') * match the `post.author_id` column value against the string `'user.id'`. * It is recommended to use the string syntax here which is more suited for a join: * - * ```php + * ``` * 'post.author_id = user.id' * ``` * @@ -1120,7 +1120,7 @@ public function orHaving($condition, $params = []) * * The following code shows the difference between this method and [[having()]]: * - * ```php + * ``` * // HAVING `age`=:age * $query->filterHaving(['name' => null, 'age' => 20]); * // HAVING `age`=:age diff --git a/framework/db/QueryBuilder.php b/framework/db/QueryBuilder.php index f8acd4e7514..1505eca1c4d 100644 --- a/framework/db/QueryBuilder.php +++ b/framework/db/QueryBuilder.php @@ -23,7 +23,10 @@ * For more details and usage information on QueryBuilder, see the [guide article on query builders](guide:db-query-builder). * * @property-write string[] $conditionClasses Map of condition aliases to condition classes. For example: - * ```php ['LIKE' => yii\db\condition\LikeCondition::class] ```. + * + * ``` + * ['LIKE' => yii\db\condition\LikeCondition::class] + * ``` * @property-write string[] $expressionBuilders Array of builders that should be merged with the pre-defined * ones in [[expressionBuilders]] property. * @@ -56,7 +59,7 @@ class QueryBuilder extends \yii\base\BaseObject /** * @var array map of condition aliases to condition classes. For example: * - * ```php + * ``` * return [ * 'LIKE' => yii\db\condition\LikeCondition::class, * ]; @@ -76,7 +79,7 @@ class QueryBuilder extends \yii\base\BaseObject * @var string[]|ExpressionBuilderInterface[] maps expression class to expression builder class. * For example: * - * ```php + * ``` * [ * yii\db\Expression::class => yii\db\ExpressionBuilder::class * ] @@ -194,7 +197,7 @@ public function setExpressionBuilders($builders) * * @param string[] $classes map of condition aliases to condition classes. For example: * - * ```php + * ``` * ['LIKE' => yii\db\condition\LikeCondition::class] * ``` * @@ -323,7 +326,7 @@ public function getExpressionBuilder(ExpressionInterface $expression) /** * Creates an INSERT SQL statement. * For example, - * ```php + * ``` * $sql = $queryBuilder->insert('user', [ * 'name' => 'Sam', * 'age' => 30, @@ -424,7 +427,7 @@ protected function prepareInsertSelectSubQuery($columns, $schema, $params = []) * * For example, * - * ```php + * ``` * $sql = $queryBuilder->batchInsert('user', ['name', 'age'], [ * ['Tom', 30], * ['Jane', 20], @@ -497,7 +500,7 @@ public function batchInsert($table, $columns, $rows, &$params = []) * * For example, * - * ```php + * ``` * $sql = $queryBuilder->upsert('pages', [ * 'name' => 'Front page', * 'url' => 'https://example.com/', // url is unique @@ -604,7 +607,7 @@ private function getTableUniqueColumnNames($name, $columns, &$constraints = []) * * For example, * - * ```php + * ``` * $params = []; * $sql = $queryBuilder->update('user', ['status' => 1], 'age > 30', $params); * ``` @@ -659,7 +662,7 @@ protected function prepareUpdateSets($table, $columns, $params = []) * * For example, * - * ```php + * ``` * $sql = $queryBuilder->delete('user', 'status = 0'); * ``` * @@ -693,7 +696,7 @@ public function delete($table, $condition, &$params) * * For example, * - * ```php + * ``` * $sql = $queryBuilder->createTable('user', [ * 'id' => 'pk', * 'name' => 'string', diff --git a/framework/db/QueryInterface.php b/framework/db/QueryInterface.php index 0f08d67c4ce..2fd60d1a2a8 100644 --- a/framework/db/QueryInterface.php +++ b/framework/db/QueryInterface.php @@ -62,7 +62,7 @@ public function exists($db = null); * This can also be a callable (e.g. anonymous function) that returns the index value based on the given * row data. The signature of the callable should be: * - * ```php + * ``` * function ($row) * { * // return the index value corresponding to $row diff --git a/framework/db/QueryTrait.php b/framework/db/QueryTrait.php index 308e31db769..840cc4eb3cb 100644 --- a/framework/db/QueryTrait.php +++ b/framework/db/QueryTrait.php @@ -65,7 +65,7 @@ trait QueryTrait * This can also be a callable (e.g. anonymous function) that returns the index value based on the given * row data. The signature of the callable should be: * - * ```php + * ``` * function ($row) * { * // return the index value corresponding to $row @@ -145,7 +145,7 @@ public function orWhere($condition) * * The following code shows the difference between this method and [[where()]]: * - * ```php + * ``` * // WHERE `age`=:age * $query->filterWhere(['name' => null, 'age' => 20]); * // WHERE `age`=:age diff --git a/framework/db/Schema.php b/framework/db/Schema.php index 5f54b5ab2fa..4b5e05fb71f 100644 --- a/framework/db/Schema.php +++ b/framework/db/Schema.php @@ -336,7 +336,7 @@ public function createColumnSchemaBuilder($type, $length = null) * * Each array element is of the following structure: * - * ```php + * ``` * [ * 'IndexName1' => ['col1' [, ...]], * 'IndexName2' => ['col2' [, ...]], diff --git a/framework/db/SchemaBuilderTrait.php b/framework/db/SchemaBuilderTrait.php index 371a48ff977..933ba9610fb 100644 --- a/framework/db/SchemaBuilderTrait.php +++ b/framework/db/SchemaBuilderTrait.php @@ -16,7 +16,7 @@ * * For example you may use the following code inside your migration files: * - * ```php + * ``` * $this->createTable('example_table', [ * 'id' => $this->primaryKey(), * 'name' => $this->string(64)->notNull(), diff --git a/framework/db/SqlToken.php b/framework/db/SqlToken.php index ad9169ccff6..64730151aee 100644 --- a/framework/db/SqlToken.php +++ b/framework/db/SqlToken.php @@ -202,7 +202,7 @@ public function getSql() * * Usage Example: * - * ```php + * ``` * $patternToken = (new \yii\db\sqlite\SqlTokenizer('SELECT any FROM any'))->tokenize(); * if ($sqlToken->matches($patternToken, 0, $firstMatchIndex, $lastMatchIndex)) { * // ... diff --git a/framework/db/SqlTokenizer.php b/framework/db/SqlTokenizer.php index 175ed9d0edc..63e53a9b4d2 100644 --- a/framework/db/SqlTokenizer.php +++ b/framework/db/SqlTokenizer.php @@ -17,7 +17,7 @@ * * Usage example: * - * ```php + * ``` * $tokenizer = new SqlTokenizer("SELECT * FROM user WHERE id = 1"); * $root = $tokeinzer->tokenize(); * $sqlTokens = $root->getChildren(); diff --git a/framework/db/TableSchema.php b/framework/db/TableSchema.php index 1e7ccf084c4..1d64c3b094b 100644 --- a/framework/db/TableSchema.php +++ b/framework/db/TableSchema.php @@ -45,7 +45,7 @@ class TableSchema extends BaseObject /** * @var array foreign keys of this table. Each array element is of the following structure: * - * ```php + * ``` * [ * 'ForeignTableName', * 'fk1' => 'pk1', // pk1 is in foreign table diff --git a/framework/db/Transaction.php b/framework/db/Transaction.php index 55f56cf7eee..9e86b633b4f 100644 --- a/framework/db/Transaction.php +++ b/framework/db/Transaction.php @@ -19,7 +19,7 @@ * The following code is a typical example of using transactions (note that some * DBMS may not support transactions): * - * ```php + * ``` * $transaction = $connection->beginTransaction(); * try { * $connection->createCommand($sql1)->execute(); diff --git a/framework/db/conditions/BetweenColumnsCondition.php b/framework/db/conditions/BetweenColumnsCondition.php index 47ffd275aba..0fd15e7c60f 100644 --- a/framework/db/conditions/BetweenColumnsCondition.php +++ b/framework/db/conditions/BetweenColumnsCondition.php @@ -15,7 +15,7 @@ * Class BetweenColumnCondition represents a `BETWEEN` condition where * values is between two columns. For example: * - * ```php + * ``` * new BetweenColumnsCondition(42, 'BETWEEN', 'min_value', 'max_value') * // Will be build to: * // 42 BETWEEN min_value AND max_value @@ -23,7 +23,7 @@ * * And a more complex example: * - * ```php + * ``` * new BetweenColumnsCondition( * new Expression('NOW()'), * 'NOT BETWEEN', @@ -62,7 +62,7 @@ class BetweenColumnsCondition implements ConditionInterface /** * Creates a condition with the `BETWEEN` operator. * - * @param mixed the value to compare against + * @param mixed $value the value to compare against * @param string $operator the operator to use (e.g. `BETWEEN` or `NOT BETWEEN`) * @param string|ExpressionInterface $intervalStartColumn the column name or expression that is a beginning of the interval * @param string|ExpressionInterface $intervalEndColumn the column name or expression that is an end of the interval diff --git a/framework/db/conditions/InCondition.php b/framework/db/conditions/InCondition.php index 9d4f0728e8c..01a6ee815ba 100644 --- a/framework/db/conditions/InCondition.php +++ b/framework/db/conditions/InCondition.php @@ -39,10 +39,10 @@ class InCondition implements ConditionInterface /** * SimpleCondition constructor * - * @param string|string[] the column name. If it is an array, a composite `IN` condition + * @param string|string[] $column the column name. If it is an array, a composite `IN` condition * will be generated. * @param string $operator the operator to use (e.g. `IN` or `NOT IN`) - * @param array an array of values that [[column]] value should be among. If it is an empty array the generated + * @param array $values an array of values that [[column]] value should be among. If it is an empty array the generated * expression will be a `false` value if [[operator]] is `IN` and empty if operator is `NOT IN`. */ public function __construct($column, $operator, $values) diff --git a/framework/db/conditions/LikeCondition.php b/framework/db/conditions/LikeCondition.php index 0fe2a8fa0eb..d886320e3f9 100644 --- a/framework/db/conditions/LikeCondition.php +++ b/framework/db/conditions/LikeCondition.php @@ -40,7 +40,7 @@ public function __construct($column, $operator, $value) /** * This method allows to specify how to escape special characters in the value(s). * - * @param array|null|false an array of mappings from the special characters to their escaped counterparts. + * @param array|null|false $escapingReplacements an array of mappings from the special characters to their escaped counterparts. * You may use `false` to indicate the values are already escaped and no escape should be applied, * or either `null` or empty array if escaping is condition builder responsibility. * Note that when using an escape mapping (or the third operand is not provided), diff --git a/framework/db/mssql/Schema.php b/framework/db/mssql/Schema.php index a8d6045d518..51613092356 100644 --- a/framework/db/mssql/Schema.php +++ b/framework/db/mssql/Schema.php @@ -635,7 +635,7 @@ protected function findViewNames($schema = '') * * Each array element is of the following structure: * - * ```php + * ``` * [ * 'IndexName1' => ['col1' [, ...]], * 'IndexName2' => ['col2' [, ...]], diff --git a/framework/db/mysql/Schema.php b/framework/db/mysql/Schema.php index 4c47aadeb1e..9f26acf3978 100644 --- a/framework/db/mysql/Schema.php +++ b/framework/db/mysql/Schema.php @@ -487,7 +487,7 @@ protected function findConstraints($table) * * Each array element is of the following structure: * - * ```php + * ``` * [ * 'IndexName1' => ['col1' [, ...]], * 'IndexName2' => ['col2' [, ...]], diff --git a/framework/db/oci/QueryBuilder.php b/framework/db/oci/QueryBuilder.php index 56b01dded05..8cc3cec29ea 100644 --- a/framework/db/oci/QueryBuilder.php +++ b/framework/db/oci/QueryBuilder.php @@ -280,7 +280,7 @@ public function upsert($table, $insertColumns, $updateColumns, &$params) * * For example, * - * ```php + * ``` * $sql = $queryBuilder->batchInsert('user', ['name', 'age'], [ * ['Tom', 30], * ['Jane', 20], diff --git a/framework/db/oci/Schema.php b/framework/db/oci/Schema.php index 05b3cb5eac6..138b17a202e 100644 --- a/framework/db/oci/Schema.php +++ b/framework/db/oci/Schema.php @@ -509,7 +509,7 @@ protected function findConstraints($table) * Returns all unique indexes for the given table. * Each array element is of the following structure:. * - * ```php + * ``` * [ * 'IndexName1' => ['col1' [, ...]], * 'IndexName2' => ['col2' [, ...]], diff --git a/framework/db/pgsql/Schema.php b/framework/db/pgsql/Schema.php index 62f91dac5fb..aed6e795793 100644 --- a/framework/db/pgsql/Schema.php +++ b/framework/db/pgsql/Schema.php @@ -425,7 +425,7 @@ protected function getUniqueIndexInformation($table) * * Each array element is of the following structure: * - * ```php + * ``` * [ * 'IndexName1' => ['col1' [, ...]], * 'IndexName2' => ['col2' [, ...]], diff --git a/framework/db/sqlite/QueryBuilder.php b/framework/db/sqlite/QueryBuilder.php index 1e2ee03aed9..8f80ccfeb12 100644 --- a/framework/db/sqlite/QueryBuilder.php +++ b/framework/db/sqlite/QueryBuilder.php @@ -116,7 +116,7 @@ public function upsert($table, $insertColumns, $updateColumns, &$params) * * For example, * - * ```php + * ``` * $connection->createCommand()->batchInsert('user', ['name', 'age'], [ * ['Tom', 30], * ['Jane', 20], diff --git a/framework/db/sqlite/Schema.php b/framework/db/sqlite/Schema.php index 8163c0b0bea..97a9c77a2e1 100644 --- a/framework/db/sqlite/Schema.php +++ b/framework/db/sqlite/Schema.php @@ -271,7 +271,7 @@ protected function findConstraints($table) * * Each array element is of the following structure: * - * ```php + * ``` * [ * 'IndexName1' => ['col1' [, ...]], * 'IndexName2' => ['col2' [, ...]], diff --git a/framework/di/Container.php b/framework/di/Container.php index 07f70cae13d..c6e4abbef33 100644 --- a/framework/di/Container.php +++ b/framework/di/Container.php @@ -36,7 +36,7 @@ * * Below is an example of using Container: * - * ```php + * ``` * namespace app\models; * * use yii\base\BaseObject; @@ -94,9 +94,11 @@ * * For more details and usage information on Container, see the [guide article on di-containers](guide:concept-di-container). * - * @property-read array $definitions The list of the object definitions or the loaded shared objects (type or - * ID => definition or instance). + * @property array $definitions The list of the object definitions or the loaded shared objects (type or ID => + * definition or instance). * @property-write bool $resolveArrays Whether to attempt to resolve elements in array dependencies. + * @property-write array $singletons Array of singleton definitions. See [[setDefinitions()]] for allowed + * formats of array. * * @author Qiang Xue * @since 2.0 @@ -212,7 +214,7 @@ public function get($class, $params = [], $config = []) * * For example, * - * ```php + * ``` * // register a class name as is. This can be skipped. * $container->set('yii\db\Connection'); * @@ -595,7 +597,7 @@ protected function resolveDependencies($dependencies, $reflection = null) * * For example, the following callback may be invoked using the Container to resolve the formatter dependency: * - * ```php + * ``` * $formatString = function($string, \yii\i18n\Formatter $formatter) { * // ... * } @@ -652,6 +654,7 @@ public function resolveCallableDependencies(callable $callback, $params = []) if ($class instanceof \ReflectionUnionType || $class instanceof \ReflectionIntersectionType) { $isClass = false; + /** @var ReflectionNamedType $type */ foreach ($class->getTypes() as $type) { if (!$type->isBuiltin()) { $class = $type; @@ -722,7 +725,7 @@ public function resolveCallableDependencies(callable $callback, $params = []) * as the second argument `$definition`. * * Example: - * ```php + * ``` * $container->setDefinitions([ * 'yii\web\Request' => 'app\components\Request', * 'yii\web\Response' => [ @@ -744,7 +747,7 @@ public function resolveCallableDependencies(callable $callback, $params = []) * second argument `$definition`, the second one — as `$params`. * * Example: - * ```php + * ``` * $container->setDefinitions([ * 'foo\Bar' => [ * ['class' => 'app\Bar'], diff --git a/framework/di/Instance.php b/framework/di/Instance.php index 0d047ed65cc..8e7597a405b 100644 --- a/framework/di/Instance.php +++ b/framework/di/Instance.php @@ -23,7 +23,7 @@ * * The following example shows how to configure a DI container with Instance: * - * ```php + * ``` * $container = new \yii\di\Container; * $container->set('cache', [ * 'class' => 'yii\caching\DbCache', @@ -37,7 +37,7 @@ * * And the following example shows how a class retrieves a component from a service locator: * - * ```php + * ``` * class DbCache extends Cache * { * public $db = 'db'; @@ -97,7 +97,7 @@ public static function of($id, $optional = false) * * For example, * - * ```php + * ``` * use yii\db\Connection; * * // returns Yii::$app->db diff --git a/framework/di/ServiceLocator.php b/framework/di/ServiceLocator.php index 43422288efc..13268a623f6 100644 --- a/framework/di/ServiceLocator.php +++ b/framework/di/ServiceLocator.php @@ -22,7 +22,7 @@ * * For example, * - * ```php + * ``` * $locator = new \yii\di\ServiceLocator; * $locator->setComponents([ * 'db' => [ @@ -150,7 +150,7 @@ public function get($id, $throwException = true) * * For example, * - * ```php + * ``` * // a class name * $locator->set('cache', 'yii\caching\FileCache'); * @@ -247,7 +247,7 @@ public function getComponents($returnDefinitions = true) * * The following is an example for registering two component definitions: * - * ```php + * ``` * [ * 'db' => [ * 'class' => 'yii\db\Connection', diff --git a/framework/filters/AccessControl.php b/framework/filters/AccessControl.php index 1785f5e79fb..75190a56c48 100644 --- a/framework/filters/AccessControl.php +++ b/framework/filters/AccessControl.php @@ -26,7 +26,7 @@ * For example, the following declarations will allow authenticated users to access the "create" * and "update" actions and deny all other users from accessing these two actions. * - * ```php + * ``` * public function behaviors() * { * return [ @@ -70,7 +70,7 @@ class AccessControl extends ActionFilter * * The signature of the callback should be as follows: * - * ```php + * ``` * function ($rule, $action) * ``` * diff --git a/framework/filters/AccessRule.php b/framework/filters/AccessRule.php index 9faf47cc487..94fee34e456 100644 --- a/framework/filters/AccessRule.php +++ b/framework/filters/AccessRule.php @@ -83,7 +83,7 @@ class AccessRule extends Component * If this is an array, it will be passed directly to [[User::can()]]. For example for passing an * ID from the current request, you may use the following: * - * ```php + * ``` * ['postId' => Yii::$app->request->get('id')] * ``` * @@ -91,7 +91,7 @@ class AccessRule extends Component * evaluate the array values only if they are needed, for example when a model needs to be * loaded like in the following code: * - * ```php + * ``` * 'rules' => [ * [ * 'allow' => true, @@ -131,7 +131,7 @@ class AccessRule extends Component * @var callable a callback that will be called to determine if the rule should be applied. * The signature of the callback should be as follows: * - * ```php + * ``` * function ($rule, $action) * ``` * @@ -150,7 +150,7 @@ class AccessRule extends Component * * The signature of the callback should be as follows: * - * ```php + * ``` * function ($rule, $action) * ``` * diff --git a/framework/filters/AjaxFilter.php b/framework/filters/AjaxFilter.php index 02b3d7ebf0e..871d474f6f2 100644 --- a/framework/filters/AjaxFilter.php +++ b/framework/filters/AjaxFilter.php @@ -15,7 +15,7 @@ /** * AjaxFilter allow to limit access only for ajax requests. * - * ```php + * ``` * public function behaviors() * { * return [ diff --git a/framework/filters/ContentNegotiator.php b/framework/filters/ContentNegotiator.php index 72c3e865d79..d3ed14d62aa 100644 --- a/framework/filters/ContentNegotiator.php +++ b/framework/filters/ContentNegotiator.php @@ -32,7 +32,7 @@ * The following code shows how you can use ContentNegotiator as a bootstrapping component. Note that in this case, * the content negotiation applies to the whole application. * - * ```php + * ``` * // in application configuration * use yii\web\Response; * @@ -57,7 +57,7 @@ * In this case, the content negotiation result only applies to the corresponding controller or module, or even * specific actions if you configure the `only` or `except` property of the filter. * - * ```php + * ``` * use yii\web\Response; * * public function behaviors() diff --git a/framework/filters/Cors.php b/framework/filters/Cors.php index c377dcb0994..d004d3593b8 100644 --- a/framework/filters/Cors.php +++ b/framework/filters/Cors.php @@ -21,7 +21,7 @@ * * You may use CORS filter by attaching it as a behavior to a controller or module, like the following, * - * ```php + * ``` * public function behaviors() * { * return [ @@ -35,7 +35,7 @@ * The CORS filter can be specialized to restrict parameters, like this, * [MDN CORS Information](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) * - * ```php + * ``` * public function behaviors() * { * return [ diff --git a/framework/filters/HostControl.php b/framework/filters/HostControl.php index 42ca30c44d2..77ab73eaac2 100644 --- a/framework/filters/HostControl.php +++ b/framework/filters/HostControl.php @@ -20,7 +20,7 @@ * * Application configuration example: * - * ```php + * ``` * return [ * 'as hostControl' => [ * 'class' => 'yii\filters\HostControl', @@ -35,7 +35,7 @@ * * Controller configuration example: * - * ```php + * ``` * use yii\web\Controller; * use yii\filters\HostControl; * @@ -70,7 +70,7 @@ class HostControl extends ActionFilter * @var array|\Closure|null list of host names, which are allowed. * Each host can be specified as a wildcard pattern. For example: * - * ```php + * ``` * [ * 'example.com', * '*.example.com', @@ -79,7 +79,7 @@ class HostControl extends ActionFilter * * This field can be specified as a PHP callback of following signature: * - * ```php + * ``` * function (\yii\base\Action $action) { * //return array of strings * } @@ -96,7 +96,7 @@ class HostControl extends ActionFilter * * The signature of the callback should be as follows: * - * ```php + * ``` * function (\yii\base\Action $action) * ``` * diff --git a/framework/filters/HttpCache.php b/framework/filters/HttpCache.php index d05011407ec..ebc9c091423 100644 --- a/framework/filters/HttpCache.php +++ b/framework/filters/HttpCache.php @@ -20,7 +20,7 @@ * In the following example the filter will be applied to the `index` action and * the Last-Modified header will contain the date of the last update to the user table in the database. * - * ```php + * ``` * public function behaviors() * { * return [ @@ -49,7 +49,7 @@ class HttpCache extends ActionFilter * @var callable a PHP callback that returns the UNIX timestamp of the last modification time. * The callback's signature should be: * - * ```php + * ``` * function ($action, $params) * ``` * @@ -63,7 +63,7 @@ class HttpCache extends ActionFilter * @var callable a PHP callback that generates the ETag seed string. * The callback's signature should be: * - * ```php + * ``` * function ($action, $params) * ``` * diff --git a/framework/filters/PageCache.php b/framework/filters/PageCache.php index b9f02ba4ec4..71a4ef1a02d 100644 --- a/framework/filters/PageCache.php +++ b/framework/filters/PageCache.php @@ -28,7 +28,7 @@ * cache the whole page for maximum 60 seconds or until the count of entries in the post table changes. * It also stores different versions of the page depending on the application language. * - * ```php + * ``` * public function behaviors() * { * return [ @@ -84,7 +84,7 @@ class PageCache extends ActionFilter implements DynamicContentAwareInterface * This can be either a [[Dependency]] object or a configuration array for creating the dependency object. * For example, * - * ```php + * ``` * [ * 'class' => 'yii\caching\DbDependency', * 'sql' => 'SELECT MAX(updated_at) FROM post', @@ -104,7 +104,7 @@ class PageCache extends ActionFilter implements DynamicContentAwareInterface * The following variation setting will cause the content to be cached in different versions * according to the current application language: * - * ```php + * ``` * [ * Yii::$app->language, * ] @@ -113,7 +113,7 @@ class PageCache extends ActionFilter implements DynamicContentAwareInterface * Since version 2.0.48 you can provide an anonymous function to generate variations. This is especially helpful * when you need to access the User component, which is resolved before the PageCache behavior: * - * ```php + * ``` * 'variations' => function() { * return [ * Yii::$app->language, diff --git a/framework/filters/RateLimiter.php b/framework/filters/RateLimiter.php index 62d1aab3a40..827eafc083f 100644 --- a/framework/filters/RateLimiter.php +++ b/framework/filters/RateLimiter.php @@ -19,7 +19,7 @@ * * You may use RateLimiter by attaching it as a behavior to a controller or module, like the following, * - * ```php + * ``` * public function behaviors() * { * return [ @@ -52,7 +52,7 @@ class RateLimiter extends ActionFilter * @var RateLimitInterface|Closure|null the user object that implements the RateLimitInterface. If not set, it will take the value of `Yii::$app->user->getIdentity(false)`. * {@since 2.0.38} It's possible to provide a closure function in order to assign the user identity on runtime. Using a closure to assign the user identity is recommend * when you are **not** using the standard `Yii::$app->user` component. See the example below: - * ```php + * ``` * 'user' => function() { * return Yii::$app->apiUser->identity; * } diff --git a/framework/filters/VerbFilter.php b/framework/filters/VerbFilter.php index ed573a2450b..bc696e9a7cf 100644 --- a/framework/filters/VerbFilter.php +++ b/framework/filters/VerbFilter.php @@ -23,7 +23,7 @@ * For example, the following declarations will define a typical set of allowed * request methods for REST CRUD actions. * - * ```php + * ``` * public function behaviors() * { * return [ @@ -61,7 +61,7 @@ class VerbFilter extends Behavior * * For example, * - * ```php + * ``` * [ * 'create' => ['GET', 'POST'], * 'update' => ['GET', 'PUT', 'POST'], diff --git a/framework/filters/auth/CompositeAuth.php b/framework/filters/auth/CompositeAuth.php index 88a6a84af30..76a4dfc517d 100644 --- a/framework/filters/auth/CompositeAuth.php +++ b/framework/filters/auth/CompositeAuth.php @@ -20,7 +20,7 @@ * * The following example shows how to support three authentication methods: * - * ```php + * ``` * public function behaviors() * { * return [ diff --git a/framework/filters/auth/HttpBasicAuth.php b/framework/filters/auth/HttpBasicAuth.php index d7969a696a9..0ddfa71dad2 100644 --- a/framework/filters/auth/HttpBasicAuth.php +++ b/framework/filters/auth/HttpBasicAuth.php @@ -12,7 +12,7 @@ * * You may use HttpBasicAuth by attaching it as a behavior to a controller or module, like the following: * - * ```php + * ``` * public function behaviors() * { * return [ @@ -29,7 +29,7 @@ * * If you want to authenticate users using username and password, you should provide the [[auth]] function for example like the following: * - * ```php + * ``` * public function behaviors() * { * return [ @@ -71,7 +71,7 @@ class HttpBasicAuth extends AuthMethod * * The following code is a typical implementation of this callable: * - * ```php + * ``` * function ($username, $password) { * return \app\models\User::findOne([ * 'username' => $username, diff --git a/framework/filters/auth/HttpBearerAuth.php b/framework/filters/auth/HttpBearerAuth.php index d2ce749c0b4..f2de82597b0 100644 --- a/framework/filters/auth/HttpBearerAuth.php +++ b/framework/filters/auth/HttpBearerAuth.php @@ -12,7 +12,7 @@ * * You may use HttpBearerAuth by attaching it as a behavior to a controller or module, like the following: * - * ```php + * ``` * public function behaviors() * { * return [ diff --git a/framework/filters/auth/HttpHeaderAuth.php b/framework/filters/auth/HttpHeaderAuth.php index 404b8e1a92f..01b1c272bb8 100644 --- a/framework/filters/auth/HttpHeaderAuth.php +++ b/framework/filters/auth/HttpHeaderAuth.php @@ -12,7 +12,7 @@ * * You may use HttpHeaderAuth by attaching it as a behavior to a controller or module, like the following: * - * ```php + * ``` * public function behaviors() * { * return [ diff --git a/framework/grid/ActionColumn.php b/framework/grid/ActionColumn.php index f943a687241..869dae95f7d 100644 --- a/framework/grid/ActionColumn.php +++ b/framework/grid/ActionColumn.php @@ -16,7 +16,7 @@ * * To add an ActionColumn to the gridview, add it to the [[GridView::columns|columns]] configuration as follows: * - * ```php + * ``` * 'columns' => [ * // ... * [ @@ -53,7 +53,7 @@ class ActionColumn extends Column * * As an example, to only have the view, and update button you can add the ActionColumn to your GridView columns as follows: * - * ```php + * ``` * ['class' => 'yii\grid\ActionColumn', 'template' => '{view} {update}'], * ``` * @@ -65,7 +65,7 @@ class ActionColumn extends Column * and the values are the corresponding button rendering callbacks. The callbacks should use the following * signature: * - * ```php + * ``` * function ($url, $model, $key) { * // return the button HTML code * } @@ -77,7 +77,7 @@ class ActionColumn extends Column * You can add further conditions to the button, for example only display it, when the model is * editable (here assuming you have a status field that indicates that): * - * ```php + * ``` * [ * 'update' => function ($url, $model, $key) { * return $model->status === 'editable' ? Html::a('Update', $url) : ''; @@ -88,7 +88,7 @@ class ActionColumn extends Column public $buttons = []; /** * @var array button icons. The array keys are the icon names and the values the corresponding html: - * ```php + * ``` * [ * 'eye-open' => '', * 'pencil' => Html::tag('span', '', ['class' => 'glyphicon glyphicon-pencil']) @@ -108,7 +108,7 @@ class ActionColumn extends Column * this array it will be shown by default. * The callbacks must use the following signature: * - * ```php + * ``` * function ($model, $key, $index) { * return $model->status === 'editable'; * } @@ -116,7 +116,7 @@ class ActionColumn extends Column * * Or you can pass a boolean value: * - * ```php + * ``` * [ * 'update' => \Yii::$app->user->can('update'), * ], @@ -129,7 +129,7 @@ class ActionColumn extends Column * The signature of the callback should be the same as that of [[createUrl()]] * Since 2.0.10 it can accept additional parameter, which refers to the column instance itself: * - * ```php + * ``` * function (string $action, mixed $model, mixed $key, integer $index, ActionColumn $this) { * //return string; * } diff --git a/framework/grid/CheckboxColumn.php b/framework/grid/CheckboxColumn.php index 2e0a890093a..177f9a41b85 100644 --- a/framework/grid/CheckboxColumn.php +++ b/framework/grid/CheckboxColumn.php @@ -17,7 +17,7 @@ * * To add a CheckboxColumn to the [[GridView]], add it to the [[GridView::columns|columns]] configuration as follows: * - * ```php + * ``` * 'columns' => [ * // ... * [ @@ -30,7 +30,7 @@ * Users may click on the checkboxes to select rows of the grid. The selected rows may be * obtained by calling the following JavaScript code: * - * ```javascript + * ``` * var keys = $('#grid').yiiGridView('getSelectedRows'); * // keys is an array consisting of the keys associated with the selected rows * ``` @@ -56,7 +56,7 @@ class CheckboxColumn extends Column * Specifically if you want to set a different value for the checkbox * you can use this option in the following way (in this example using the `name` attribute of the model): * - * ```php + * ``` * 'checkboxOptions' => function ($model, $key, $index, $column) { * return ['value' => $model->name]; * } diff --git a/framework/grid/GridView.php b/framework/grid/GridView.php index 452a7b0f3a7..cd42e1705bb 100644 --- a/framework/grid/GridView.php +++ b/framework/grid/GridView.php @@ -24,7 +24,7 @@ * * A basic usage looks like the following: * - * ```php + * ``` * $dataProvider, * 'columns' => [ @@ -95,7 +95,7 @@ class GridView extends BaseListView * returns an array of the HTML attributes. The anonymous function will be called once for every * data model returned by [[dataProvider]]. It should have the following signature: * - * ```php + * ``` * function ($model, $key, $index, $grid) * ``` * @@ -146,7 +146,7 @@ class GridView extends BaseListView * @var array grid column configuration. Each array element represents the configuration * for one particular grid column. For example, * - * ```php + * ``` * [ * ['class' => SerialColumn::class], * [ @@ -169,7 +169,7 @@ class GridView extends BaseListView * * Using the shortcut format the configuration for columns in simple cases would look like this: * - * ```php + * ``` * [ * 'id', * 'amount:currency:Total Amount', @@ -180,7 +180,7 @@ class GridView extends BaseListView * When using a [[dataProvider]] with active records, you can also display values from related records, * e.g. the `name` attribute of the `author` relation: * - * ```php + * ``` * // shortcut syntax * 'author.name', * // full syntax diff --git a/framework/grid/RadioButtonColumn.php b/framework/grid/RadioButtonColumn.php index 7a7cef18056..279e087c2f2 100644 --- a/framework/grid/RadioButtonColumn.php +++ b/framework/grid/RadioButtonColumn.php @@ -16,7 +16,7 @@ * * To add a RadioButtonColumn to the [[GridView]], add it to the [[GridView::columns|columns]] configuration as follows: * - * ```php + * ``` * 'columns' => [ * // ... * [ @@ -52,7 +52,7 @@ class RadioButtonColumn extends Column * Specifically if you want to set a different value for the radio button you can use this option * in the following way (in this example using the `name` attribute of the model): * - * ```php + * ``` * 'radioOptions' => function ($model, $key, $index, $column) { * return ['value' => $model->attribute]; * } diff --git a/framework/grid/SerialColumn.php b/framework/grid/SerialColumn.php index 28d23549cdf..b63696e8c9b 100644 --- a/framework/grid/SerialColumn.php +++ b/framework/grid/SerialColumn.php @@ -12,7 +12,7 @@ * * To add a SerialColumn to the [[GridView]], add it to the [[GridView::columns|columns]] configuration as follows: * - * ```php + * ``` * 'columns' => [ * // ... * [ diff --git a/framework/helpers/BaseArrayHelper.php b/framework/helpers/BaseArrayHelper.php index a2ece64d1c5..4f56d38f0c5 100644 --- a/framework/helpers/BaseArrayHelper.php +++ b/framework/helpers/BaseArrayHelper.php @@ -29,7 +29,7 @@ class BaseArrayHelper * @param array $properties a mapping from object class names to the properties that need to put into the resulting arrays. * The properties specified for each class is an array of the following format: * - * ```php + * ``` * [ * 'app\models\Post' => [ * 'id', @@ -46,7 +46,7 @@ class BaseArrayHelper * * The result of `ArrayHelper::toArray($post, $properties)` could be like the following: * - * ```php + * ``` * [ * 'id' => 123, * 'title' => 'test', @@ -169,7 +169,7 @@ public static function merge($a, ...$b) * * Below are some usage examples, * - * ```php + * ``` * // working with array * $username = \yii\helpers\ArrayHelper::getValue($_POST, 'username'); * // working with object @@ -244,7 +244,7 @@ public static function getValue($array, $key, $default = null) * If there is no such key path yet, it will be created recursively. * If the key exists, it will be overwritten. * - * ```php + * ``` * $array = [ * 'key' => [ * 'in' => [ @@ -257,7 +257,7 @@ public static function getValue($array, $key, $default = null) * * The result of `ArrayHelper::setValue($array, 'key.in.0', ['arr' => 'val']);` will be the following: * - * ```php + * ``` * [ * 'key' => [ * 'in' => [ @@ -274,7 +274,7 @@ public static function getValue($array, $key, $default = null) * `ArrayHelper::setValue($array, ['key', 'in'], ['arr' => 'val']);` * will be the following: * - * ```php + * ``` * [ * 'key' => [ * 'in' => [ @@ -321,7 +321,7 @@ public static function setValue(&$array, $path, $value) * * Usage examples, * - * ```php + * ``` * // $array = ['type' => 'A', 'options' => [1, 2]]; * // working with array * $type = \yii\helpers\ArrayHelper::remove($array, 'type'); @@ -356,7 +356,7 @@ public static function remove(&$array, $key, $default = null) * * Example, * - * ```php + * ``` * $array = ['Bob' => 'Dylan', 'Michael' => 'Jackson', 'Mick' => 'Jagger', 'Janet' => 'Jackson']; * $removed = \yii\helpers\ArrayHelper::removeValue($array, 'Jackson'); * // result: @@ -399,7 +399,7 @@ public static function removeValue(&$array, $value) * * For example: * - * ```php + * ``` * $array = [ * ['id' => '123', 'data' => 'abc', 'device' => 'laptop'], * ['id' => '345', 'data' => 'def', 'device' => 'tablet'], @@ -410,7 +410,7 @@ public static function removeValue(&$array, $value) * * The result will be an associative array, where the key is the value of `id` attribute * - * ```php + * ``` * [ * '123' => ['id' => '123', 'data' => 'abc', 'device' => 'laptop'], * '345' => ['id' => '345', 'data' => 'hgi', 'device' => 'smartphone'] @@ -420,7 +420,7 @@ public static function removeValue(&$array, $value) * * An anonymous function can be used in the grouping array as well. * - * ```php + * ``` * $result = ArrayHelper::index($array, function ($element) { * return $element['id']; * }); @@ -428,13 +428,13 @@ public static function removeValue(&$array, $value) * * Passing `id` as a third argument will group `$array` by `id`: * - * ```php + * ``` * $result = ArrayHelper::index($array, null, 'id'); * ``` * * The result will be a multidimensional array grouped by `id`: * - * ```php + * ``` * [ * '123' => [ * ['id' => '123', 'data' => 'abc', 'device' => 'laptop'] @@ -448,7 +448,7 @@ public static function removeValue(&$array, $value) * * The anonymous function can be used in the array of grouping keys as well: * - * ```php + * ``` * $result = ArrayHelper::index($array, 'data', [function ($element) { * return $element['id']; * }, 'device']); @@ -457,7 +457,7 @@ public static function removeValue(&$array, $value) * The result will be a multidimensional array grouped by `id` on the first level, by the `device` on the second one * and indexed by the `data` on the third level: * - * ```php + * ``` * [ * '123' => [ * 'laptop' => [ @@ -524,7 +524,7 @@ public static function index($array, $key, $groups = []) * * For example, * - * ```php + * ``` * $array = [ * ['id' => '123', 'data' => 'abc'], * ['id' => '345', 'data' => 'def'], @@ -567,7 +567,7 @@ public static function getColumn($array, $name, $keepKeys = true) * * For example, * - * ```php + * ``` * $array = [ * ['id' => '123', 'name' => 'aaa', 'class' => 'x'], * ['id' => '124', 'name' => 'bbb', 'class' => 'x'], @@ -932,7 +932,7 @@ public static function isSubset($needles, $haystack, $strict = false) * * For example: * - * ```php + * ``` * $array = [ * 'A' => [1, 2], * 'B' => [ @@ -1060,7 +1060,7 @@ public static function recursiveSort(array &$array, $sorter = null) * * Example: * - * ```php + * ``` * $array = [ * 'A' => [1, 2], * 'B' => [ diff --git a/framework/helpers/BaseConsole.php b/framework/helpers/BaseConsole.php index 04a031f73dd..59e6749840e 100644 --- a/framework/helpers/BaseConsole.php +++ b/framework/helpers/BaseConsole.php @@ -268,7 +268,7 @@ public static function beginAnsiFormat($format) * Any output after this will have default text format. * This is equal to calling. * - * ```php + * ``` * echo Console::ansiFormatCode([Console::RESET]) * ``` */ @@ -676,7 +676,7 @@ public static function isRunningOnWindows() * * Usage: * - * ```php + * ``` * list($width, $height) = ConsoleHelper::getScreenSize(); * ``` * @@ -907,7 +907,7 @@ public static function prompt($text, $options = []) * * A typical usage looks like the following: * - * ```php + * ``` * if (Console::confirm("Are you sure?")) { * echo "user typed yes\n"; * } else { @@ -987,7 +987,7 @@ public static function select($prompt, $options = [], $default = null) * * The following example shows a simple usage of a progress bar: * - * ```php + * ``` * Console::startProgress(0, 1000); * for ($n = 1; $n <= 1000; $n++) { * usleep(1000); @@ -998,7 +998,7 @@ public static function select($prompt, $options = [], $default = null) * * Git clone like progress (showing only status information): * - * ```php + * ``` * Console::startProgress(0, 1000, 'Counting objects: ', false); * for ($n = 1; $n <= 1000; $n++) { * usleep(1000); diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index 3d7bc17d772..c1858086cf0 100644 --- a/framework/helpers/BaseHtml.php +++ b/framework/helpers/BaseHtml.php @@ -412,7 +412,7 @@ public static function endForm() * If you want to use an absolute url you can call [[Url::to()]] yourself, before passing the URL to this method, * like this: * - * ```php + * ``` * Html::a('link text', Url::to($url, true)) * ``` * @@ -817,14 +817,14 @@ protected static function booleanInput($type, $name, $checked = false, $options * - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array * to override the value and to set other tag attributes: * - * ```php + * ``` * ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']], * ``` * * - options: array, the attributes for the select option tags. The array keys must be valid option values, * and the array values are the extra attributes for the corresponding option tags. For example, * - * ```php + * ``` * [ * 'value1' => ['disabled' => true], * 'value2' => ['label' => 'value 2'], @@ -875,14 +875,14 @@ public static function dropDownList($name, $selection = null, $items = [], $opti * - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array * to override the value and to set other tag attributes: * - * ```php + * ``` * ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']], * ``` * * - options: array, the attributes for the select option tags. The array keys must be valid option values, * and the array values are the extra attributes for the corresponding option tags. For example, * - * ```php + * ``` * [ * 'value1' => ['disabled' => true], * 'value2' => ['label' => 'value 2'], @@ -961,7 +961,7 @@ public static function listBox($name, $selection = null, $items = [], $options = * - item: callable, a callback that can be used to customize the generation of the HTML code * corresponding to a single item in $items. The signature of this callback must be: * - * ```php + * ``` * function ($index, $label, $name, $checked, $value) * ``` * @@ -1054,7 +1054,7 @@ public static function checkboxList($name, $selection = null, $items = [], $opti * - item: callable, a callback that can be used to customize the generation of the HTML code * corresponding to a single item in $items. The signature of this callback must be: * - * ```php + * ``` * function ($index, $label, $name, $checked, $value) * ``` * @@ -1130,7 +1130,7 @@ public static function radioList($name, $selection = null, $items = [], $options * - item: callable, a callback that is used to generate each individual list item. * The signature of this callback must be: * - * ```php + * ``` * function ($item, $index) * ``` * @@ -1181,7 +1181,7 @@ public static function ul($items, $options = []) * - item: callable, a callback that is used to generate each individual list item. * The signature of this callback must be: * - * ```php + * ``` * function ($item, $index) * ``` * @@ -1670,14 +1670,14 @@ protected static function activeBooleanInput($type, $model, $attribute, $options * - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array * to override the value and to set other tag attributes: * - * ```php + * ``` * ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']], * ``` * * - options: array, the attributes for the select option tags. The array keys must be valid option values, * and the array values are the extra attributes for the corresponding option tags. For example, * - * ```php + * ``` * [ * 'value1' => ['disabled' => true], * 'value2' => ['label' => 'value 2'], @@ -1725,14 +1725,14 @@ public static function activeDropDownList($model, $attribute, $items, $options = * - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array * to override the value and to set other tag attributes: * - * ```php + * ``` * ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']], * ``` * * - options: array, the attributes for the select option tags. The array keys must be valid option values, * and the array values are the extra attributes for the corresponding option tags. For example, * - * ```php + * ``` * [ * 'value1' => ['disabled' => true], * 'value2' => ['label' => 'value 2'], @@ -1785,7 +1785,7 @@ public static function activeListBox($model, $attribute, $items, $options = []) * - item: callable, a callback that can be used to customize the generation of the HTML code * corresponding to a single item in $items. The signature of this callback must be: * - * ```php + * ``` * function ($index, $label, $name, $checked, $value) * ``` * @@ -1826,7 +1826,7 @@ public static function activeCheckboxList($model, $attribute, $items, $options = * - item: callable, a callback that can be used to customize the generation of the HTML code * corresponding to a single item in $items. The signature of this callback must be: * - * ```php + * ``` * function ($index, $label, $name, $checked, $value) * ``` * @@ -2057,7 +2057,7 @@ public static function renderTagAttributes($attributes) * If class specification at given options is an array, and some class placed there with the named (string) key, * overriding of such key will have no effect. For example: * - * ```php + * ``` * $options = ['class' => ['persistent' => 'initial']]; * Html::addCssClass($options, ['persistent' => 'override']); * var_dump($options['class']); // outputs: array('persistent' => 'initial'); @@ -2139,7 +2139,7 @@ public static function removeCssClass(&$options, $class) * * For example, * - * ```php + * ``` * Html::addCssStyle($options, 'width: 100px; height: 200px'); * ``` * @@ -2174,7 +2174,7 @@ public static function addCssStyle(&$options, $style, $overwrite = true) * * For example, * - * ```php + * ``` * Html::removeCssStyle($options, ['width', 'height']); * ``` * @@ -2199,7 +2199,7 @@ public static function removeCssStyle(&$options, $properties) * * For example, * - * ```php + * ``` * print_r(Html::cssStyleFromArray(['width' => '100px', 'height' => '200px'])); * // will display: 'width: 100px; height: 200px;' * ``` @@ -2226,7 +2226,7 @@ public static function cssStyleFromArray(array $style) * * For example, * - * ```php + * ``` * print_r(Html::cssStyleToArray('width: 100px; height: 200px;')); * // will display: ['width' => '100px', 'height' => '200px'] * ``` diff --git a/framework/helpers/BaseHtmlPurifier.php b/framework/helpers/BaseHtmlPurifier.php index 2397bff57ad..c01241fcfbf 100644 --- a/framework/helpers/BaseHtmlPurifier.php +++ b/framework/helpers/BaseHtmlPurifier.php @@ -32,7 +32,7 @@ class BaseHtmlPurifier * * Here is a usage example of such a function: * - * ```php + * ``` * // Allow the HTML5 data attribute `data-type` on `img` elements. * $content = HtmlPurifier::process($content, function ($config) { * $config->getHTMLDefinition(true) diff --git a/framework/helpers/BaseInflector.php b/framework/helpers/BaseInflector.php index 202a46c239a..08bd059131a 100644 --- a/framework/helpers/BaseInflector.php +++ b/framework/helpers/BaseInflector.php @@ -613,7 +613,7 @@ public static function ordinalize($number) * * Special treatment is done for the last few words. For example, * - * ```php + * ``` * $words = ['Spain', 'France']; * echo Inflector::sentence($words); * // output: Spain and France diff --git a/framework/helpers/BaseIpHelper.php b/framework/helpers/BaseIpHelper.php index 5ab73a63106..cf90cd32d50 100644 --- a/framework/helpers/BaseIpHelper.php +++ b/framework/helpers/BaseIpHelper.php @@ -47,14 +47,14 @@ public static function getIpVersion($ip) * * For example, the following code checks whether subnet `192.168.1.0/24` is in subnet `192.168.0.0/22`: * - * ```php + * ``` * IpHelper::inRange('192.168.1.0/24', '192.168.0.0/22'); // true * ``` * * In case you need to check whether a single IP address `192.168.1.21` is in the subnet `192.168.1.0/24`, * you can use any of theses examples: * - * ```php + * ``` * IpHelper::inRange('192.168.1.21', '192.168.1.0/24'); // true * IpHelper::inRange('192.168.1.21/32', '192.168.1.0/24'); // true * ``` diff --git a/framework/helpers/BaseUrl.php b/framework/helpers/BaseUrl.php index 864dbc63c48..b88c6e664ce 100644 --- a/framework/helpers/BaseUrl.php +++ b/framework/helpers/BaseUrl.php @@ -36,7 +36,7 @@ class BaseUrl * if you want to specify additional query parameters for the URL being created. The * array format must be: * - * ```php + * ``` * // generates: /index.php?r=site/index¶m1=value1¶m2=value2 * ['site/index', 'param1' => 'value1', 'param2' => 'value2'] * ``` @@ -44,7 +44,7 @@ class BaseUrl * If you want to create a URL with an anchor, you can use the array format with a `#` parameter. * For example, * - * ```php + * ``` * // generates: /index.php?r=site/index¶m1=value1#name * ['site/index', 'param1' => 'value1', '#' => 'name'] * ``` @@ -64,7 +64,7 @@ class BaseUrl * * Below are some examples of using this method: * - * ```php + * ``` * // /index.php?r=site%2Findex * echo Url::toRoute('site/index'); * @@ -167,7 +167,7 @@ protected static function normalizeRoute($route) * * Below are some examples of using this method: * - * ```php + * ``` * // /index.php?r=site%2Findex * echo Url::to(['site/index']); * @@ -332,7 +332,7 @@ public static function previous($name = null) * [[\yii\web\Controller::actionParams]]. You may use the following code in the layout view to add a link tag * about canonical URL: * - * ```php + * ``` * $this->registerLinkTag(['rel' => 'canonical', 'href' => Url::canonical()]); * ``` * @@ -389,7 +389,7 @@ public static function isRelative($url) * will be removed from the existing GET parameters; all other parameters specified in `$params` will * be merged with the existing GET parameters. For example, * - * ```php + * ``` * // assume $_GET = ['id' => 123, 'src' => 'google'], current route is "post/view" * * // /index.php?r=post%2Fview&id=123&src=google @@ -406,7 +406,7 @@ public static function isRelative($url) * For a `PostSearchForm` model where parameter names are `PostSearchForm[id]` and `PostSearchForm[src]` the syntax * would be the following: * - * ```php + * ``` * // index.php?r=post%2Findex&PostSearchForm%5Bid%5D=100&PostSearchForm%5Bsrc%5D=google * echo Url::current([ * $postSearch->formName() => ['id' => 100, 'src' => 'google'], diff --git a/framework/helpers/HtmlPurifier.php b/framework/helpers/HtmlPurifier.php index 6157c43983d..f90653ec9b3 100644 --- a/framework/helpers/HtmlPurifier.php +++ b/framework/helpers/HtmlPurifier.php @@ -12,13 +12,13 @@ * * Basic usage is the following: * - * ```php + * ``` * echo HtmlPurifier::process($html); * ``` * * If you want to configure it: * - * ```php + * ``` * echo HtmlPurifier::process($html, [ * 'Attr.EnableID' => true, * ]); diff --git a/framework/helpers/Markdown.php b/framework/helpers/Markdown.php index 4cc8848dac5..c4436dfbb0c 100644 --- a/framework/helpers/Markdown.php +++ b/framework/helpers/Markdown.php @@ -12,7 +12,7 @@ * * Basic usage is the following: * - * ```php + * ``` * $myHtml = Markdown::process($myText); // use original markdown flavor * $myHtml = Markdown::process($myText, 'gfm'); // use github flavored markdown * $myHtml = Markdown::process($myText, 'extra'); // use markdown extra diff --git a/framework/helpers/ReplaceArrayValue.php b/framework/helpers/ReplaceArrayValue.php index 3ed6208f26f..c1d61592142 100644 --- a/framework/helpers/ReplaceArrayValue.php +++ b/framework/helpers/ReplaceArrayValue.php @@ -14,7 +14,7 @@ * * Usage example: * - * ```php + * ``` * $array1 = [ * 'ids' => [ * 1, @@ -40,7 +40,7 @@ * * The result will be * - * ```php + * ``` * [ * 'ids' => [ * 1, diff --git a/framework/helpers/UnsetArrayValue.php b/framework/helpers/UnsetArrayValue.php index 25e67bbc0d4..e6ac3deffe9 100644 --- a/framework/helpers/UnsetArrayValue.php +++ b/framework/helpers/UnsetArrayValue.php @@ -12,7 +12,7 @@ * * Usage example: * - * ```php + * ``` * $array1 = [ * 'ids' => [ * 1, @@ -35,7 +35,7 @@ * * The result will be * - * ```php + * ``` * [ * 'ids' => [ * 1, diff --git a/framework/helpers/VarDumper.php b/framework/helpers/VarDumper.php index d75521fb7a7..f375a21126e 100644 --- a/framework/helpers/VarDumper.php +++ b/framework/helpers/VarDumper.php @@ -15,7 +15,7 @@ * * VarDumper can be used as follows, * - * ```php + * ``` * VarDumper::dump($var); * ``` * diff --git a/framework/helpers/mimeAliases.php b/framework/helpers/mimeAliases.php index a9e677adcbd..94ff2b05f3e 100644 --- a/framework/helpers/mimeAliases.php +++ b/framework/helpers/mimeAliases.php @@ -4,7 +4,7 @@ * * This file contains aliases for MIME types. * - * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * All extra changes made to this file must be committed to /build/controllers/MimeTypeController.php * otherwise they will be lost on next build. */ return [ diff --git a/framework/helpers/mimeExtensions.php b/framework/helpers/mimeExtensions.php index 02109df1cae..115b3407586 100644 --- a/framework/helpers/mimeExtensions.php +++ b/framework/helpers/mimeExtensions.php @@ -9,7 +9,7 @@ * https://raw.githubusercontent.com/apache/httpd/refs/heads/trunk/docs/conf/mime.types * This file has been placed in the public domain for unlimited redistribution. * - * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * All extra changes made to this file must be committed to /build/controllers/MimeTypeController.php * otherwise they will be lost on next build. */ return [ diff --git a/framework/helpers/mimeTypes.php b/framework/helpers/mimeTypes.php index 8ff418d6abe..9f45b1195b1 100644 --- a/framework/helpers/mimeTypes.php +++ b/framework/helpers/mimeTypes.php @@ -8,7 +8,7 @@ * https://raw.githubusercontent.com/apache/httpd/refs/heads/trunk/docs/conf/mime.types * This file has been placed in the public domain for unlimited redistribution. * - * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * All extra changes made to this file must be committed to /build/controllers/MimeTypeController.php * otherwise they will be lost on next build. */ $mimeTypes = [ diff --git a/framework/i18n/Formatter.php b/framework/i18n/Formatter.php index 2a7066c9db4..354382bd27f 100644 --- a/framework/i18n/Formatter.php +++ b/framework/i18n/Formatter.php @@ -141,7 +141,7 @@ class Formatter extends Component * * For example: * - * ```php + * ``` * 'MM/dd/yyyy' // date in ICU format * 'php:m/d/Y' // the same date in PHP format * ``` @@ -157,7 +157,7 @@ class Formatter extends Component * * For example: * - * ```php + * ``` * 'HH:mm:ss' // time in ICU format * 'php:H:i:s' // the same time in PHP format * ``` @@ -174,7 +174,7 @@ class Formatter extends Component * * For example: * - * ```php + * ``` * 'MM/dd/yyyy HH:mm:ss' // date and time in ICU format * 'php:m/d/Y H:i:s' // the same date and time in PHP format * ``` @@ -191,7 +191,7 @@ class Formatter extends Component * set this property to `\IntlDateFormatter::TRADITIONAL`. * The calendar must then be specified in the [[locale]], for example for the persian calendar the configuration for the formatter would be: * - * ```php + * ``` * 'formatter' => [ * 'locale' => 'fa_IR@calendar=persian', * 'calendar' => \IntlDateFormatter::TRADITIONAL, @@ -241,7 +241,7 @@ class Formatter extends Component * * For example to adjust the maximum and minimum value of fraction digits you can configure this property like the following: * - * ```php + * ``` * [ * NumberFormatter::MIN_FRACTION_DIGITS => 0, * NumberFormatter::MAX_FRACTION_DIGITS => 2, @@ -260,7 +260,7 @@ class Formatter extends Component * * For example to change the minus sign for negative numbers you can configure this property like the following: * - * ```php + * ``` * [ * NumberFormatter::NEGATIVE_PREFIX => 'MINUS', * ] @@ -278,7 +278,7 @@ class Formatter extends Component * * For example to choose a custom currency symbol, e.g. [U+20BD](https://unicode-table.com/en/20BD/) instead of `руб.` for Russian Ruble: * - * ```php + * ``` * [ * NumberFormatter::CURRENCY_SYMBOL => '₽', * ] @@ -317,7 +317,7 @@ class Formatter extends Component * * For example, you can add smaller measure unit: * - * ```php + * ``` * $this->measureUnits[self::UNIT_LENGTH][self::UNIT_SYSTEM_METRIC] = [ * 'nanometer' => 0.000001 * ] diff --git a/framework/i18n/PhpMessageSource.php b/framework/i18n/PhpMessageSource.php index 90183f2e3a5..dcee5eae99e 100644 --- a/framework/i18n/PhpMessageSource.php +++ b/framework/i18n/PhpMessageSource.php @@ -20,7 +20,7 @@ * - Each PHP script is saved as a file named as "[[basePath]]/LanguageID/CategoryName.php"; * - Within each PHP script, the message translations are returned as an array like the following: * - * ```php + * ``` * return [ * 'original message 1' => 'translated message 1', * 'original message 2' => 'translated message 2', @@ -42,7 +42,7 @@ class PhpMessageSource extends MessageSource * @var array mapping between message categories and the corresponding message file paths. * The file paths are relative to [[basePath]]. For example, * - * ```php + * ``` * [ * 'core' => 'core.php', * 'ext' => 'extensions.php', diff --git a/framework/log/Dispatcher.php b/framework/log/Dispatcher.php index 11b6b0016a9..9dd81fa1632 100644 --- a/framework/log/Dispatcher.php +++ b/framework/log/Dispatcher.php @@ -21,7 +21,7 @@ * * You may configure the targets in application configuration, like the following: * - * ```php + * ``` * [ * 'components' => [ * 'log' => [ @@ -46,12 +46,12 @@ * * Each log target can have a name and can be referenced via the [[targets]] property as follows: * - * ```php + * ``` * Yii::$app->log->targets['file']->enabled = false; * ``` * - * @property int $flushInterval How many messages should be logged before they are sent to targets. This - * method returns the value of [[Logger::flushInterval]]. + * @property int $flushInterval How many messages should be logged before they are sent to targets. See + * [[getFlushInterval()]] and [[setFlushInterval()]] for details. * @property Logger $logger The logger. If not set, [[Yii::getLogger()]] will be used. Note that the type of * this property differs in getter and setter. See [[getLogger()]] and [[setLogger()]] for details. * @property int $traceLevel How many application call stacks should be logged together with each message. @@ -107,7 +107,6 @@ public function init() /** * Gets the connected logger. * If not set, [[Yii::getLogger()]] will be used. - * @property Logger the logger. If not set, [[Yii::getLogger()]] will be used. * @return Logger the logger. */ public function getLogger() diff --git a/framework/log/EmailTarget.php b/framework/log/EmailTarget.php index 6029e67db82..ba70749d23b 100644 --- a/framework/log/EmailTarget.php +++ b/framework/log/EmailTarget.php @@ -18,7 +18,7 @@ * You may configure the email to be sent by setting the [[message]] property, through which * you can set the target email addresses, subject, etc.: * - * ```php + * ``` * 'components' => [ * 'log' => [ * 'targets' => [ diff --git a/framework/log/Target.php b/framework/log/Target.php index 8d5d2e36552..2e0ebda6d72 100644 --- a/framework/log/Target.php +++ b/framework/log/Target.php @@ -211,7 +211,7 @@ public function getLevels() * * For example, * - * ```php + * ``` * ['error', 'warning'] * // which is equivalent to: * Logger::LEVEL_ERROR | Logger::LEVEL_WARNING @@ -368,7 +368,7 @@ public function getMessagePrefix($message) * For example, to only enable a log if the current user is logged in you can configure the target * as follows: * - * ```php + * ``` * 'enabled' => function() { * return !Yii::$app->user->isGuest; * } @@ -381,7 +381,6 @@ public function setEnabled($value) /** * Check whether the log target is enabled. - * @property bool Indicates whether this log target is enabled. Defaults to true. * @return bool A value indicating whether this log target is enabled. */ public function getEnabled() diff --git a/framework/mail/BaseMailer.php b/framework/mail/BaseMailer.php index e334d74aa9d..56f32189918 100644 --- a/framework/mail/BaseMailer.php +++ b/framework/mail/BaseMailer.php @@ -63,7 +63,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont * * For example: * - * ```php + * ``` * [ * 'charset' => 'UTF-8', * 'from' => 'noreply@mydomain.com', @@ -93,7 +93,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont * * The signature of the callback is: * - * ```php + * ``` * function ($mailer, $message) * ``` */ diff --git a/framework/mail/MailerInterface.php b/framework/mail/MailerInterface.php index c6f3aa94eb1..352de81ce8a 100644 --- a/framework/mail/MailerInterface.php +++ b/framework/mail/MailerInterface.php @@ -13,7 +13,7 @@ * A mailer should mainly support creating and sending [[MessageInterface|mail messages]]. It should * also support composition of the message body through the view rendering mechanism. For example, * - * ```php + * ``` * Yii::$app->mailer->compose('contact/html', ['contactForm' => $form]) * ->setFrom('from@domain.com') * ->setTo($form->email) diff --git a/framework/mail/MessageInterface.php b/framework/mail/MessageInterface.php index d5c70e21e54..a3272213846 100644 --- a/framework/mail/MessageInterface.php +++ b/framework/mail/MessageInterface.php @@ -15,7 +15,7 @@ * * Messages are sent by a [[\yii\mail\MailerInterface|mailer]], like the following, * - * ```php + * ``` * Yii::$app->mailer->compose() * ->setFrom('from@domain.com') * ->setTo($form->email) diff --git a/framework/mutex/FileMutex.php b/framework/mutex/FileMutex.php index 241f3fce0df..e40e4cf48ef 100644 --- a/framework/mutex/FileMutex.php +++ b/framework/mutex/FileMutex.php @@ -18,7 +18,7 @@ * * Application configuration example: * - * ```php + * ``` * [ * 'components' => [ * 'mutex' => [ diff --git a/framework/requirements/YiiRequirementChecker.php b/framework/requirements/YiiRequirementChecker.php index 955d2294186..0982a66ffe9 100644 --- a/framework/requirements/YiiRequirementChecker.php +++ b/framework/requirements/YiiRequirementChecker.php @@ -16,7 +16,7 @@ * * Example: * - * ```php + * ``` * require_once 'path/to/YiiRequirementChecker.php'; * $requirementsChecker = new YiiRequirementChecker(); * $requirements = array( @@ -37,7 +37,7 @@ * In this case specified PHP expression will be evaluated in the context of this class instance. * For example: * - * ```php + * ``` * $requirements = array( * array( * 'name' => 'Upload max file size', @@ -49,15 +49,13 @@ * Note: this class definition does not match ordinary Yii style, because it should match PHP 4.3 * and should not use features from newer PHP versions! * - * @property array|null $result the check results, this property is for internal usage only. - * * @author Paul Klimov * @since 2.0 */ class YiiRequirementChecker { /** - * @var Check result + * @var array|null the check results, this property is for internal usage only. */ public $result; @@ -124,7 +122,7 @@ function checkYii() * Return the check results. * @return array|null check results in format: * - * ```php + * ``` * array( * 'summary' => array( * 'total' => total number of checks, @@ -321,6 +319,8 @@ function renderViewFile($_viewFile_, $_data_ = null, $_return_ = false) } else { require $_viewFile_; } + + return null; } /** diff --git a/framework/rest/Action.php b/framework/rest/Action.php index 3b6b2e2eb97..391735a64b6 100644 --- a/framework/rest/Action.php +++ b/framework/rest/Action.php @@ -10,6 +10,7 @@ use yii\base\InvalidConfigException; use yii\db\ActiveRecordInterface; use yii\web\NotFoundHttpException; +use yii\base\Action as BaseAction; /** * Action is the base class for action classes that implement RESTful API. @@ -18,8 +19,11 @@ * * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends BaseAction */ -class Action extends \yii\base\Action +class Action extends BaseAction { /** * @var string class name of the model which will be handled by this action. @@ -32,7 +36,7 @@ class Action extends \yii\base\Action * to the specified primary key value. If not set, [[findModel()]] will be used instead. * The signature of the callable should be: * - * ```php + * ``` * function ($id, $action) { * // $id is the primary key value. If composite primary key, the key values * // will be separated by comma. @@ -48,7 +52,7 @@ class Action extends \yii\base\Action * if the current user has the permission to execute the action. If not set, the access * check will not be performed. The signature of the callable should be as follows, * - * ```php + * ``` * function ($action, $model = null) { * // $model is the requested model instance. * // If null, it means no specific model (e.g. IndexAction) diff --git a/framework/rest/CreateAction.php b/framework/rest/CreateAction.php index 0dab7044f77..30481f40c0f 100644 --- a/framework/rest/CreateAction.php +++ b/framework/rest/CreateAction.php @@ -19,6 +19,9 @@ * * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends Action */ class CreateAction extends Action { diff --git a/framework/rest/DeleteAction.php b/framework/rest/DeleteAction.php index 43ad64bcc78..18b8964f0a6 100644 --- a/framework/rest/DeleteAction.php +++ b/framework/rest/DeleteAction.php @@ -17,6 +17,9 @@ * * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends Action */ class DeleteAction extends Action { diff --git a/framework/rest/IndexAction.php b/framework/rest/IndexAction.php index 8b0891917ab..d95350d7cbb 100644 --- a/framework/rest/IndexAction.php +++ b/framework/rest/IndexAction.php @@ -21,6 +21,9 @@ * * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends Action */ class IndexAction extends Action { @@ -29,7 +32,7 @@ class IndexAction extends Action * should return a collection of the models. If not set, [[prepareDataProvider()]] will be used instead. * The signature of the callable should be: * - * ```php + * ``` * function (IndexAction $action) { * // $action is the action object currently running * } @@ -40,7 +43,7 @@ class IndexAction extends Action * If [[dataFilter]] is set the result of [[DataFilter::build()]] will be passed to the callable as a second parameter. * In this case the signature of the callable should be the following: * - * ```php + * ``` * function (IndexAction $action, mixed $filter) { * // $action is the action object currently running * // $filter the built filter condition @@ -53,7 +56,7 @@ class IndexAction extends Action * Should return $query. * For example: * - * ```php + * ``` * function ($query, $requestParams) { * $query->andFilterWhere(['id' => 1]); * ... @@ -69,7 +72,7 @@ class IndexAction extends Action * You must set up this field explicitly in order to enable filter processing. * For example: * - * ```php + * ``` * [ * 'class' => 'yii\data\ActiveDataFilter', * 'searchModel' => function () { diff --git a/framework/rest/Serializer.php b/framework/rest/Serializer.php index edc689e94e8..bc761e340be 100644 --- a/framework/rest/Serializer.php +++ b/framework/rest/Serializer.php @@ -68,7 +68,7 @@ class Serializer extends Component * This is used when serving a resource collection. When this is set and pagination is enabled, the serializer * will return a collection in the following format: * - * ```php + * ``` * [ * 'items' => [...], // assuming collectionEnvelope is "items" * '_links' => { // pagination links as returned by Pagination::getLinks() diff --git a/framework/rest/UpdateAction.php b/framework/rest/UpdateAction.php index 62cbf5e4bef..03b7d32af71 100644 --- a/framework/rest/UpdateAction.php +++ b/framework/rest/UpdateAction.php @@ -19,6 +19,9 @@ * * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends Action */ class UpdateAction extends Action { diff --git a/framework/rest/UrlRule.php b/framework/rest/UrlRule.php index 1d595592c95..78a90b35fc0 100644 --- a/framework/rest/UrlRule.php +++ b/framework/rest/UrlRule.php @@ -19,7 +19,7 @@ * * The simplest usage of UrlRule is to declare a rule like the following in the application configuration, * - * ```php + * ``` * [ * 'class' => 'yii\rest\UrlRule', * 'controller' => 'user', @@ -41,7 +41,7 @@ * You may configure [[controller]] with multiple controller IDs to generate rules for all these controllers. * For example, the following code will disable the `delete` rule and generate rules for both `user` and `post` controllers: * - * ```php + * ``` * [ * 'class' => 'yii\rest\UrlRule', * 'controller' => ['user', 'post'], diff --git a/framework/rest/ViewAction.php b/framework/rest/ViewAction.php index 901fa6beece..f4e9a18fbbd 100644 --- a/framework/rest/ViewAction.php +++ b/framework/rest/ViewAction.php @@ -14,6 +14,9 @@ * * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends Action */ class ViewAction extends Action { diff --git a/framework/test/FixtureTrait.php b/framework/test/FixtureTrait.php index 4be70470eab..0ce10738dca 100644 --- a/framework/test/FixtureTrait.php +++ b/framework/test/FixtureTrait.php @@ -40,7 +40,7 @@ trait FixtureTrait * * The return value of this method must be an array of fixture configurations. For example, * - * ```php + * ``` * [ * // anonymous fixture * PostFixture::class, diff --git a/framework/validators/DateValidator.php b/framework/validators/DateValidator.php index c0f66454120..9ea6bbf4d01 100644 --- a/framework/validators/DateValidator.php +++ b/framework/validators/DateValidator.php @@ -88,7 +88,7 @@ class DateValidator extends Validator * * Here are some example values: * - * ```php + * ``` * 'MM/dd/yyyy' // date in ICU format * 'php:m/d/Y' // the same date in PHP format * 'MM/dd/yyyy HH:mm' // not only dates but also times can be validated diff --git a/framework/validators/DefaultValueValidator.php b/framework/validators/DefaultValueValidator.php index 862acd22951..5a0b27124ba 100644 --- a/framework/validators/DefaultValueValidator.php +++ b/framework/validators/DefaultValueValidator.php @@ -23,7 +23,7 @@ class DefaultValueValidator extends Validator * be assigned to the attributes being validated if they are empty. The signature of the anonymous function * should be as follows, * - * ```php + * ``` * function($model, $attribute) { * // compute value * return $value; diff --git a/framework/validators/EachValidator.php b/framework/validators/EachValidator.php index 56c7dd3bd3a..973ffae92b8 100644 --- a/framework/validators/EachValidator.php +++ b/framework/validators/EachValidator.php @@ -15,7 +15,7 @@ /** * EachValidator validates an array by checking each of its elements against an embedded validation rule. * - * ```php + * ``` * class MyModel extends Model * { * public $categoryIDs = []; @@ -47,7 +47,7 @@ class EachValidator extends Validator * contain attribute list as the first element. * For example: * - * ```php + * ``` * ['integer'] * ['match', 'pattern' => '/[a-z]/is'] * ``` diff --git a/framework/validators/ExistValidator.php b/framework/validators/ExistValidator.php index c0f72f6910d..185d59456a2 100644 --- a/framework/validators/ExistValidator.php +++ b/framework/validators/ExistValidator.php @@ -26,7 +26,7 @@ * * The following are examples of validation rules using this validator: * - * ```php + * ``` * // a1 needs to exist * ['a1', 'exist'] * // a1 needs to exist, but its value will use a2 to check for the existence diff --git a/framework/validators/FilterValidator.php b/framework/validators/FilterValidator.php index a08b0b51d29..53dc0c78cbf 100644 --- a/framework/validators/FilterValidator.php +++ b/framework/validators/FilterValidator.php @@ -18,7 +18,7 @@ * and save the processed value back to the attribute. The filter must be * a valid PHP callback with the following signature: * - * ```php + * ``` * function foo($value) { * // compute $newValue here * return $newValue; @@ -40,7 +40,7 @@ class FilterValidator extends Validator * @var callable the filter. This can be a global function name, anonymous function, etc. * The function signature must be as follows, * - * ```php + * ``` * function foo($value) { * // compute $newValue here * return $newValue; diff --git a/framework/validators/InlineValidator.php b/framework/validators/InlineValidator.php index 800046d7081..877d20ac343 100644 --- a/framework/validators/InlineValidator.php +++ b/framework/validators/InlineValidator.php @@ -19,7 +19,7 @@ class InlineValidator extends Validator * @var string|callable an anonymous function or the name of a model class method that will be * called to perform the actual validation. The signature of the method should be like the following: * - * ```php + * ``` * function (string $attribute, mixed $params, InlineValidator $validator, mixed $current): bool { * } * ``` @@ -38,7 +38,7 @@ class InlineValidator extends Validator * @var string|\Closure an anonymous function or the name of a model class method that returns the client validation code. * The signature of the method should be like the following: * - * ```php + * ``` * function (string $attribute, mixed $params, InlineValidator $validator, mixed $current, View $view): string * { * // $view->registerJs('JS validation function'); @@ -67,7 +67,7 @@ public function validateAttribute($model, $attribute) if (is_string($method)) { $method = [$model, $method]; } elseif ($method instanceof \Closure) { - $method = $this->method->bindTo($model); + $method = $method->bindTo($model); } $current = $this->current; diff --git a/framework/validators/IpValidator.php b/framework/validators/IpValidator.php index c4a9555bf8a..d94ca6a2195 100644 --- a/framework/validators/IpValidator.php +++ b/framework/validators/IpValidator.php @@ -21,7 +21,7 @@ * * The following are examples of validation rules using this validator: * - * ```php + * ``` * ['ip_address', 'ip'], // IPv4 or IPv6 address * ['ip_address', 'ip', 'ipv6' => false], // IPv4 address (IPv6 is disabled) * ['ip_address', 'ip', 'subnet' => true], // requires a CIDR prefix (like 10.0.0.1/24) for the IP address @@ -254,7 +254,7 @@ public function init() * * Example: * - * ```php + * ``` * [ * 'ranges' => [ * '192.168.10.128' diff --git a/framework/validators/RangeValidator.php b/framework/validators/RangeValidator.php index e58ea601096..1c1c7bc0102 100644 --- a/framework/validators/RangeValidator.php +++ b/framework/validators/RangeValidator.php @@ -28,7 +28,7 @@ class RangeValidator extends Validator * @var array|\Traversable|\Closure a list of valid values that the attribute value should be among or an anonymous function that returns * such a list. The signature of the anonymous function should be as follows, * - * ```php + * ``` * function($model, $attribute) { * // compute range * return $range; diff --git a/framework/validators/UniqueValidator.php b/framework/validators/UniqueValidator.php index e29cc714473..133af1ebff4 100644 --- a/framework/validators/UniqueValidator.php +++ b/framework/validators/UniqueValidator.php @@ -23,7 +23,7 @@ * * The following are examples of validation rules using this validator: * - * ```php + * ``` * // a1 needs to be unique * ['a1', 'unique'] * // a1 needs to be unique, but column a2 will be used to check the uniqueness of the a1 value diff --git a/framework/validators/Validator.php b/framework/validators/Validator.php index f3395fa6351..1c4c041a89d 100644 --- a/framework/validators/Validator.php +++ b/framework/validators/Validator.php @@ -160,7 +160,7 @@ class Validator extends Component * * The following example will enable the validator only when the country currently selected is USA: * - * ```php + * ``` * function ($model) { * return $model->country == Country::USA; * } @@ -180,7 +180,7 @@ class Validator extends Component * * The following example will enable the validator only when the country currently selected is USA: * - * ```javascript + * ``` * function (attribute, value) { * return $('#country').val() === 'USA'; * } @@ -342,7 +342,7 @@ public function validate($value, &$error = null) * A validator class can implement this method to support data validation out of the context of a data model. * @param mixed $value the data value to be validated. * @return array|null the error message and the array of parameters to be inserted into the error message. - * ```php + * ``` * if (!$valid) { * return [$this->message, [ * 'param1' => $this->param1, diff --git a/framework/web/Application.php b/framework/web/Application.php index b05ac8b1e16..5f9dcd0418c 100644 --- a/framework/web/Application.php +++ b/framework/web/Application.php @@ -40,7 +40,7 @@ class Application extends \yii\base\Application * The rest of the array elements (key-value pairs) specify the parameters to be bound * to the action. For example, * - * ```php + * ``` * [ * 'offline/notice', * 'param1' => 'value1', diff --git a/framework/web/AssetBundle.php b/framework/web/AssetBundle.php index c6bdbed08c0..5990e4f68d9 100644 --- a/framework/web/AssetBundle.php +++ b/framework/web/AssetBundle.php @@ -75,7 +75,7 @@ class AssetBundle extends BaseObject * * For example: * - * ```php + * ``` * public $depends = [ * 'yii\web\YiiAsset', * 'yii\bootstrap\BootstrapAsset', diff --git a/framework/web/AssetConverter.php b/framework/web/AssetConverter.php index 64af54907e0..4047d09fc83 100644 --- a/framework/web/AssetConverter.php +++ b/framework/web/AssetConverter.php @@ -30,7 +30,7 @@ class AssetConverter extends Component implements AssetConverterInterface * * You may also use a [path alias](guide:concept-aliases) to specify the location of the command: * - * ```php + * ``` * [ * 'styl' => ['css', '@app/node_modules/bin/stylus < {from} > {to}'], * ] diff --git a/framework/web/AssetManager.php b/framework/web/AssetManager.php index 3266336d91c..602af110901 100644 --- a/framework/web/AssetManager.php +++ b/framework/web/AssetManager.php @@ -23,7 +23,7 @@ * You can modify its configuration by adding an array to your application config under `components` * as shown in the following example: * - * ```php + * ``` * 'assetManager' => [ * 'bundles' => [ * // you can override AssetBundle configs here @@ -74,7 +74,7 @@ class AssetManager extends Component * The following example shows how to disable the bootstrap css file used by Bootstrap widgets * (because you want to use your own styles): * - * ```php + * ``` * [ * 'yii\bootstrap\BootstrapAsset' => [ * 'css' => [], @@ -107,7 +107,7 @@ class AssetManager extends Component * In the following example, any assets ending with `jquery.min.js` will be replaced with `jquery/dist/jquery.js` * which is relative to [[baseUrl]] and [[basePath]]. * - * ```php + * ``` * [ * 'jquery.min.js' => 'jquery/dist/jquery.js', * ] @@ -115,7 +115,7 @@ class AssetManager extends Component * * You may also use aliases while specifying map value, for example: * - * ```php + * ``` * [ * 'jquery.min.js' => '@web/js/jquery/jquery.js', * ] @@ -135,7 +135,7 @@ class AssetManager extends Component * to Web users. For example, for Apache Web server, the following configuration directive should be added * for the Web folder: * - * ```apache + * ``` * Options FollowSymLinks * ``` */ @@ -206,7 +206,7 @@ class AssetManager extends Component * * Example of an implementation using MD4 hash: * - * ```php + * ``` * function ($path) { * return hash('md4', $path); * } diff --git a/framework/web/CacheSession.php b/framework/web/CacheSession.php index f3d0d87a1af..eefc260d8a2 100644 --- a/framework/web/CacheSession.php +++ b/framework/web/CacheSession.php @@ -23,7 +23,7 @@ * The following example shows how you can configure the application to use CacheSession: * Add the following to your application config under `components`: * - * ```php + * ``` * 'session' => [ * 'class' => 'yii\web\CacheSession', * // 'cache' => 'mycache', diff --git a/framework/web/Controller.php b/framework/web/Controller.php index 22049892103..0eb127dc056 100644 --- a/framework/web/Controller.php +++ b/framework/web/Controller.php @@ -52,7 +52,10 @@ class Controller extends \yii\base\Controller */ public function renderAjax($view, $params = []) { - return $this->getView()->renderAjax($view, $params, $this); + /** @var View */ + $viewComponent = $this->getView(); + + return $viewComponent->renderAjax($view, $params, $this); } /** @@ -63,7 +66,7 @@ public function renderAjax($view, $params = []) * the [[Response::$format|format]] and setting the [[Response::$data|data]] that should * be formatted. A common usage will be: * - * ```php + * ``` * return $this->asJson($data); * ``` * @@ -89,7 +92,7 @@ public function asJson($data) * the [[Response::$format|format]] and setting the [[Response::$data|data]] that should * be formatted. A common usage will be: * - * ```php + * ``` * return $this->asXml($data); * ``` * @@ -344,7 +347,7 @@ public function beforeAction($action) * * You can use it in an action by returning the [[Response]] directly: * - * ```php + * ``` * // stop executing this action and redirect to login page * return $this->redirect(['login']); * ``` @@ -375,7 +378,7 @@ public function redirect($url, $statusCode = 302) * * You can use this method in an action by returning the [[Response]] directly: * - * ```php + * ``` * // stop executing this action and redirect to home page * return $this->goHome(); * ``` @@ -392,7 +395,7 @@ public function goHome() * * You can use this method in an action by returning the [[Response]] directly: * - * ```php + * ``` * // stop executing this action and redirect to last visited page * return $this->goBack(); * ``` @@ -416,7 +419,7 @@ public function goBack($defaultUrl = null) * * You can use it in an action by returning the [[Response]] directly: * - * ```php + * ``` * // stop executing this action and refresh the current page * return $this->refresh(); * ``` diff --git a/framework/web/Cookie.php b/framework/web/Cookie.php index d249afa6cbd..598a6b75549 100644 --- a/framework/web/Cookie.php +++ b/framework/web/Cookie.php @@ -88,7 +88,7 @@ class Cookie extends \yii\base\BaseObject /** * Magic method to turn a cookie object into a string without having to explicitly access [[value]]. * - * ```php + * ``` * if (isset($request->cookies['name'])) { * $value = (string) $request->cookies['name']; * } diff --git a/framework/web/CookieCollection.php b/framework/web/CookieCollection.php index 8b7db87c5ec..c476c694c85 100644 --- a/framework/web/CookieCollection.php +++ b/framework/web/CookieCollection.php @@ -116,19 +116,27 @@ public function getValue($name, $defaultValue = null) */ public function has($name) { - return isset($this->_cookies[$name]) && $this->_cookies[$name]->value !== '' - && ($this->_cookies[$name]->expire === null - || $this->_cookies[$name]->expire === 0 - || ( - (is_string($this->_cookies[$name]->expire) && strtotime($this->_cookies[$name]->expire) >= time()) - || ( - interface_exists('\\DateTimeInterface') - && $this->_cookies[$name]->expire instanceof \DateTimeInterface - && $this->_cookies[$name]->expire->getTimestamp() >= time() - ) - || $this->_cookies[$name]->expire >= time() - ) - ); + if (!isset($this->_cookies[$name]) || $this->_cookies[$name]->value === '') { + return false; + } + + $expire = $this->_cookies[$name]->expire; + + if ($expire === null || $expire === 0) { + return true; + } + + $currentTime = time(); + + if (is_numeric($expire)) { + return (int) $expire >= $currentTime; + } + + if (is_string($expire)) { + return strtotime($expire) >= $currentTime; + } + + return $expire->getTimestamp() >= $currentTime; } /** diff --git a/framework/web/DbSession.php b/framework/web/DbSession.php index b2e48b9ef57..389b3ca2ba8 100644 --- a/framework/web/DbSession.php +++ b/framework/web/DbSession.php @@ -23,7 +23,7 @@ * The following example shows how you can configure the application to use DbSession: * Add the following to your application config under `components`: * - * ```php + * ``` * 'session' => [ * 'class' => 'yii\web\DbSession', * // 'db' => 'mydb', @@ -50,7 +50,7 @@ class DbSession extends MultiFieldSession * @var string the name of the DB table that stores the session data. * The table should be pre-created as follows: * - * ```sql + * ``` * CREATE TABLE session * ( * id CHAR(40) NOT NULL PRIMARY KEY, diff --git a/framework/web/ErrorAction.php b/framework/web/ErrorAction.php index e59f3ab2453..d146dfddd63 100644 --- a/framework/web/ErrorAction.php +++ b/framework/web/ErrorAction.php @@ -20,7 +20,7 @@ * First, declare an action of ErrorAction type in the `actions()` method of your `SiteController` * class (or whatever controller you prefer), like the following: * - * ```php + * ``` * public function actions() * { * return [ @@ -38,7 +38,7 @@ * * Finally, configure the "errorHandler" application component as follows, * - * ```php + * ``` * 'errorHandler' => [ * 'errorAction' => 'site/error', * ] @@ -47,6 +47,9 @@ * @author Qiang Xue * @author Dmitry Naumenko * @since 2.0 + * + * @template T of Controller + * @extends Action */ class ErrorAction extends Action { diff --git a/framework/web/ErrorHandler.php b/framework/web/ErrorHandler.php index 201eaef9de3..b902ac69434 100644 --- a/framework/web/ErrorHandler.php +++ b/framework/web/ErrorHandler.php @@ -105,7 +105,9 @@ protected function renderException($exception) $useErrorView = $response->format === Response::FORMAT_HTML && (!YII_DEBUG || $exception instanceof UserException); if ($useErrorView && $this->errorAction !== null) { - Yii::$app->view->clear(); + /** @var View */ + $view = Yii::$app->view; + $view->clear(); $result = Yii::$app->runAction($this->errorAction); if ($result instanceof Response) { $response = $result; @@ -264,6 +266,7 @@ public function renderFile($_file_, $_params_) return ob_get_clean(); } + /** @var View */ $view = Yii::$app->getView(); $view->clear(); diff --git a/framework/web/GroupUrlRule.php b/framework/web/GroupUrlRule.php index 1b11721da25..f8a11924349 100644 --- a/framework/web/GroupUrlRule.php +++ b/framework/web/GroupUrlRule.php @@ -16,7 +16,7 @@ * GroupUrlRule is best used by a module which often uses module ID as the prefix for the URL rules. * For example, the following code creates a rule for the `admin` module: * - * ```php + * ``` * new GroupUrlRule([ * 'prefix' => 'admin', * 'rules' => [ diff --git a/framework/web/HttpException.php b/framework/web/HttpException.php index 78dc9bdef72..ed749865c32 100644 --- a/framework/web/HttpException.php +++ b/framework/web/HttpException.php @@ -18,7 +18,7 @@ * * Throwing an HttpException like in the following example will result in the 404 page to be displayed. * - * ```php + * ``` * if ($item === null) { // item does not exist * throw new \yii\web\HttpException(404, 'The requested Item could not be found.'); * } diff --git a/framework/web/IdentityInterface.php b/framework/web/IdentityInterface.php index 655ceebacd4..0fe76492fc2 100644 --- a/framework/web/IdentityInterface.php +++ b/framework/web/IdentityInterface.php @@ -13,7 +13,7 @@ * This interface can typically be implemented by a user model class. For example, the following * code shows how to implement this interface by a User ActiveRecord class: * - * ```php + * ``` * class User extends ActiveRecord implements IdentityInterface * { * public static function findIdentity($id) diff --git a/framework/web/JsonParser.php b/framework/web/JsonParser.php index 6d5c3e7552c..f415a2734e9 100644 --- a/framework/web/JsonParser.php +++ b/framework/web/JsonParser.php @@ -15,7 +15,7 @@ * * To enable parsing for JSON requests you can configure [[Request::parsers]] using this class: * - * ```php + * ``` * 'request' => [ * 'parsers' => [ * 'application/json' => 'yii\web\JsonParser', diff --git a/framework/web/JsonResponseFormatter.php b/framework/web/JsonResponseFormatter.php index 5cb10d3ed42..d26545283a6 100644 --- a/framework/web/JsonResponseFormatter.php +++ b/framework/web/JsonResponseFormatter.php @@ -19,7 +19,7 @@ * To configure properties like [[encodeOptions]] or [[prettyPrint]], you can configure the `response` * application component like the following: * - * ```php + * ``` * 'response' => [ * // ... * 'formatters' => [ diff --git a/framework/web/Linkable.php b/framework/web/Linkable.php index 1c7d1bdeb8f..a3fb997bc1a 100644 --- a/framework/web/Linkable.php +++ b/framework/web/Linkable.php @@ -25,7 +25,7 @@ interface Linkable * * For example, * - * ```php + * ``` * [ * 'self' => 'https://example.com/users/1', * 'friends' => [ diff --git a/framework/web/MultiFieldSession.php b/framework/web/MultiFieldSession.php index 012efcf79a5..c47236201e2 100644 --- a/framework/web/MultiFieldSession.php +++ b/framework/web/MultiFieldSession.php @@ -42,7 +42,7 @@ abstract class MultiFieldSession extends Session * * For example: * - * ```php + * ``` * function ($fields) { * return [ * 'expireDate' => Yii::$app->formatter->asDate($fields['expire']), @@ -64,7 +64,7 @@ abstract class MultiFieldSession extends Session * * For example: * - * ```php + * ``` * function ($session) { * return [ * 'user_id' => Yii::$app->user->id, diff --git a/framework/web/MultipartFormDataParser.php b/framework/web/MultipartFormDataParser.php index f6bc9d7197d..5aedfcf5e8c 100644 --- a/framework/web/MultipartFormDataParser.php +++ b/framework/web/MultipartFormDataParser.php @@ -18,7 +18,7 @@ * * In order to enable this parser you should configure [[Request::parsers]] in the following way: * - * ```php + * ``` * return [ * 'components' => [ * 'request' => [ @@ -41,7 +41,7 @@ * * Usage example: * - * ```php + * ``` * use yii\web\UploadedFile; * * $restRequestData = Yii::$app->request->getBodyParams(); diff --git a/framework/web/Request.php b/framework/web/Request.php index a1e0ea93769..5366de151e3 100644 --- a/framework/web/Request.php +++ b/framework/web/Request.php @@ -23,6 +23,9 @@ * * For more details and usage information on Request, see the [guide article on requests](guide:runtime-requests). * + * @property string|null $hostInfo Schema and hostname part (with port number if needed) of the request URL + * (e.g. `https://www.yiiframework.com`), null if can't be obtained from `$_SERVER` and wasn't set. See + * [[getHostInfo()]] for security related notes on this property. * @property-read string $absoluteUrl The currently requested absolute URL. * @property array $acceptableContentTypes The content types ordered by the quality score. Types with the * highest scores will be returned first. The array keys are the content types, while the array values are the @@ -47,9 +50,6 @@ * returned if no such header is sent. * @property-read array $eTags The entity tags. * @property-read HeaderCollection $headers The header collection. - * @property string|null $hostInfo Schema and hostname part (with port number if needed) of the request URL - * (e.g. `https://www.yiiframework.com`), null if can't be obtained from `$_SERVER` and wasn't set. See - * [[getHostInfo()]] for security related notes on this property. * @property-read string|null $hostName Hostname part of the request URL (e.g. `www.yiiframework.com`). * @property-read bool $isAjax Whether this is an AJAX (XMLHttpRequest) request. * @property-read bool $isDelete Whether this is a DELETE request. @@ -207,7 +207,7 @@ class Request extends \yii\base\Request * For example, to trust all headers listed in [[secureHeaders]] for IP addresses * in range `192.168.0.0-192.168.0.254` write the following: * - * ```php + * ``` * [ * '192.168.0.0/24', * ] @@ -771,9 +771,6 @@ public function getQueryParam($name, $defaultValue = null) * > If you don't have access to the server configuration, you can setup [[\yii\filters\HostControl]] filter at * > application level in order to protect against such kind of attack. * - * @property string|null schema and hostname part (with port number if needed) of the request URL - * (e.g. `https://www.yiiframework.com`), null if can't be obtained from `$_SERVER` and wasn't set. - * See [[getHostInfo()]] for security related notes on this property. * @return string|null schema and hostname part (with port number if needed) of the request URL * (e.g. `https://www.yiiframework.com`), null if can't be obtained from `$_SERVER` and wasn't set. * @see setHostInfo() @@ -1485,7 +1482,7 @@ public function setSecurePort($value) * * This is determined by the `Accept` HTTP header. For example, * - * ```php + * ``` * $_SERVER['HTTP_ACCEPT'] = 'text/plain; q=0.5, application/json; version=1.0, application/xml; version=2.0;'; * $types = $request->getAcceptableContentTypes(); * print_r($types); @@ -1585,7 +1582,7 @@ public function setAcceptableLanguages($value) * while the array values consisting of the corresponding quality scores and parameters. The acceptable * values with the highest quality scores will be returned first. For example, * - * ```php + * ``` * $header = 'text/plain; q=0.5, application/json; version=1.0, application/xml; version=2.0;'; * $accepts = $request->parseAcceptHeader($header); * print_r($accepts); @@ -1719,7 +1716,7 @@ public function getETags() * * Through the returned cookie collection, you may access a cookie using the following syntax: * - * ```php + * ``` * $cookie = $request->cookies['name'] * if ($cookie !== null) { * $value = $cookie->value; diff --git a/framework/web/Response.php b/framework/web/Response.php index b3936348505..9656a9c5241 100644 --- a/framework/web/Response.php +++ b/framework/web/Response.php @@ -28,7 +28,7 @@ * You can modify its configuration by adding an array to your application config under `components` * as it is shown in the following example: * - * ```php + * ``` * 'response' => [ * 'format' => yii\web\Response::FORMAT_JSON, * 'charset' => 'UTF-8', @@ -485,7 +485,7 @@ protected function sendContent() * The following is an example implementation of a controller action that allows requesting files from a directory * that is not accessible from web: * - * ```php + * ``` * public function actionFile($filename) * { * $storagePath = Yii::getAlias('@app/files'); @@ -738,7 +738,7 @@ protected function getHttpRange($fileSize) * * **Example** * - * ```php + * ``` * Yii::$app->response->xSendFile('/home/user/Pictures/picture1.jpg'); * ``` * @@ -828,14 +828,14 @@ protected function getDispositionHeaderValue($disposition, $attachmentName) * This method adds a "Location" header to the current response. Note that it does not send out * the header until [[send()]] is called. In a controller action you may use this method as follows: * - * ```php + * ``` * return Yii::$app->getResponse()->redirect($url); * ``` * * In other places, if you want to send out the "Location" header immediately, you should use * the following code: * - * ```php + * ``` * Yii::$app->getResponse()->redirect($url)->send(); * return; * ``` @@ -848,7 +848,7 @@ protected function getDispositionHeaderValue($disposition, $attachmentName) * described above. Otherwise, you should write the following JavaScript code to * handle the redirection: * - * ```javascript + * ``` * $document.ajaxComplete(function (event, xhr, settings) { * var url = xhr && xhr.getResponseHeader('X-Redirect'); * if (url) { @@ -923,7 +923,7 @@ public function redirect($url, $statusCode = 302, $checkAjax = true) * * In a controller action you may use this method like this: * - * ```php + * ``` * return Yii::$app->getResponse()->refresh(); * ``` * @@ -943,7 +943,7 @@ public function refresh($anchor = '') * * Through the returned cookie collection, you add or remove cookies as follows, * - * ```php + * ``` * // add a cookie * $response->cookies->add(new Cookie([ * 'name' => $name, diff --git a/framework/web/Session.php b/framework/web/Session.php index 0d7c1607e6e..f72a29720df 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -22,7 +22,7 @@ * * Session can be used like an array to set and get session data. For example, * - * ```php + * ``` * $session = new Session; * $session->open(); * $value1 = $session['name1']; // get session variable 'name1' @@ -46,8 +46,8 @@ * For more details and usage information on Session, see the [guide article on sessions](guide:runtime-sessions-cookies). * * @property-read array $allFlashes Flash messages (key => message or key => [message1, message2]). - * @property-read string $cacheLimiter Current cache limiter. - * @property-read array $cookieParams The session cookie parameters. + * @property string $cacheLimiter Current cache limiter. + * @property array $cookieParams The session cookie parameters. * @property-read int $count The number of session variables. * @property-write string $flash The key identifying the flash message. Note that flash messages and normal * session variables share the same name space. If you have a normal session variable using the same name, its @@ -392,7 +392,7 @@ public function getCookieParams() * Starting with Yii 2.0.21 `sameSite` is also supported. It requires PHP version 7.3.0 or higher. * For security, an exception will be thrown if `sameSite` is set while using an unsupported version of PHP. * To use this feature across different PHP versions check the version first. E.g. - * ```php + * ``` * [ * 'sameSite' => PHP_VERSION_ID >= 70300 ? yii\web\Cookie::SAME_SITE_LAX : null, * ] @@ -477,7 +477,13 @@ public function setUseCookies($value) */ public function getGCProbability() { - return (float) (ini_get('session.gc_probability') / ini_get('session.gc_divisor') * 100); + /** @phpstan-var numeric-string|false */ + $gcProbability = ini_get('session.gc_probability'); + + /** @phpstan-var numeric-string|false */ + $gcDivisor = ini_get('session.gc_divisor'); + + return (float) ($gcProbability / $gcDivisor * 100); } /** @@ -793,7 +799,7 @@ public function getFlash($key, $defaultValue = null, $delete = false) * * You may use this method to display all the flash messages in a view file: * - * ```php + * ``` * session->getAllFlashes() as $key => $message) { * echo '
' . $message . '
'; diff --git a/framework/web/UploadedFile.php b/framework/web/UploadedFile.php index 341967c27af..7e5f82459b2 100644 --- a/framework/web/UploadedFile.php +++ b/framework/web/UploadedFile.php @@ -299,7 +299,12 @@ private static function loadFilesRecursive($key, $names, $tempNames, $types, $si isset($tempResources[$i]) ? $tempResources[$i] : null ); } - } elseif ($errors != UPLOAD_ERR_NO_FILE) { + + return; + } + + /** @var int $errors */ + if ($errors != UPLOAD_ERR_NO_FILE) { self::$_files[$key] = [ 'name' => $names, 'tempName' => $tempNames, diff --git a/framework/web/UrlManager.php b/framework/web/UrlManager.php index b2b7c6703c6..d7d161b5179 100644 --- a/framework/web/UrlManager.php +++ b/framework/web/UrlManager.php @@ -23,7 +23,7 @@ * You can modify its configuration by adding an array to your application config under `components` * as it is shown in the following example: * - * ```php + * ``` * 'urlManager' => [ * 'enablePrettyUrl' => true, * 'rules' => [ @@ -86,7 +86,7 @@ class UrlManager extends Component * * Here is an example configuration for RESTful CRUD controller: * - * ```php + * ``` * [ * 'dashboard' => 'site/index', * @@ -144,7 +144,7 @@ class UrlManager extends Component * If you wish to enable URL normalization, you should configure this property manually. * For example: * - * ```php + * ``` * [ * 'class' => 'yii\web\UrlNormalizer', * 'collapseSlashes' => true, @@ -385,7 +385,7 @@ public function parseRequest($request) * if you want to specify additional query parameters for the URL being created. The * array format must be: * - * ```php + * ``` * // generates: /index.php?r=site%2Findex¶m1=value1¶m2=value2 * ['site/index', 'param1' => 'value1', 'param2' => 'value2'] * ``` @@ -393,7 +393,7 @@ public function parseRequest($request) * If you want to create a URL with an anchor, you can use the array format with a `#` parameter. * For example, * - * ```php + * ``` * // generates: /index.php?r=site%2Findex¶m1=value1#name * ['site/index', 'param1' => 'value1', '#' => 'name'] * ``` diff --git a/framework/web/UrlNormalizer.php b/framework/web/UrlNormalizer.php index 7d7459e868b..f356f740379 100644 --- a/framework/web/UrlNormalizer.php +++ b/framework/web/UrlNormalizer.php @@ -57,7 +57,7 @@ class UrlNormalizer extends BaseObject * - `404` - [[NotFoundHttpException]] will be thrown * - `callable` - custom user callback, for example: * - * ```php + * ``` * function ($route, $normalizer) { * // use custom action for redirections * $route[1]['oldRoute'] = $route[0]; diff --git a/framework/web/UrlRule.php b/framework/web/UrlRule.php index 07c9ec1dab2..7bb15411674 100644 --- a/framework/web/UrlRule.php +++ b/framework/web/UrlRule.php @@ -17,7 +17,7 @@ * To define your own URL parsing and creation logic you can extend from this class * and add it to [[UrlManager::rules]] like this: * - * ```php + * ``` * 'rules' => [ * ['class' => 'MyUrlRule', 'pattern' => '...', 'route' => 'site/index', ...], * // ... diff --git a/framework/web/User.php b/framework/web/User.php index f48b0402135..7edb08747f4 100644 --- a/framework/web/User.php +++ b/framework/web/User.php @@ -38,7 +38,7 @@ * You can modify its configuration by adding an array to your application config under `components` * as it is shown in the following example: * - * ```php + * ``` * 'user' => [ * 'identityClass' => 'app\models\User', // User must implement the IdentityInterface * 'enableAutoLogin' => true, @@ -92,7 +92,7 @@ class User extends Component * The first element of the array should be the route to the login action, and the rest of * the name-value pairs are GET parameters used to construct the login URL. For example, * - * ```php + * ``` * ['site/login', 'ref' => 1] * ``` * @@ -430,7 +430,7 @@ public function getReturnUrl($defaultUrl = null) * The first element of the array should be the route, and the rest of * the name-value pairs are GET parameters used to construct the URL. For example, * - * ```php + * ``` * ['admin/index', 'ref' => 1] * ``` */ @@ -626,7 +626,10 @@ protected function getIdentityAndDurationFromCookie() $data = json_decode($value, true); if (is_array($data) && count($data) == 3) { list($id, $authKey, $duration) = $data; - /** @var IdentityInterface $class */ + /** + * @var IdentityInterface + * @phpstan-var class-string + */ $class = $this->identityClass; $identity = $class::findIdentity($id); if ($identity !== null) { diff --git a/framework/web/View.php b/framework/web/View.php index 94524036055..5ab16d4bcb3 100644 --- a/framework/web/View.php +++ b/framework/web/View.php @@ -24,7 +24,7 @@ * You can modify its configuration by adding an array to your application config under `components` * as it is shown in the following example: * - * ```php + * ``` * 'view' => [ * 'theme' => 'app\themes\MyTheme', * 'renderers' => [ @@ -374,7 +374,7 @@ public function registerAssetBundle($name, $position = null) * * For example, a description meta tag can be added like the following: * - * ```php + * ``` * $view->registerMetaTag([ * 'name' => 'description', * 'content' => 'This website is about funny raccoons.' @@ -401,7 +401,7 @@ public function registerMetaTag($options, $key = null) * Registers CSRF meta tags. * They are rendered dynamically to retrieve a new CSRF token for each request. * - * ```php + * ``` * $view->registerCsrfMetaTags(); * ``` * @@ -424,7 +424,7 @@ public function registerCsrfMetaTags() * For example, a link tag for a custom [favicon](https://www.w3.org/2005/10/howto-favicon) * can be added like the following: * - * ```php + * ``` * $view->registerLinkTag(['rel' => 'icon', 'type' => 'image/png', 'href' => '/myicon.png']); * ``` * diff --git a/framework/web/ViewAction.php b/framework/web/ViewAction.php index 26435f37857..a6bd51be3ff 100644 --- a/framework/web/ViewAction.php +++ b/framework/web/ViewAction.php @@ -27,6 +27,9 @@ * @author Alexander Makarov * @author Qiang Xue * @since 2.0 + * + * @template T of Controller + * @extends Action */ class ViewAction extends Action { diff --git a/framework/widgets/ActiveField.php b/framework/widgets/ActiveField.php index 54712d7a3b9..c117b717318 100644 --- a/framework/widgets/ActiveField.php +++ b/framework/widgets/ActiveField.php @@ -188,7 +188,7 @@ public function __toString() * and use them as the content. * If a callable, it will be called to generate the content. The signature of the callable should be: * - * ```php + * ``` * function ($field) { * return $html; * } @@ -751,7 +751,7 @@ public function radioList($items, $options = []) * For example to use the [[MaskedInput]] widget to get some date input, you can use * the following code, assuming that `$form` is your [[ActiveForm]] instance: * - * ```php + * ``` * $form->field($model, 'date')->widget(\yii\widgets\MaskedInput::class, [ * 'mask' => '99/99/9999', * ]); diff --git a/framework/widgets/ActiveForm.php b/framework/widgets/ActiveForm.php index 5251ad4cd35..a9d72de06a4 100644 --- a/framework/widgets/ActiveForm.php +++ b/framework/widgets/ActiveForm.php @@ -50,7 +50,7 @@ class ActiveForm extends Widget * will add new parameters instead of replacing existing ones. * You may set [[action]] explicitly to avoid this: * - * ```php + * ``` * $form = ActiveForm::begin([ * 'method' => 'get', * 'action' => ['controller/action'], @@ -73,7 +73,7 @@ class ActiveForm extends Widget * This can be either a configuration array or an anonymous function returning a configuration array. * If the latter, the signature should be as follows: * - * ```php + * ``` * function ($model, $attribute) * ``` * @@ -377,7 +377,7 @@ public function endField() * For example, you may use the following code in a controller action to respond * to an AJAX validation request: * - * ```php + * ``` * $model = new Post; * $model->load(Yii::$app->request->post()); * if (Yii::$app->request->isAjax) { @@ -390,7 +390,7 @@ public function endField() * To validate multiple models, simply pass each model as a parameter to this method, like * the following: * - * ```php + * ``` * ActiveForm::validate($model1, $model2, ...); * ``` * @@ -435,7 +435,7 @@ public static function validate($model, $attributes = null) * For example, you may use the following code in a controller action to respond * to an AJAX validation request: * - * ```php + * ``` * // ... load $models ... * if (Yii::$app->request->isAjax) { * Yii::$app->response->format = Response::FORMAT_JSON; diff --git a/framework/widgets/Block.php b/framework/widgets/Block.php index cc4ee5271c8..5544ec8be3d 100644 --- a/framework/widgets/Block.php +++ b/framework/widgets/Block.php @@ -16,7 +16,7 @@ * [[\yii\base\View]] component contains two methods [[\yii\base\View::beginBlock()]] and [[\yii\base\View::endBlock()]]. * The general idea is that you're defining block default in a view or layout: * - * ```php + * ``` * beginBlock('messages', true) ?> * Nothing. * endBlock() ?> @@ -24,7 +24,7 @@ * * And then overriding default in sub-views: * - * ```php + * ``` * beginBlock('username') ?> * Umm... hello? * endBlock() ?> diff --git a/framework/widgets/Breadcrumbs.php b/framework/widgets/Breadcrumbs.php index 9def4aa5db7..fbf94724735 100644 --- a/framework/widgets/Breadcrumbs.php +++ b/framework/widgets/Breadcrumbs.php @@ -22,7 +22,7 @@ * * To use Breadcrumbs, you need to configure its [[links]] property, which specifies the links to be displayed. For example, * - * ```php + * ``` * // $this is the view object currently being used * echo Breadcrumbs::widget([ * 'itemTemplate' => "
  • {link}
  • \n", // template for all links @@ -42,7 +42,7 @@ * You can use a view parameter (e.g. `$this->params['breadcrumbs']`) to configure the links in different * views. In the layout view, you assign this view parameter to the [[links]] property like the following: * - * ```php + * ``` * // $this is the view object currently being used * echo Breadcrumbs::widget([ * 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], @@ -79,7 +79,7 @@ class Breadcrumbs extends Widget * the widget will not render anything. Each array element represents a single link in the breadcrumbs * with the following structure: * - * ```php + * ``` * [ * 'label' => 'label of the link', // required * 'url' => 'url of the link', // optional, will be processed by Url::to() @@ -94,7 +94,7 @@ class Breadcrumbs extends Widget * for the hyperlink tag. For example, the following link specification will generate a hyperlink * with CSS class `external`: * - * ```php + * ``` * [ * 'label' => 'demo', * 'url' => 'https://example.com', @@ -104,7 +104,7 @@ class Breadcrumbs extends Widget * * Since version 2.0.3 each individual link can override global [[encodeLabels]] param like the following: * - * ```php + * ``` * [ * 'label' => 'Hello!', * 'encode' => false, diff --git a/framework/widgets/ContentDecorator.php b/framework/widgets/ContentDecorator.php index 1b7d00781db..39f3756ae2c 100644 --- a/framework/widgets/ContentDecorator.php +++ b/framework/widgets/ContentDecorator.php @@ -14,7 +14,7 @@ * ContentDecorator records all output between [[begin()]] and [[end()]] calls, passes it to the given view file * as `$content` and then echoes rendering result. * - * ```php + * ``` * '@app/views/layouts/base.php', * 'params' => [], @@ -29,7 +29,7 @@ * There are [[\yii\base\View::beginContent()]] and [[\yii\base\View::endContent()]] wrapper methods in the * [[\yii\base\View]] component to make syntax more friendly. In the view these could be used as follows: * - * ```php + * ``` * beginContent('@app/views/layouts/base.php') ?> * * some content here diff --git a/framework/widgets/DetailView.php b/framework/widgets/DetailView.php index 06b9fa4b566..81fba62b2e6 100644 --- a/framework/widgets/DetailView.php +++ b/framework/widgets/DetailView.php @@ -29,7 +29,7 @@ * * A typical usage of DetailView is as follows: * - * ```php + * ``` * echo DetailView::widget([ * 'model' => $model, * 'attributes' => [ @@ -76,7 +76,7 @@ class DetailView extends Widget * according to the `format` option. Since version 2.0.11 it can be defined as closure with the following * parameters: * - * ```php + * ``` * function ($model, $widget) * ``` * @@ -96,7 +96,7 @@ class DetailView extends Widget * and `{value}` will be replaced with the label and the value of the corresponding attribute. * If a callback (e.g. an anonymous function), the signature must be as follows: * - * ```php + * ``` * function ($attribute, $index, $widget) * ``` * diff --git a/framework/widgets/FragmentCache.php b/framework/widgets/FragmentCache.php index 580e5f497dd..93c8f060924 100644 --- a/framework/widgets/FragmentCache.php +++ b/framework/widgets/FragmentCache.php @@ -45,7 +45,7 @@ class FragmentCache extends Widget implements DynamicContentAwareInterface * This can be either a [[Dependency]] object or a configuration array for creating the dependency object. * For example, * - * ```php + * ``` * [ * 'class' => 'yii\caching\DbDependency', * 'sql' => 'SELECT MAX(updated_at) FROM post', @@ -62,7 +62,7 @@ class FragmentCache extends Widget implements DynamicContentAwareInterface * The following variation setting will cause the content to be cached in different versions * according to the current application language: * - * ```php + * ``` * [ * Yii::$app->language, * ] diff --git a/framework/widgets/InputWidget.php b/framework/widgets/InputWidget.php index 6bdab5a340b..78e01d61241 100644 --- a/framework/widgets/InputWidget.php +++ b/framework/widgets/InputWidget.php @@ -23,7 +23,7 @@ * Classes extending from this widget can be used in an [[\yii\widgets\ActiveForm|ActiveForm]] * using the [[\yii\widgets\ActiveField::widget()|widget()]] method, for example like this: * - * ```php + * ``` * field($model, 'from_date')->widget('WidgetClassName', [ * // configure additional widget properties here * ]) ?> diff --git a/framework/widgets/LinkPager.php b/framework/widgets/LinkPager.php index 9056981c31e..3e73eb58081 100644 --- a/framework/widgets/LinkPager.php +++ b/framework/widgets/LinkPager.php @@ -84,7 +84,7 @@ class LinkPager extends Widget * @var array the options for the disabled tag to be generated inside the disabled list element. * In order to customize the html tag, please use the tag key. * - * ```php + * ``` * $disabledListItemSubTagOptions = ['tag' => 'div', 'class' => 'disabled-div']; * ``` * @since 2.0.11 diff --git a/framework/widgets/ListView.php b/framework/widgets/ListView.php index 9ac0c0c24f6..a38595a6866 100644 --- a/framework/widgets/ListView.php +++ b/framework/widgets/ListView.php @@ -33,7 +33,7 @@ class ListView extends BaseListView * * If this property is specified as an anonymous function, it should have the following signature: * - * ```php + * ``` * function ($model, $key, $index, $widget) * ``` * @@ -54,7 +54,7 @@ class ListView extends BaseListView * * If this property is specified as a callback, it should have the following signature: * - * ```php + * ``` * function ($model, $key, $index, $widget) * ``` */ @@ -78,7 +78,7 @@ class ListView extends BaseListView * @var Closure an anonymous function that is called once BEFORE rendering each data model. * It should have the following signature: * - * ```php + * ``` * function ($model, $key, $index, $widget) * ``` * diff --git a/framework/widgets/MaskedInput.php b/framework/widgets/MaskedInput.php index f7307986c0e..104dec71b26 100644 --- a/framework/widgets/MaskedInput.php +++ b/framework/widgets/MaskedInput.php @@ -21,7 +21,7 @@ * To use MaskedInput, you must set the [[mask]] property. The following example * shows how to use MaskedInput to collect phone numbers: * - * ```php + * ``` * echo MaskedInput::widget([ * 'name' => 'phone', * 'mask' => '999-999-9999', @@ -31,7 +31,7 @@ * You can also use this widget in an [[ActiveForm]] using the [[ActiveField::widget()|widget()]] * method, for example like this: * - * ```php + * ``` * field($model, 'from_date')->widget(\yii\widgets\MaskedInput::class, [ * 'mask' => '999-999-9999', * ]) ?> diff --git a/framework/widgets/Menu.php b/framework/widgets/Menu.php index d474ceb3a0e..01ba758a947 100644 --- a/framework/widgets/Menu.php +++ b/framework/widgets/Menu.php @@ -28,7 +28,7 @@ * * The following example shows how to use Menu: * - * ```php + * ``` * echo Menu::widget([ * 'items' => [ * // Important: you need to specify url as 'controller/action', diff --git a/framework/widgets/Pjax.php b/framework/widgets/Pjax.php index fceaf1821a9..b2ccc810ebd 100644 --- a/framework/widgets/Pjax.php +++ b/framework/widgets/Pjax.php @@ -31,7 +31,7 @@ * The following example shows how to use Pjax with the [[\yii\grid\GridView]] widget so that the grid pagination, * sorting and filtering can be done via pjax: * - * ```php + * ``` * use yii\widgets\Pjax; * * Pjax::begin(); diff --git a/framework/widgets/Spaceless.php b/framework/widgets/Spaceless.php index c766dafa239..3bd3c1dd405 100644 --- a/framework/widgets/Spaceless.php +++ b/framework/widgets/Spaceless.php @@ -15,7 +15,7 @@ * * Usage example: * - * ```php + * ``` * * *