diff --git a/docs/internals-ja/core-code-style.md b/docs/internals-ja/core-code-style.md index d2503e4..979a7a5 100644 --- a/docs/internals-ja/core-code-style.md +++ b/docs/internals-ja/core-code-style.md @@ -115,7 +115,7 @@ class Foo - クラスのメソッドは常に修飾子 `private`、`protected` または `public` を使って、可視性を宣言すべきです。`var` は許可されません。 - 関数の開始の中括弧は関数宣言の次の行に置くべきです。 -~~~ +``` /** * ドキュメント */ @@ -130,7 +130,7 @@ class Foo return $value; } } -~~~ +``` ### 4.4 Doc ブロック @@ -396,9 +396,9 @@ class Component extends \yii\base\Object * 返された [[Vector]] オブジェクトを操作して、ハンドラを追加したり削除したり出来る。 * 例えば、 * - * ~~~ + * ``` * $component->getEventHandlers($eventName)->insertAt(0, $eventHandler); - * ~~~ + * ``` * * @param string $name イベントの名前 * @return Vector イベントにアタッチされたハンドラのリスト diff --git a/docs/internals-uk/core-code-style.md b/docs/internals-uk/core-code-style.md index 958a97a..95687c5 100644 --- a/docs/internals-uk/core-code-style.md +++ b/docs/internals-uk/core-code-style.md @@ -398,9 +398,9 @@ class Component extends \yii\base\Object * You may manipulate the returned [[Vector]] object by adding or removing handlers. * For example, * - * ~~~ + * ``` * $component->getEventHandlers($eventName)->insertAt(0, $eventHandler); - * ~~~ + * ``` * * @param string $name the event name * @return Vector list of attached event handlers for the event diff --git a/docs/internals/core-code-style.md b/docs/internals/core-code-style.md index 2016a0a..e8382fd 100644 --- a/docs/internals/core-code-style.md +++ b/docs/internals/core-code-style.md @@ -115,7 +115,7 @@ class Foo `public` modifiers. `var` is not allowed. - Opening brace of a function should be on the line after the function declaration. -~~~ +``` /** * Documentation */ @@ -130,7 +130,7 @@ class Foo return $value; } } -~~~ +``` ### 4.4 Doc blocks @@ -398,9 +398,9 @@ class Component extends \yii\base\Object * You may manipulate the returned [[Vector]] object by adding or removing handlers. * For example, * - * ~~~ + * ``` * $component->getEventHandlers($eventName)->insertAt(0, $eventHandler); - * ~~~ + * ``` * * @param string $name the event name * @return Vector list of attached event handlers for the event diff --git a/framework/BaseYii.php b/framework/BaseYii.php index b7cc5f7..7e590e0 100644 --- a/framework/BaseYii.php +++ b/framework/BaseYii.php @@ -429,14 +429,14 @@ class BaseYii * 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'); * // some other code to be profiled * \Yii::endProfile('block2'); * \Yii::endProfile('block1'); - * ~~~ + * ``` * @param string $token token for the code block * @param string $category the category of this log message * @see endProfile() diff --git a/framework/assets/yii.js b/framework/assets/yii.js index 9a95fb0..fd83a8d 100644 --- a/framework/assets/yii.js +++ b/framework/assets/yii.js @@ -16,7 +16,7 @@ * * A module may be structured as follows: * - * ~~~ + * ```javascript * yii.sample = (function($) { * var pub = { * // whether this module is currently active. If false, init() will not be called for this module @@ -33,7 +33,7 @@ * * return pub; * })(jQuery); - * ~~~ + * ``` * * Using this structure, you can define public and private functions/properties for a module. * Private functions/properties are only visible within the module, while public functions/properties diff --git a/framework/base/Action.php b/framework/base/Action.php index bd884c5..2c0ff1b 100644 --- a/framework/base/Action.php +++ b/framework/base/Action.php @@ -21,9 +21,9 @@ use Yii; * 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') { ... } - * ~~~ + * ``` * * And the parameters provided for the action are: `['id' => 1]`. * Then the `run()` method will be invoked as `run(1)` automatically. diff --git a/framework/base/Application.php b/framework/base/Application.php index c864327..b85b8a6 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -140,7 +140,7 @@ abstract class Application extends Module * @var array list of installed Yii extensions. Each array element represents a single extension * with the following structure: * - * ~~~ + * ```php * [ * 'name' => 'extension name', * 'version' => 'version number', @@ -150,7 +150,7 @@ abstract class Application extends Module * '@alias2' => 'to/path2', * ], * ] - * ~~~ + * ``` * * The "bootstrap" class listed above will be instantiated during the application * [[bootstrap()|bootstrapping process]]. If the class implements [[BootstrapInterface]], diff --git a/framework/base/Behavior.php b/framework/base/Behavior.php index a55afaf..46505e9 100644 --- a/framework/base/Behavior.php +++ b/framework/base/Behavior.php @@ -45,12 +45,12 @@ class Behavior extends Object * * The following is an example: * - * ~~~ + * ```php * [ * Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate', * Model::EVENT_AFTER_VALIDATE => 'myAfterValidate', * ] - * ~~~ + * ``` * * @return array events (array keys) and the corresponding event handler methods (array values). */ diff --git a/framework/base/Component.php b/framework/base/Component.php index 803a112..da85049 100644 --- a/framework/base/Component.php +++ b/framework/base/Component.php @@ -27,11 +27,11 @@ use Yii; * * To attach an event handler to an event, call [[on()]]: * - * ~~~ + * ```php * $post->on('update', function ($event) { * // send email notification * }); - * ~~~ + * ``` * * In the above, an anonymous function is attached to the "update" event of the post. You may attach * the following types of event handlers: @@ -43,31 +43,31 @@ use Yii; * * The signature of an event handler should be like the following: * - * ~~~ + * ```php * function foo($event) - * ~~~ + * ``` * * where `$event` is an [[Event]] object which includes parameters associated with the event. * * 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) { ... } * ] - * ~~~ + * ``` * * where `on add` stands for attaching an event to the `add` event. * * 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); - * ~~~ + * ``` * * A behavior is an instance of [[Behavior]] or its child class. A component can be attached with one or multiple * behaviors. When a behavior is attached to a component, its public properties and methods can be accessed via the @@ -79,13 +79,13 @@ use Yii; * 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', * ], * ] - * ~~~ + * ``` * * where `as tree` stands for attaching a behavior named `tree`, and the array will be passed to [[\Yii::createObject()]] * to create the behavior object. @@ -411,13 +411,13 @@ class Component extends Object * 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', * 'property2' => 'value2', * ] - * ~~~ + * ``` * * Note that a behavior class must extend from [[Behavior]]. Behavior names can be strings * or integers. If the former, they uniquely identify the behaviors. If the latter, the corresponding @@ -450,18 +450,18 @@ class Component extends Object * The event handler must be a valid PHP callback. The following are * some examples: * - * ~~~ + * ``` * function ($event) { ... } // anonymous function * [$object, 'handleClick'] // $object->handleClick() * ['Page', 'handleClick'] // Page::handleClick() * 'handleClick' // global function handleClick() - * ~~~ + * ``` * * The event handler must be defined with the following signature, * - * ~~~ + * ``` * function ($event) - * ~~~ + * ``` * * where `$event` is an [[Event]] object which includes parameters associated with the event. * diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 19eb478..8852d8a 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -90,7 +90,7 @@ class Controller extends Component implements ViewContextInterface * 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' => [ @@ -99,7 +99,7 @@ class Controller extends Component implements ViewContextInterface * 'property2' => 'value2', * ], * ]; - * ~~~ + * ``` * * [[\Yii::createObject()]] will be used later to create the requested action * using the configuration provided here. diff --git a/framework/base/Event.php b/framework/base/Event.php index e6a602c..b801aa2 100644 --- a/framework/base/Event.php +++ b/framework/base/Event.php @@ -60,11 +60,11 @@ class Event extends Object * For example, the following code attaches an event handler to `ActiveRecord`'s * `afterInsert` event: * - * ~~~ + * ```php * Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_INSERT, function ($event) { * Yii::trace(get_class($event->sender) . ' is inserted.'); * }); - * ~~~ + * ``` * * The handler will be invoked for EVERY successful ActiveRecord insertion. * diff --git a/framework/base/Model.php b/framework/base/Model.php index 15ab32d..4d8977f 100644 --- a/framework/base/Model.php +++ b/framework/base/Model.php @@ -92,14 +92,14 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab * * Each rule is an array with the following structure: * - * ~~~ + * ```php * [ * ['attribute1', 'attribute2'], * 'validator type', * 'on' => ['scenario1', 'scenario2'], - * ...other parameters... + * //...other parameters... * ] - * ~~~ + * ``` * * where * @@ -114,10 +114,10 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab * 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) - * ~~~ + * ``` * * In the above `$attribute` refers to the attribute currently being validated while `$params` contains an array of * validator configuration options such as `max` in case of `string` validator. The value of the attribute currently being validated @@ -129,7 +129,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab * * Below are some examples: * - * ~~~ + * ```php * [ * // built-in "required" validator * [['username', 'password'], 'required'], @@ -142,7 +142,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab * // a validator of class "DateRangeValidator" * ['dateRange', 'DateRangeValidator'], * ]; - * ~~~ + * ``` * * Note, in order to inherit rules defined in the parent class, a child class needs to * merge the parent rules with child rules using functions such as `array_merge()`. @@ -397,9 +397,9 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab * manipulate it by inserting or removing validators (useful in model behaviors). * For example, * - * ~~~ + * ```php * $model->validators[] = $newValidator; - * ~~~ + * ``` * * @return ArrayObject|\yii\validators\Validator[] all the validators declared in the model. */ @@ -541,7 +541,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab * @return array errors for all attributes or the specified attribute. Empty array is returned if no error. * Note that when returning errors for all attributes, the result is a two-dimensional array, like the following: * - * ~~~ + * ```php * [ * 'username' => [ * 'Username is required.', @@ -551,7 +551,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab * 'Email address is invalid.', * ] * ] - * ~~~ + * ``` * * @see getFirstErrors() * @see getFirstError() diff --git a/framework/base/Module.php b/framework/base/Module.php index 53a7c2e..e497ed9 100644 --- a/framework/base/Module.php +++ b/framework/base/Module.php @@ -74,7 +74,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' => [ @@ -82,7 +82,7 @@ class Module extends ServiceLocator * 'pageTitle' => 'something new', * ], * ] - * ~~~ + * ``` */ public $controllerMap = []; /** @@ -293,12 +293,12 @@ class Module extends ServiceLocator * (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 * ] - * ~~~ + * ``` */ public function setAliases($aliases) { @@ -414,7 +414,7 @@ class Module extends ServiceLocator * * The following is an example for registering two sub-modules: * - * ~~~ + * ```php * [ * 'comment' => [ * 'class' => 'app\modules\comment\CommentModule', @@ -422,7 +422,7 @@ class Module extends ServiceLocator * ], * 'booking' => ['class' => 'app\modules\booking\BookingModule'], * ] - * ~~~ + * ``` * * @param array $modules modules (id => module configuration or instances) */ diff --git a/framework/base/Object.php b/framework/base/Object.php index 0545711..220ab3e 100644 --- a/framework/base/Object.php +++ b/framework/base/Object.php @@ -15,7 +15,7 @@ use Yii; * 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() @@ -27,19 +27,19 @@ use Yii; * { * $this->_label = $value; * } - * ~~~ + * ``` * * Property names are *case-insensitive*. * * 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'); * $object->label = 'abc'; - * ~~~ + * ``` * * If a property has only a getter method and has no setter method, it is considered as *read-only*. In this case, trying * to modify the property value will cause an exception. @@ -60,13 +60,13 @@ use Yii; * In order to ensure the above life cycles, if a child class of Object needs to override the constructor, * it should be done like the following: * - * ~~~ + * ```php * public function __construct($param1, $param2, ..., $config = []) * { * ... * parent::__construct($config); * } - * ~~~ + * ``` * * That is, a `$config` parameter (defaults to `[]`) should be declared as the last parameter * of the constructor, and the parent implementation should be called at the end of the constructor. diff --git a/framework/base/Security.php b/framework/base/Security.php index 130499b..3b3ac11 100644 --- a/framework/base/Security.php +++ b/framework/base/Security.php @@ -520,7 +520,7 @@ class Security extends Component * 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... @@ -531,7 +531,7 @@ class Security extends Component * } else { * // password is bad * } - * ~~~ + * ``` * * @param string $password The password to be hashed. * @param integer $cost Cost parameter used by the Blowfish hash algorithm. diff --git a/framework/base/Theme.php b/framework/base/Theme.php index 6d16543..2306621 100644 --- a/framework/base/Theme.php +++ b/framework/base/Theme.php @@ -33,14 +33,14 @@ use yii\helpers\FileHelper; * * It is possible to map a single path to multiple paths. For example, * - * ~~~ + * ```php * 'pathMap' => [ * '@app/views' => [ * '@app/themes/christmas', * '@app/themes/basic', * ], * ] - * ~~~ + * ``` * * In this case, the themed version could be either `@app/themes/christmas/site/index.php` or * `@app/themes/basic/site/index.php`. The former has precedence over the latter if both files exist. @@ -48,14 +48,14 @@ use yii\helpers\FileHelper; * 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', * 'baseUrl' => '@web/themes/basic', * ], * ], - * ~~~ + * ``` * * The above configuration specifies a theme located under the "themes/basic" directory of the Web folder * that contains the entry script of the application. If your theme is designed to handle modules, diff --git a/framework/base/View.php b/framework/base/View.php index 74b0515..53c0eab 100644 --- a/framework/base/View.php +++ b/framework/base/View.php @@ -56,12 +56,12 @@ class View extends Component * 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'], * ] - * ~~~ + * ``` * * If no renderer is available for the given view file, the view file will be treated as a normal PHP * and rendered via [[renderPhpFile()]]. @@ -404,11 +404,11 @@ class View extends Component * 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... + * //...layout content here... * endContent(); ?> - * ~~~ + * ``` * * @param string $viewFile the view file that will be used to decorate the content enclosed by this widget. * This can be specified as either the view file path or path alias. @@ -440,12 +440,12 @@ class View extends Component * 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(); * } - * ~~~ + * ``` * * @param string $id a unique ID identifying the fragment to be cached. * @param array $properties initial property values for [[FragmentCache]] diff --git a/framework/behaviors/AttributeBehavior.php b/framework/behaviors/AttributeBehavior.php index ced7ef0..6806658 100644 --- a/framework/behaviors/AttributeBehavior.php +++ b/framework/behaviors/AttributeBehavior.php @@ -21,7 +21,7 @@ use yii\base\Event; * [[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() @@ -39,7 +39,7 @@ use yii\base\Event; * ], * ]; * } - * ~~~ + * ``` * * @author Luciano Baraglia * @author Qiang Xue diff --git a/framework/caching/DbCache.php b/framework/caching/DbCache.php index b27a82c..8c1fcbb 100644 --- a/framework/caching/DbCache.php +++ b/framework/caching/DbCache.php @@ -47,13 +47,13 @@ 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), * data BLOB * ); - * ~~~ + * ``` * * where 'BLOB' refers to the BLOB-type of your preferred DBMS. Below are the BLOB type * that can be used for some popular DBMS: diff --git a/framework/caching/MemCache.php b/framework/caching/MemCache.php index 876762b..3fecb42 100644 --- a/framework/caching/MemCache.php +++ b/framework/caching/MemCache.php @@ -28,7 +28,7 @@ use yii\base\InvalidConfigException; * * To use MemCache as the cache application component, configure the application as follows, * - * ~~~ + * ```php * [ * 'components' => [ * 'cache' => [ @@ -48,7 +48,7 @@ use yii\base\InvalidConfigException; * ], * ], * ] - * ~~~ + * ``` * * In the above, two memcache servers are used: server1 and server2. You can configure more properties of * each server, such as `persistent`, `weight`, `timeout`. Please see [[MemCacheServer]] for available options. diff --git a/framework/console/Application.php b/framework/console/Application.php index b392d56..cc94fde 100644 --- a/framework/console/Application.php +++ b/framework/console/Application.php @@ -34,9 +34,9 @@ defined('STDERR') or define('STDERR', fopen('php://stderr', 'w')); * * To run the console application, enter the following on the command line: * - * ~~~ + * ``` * yii [--param1=value1 --param2 ...] - * ~~~ + * ``` * * where `` refers to a controller route in the form of `ModuleID/ControllerID/ActionID` * (e.g. `sitemap/create`), and `param1`, `param2` refers to a set of named parameters that @@ -46,9 +46,9 @@ defined('STDERR') or define('STDERR', fopen('php://stderr', 'w')); * A `help` command is provided by default, which lists available commands and shows their usage. * To use this command, simply type: * - * ~~~ + * ``` * yii help - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 diff --git a/framework/console/Controller.php b/framework/console/Controller.php index 0945ea5..97296a4 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -20,9 +20,9 @@ use yii\helpers\Console; * Users call a console command by specifying the corresponding route which identifies a controller action. * The `yii` program is used when calling a console command, like the following: * - * ~~~ + * ``` * yii [--param1=value1 --param2 ...] - * ~~~ + * ``` * * where `` is a route to a controller action and the params will be populated as properties of a command. * See [[options()]] for details. @@ -166,9 +166,9 @@ class Controller extends \yii\base\Controller * * Example: * - * ~~~ + * ``` * echo $this->ansiFormat('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE); - * ~~~ + * ``` * * @param string $string the string to be formatted * @return string @@ -191,9 +191,9 @@ class Controller extends \yii\base\Controller * * Example: * - * ~~~ + * ``` * $this->stdout('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE); - * ~~~ + * ``` * * @param string $string the string to print * @return int|boolean Number of bytes printed or false on error @@ -216,9 +216,9 @@ class Controller extends \yii\base\Controller * * Example: * - * ~~~ + * ``` * $this->stderr('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE); - * ~~~ + * ``` * * @param string $string the string to print * @return int|boolean Number of bytes printed or false on error diff --git a/framework/console/controllers/AssetController.php b/framework/console/controllers/AssetController.php index 8535e29..6cfa540 100644 --- a/framework/console/controllers/AssetController.php +++ b/framework/console/controllers/AssetController.php @@ -58,13 +58,13 @@ 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', * 'depends' => [ ... ], * ] - * ~~~ + * ``` * * File names can contain placeholder "{hash}", which will be filled by the hash of the resulting file. * @@ -74,7 +74,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', @@ -97,7 +97,7 @@ class AssetController extends Controller * 'css' => 'css/all-{hash}.css', * 'depends' => [], // Include all remaining assets * ], - * ~~~ + * ``` */ public $targets = []; /** diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 0279467..9742cf0 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -108,10 +108,10 @@ abstract class BaseMigrateController extends Controller * Upgrades the application by applying new migrations. * For example, * - * ~~~ + * ``` * yii migrate # apply all new migrations * yii migrate 3 # apply the first 3 new migrations - * ~~~ + * ``` * * @param integer $limit the number of new migrations to be applied. If 0, it means * applying all available new migrations. @@ -166,11 +166,11 @@ abstract class BaseMigrateController extends Controller * Downgrades the application by reverting old migrations. * For example, * - * ~~~ + * ``` * yii migrate/down # revert the last migration * yii migrate/down 3 # revert the last 3 migrations * yii migrate/down all # revert all migrations - * ~~~ + * ``` * * @param integer $limit the number of migrations to be reverted. Defaults to 1, * meaning the last applied migration will be reverted. @@ -228,11 +228,11 @@ abstract class BaseMigrateController extends Controller * This command will first revert the specified migrations, and then apply * them again. For example, * - * ~~~ + * ``` * yii migrate/redo # redo the last applied migration * yii migrate/redo 3 # redo the last 3 applied migrations * yii migrate/redo all # redo all migrations - * ~~~ + * ``` * * @param integer $limit the number of migrations to be redone. Defaults to 1, * meaning the last applied migration will be redone. @@ -298,12 +298,12 @@ abstract class BaseMigrateController extends Controller * This command will first revert the specified migrations, and then apply * them again. For example, * - * ~~~ + * ``` * yii migrate/to 101129_185401 # using timestamp * yii migrate/to m101129_185401_create_user_table # using full name * yii migrate/to 1392853618 # using UNIX timestamp * yii migrate/to "2014-02-15 13:00:50" # using strtotime() parseable string - * ~~~ + * ``` * * @param string $version either the version name or the certain time value in the past * that the application should be migrated to. This can be either the timestamp, @@ -329,10 +329,10 @@ abstract class BaseMigrateController extends Controller * * No actual migration will be performed. * - * ~~~ + * ``` * yii migrate/mark 101129_185401 # using timestamp * yii migrate/mark m101129_185401_create_user_table # using full name - * ~~~ + * ``` * * @param string $version the version at which the migration history should be marked. * This can be either the timestamp or the full name of the migration. @@ -391,11 +391,11 @@ abstract class BaseMigrateController extends Controller * This command will show the list of migrations that have been applied * so far. For example, * - * ~~~ + * ``` * yii migrate/history # showing the last 10 migrations * yii migrate/history 5 # showing the last 5 migrations * yii migrate/history all # showing the whole history - * ~~~ + * ``` * * @param integer $limit the maximum number of migrations to be displayed. * If it is "all", the whole migration history will be displayed. @@ -435,11 +435,11 @@ abstract class BaseMigrateController extends Controller * This command will show the new migrations that have not been applied. * For example, * - * ~~~ + * ``` * yii migrate/new # showing the first 10 new migrations * yii migrate/new 5 # showing the first 5 new migrations * yii migrate/new all # showing all new migrations - * ~~~ + * ``` * * @param integer $limit the maximum number of new migrations to be displayed. * If it is `all`, all available new migrations will be displayed. @@ -482,9 +482,9 @@ abstract class BaseMigrateController extends Controller * After using this command, developers should modify the created migration * skeleton by filling up the actual migration logic. * - * ~~~ + * ``` * yii migrate/create create_user_table - * ~~~ + * ``` * * @param string $name the name of the new migration. This should only contain * letters, digits and/or underscores. diff --git a/framework/console/controllers/CacheController.php b/framework/console/controllers/CacheController.php index 3b8a89e..1e612cf 100644 --- a/framework/console/controllers/CacheController.php +++ b/framework/console/controllers/CacheController.php @@ -56,10 +56,10 @@ class CacheController extends Controller * Flushes given cache components. * For example, * - * ~~~ + * ``` * # flushes caches specified by their id: "first", "second", "third" * yii cache/flush first second third - * ~~~ + * ``` * */ public function actionFlush() @@ -127,10 +127,10 @@ class CacheController extends Controller /** * Clears DB schema cache for a given connection component. * - * ~~~ + * ``` * # clears cache schema specified by component id: "db" * yii cache/flush-schema db - * ~~~ + * ``` * * @param string $db id connection component * @return int exit code diff --git a/framework/console/controllers/FixtureController.php b/framework/console/controllers/FixtureController.php index 7809af2..0de5eed 100644 --- a/framework/console/controllers/FixtureController.php +++ b/framework/console/controllers/FixtureController.php @@ -17,7 +17,7 @@ use yii\test\FixtureTrait; /** * Manages fixture data loading and unloading. * - * ~~~ + * ``` * #load fixtures from UsersFixture class with default namespace "tests\unit\fixtures" * yii fixture/load User * @@ -32,7 +32,7 @@ use yii\test\FixtureTrait; * * #load fixtures with different namespace. * yii fixture/load User --namespace=alias\my\custom\namespace\goes\here - * ~~~ + * ``` * * The `unload` sub-command can be used similarly to unload fixtures. * @@ -74,7 +74,7 @@ class FixtureController extends Controller * Loads the specified fixture data. * For example, * - * ~~~ + * ``` * # load the fixture data specified by User and UserProfile. * # any existing fixture data will be removed first * yii fixture/load User UserProfile @@ -84,7 +84,7 @@ class FixtureController extends Controller * * # load all fixtures except User and UserProfile * yii fixture/load "*" -User -UserProfile - * ~~~ + * ``` * * @throws Exception if the specified fixture does not exist. */ @@ -155,7 +155,7 @@ class FixtureController extends Controller * Unloads the specified fixtures. * For example, * - * ~~~ + * ``` * # unload the fixture data specified by User and UserProfile. * yii fixture/unload User UserProfile * @@ -164,7 +164,7 @@ class FixtureController extends Controller * * # unload all fixtures except User and UserProfile * yii fixture/unload "*" -User -UserProfile - * ~~~ + * ``` * * @throws Exception if the specified fixture does not exist. */ @@ -434,7 +434,7 @@ class FixtureController extends Controller * 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', @@ -445,7 +445,7 @@ class FixtureController extends Controller * ... * ], * ] - * ~~~ + * ``` * @param array $fixtures * @return array fixtures array with 'apply' and 'except' elements. */ diff --git a/framework/console/controllers/HelpController.php b/framework/console/controllers/HelpController.php index f2c0e0cd..16bbfe2 100644 --- a/framework/console/controllers/HelpController.php +++ b/framework/console/controllers/HelpController.php @@ -23,9 +23,9 @@ use yii\helpers\Inflector; * * This command can be used as follows on command line: * - * ~~~ + * ``` * yii help [command name] - * ~~~ + * ``` * * In the above, if the command name is not provided, all * available commands will be displayed. diff --git a/framework/console/controllers/MigrateController.php b/framework/console/controllers/MigrateController.php index 999d89a..8332ad7 100644 --- a/framework/console/controllers/MigrateController.php +++ b/framework/console/controllers/MigrateController.php @@ -30,16 +30,16 @@ use yii\helpers\Console; * 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 * ) - * ~~~ + * ``` * * Below are some common usages of this command: * - * ~~~ + * ``` * # creates a new migration named 'create_user_table' * yii migrate/create create_user_table * @@ -48,7 +48,7 @@ use yii\helpers\Console; * * # reverts the last applied migration * yii migrate/down - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 diff --git a/framework/data/ActiveDataProvider.php b/framework/data/ActiveDataProvider.php index 47a39ff..17bb3de 100644 --- a/framework/data/ActiveDataProvider.php +++ b/framework/data/ActiveDataProvider.php @@ -22,7 +22,7 @@ use yii\di\Instance; * * The following is an example of using ActiveDataProvider to provide ActiveRecord instances: * - * ~~~ + * ```php * $provider = new ActiveDataProvider([ * 'query' => Post::find(), * 'pagination' => [ @@ -32,12 +32,12 @@ use yii\di\Instance; * * // get the posts in the current page * $posts = $provider->getModels(); - * ~~~ + * ``` * * And the following example shows how to use ActiveDataProvider without ActiveRecord: * - * ~~~ - * $query = new Query; + * ```php + * $query = new Query(); * $provider = new ActiveDataProvider([ * 'query' => $query->from('post'), * 'pagination' => [ @@ -47,7 +47,7 @@ use yii\di\Instance; * * // get the posts in the current page * $posts = $provider->getModels(); - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 diff --git a/framework/data/Pagination.php b/framework/data/Pagination.php index 7262d03..dd62086 100644 --- a/framework/data/Pagination.php +++ b/framework/data/Pagination.php @@ -26,7 +26,7 @@ use yii\web\Request; * * Controller action: * - * ~~~ + * ```php * function actionIndex() * { * $query = Article::find()->where(['status' => 1]); @@ -41,11 +41,11 @@ use yii\web\Request; * 'pages' => $pages, * ]); * } - * ~~~ + * ``` * * View: * - * ~~~ + * ```php * foreach ($models as $model) { * // display $model here * } @@ -54,7 +54,7 @@ use yii\web\Request; * echo LinkPager::widget([ * 'pagination' => $pages, * ]); - * ~~~ + * ``` * * @property integer $limit The limit of the data. This may be used to set the LIMIT value for a SQL statement * for fetching the current page of data. Note that if the page size is infinite, a value -1 will be returned. diff --git a/framework/data/SqlDataProvider.php b/framework/data/SqlDataProvider.php index 125d658..f36b8c4 100644 --- a/framework/data/SqlDataProvider.php +++ b/framework/data/SqlDataProvider.php @@ -25,7 +25,7 @@ use yii\di\Instance; * * SqlDataProvider may be used in the following way: * - * ~~~ + * ```php * $count = Yii::$app->db->createCommand(' * SELECT COUNT(*) FROM user WHERE status=:status * ', [':status' => 1])->queryScalar(); @@ -52,7 +52,7 @@ use yii\di\Instance; * * // get the user records in the current page * $models = $dataProvider->getModels(); - * ~~~ + * ``` * * Note: if you want to use the pagination feature, you must configure the [[totalCount]] property * to be the total number of rows (without pagination). And if you want to use the sorting feature, diff --git a/framework/db/ActiveQueryInterface.php b/framework/db/ActiveQueryInterface.php index d7a404a..4a08b66 100644 --- a/framework/db/ActiveQueryInterface.php +++ b/framework/db/ActiveQueryInterface.php @@ -35,14 +35,14 @@ interface ActiveQueryInterface extends QueryInterface * 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) * { * // return the index value corresponding to $model * } - * ~~~ + * ``` * * @return $this the query object itself */ @@ -61,7 +61,7 @@ interface ActiveQueryInterface extends QueryInterface * * 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 @@ -73,7 +73,7 @@ interface ActiveQueryInterface extends QueryInterface * }, * 'country', * ])->all(); - * ~~~ + * ``` * * @return $this the query object itself */ diff --git a/framework/db/ActiveQueryTrait.php b/framework/db/ActiveQueryTrait.php index aa1acdb..4e56c0a 100644 --- a/framework/db/ActiveQueryTrait.php +++ b/framework/db/ActiveQueryTrait.php @@ -55,7 +55,7 @@ trait ActiveQueryTrait * * 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 @@ -67,15 +67,15 @@ trait ActiveQueryTrait * }, * 'country', * ])->all(); - * ~~~ + * ``` * * 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(); - * ~~~ + * ``` * * @return $this the query object itself */ diff --git a/framework/db/Command.php b/framework/db/Command.php index 5847a54..46517fb 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -22,9 +22,9 @@ use yii\base\NotSupportedException; * use [[queryAll()]], [[queryOne()]], [[queryColumn()]], [[queryScalar()]], or [[query()]]. * For example, * - * ~~~ + * ```php * $users = $connection->createCommand('SELECT * FROM user')->queryAll(); - * ~~~ + * ``` * * Command supports SQL statement preparation and parameter binding. * Call [[bindValue()]] to bind a value to a SQL parameter; @@ -35,12 +35,12 @@ use yii\base\NotSupportedException; * Command also supports building SQL statements by providing methods such as [[insert()]], * [[update()]], etc. For example, * - * ~~~ + * ```php * $connection->createCommand()->insert('user', [ * 'name' => 'Sam', * 'age' => 30, * ])->execute(); - * ~~~ + * ``` * * To build SELECT SQL statements, please use [[QueryBuilder]] instead. * @@ -408,12 +408,12 @@ class Command extends Component * Creates an INSERT command. * For example, * - * ~~~ + * ```php * $connection->createCommand()->insert('user', [ * 'name' => 'Sam', * 'age' => 30, * ])->execute(); - * ~~~ + * ``` * * The method will properly escape the column names, and bind the values to be inserted. * @@ -435,13 +435,13 @@ class Command extends Component * Creates a batch INSERT command. * For example, * - * ~~~ + * ```php * $connection->createCommand()->batchInsert('user', ['name', 'age'], [ * ['Tom', 30], * ['Jane', 20], * ['Linda', 25], * ])->execute(); - * ~~~ + * ``` * * The method will properly escape the column names, and quote the values to be inserted. * @@ -465,9 +465,9 @@ class Command extends Component * Creates an UPDATE command. * For example, * - * ~~~ + * ```php * $connection->createCommand()->update('user', ['status' => 1], 'age > 30')->execute(); - * ~~~ + * ``` * * The method will properly escape the column names and bind the values to be updated. * @@ -491,9 +491,9 @@ class Command extends Component * Creates a DELETE command. * For example, * - * ~~~ + * ```php * $connection->createCommand()->delete('user', 'status = 0')->execute(); - * ~~~ + * ``` * * The method will properly escape the table and column names. * diff --git a/framework/db/Connection.php b/framework/db/Connection.php index 47a17e4..258694a 100644 --- a/framework/db/Connection.php +++ b/framework/db/Connection.php @@ -32,40 +32,40 @@ use yii\caching\Cache; * 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, * 'password' => $password, * ]); * $connection->open(); - * ~~~ + * ``` * * 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'); * $command->execute(); - * ~~~ + * ``` * * One can also do prepared SQL execution and bind parameters to the prepared SQL. * 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(); - * ~~~ + * ``` * * For more information about how to perform various DB queries, please refer to [[Command]]. * * If the underlying DBMS supports transactions, you can perform transactional SQL queries * like the following: * - * ~~~ + * ```php * $transaction = $connection->beginTransaction(); * try { * $connection->createCommand($sql1)->execute(); @@ -75,30 +75,30 @@ use yii\caching\Cache; * } catch (Exception $e) { * $transaction->rollBack(); * } - * ~~~ + * ``` * * You also can use shortcut for the above like the following: * - * ~~~ + * ```php * $connection->transaction(function () { * $order = new Order($customer); * $order->save(); * $order->addItems($items); * }); - * ~~~ + * ``` * * If needed you can pass transaction isolation level as a second parameter: * - * ~~~ + * ```php * $connection->transaction(function (Connection $db) { * //return $db->... * }, Transaction::READ_UNCOMMITTED); - * ~~~ + * ``` * * Connection is often used as an application component and configured in the application * configuration like the following: * - * ~~~ + * ```php * 'components' => [ * 'db' => [ * 'class' => '\yii\db\Connection', @@ -108,7 +108,7 @@ use yii\caching\Cache; * 'charset' => 'utf8', * ], * ], - * ~~~ + * ``` * * @property string $driverName Name of the DB driver. * @property boolean $isActive Whether the DB connection is established. This property is read-only. diff --git a/framework/db/DataReader.php b/framework/db/DataReader.php index 2630790..35d57a9 100644 --- a/framework/db/DataReader.php +++ b/framework/db/DataReader.php @@ -16,7 +16,7 @@ use yii\base\InvalidCallException; * 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(); * @@ -31,7 +31,7 @@ use yii\base\InvalidCallException; * * // equivalent to: * $rows = $reader->readAll(); - * ~~~ + * ``` * * Note that since DataReader is a forward-only stream, you can only traverse it once. * Doing it the second time will throw an exception. diff --git a/framework/db/Expression.php b/framework/db/Expression.php index 8e725ec..ea75862 100644 --- a/framework/db/Expression.php +++ b/framework/db/Expression.php @@ -13,10 +13,10 @@ namespace yii\db; * it will be replaced with the [[expression]] property value without any * DB escaping or quoting. For example, * - * ~~~ + * ```php * $expression = new Expression('NOW()'); * $sql = 'SELECT ' . $expression; // SELECT NOW() - * ~~~ + * ``` * * An expression can also be bound with parameters specified via [[params]]. * diff --git a/framework/db/Query.php b/framework/db/Query.php index 6cf1fed..6676488 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -74,18 +74,18 @@ class Query extends Component implements QueryInterface * @var array 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'], * ] - * ~~~ + * ``` */ public $join; /** diff --git a/framework/db/QueryBuilder.php b/framework/db/QueryBuilder.php index f58cd87..9e015de 100644 --- a/framework/db/QueryBuilder.php +++ b/framework/db/QueryBuilder.php @@ -113,12 +113,12 @@ class QueryBuilder extends \yii\base\Object * Creates an INSERT SQL statement. * For example, * - * ~~~ + * ```php * $sql = $queryBuilder->insert('user', [ - * 'name' => 'Sam', - * 'age' => 30, + * 'name' => 'Sam', + * 'age' => 30, * ], $params); - * ~~~ + * ``` * * The method will properly escape the table and column names. * @@ -161,13 +161,13 @@ class QueryBuilder extends \yii\base\Object * Generates a batch INSERT SQL statement. * For example, * - * ~~~ + * ```php * $sql = $queryBuilder->batchInsert('user', ['name', 'age'], [ * ['Tom', 30], * ['Jane', 20], * ['Linda', 25], * ]); - * ~~~ + * ``` * * Note that the values in each row must match the corresponding column names. * @@ -218,10 +218,10 @@ class QueryBuilder extends \yii\base\Object * Creates an UPDATE SQL statement. * For example, * - * ~~~ + * ```php * $params = []; * $sql = $queryBuilder->update('user', ['status' => 1], 'age > 30', $params); - * ~~~ + * ``` * * The method will properly escape the table and column names. * @@ -265,9 +265,9 @@ class QueryBuilder extends \yii\base\Object * Creates a DELETE SQL statement. * For example, * - * ~~~ + * ```php * $sql = $queryBuilder->delete('user', 'status = 0'); - * ~~~ + * ``` * * The method will properly escape the table and column names. * @@ -299,13 +299,13 @@ class QueryBuilder extends \yii\base\Object * * For example, * - * ~~~ + * ```php * $sql = $queryBuilder->createTable('user', [ * 'id' => 'pk', * 'name' => 'string', * 'age' => 'integer', * ]); - * ~~~ + * ``` * * @param string $table the name of the table to be created. The name will be properly quoted by the method. * @param array $columns the columns (name => definition) in the new table. diff --git a/framework/db/QueryInterface.php b/framework/db/QueryInterface.php index 73ae360..1c18891 100644 --- a/framework/db/QueryInterface.php +++ b/framework/db/QueryInterface.php @@ -62,12 +62,12 @@ interface QueryInterface * 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 * } - * ~~~ + * ``` * * @return $this the query object itself */ diff --git a/framework/db/QueryTrait.php b/framework/db/QueryTrait.php index 1e6f226..371221e 100644 --- a/framework/db/QueryTrait.php +++ b/framework/db/QueryTrait.php @@ -58,12 +58,12 @@ 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 * } - * ~~~ + * ``` * * @return $this the query object itself */ diff --git a/framework/db/Schema.php b/framework/db/Schema.php index f91ac03..985e229 100644 --- a/framework/db/Schema.php +++ b/framework/db/Schema.php @@ -353,12 +353,12 @@ abstract class Schema extends Object * Returns all unique indexes for the given table. * Each array element is of the following structure: * - * ~~~ + * ```php * [ * 'IndexName1' => ['col1' [, ...]], * 'IndexName2' => ['col2' [, ...]], * ] - * ~~~ + * ``` * * This method should be overridden by child classes in order to support this feature * because the default implementation simply throws an exception diff --git a/framework/db/TableSchema.php b/framework/db/TableSchema.php index 7aa0218..e13daab 100644 --- a/framework/db/TableSchema.php +++ b/framework/db/TableSchema.php @@ -45,13 +45,13 @@ class TableSchema extends Object /** * @var array foreign keys of this table. Each array element is of the following structure: * - * ~~~ + * ```php * [ * 'ForeignTableName', * 'fk1' => 'pk1', // pk1 is in foreign table * 'fk2' => 'pk2', // if composite foreign key * ] - * ~~~ + * ``` */ public $foreignKeys = []; /** diff --git a/framework/db/mssql/Schema.php b/framework/db/mssql/Schema.php index d35b180..5e529b7 100644 --- a/framework/db/mssql/Schema.php +++ b/framework/db/mssql/Schema.php @@ -407,12 +407,12 @@ SQL; * Returns all unique indexes for the given table. * Each array element is of the following structure: * - * ~~~ + * ```php * [ - * 'IndexName1' => ['col1' [, ...]], - * 'IndexName2' => ['col2' [, ...]], + * 'IndexName1' => ['col1' [, ...]], + * 'IndexName2' => ['col2' [, ...]], * ] - * ~~~ + * ``` * * @param TableSchema $table the table metadata * @return array all unique indexes for the given table. diff --git a/framework/db/mysql/Schema.php b/framework/db/mysql/Schema.php index 600a06e..6f9afb2 100644 --- a/framework/db/mysql/Schema.php +++ b/framework/db/mysql/Schema.php @@ -306,12 +306,12 @@ SQL; * Returns all unique indexes for the given table. * Each array element is of the following structure: * - * ~~~ + * ```php * [ - * 'IndexName1' => ['col1' [, ...]], - * 'IndexName2' => ['col2' [, ...]], + * 'IndexName1' => ['col1' [, ...]], + * 'IndexName2' => ['col2' [, ...]], * ] - * ~~~ + * ``` * * @param TableSchema $table the table metadata * @return array all unique indexes for the given table. diff --git a/framework/db/oci/QueryBuilder.php b/framework/db/oci/QueryBuilder.php index 334c9a0..865116e 100644 --- a/framework/db/oci/QueryBuilder.php +++ b/framework/db/oci/QueryBuilder.php @@ -205,13 +205,13 @@ EOD; * Generates a batch INSERT SQL statement. * For example, * - * ~~~ + * ```php * $sql = $queryBuilder->batchInsert('user', ['name', 'age'], [ * ['Tom', 30], * ['Jane', 20], * ['Linda', 25], * ]); - * ~~~ + * ``` * * Note that the values in each row must match the corresponding column names. * diff --git a/framework/db/oci/Schema.php b/framework/db/oci/Schema.php index 3f87572..65254e0 100644 --- a/framework/db/oci/Schema.php +++ b/framework/db/oci/Schema.php @@ -359,12 +359,12 @@ SQL; * Returns all unique indexes for the given table. * Each array element is of the following structure: * - * ~~~ + * ```php * [ - * 'IndexName1' => ['col1' [, ...]], - * 'IndexName2' => ['col2' [, ...]], + * 'IndexName1' => ['col1' [, ...]], + * 'IndexName2' => ['col2' [, ...]], * ] - * ~~~ + * ``` * * @param TableSchema $table the table metadata * @return array all unique indexes for the given table. diff --git a/framework/db/pgsql/Schema.php b/framework/db/pgsql/Schema.php index 9711c60..1a4670d 100644 --- a/framework/db/pgsql/Schema.php +++ b/framework/db/pgsql/Schema.php @@ -303,12 +303,12 @@ SQL; * Returns all unique indexes for the given table. * Each array element is of the following structure: * - * ~~~ + * ```php * [ - * 'IndexName1' => ['col1' [, ...]], - * 'IndexName2' => ['col2' [, ...]], + * 'IndexName1' => ['col1' [, ...]], + * 'IndexName2' => ['col2' [, ...]], * ] - * ~~~ + * ``` * * @param TableSchema $table the table metadata * @return array all unique indexes for the given table. diff --git a/framework/db/sqlite/QueryBuilder.php b/framework/db/sqlite/QueryBuilder.php index 763ebde..ebcab8a 100644 --- a/framework/db/sqlite/QueryBuilder.php +++ b/framework/db/sqlite/QueryBuilder.php @@ -49,13 +49,13 @@ class QueryBuilder extends \yii\db\QueryBuilder * Generates a batch INSERT SQL statement. * For example, * - * ~~~ + * ```php * $connection->createCommand()->batchInsert('user', ['name', 'age'], [ * ['Tom', 30], * ['Jane', 20], * ['Linda', 25], * ])->execute(); - * ~~~ + * ``` * * Note that the values in each row must match the corresponding column names. * diff --git a/framework/db/sqlite/Schema.php b/framework/db/sqlite/Schema.php index 443d3be..25d00ea 100644 --- a/framework/db/sqlite/Schema.php +++ b/framework/db/sqlite/Schema.php @@ -174,12 +174,12 @@ class Schema extends \yii\db\Schema * Returns all unique indexes for the given table. * Each array element is of the following structure: * - * ~~~ + * ```php * [ - * 'IndexName1' => ['col1' [, ...]], - * 'IndexName2' => ['col2' [, ...]], + * 'IndexName1' => ['col1' [, ...]], + * 'IndexName2' => ['col2' [, ...]], * ] - * ~~~ + * ``` * * @param TableSchema $table the table metadata * @return array all unique indexes for the given table. diff --git a/framework/filters/AccessControl.php b/framework/filters/AccessControl.php index 85da2d6..5c1ce9a 100644 --- a/framework/filters/AccessControl.php +++ b/framework/filters/AccessControl.php @@ -26,7 +26,7 @@ use yii\web\ForbiddenHttpException; * 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 [ @@ -49,7 +49,7 @@ use yii\web\ForbiddenHttpException; * ], * ]; * } - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 @@ -67,9 +67,9 @@ class AccessControl extends ActionFilter * * The signature of the callback should be as follows: * - * ~~~ + * ```php * function ($rule, $action) - * ~~~ + * ``` * * where `$rule` is the rule that denies the user, and `$action` is the current [[Action|action]] object. * `$rule` can be `null` if access is denied because none of the rules matched. diff --git a/framework/filters/AccessRule.php b/framework/filters/AccessRule.php index 3c8d08e..e60f95a 100644 --- a/framework/filters/AccessRule.php +++ b/framework/filters/AccessRule.php @@ -67,9 +67,9 @@ 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) - * ~~~ + * ``` * * where `$rule` is this rule, and `$action` is the current [[Action|action]] object. * The callback should return a boolean value indicating whether this rule should be applied. @@ -82,9 +82,9 @@ class AccessRule extends Component * * The signature of the callback should be as follows: * - * ~~~ + * ```php * function ($rule, $action) - * ~~~ + * ``` * * where `$rule` is this rule, and `$action` is the current [[Action|action]] object. */ diff --git a/framework/filters/HttpCache.php b/framework/filters/HttpCache.php index 86f5a84..5392d2a 100644 --- a/framework/filters/HttpCache.php +++ b/framework/filters/HttpCache.php @@ -20,7 +20,7 @@ use yii\base\Action; * In the following example the filter will be applied to the `list`-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 [ @@ -37,7 +37,7 @@ use yii\base\Action; * ], * ]; * } - * ~~~ + * ``` * * @author Da:Sourcerer * @author Qiang Xue @@ -49,9 +49,9 @@ 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) - * ~~~ + * ``` * * where `$action` is the [[Action]] object that this filter is currently handling; * `$params` takes the value of [[params]]. The callback should return a UNIX timestamp. @@ -61,9 +61,9 @@ 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) - * ~~~ + * ``` * * where `$action` is the [[Action]] object that this filter is currently handling; * `$params` takes the value of [[params]]. The callback should return a string serving diff --git a/framework/filters/PageCache.php b/framework/filters/PageCache.php index 50a1a3b..cac3bb4 100644 --- a/framework/filters/PageCache.php +++ b/framework/filters/PageCache.php @@ -25,7 +25,7 @@ use yii\web\Response; * 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 [ @@ -43,7 +43,7 @@ use yii\web\Response; * ], * ]; * } - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 @@ -92,11 +92,11 @@ class PageCache extends ActionFilter * The following variation setting will cause the content to be cached in different versions * according to the current application language: * - * ~~~ + * ```php * [ * Yii::$app->language, * ] - * ~~~ + * ``` */ public $variations; /** diff --git a/framework/filters/VerbFilter.php b/framework/filters/VerbFilter.php index b2cdb10..6a96810 100644 --- a/framework/filters/VerbFilter.php +++ b/framework/filters/VerbFilter.php @@ -23,7 +23,7 @@ use yii\web\MethodNotAllowedHttpException; * For example, the following declarations will define a typical set of allowed * request methods for REST CRUD actions. * - * ~~~ + * ```php * public function behaviors() * { * return [ @@ -39,7 +39,7 @@ use yii\web\MethodNotAllowedHttpException; * ], * ]; * } - * ~~~ + * ``` * * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7 * @author Carsten Brandt @@ -59,14 +59,14 @@ class VerbFilter extends Behavior * * For example, * - * ~~~ + * ```php * [ * 'create' => ['get', 'post'], * 'update' => ['get', 'put', 'post'], * 'delete' => ['post', 'delete'], * '*' => ['get'], * ] - * ~~~ + * ``` */ public $actions = []; diff --git a/framework/helpers/BaseArrayHelper.php b/framework/helpers/BaseArrayHelper.php index 4abe69d..037192f 100644 --- a/framework/helpers/BaseArrayHelper.php +++ b/framework/helpers/BaseArrayHelper.php @@ -27,7 +27,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', @@ -40,18 +40,18 @@ class BaseArrayHelper * }, * ], * ] - * ~~~ + * ``` * * The result of `ArrayHelper::toArray($post, $properties)` could be like the following: * - * ~~~ + * ```php * [ * 'id' => 123, * 'title' => 'test', * 'createTime' => '2013-01-01 12:00AM', * 'length' => 301, * ] - * ~~~ + * ``` * * @param boolean $recursive whether to recursively converts properties which are objects into arrays. * @return array the array representation of the object @@ -150,7 +150,7 @@ class BaseArrayHelper * * Below are some usage examples, * - * ~~~ + * ```php * // working with array * $username = \yii\helpers\ArrayHelper::getValue($_POST, 'username'); * // working with object @@ -163,7 +163,7 @@ class BaseArrayHelper * $street = \yii\helpers\ArrayHelper::getValue($users, 'address.street'); * // using an array of keys to retrieve the value * $value = \yii\helpers\ArrayHelper::getValue($versions, ['1.0', 'date']); - * ~~~ + * ``` * * @param array|object $array array or object to extract value from * @param string|\Closure|array $key key name of the array element, an array of keys or property name of the object, @@ -213,13 +213,13 @@ class BaseArrayHelper * * Usage examples, * - * ~~~ + * ```php * // $array = ['type' => 'A', 'options' => [1, 2]]; * // working with array * $type = \yii\helpers\ArrayHelper::remove($array, 'type'); * // $array content * // $array = ['options' => [1, 2]]; - * ~~~ + * ``` * * @param array $array the array to extract value from * @param string $key key name of the array element @@ -249,7 +249,7 @@ class BaseArrayHelper * * For example, * - * ~~~ + * ```php * $array = [ * ['id' => '123', 'data' => 'abc'], * ['id' => '345', 'data' => 'def'], @@ -265,7 +265,7 @@ class BaseArrayHelper * $result = ArrayHelper::index($array, function ($element) { * return $element['id']; * }); - * ~~~ + * ``` * * @param array $array the array that needs to be indexed * @param string|\Closure $key the column name or anonymous function whose result will be used to index the array @@ -288,7 +288,7 @@ class BaseArrayHelper * * For example, * - * ~~~ + * ```php * $array = [ * ['id' => '123', 'data' => 'abc'], * ['id' => '345', 'data' => 'def'], @@ -300,7 +300,7 @@ class BaseArrayHelper * $result = ArrayHelper::getColumn($array, function ($element) { * return $element['id']; * }); - * ~~~ + * ``` * * @param array $array * @param string|\Closure $name @@ -331,7 +331,7 @@ class BaseArrayHelper * * For example, * - * ~~~ + * ```php * $array = [ * ['id' => '123', 'name' => 'aaa', 'class' => 'x'], * ['id' => '124', 'name' => 'bbb', 'class' => 'x'], @@ -357,7 +357,7 @@ class BaseArrayHelper * // '345' => 'ccc', * // ], * // ] - * ~~~ + * ``` * * @param array $array * @param string|\Closure $from diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index 40f8884..d5a976b 100644 --- a/framework/helpers/BaseHtml.php +++ b/framework/helpers/BaseHtml.php @@ -750,12 +750,12 @@ class BaseHtml * - 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'], * ]; - * ~~~ + * ``` * * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', * except that the array keys represent the optgroup labels specified in $items. @@ -799,12 +799,12 @@ class BaseHtml * - 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'], * ]; - * ~~~ + * ``` * * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', * except that the array keys represent the optgroup labels specified in $items. @@ -866,9 +866,9 @@ class BaseHtml * - 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) - * ~~~ + * ``` * * where $index is the zero-based index of the checkbox in the whole list; $label * is the label for the checkbox; and $name, $value and $checked represent the name, @@ -939,9 +939,9 @@ class BaseHtml * - 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) - * ~~~ + * ``` * * where $index is the zero-based index of the radio button in the whole list; $label * is the label for the radio button; and $name, $value and $checked represent the name, @@ -999,9 +999,9 @@ class BaseHtml * - item: callable, a callback that is used to generate each individual list item. * The signature of this callback must be: * - * ~~~ + * ```php * function ($item, $index) - * ~~~ + * ``` * * where $index is the array key corresponding to `$item` in `$items`. The callback should return * the whole list item tag. @@ -1045,9 +1045,9 @@ class BaseHtml * - item: callable, a callback that is used to generate each individual list item. * The signature of this callback must be: * - * ~~~ + * ```php * function ($item, $index) - * ~~~ + * ``` * * where $index is the array key corresponding to `$item` in `$items`. The callback should return * the whole list item tag. @@ -1477,12 +1477,12 @@ class BaseHtml * - 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'], * ]; - * ~~~ + * ``` * * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', * except that the array keys represent the optgroup labels specified in $items. @@ -1526,12 +1526,12 @@ class BaseHtml * - 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'], * ]; - * ~~~ + * ``` * * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', * except that the array keys represent the optgroup labels specified in $items. @@ -1579,9 +1579,9 @@ class BaseHtml * - 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) - * ~~~ + * ``` * * where $index is the zero-based index of the checkbox in the whole list; $label * is the label for the checkbox; and $name, $value and $checked represent the name, @@ -1620,9 +1620,9 @@ class BaseHtml * - 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) - * ~~~ + * ``` * * where $index is the zero-based index of the radio button in the whole list; $label * is the label for the radio button; and $name, $value and $checked represent the name, @@ -1803,11 +1803,11 @@ class BaseHtml * 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 + * ```php * $options = ['class' => ['persistent' => 'initial']]; * Html::addCssClass($options, ['persistent' => 'override']); * var_dump($options['class']); // outputs: array('persistent' => 'initial'); - * ~~~ + * ``` * * @param array $options the options to be modified. * @param string|array $class the CSS class(es) to be added diff --git a/framework/helpers/BaseHtmlPurifier.php b/framework/helpers/BaseHtmlPurifier.php index 1213be2..ba24253 100644 --- a/framework/helpers/BaseHtmlPurifier.php +++ b/framework/helpers/BaseHtmlPurifier.php @@ -32,13 +32,13 @@ 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) * ->addAttribute('img', 'data-type', 'Text'); * }); - * ~~~ + * ``` * * @return string the purified HTML content. */ diff --git a/framework/helpers/VarDumper.php b/framework/helpers/VarDumper.php index cb5d0f9..fcffecb 100644 --- a/framework/helpers/VarDumper.php +++ b/framework/helpers/VarDumper.php @@ -15,9 +15,9 @@ namespace yii\helpers; * * VarDumper can be used as follows, * - * ~~~ + * ```php * VarDumper::dump($var); - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 diff --git a/framework/i18n/DbMessageSource.php b/framework/i18n/DbMessageSource.php index 893e76b..7be4251 100644 --- a/framework/i18n/DbMessageSource.php +++ b/framework/i18n/DbMessageSource.php @@ -21,7 +21,7 @@ use yii\db\Query; * * The database must contain the following two tables: * - * ~~~ + * ```sql * CREATE TABLE source_message ( * id INTEGER PRIMARY KEY AUTO_INCREMENT, * category VARCHAR(32), @@ -36,7 +36,7 @@ use yii\db\Query; * CONSTRAINT fk_message_source_message FOREIGN KEY (id) * REFERENCES source_message (id) ON DELETE CASCADE ON UPDATE RESTRICT * ); - * ~~~ + * ``` * * The `source_message` table stores the messages to be translated, and the `message` table stores * the translated messages. The name of these two tables can be customized by setting [[sourceMessageTable]] diff --git a/framework/i18n/PhpMessageSource.php b/framework/i18n/PhpMessageSource.php index b127d77..b534f02 100644 --- a/framework/i18n/PhpMessageSource.php +++ b/framework/i18n/PhpMessageSource.php @@ -19,12 +19,12 @@ use Yii; * - 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', * ]; - * ~~~ + * ``` * * You may use [[fileMap]] to customize the association between category names and the file names. * @@ -41,12 +41,12 @@ 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', * ] - * ~~~ + * ``` */ public $fileMap; diff --git a/framework/log/Logger.php b/framework/log/Logger.php index 107d90d..86b584b 100644 --- a/framework/log/Logger.php +++ b/framework/log/Logger.php @@ -78,7 +78,7 @@ class Logger extends Component * @var array logged messages. This property is managed by [[log()]] and [[flush()]]. * Each log message is of the following structure: * - * ~~~ + * ``` * [ * [0] => message (mixed, can be a string or some complex data, such as an exception object) * [1] => level (integer) @@ -86,7 +86,7 @@ class Logger extends Component * [3] => timestamp (float, obtained by microtime(true)) * [4] => traces (array, debug backtrace, contains the application code call stacks) * ] - * ~~~ + * ``` */ public $messages = []; /** diff --git a/framework/log/Target.php b/framework/log/Target.php index 1d0ae58..a74329e 100644 --- a/framework/log/Target.php +++ b/framework/log/Target.php @@ -152,11 +152,11 @@ abstract class Target extends Component * * For example, * - * ~~~ + * ```php * ['error', 'warning'] * // which is equivalent to: * Logger::LEVEL_ERROR | Logger::LEVEL_WARNING - * ~~~ + * ``` * * @param array|integer $levels message levels that this target is interested in. * @throws InvalidConfigException if an unknown level name is given diff --git a/framework/mail/BaseMailer.php b/framework/mail/BaseMailer.php index 0451d11..f036bc2 100644 --- a/framework/mail/BaseMailer.php +++ b/framework/mail/BaseMailer.php @@ -61,13 +61,13 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont * * For example: * - * ~~~ + * ```php * [ * 'charset' => 'UTF-8', * 'from' => 'noreply@mydomain.com', * 'bcc' => 'developer@mydomain.com', * ] - * ~~~ + * ``` */ public $messageConfig = []; /** @@ -91,9 +91,9 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont * * The signature of the callback is: * - * ~~~ + * ```php * function ($mailer, $message) - * ~~~ + * ``` */ public $fileTransportCallback; diff --git a/framework/mail/MailerInterface.php b/framework/mail/MailerInterface.php index 22231c0..ef7e595 100644 --- a/framework/mail/MailerInterface.php +++ b/framework/mail/MailerInterface.php @@ -13,13 +13,13 @@ namespace yii\mail; * 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) * ->setSubject($form->subject) * ->send(); - * ~~~ + * ``` * * @see MessageInterface * diff --git a/framework/mail/MessageInterface.php b/framework/mail/MessageInterface.php index 9aa83da..57128fd 100644 --- a/framework/mail/MessageInterface.php +++ b/framework/mail/MessageInterface.php @@ -15,7 +15,7 @@ namespace yii\mail; * * Messages are sent by a [[\yii\mail\MailerInterface|mailer]], like the following, * - * ~~~ + * ```php * Yii::$app->mailer->compose() * ->setFrom('from@domain.com') * ->setTo($form->email) @@ -23,7 +23,7 @@ namespace yii\mail; * ->setTextBody('Plain text content') * ->setHtmlBody('HTML content') * ->send(); - * ~~~ + * ``` * * @see MailerInterface * diff --git a/framework/requirements/YiiRequirementChecker.php b/framework/requirements/YiiRequirementChecker.php index a1011fb..ef902f1 100644 --- a/framework/requirements/YiiRequirementChecker.php +++ b/framework/requirements/YiiRequirementChecker.php @@ -16,7 +16,7 @@ if (version_compare(PHP_VERSION, '4.3', '<')) { * * Example: * - * ~~~php + * ```php * require_once('path/to/YiiRequirementChecker.php'); * $requirementsChecker = new YiiRequirementChecker(); * $requirements = array( @@ -29,7 +29,7 @@ if (version_compare(PHP_VERSION, '4.3', '<')) { * ), * ); * $requirementsChecker->checkYii()->check($requirements)->render(); - * ~~~ + * ``` * * If you wish to render the report with your own representation, use [[getResult()]] instead of [[render()]] * @@ -37,14 +37,14 @@ if (version_compare(PHP_VERSION, '4.3', '<')) { * 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', * 'condition' => 'eval:$this->checkUploadMaxFileSize("5M")', * ), * ); - * ~~~ + * ``` * * 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! diff --git a/framework/validators/EachValidator.php b/framework/validators/EachValidator.php index bb891b5..9194201 100644 --- a/framework/validators/EachValidator.php +++ b/framework/validators/EachValidator.php @@ -14,7 +14,7 @@ use yii\base\Model; /** * EachValidator validates an array by checking each of its elements against an embedded validation rule. * - * ~~~php + * ```php * class MyModel extends Model * { * public $categoryIDs = []; @@ -27,7 +27,7 @@ use yii\base\Model; * ] * } * } - * ~~~ + * ``` * * > Note: This validator will not work with inline validation rules in case of usage outside the model scope, * e.g. via [[validate()]] method. @@ -43,10 +43,10 @@ class EachValidator extends Validator * contain attribute list as the first element. * For example: * - * ~~~ + * ```php * ['integer'] * ['match', 'pattern' => '/[a-z]/is'] - * ~~~ + * ``` * * Please refer to [[yii\base\Model::rules()]] for more details. */ diff --git a/framework/validators/FilterValidator.php b/framework/validators/FilterValidator.php index b9a7464..b17428f 100644 --- a/framework/validators/FilterValidator.php +++ b/framework/validators/FilterValidator.php @@ -17,9 +17,9 @@ use yii\base\InvalidConfigException; * and save the processed value back to the attribute. The filter must be * a valid PHP callback with the following signature: * - * ~~~ - * function foo($value) {...return $newValue; } - * ~~~ + * ```php + * function foo($value) { return $newValue; } + * ``` * * Many PHP functions qualify this signature (e.g. `trim()`). * @@ -34,9 +34,9 @@ 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, * - * ~~~ - * function foo($value) {...return $newValue; } - * ~~~ + * ```php + * function foo($value) { return $newValue; } + * ``` */ public $filter; /** diff --git a/framework/validators/InlineValidator.php b/framework/validators/InlineValidator.php index 3df96db..8423e8b 100644 --- a/framework/validators/InlineValidator.php +++ b/framework/validators/InlineValidator.php @@ -12,9 +12,9 @@ namespace yii\validators; * * The validation method must have the following signature: * - * ~~~ + * ```php * function foo($attribute, $params) - * ~~~ + * ``` * * where `$attribute` refers to the name of the attribute being validated, while `$params` * is an array representing the additional parameters supplied in the validation rule. @@ -30,9 +30,9 @@ class InlineValidator extends Validator * where `$attribute` is the name of the attribute to be validated, and `$params` contains the value * of [[params]] that you specify when declaring the inline validation rule: * - * ~~~ + * ```php * function foo($attribute, $params) - * ~~~ + * ``` */ public $method; /** @@ -43,12 +43,12 @@ 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 foo($attribute, $params) * { * return "javascript"; * } - * ~~~ + * ``` * * where `$attribute` refers to the attribute name to be validated. * diff --git a/framework/web/Application.php b/framework/web/Application.php index c02e30d..24fdfed 100644 --- a/framework/web/Application.php +++ b/framework/web/Application.php @@ -34,13 +34,13 @@ 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', * 'param2' => 'value2', * ] - * ~~~ + * ``` * * Defaults to null, meaning catch-all is not used. */ diff --git a/framework/web/AssetManager.php b/framework/web/AssetManager.php index ada09ca..97365d2 100644 --- a/framework/web/AssetManager.php +++ b/framework/web/AssetManager.php @@ -54,13 +54,13 @@ 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' => [], * ], * ] - * ~~~ + * ``` */ public $bundles = []; /** @@ -115,9 +115,9 @@ 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 - * ~~~ + * ``` */ public $linkAssets = false; /** diff --git a/framework/web/CacheSession.php b/framework/web/CacheSession.php index 12cc227..acbf03e 100644 --- a/framework/web/CacheSession.php +++ b/framework/web/CacheSession.php @@ -24,12 +24,12 @@ use yii\di\Instance; * 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', * ] - * ~~~ + * ``` * * @property boolean $useCustomStorage Whether to use custom storage. This property is read-only. * diff --git a/framework/web/Cookie.php b/framework/web/Cookie.php index 924eb02..56e5904 100644 --- a/framework/web/Cookie.php +++ b/framework/web/Cookie.php @@ -51,11 +51,11 @@ class Cookie extends \yii\base\Object /** * 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']; * } - * ~~~ + * ``` * * @return string The value of the cookie. If the value property is null, an empty string will be returned. */ diff --git a/framework/web/DbSession.php b/framework/web/DbSession.php index ad06fd6..108e94b 100644 --- a/framework/web/DbSession.php +++ b/framework/web/DbSession.php @@ -22,13 +22,13 @@ use yii\di\Instance; * 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', * // 'sessionTable' => 'my_session', * ] - * ~~~ + * ``` * * DbSession extends [[MultiFieldSession]], thus it allows saving extra fields into the [[sessionTable]]. * Refer to [[MultiFieldSession]] for more details. @@ -49,14 +49,14 @@ 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, * expire INTEGER, * data BLOB * ) - * ~~~ + * ``` * * where 'BLOB' refers to the BLOB-type of your preferred DBMS. Below are the BLOB type * that can be used for some popular DBMS: diff --git a/framework/web/IdentityInterface.php b/framework/web/IdentityInterface.php index 8af1769..c83f686 100644 --- a/framework/web/IdentityInterface.php +++ b/framework/web/IdentityInterface.php @@ -13,7 +13,7 @@ namespace yii\web; * 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) @@ -41,7 +41,7 @@ namespace yii\web; * return $this->authKey === $authKey; * } * } - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 diff --git a/framework/web/Request.php b/framework/web/Request.php index a0963a3..536909a 100644 --- a/framework/web/Request.php +++ b/framework/web/Request.php @@ -1183,7 +1183,7 @@ class Request extends \yii\base\Request * Returns the cookie collection. * 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; @@ -1191,7 +1191,7 @@ class Request extends \yii\base\Request * * // alternatively * $value = $request->cookies->getValue('name'); - * ~~~ + * ``` * * @return CookieCollection the cookie collection. */ diff --git a/framework/web/Response.php b/framework/web/Response.php index 056ec33..f16f7ec 100644 --- a/framework/web/Response.php +++ b/framework/web/Response.php @@ -26,13 +26,13 @@ use yii\helpers\StringHelper; * 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', * // ... * ] - * ~~~ + * ``` * * @property CookieCollection $cookies The cookie collection. This property is read-only. * @property string $downloadHeaders The attachment file name. This property is write-only. @@ -649,9 +649,9 @@ class Response extends \yii\base\Response * * **Example** * - * ~~~ + * ```php * Yii::$app->response->xSendFile('/home/user/Pictures/picture1.jpg'); - * ~~~ + * ``` * * @param string $filePath file name with full path * @param string $attachmentName file name shown to the user. If null, it will be determined from `$filePath`. @@ -697,17 +697,17 @@ class Response extends \yii\base\Response * 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; - * ~~~ + * ``` * * In AJAX mode, this normally will not work as expected unless there are some * client-side JavaScript code handling the redirection. To help achieve this goal, @@ -717,14 +717,14 @@ class Response extends \yii\base\Response * described above. Otherwise, you should write the following JavaScript code to * handle the redirection: * - * ~~~ + * ```javascript * $document.ajaxComplete(function (event, xhr, settings) { * var url = xhr.getResponseHeader('X-Redirect'); * if (url) { * window.location = url; * } * }); - * ~~~ + * ``` * * @param string|array $url the URL to be redirected to. This can be in one of the following formats: * @@ -781,9 +781,9 @@ class Response extends \yii\base\Response * * In a controller action you may use this method like this: * - * ~~~ + * ```php * return Yii::$app->getResponse()->refresh(); - * ~~~ + * ``` * * @param string $anchor the anchor that should be appended to the redirection URL. * Defaults to empty. Make sure the anchor starts with '#' if you want to specify it. @@ -800,7 +800,7 @@ class Response extends \yii\base\Response * Returns the cookie collection. * Through the returned cookie collection, you add or remove cookies as follows, * - * ~~~ + * ```php * // add a cookie * $response->cookies->add(new Cookie([ * 'name' => $name, @@ -811,7 +811,7 @@ class Response extends \yii\base\Response * $response->cookies->remove('name'); * // alternatively * unset($response->cookies['name']); - * ~~~ + * ``` * * @return CookieCollection the cookie collection. */ diff --git a/framework/web/Session.php b/framework/web/Session.php index 393fb76..ce18ac3 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -22,14 +22,14 @@ use yii\base\InvalidParamException; * * 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' * $value2 = $session['name2']; // get session variable 'name2' * foreach ($session as $name => $value) // traverse all session variables * $session['name3'] = $value3; // set session variable 'name3' - * ~~~ + * ``` * * Session can be extended to support customized session storage. * To do so, override [[useCustomStorage]] so that it returns true, and diff --git a/framework/web/UrlManager.php b/framework/web/UrlManager.php index eb01853..3e8a16a 100644 --- a/framework/web/UrlManager.php +++ b/framework/web/UrlManager.php @@ -21,7 +21,7 @@ use yii\caching\Cache; * 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' => [ @@ -29,7 +29,7 @@ use yii\caching\Cache; * ], * // ... * ] - * ~~~ + * ``` * * @property string $baseUrl The base URL that is used by [[createUrl()]] to prepend to created URLs. * @property string $hostInfo The host info (e.g. "http://www.example.com") that is used by @@ -79,7 +79,7 @@ class UrlManager extends Component * * Here is an example configuration for RESTful CRUD controller: * - * ~~~php + * ```php * [ * 'dashboard' => 'site/index', * @@ -90,7 +90,7 @@ class UrlManager extends Component * 'DELETE /' => '/delete', * '/' => '/view', * ]; - * ~~~ + * ``` * * Note that if you modify this property after the UrlManager object is created, make sure * you populate the array with rule objects instead of rule configurations. diff --git a/framework/web/UrlRule.php b/framework/web/UrlRule.php index a95a500..9b7d03f 100644 --- a/framework/web/UrlRule.php +++ b/framework/web/UrlRule.php @@ -17,12 +17,12 @@ use yii\base\InvalidConfigException; * 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', ...], * // ... * ] - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 diff --git a/framework/web/User.php b/framework/web/User.php index 250a850..788e389 100644 --- a/framework/web/User.php +++ b/framework/web/User.php @@ -36,14 +36,14 @@ use yii\base\InvalidValueException; * 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, * // 'loginUrl' => ['user/login'], * // ... * ] - * ~~~ + * ``` * * @property string|integer $id The unique identifier for the user. If null, it means the user is a guest. * This property is read-only. @@ -84,9 +84,9 @@ 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] - * ~~~ + * ``` * * If this property is null, a 403 HTTP exception will be raised when [[loginRequired()]] is called. */ @@ -391,9 +391,9 @@ class User extends Component * 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] - * ~~~ + * ``` */ public function setReturnUrl($url) { diff --git a/framework/web/View.php b/framework/web/View.php index 9c39dc1..2040e8e 100644 --- a/framework/web/View.php +++ b/framework/web/View.php @@ -23,7 +23,7 @@ use yii\base\InvalidConfigException; * 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' => [ @@ -31,7 +31,7 @@ use yii\base\InvalidConfigException; * ] * // ... * ] - * ~~~ + * ``` * * @property \yii\web\AssetManager $assetManager The asset manager. Defaults to the "assetManager" application * component. diff --git a/framework/widgets/ActiveForm.php b/framework/widgets/ActiveForm.php index c50c0c8..6271da0 100644 --- a/framework/widgets/ActiveForm.php +++ b/framework/widgets/ActiveForm.php @@ -330,7 +330,7 @@ class ActiveForm extends Widget * 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($_POST); * if (Yii::$app->request->isAjax) { @@ -338,14 +338,14 @@ class ActiveForm extends Widget * return ActiveForm::validate($model); * } * // ... respond to non-AJAX request ... - * ~~~ + * ``` * * To validate multiple models, simply pass each model as a parameter to this method, like * the following: * - * ~~~ + * ```php * ActiveForm::validate($model1, $model2, ...); - * ~~~ + * ``` * * @param Model $model the model to be validated * @param mixed $attributes list of attributes that should be validated. @@ -385,14 +385,14 @@ class ActiveForm extends Widget * 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; * return ActiveForm::validateMultiple($models); * } * // ... respond to non-AJAX request ... - * ~~~ + * ``` * * @param array $models an array of models to be validated. * @param mixed $attributes list of attributes that should be validated. diff --git a/framework/widgets/Breadcrumbs.php b/framework/widgets/Breadcrumbs.php index 1934b6e..c5f00e3 100644 --- a/framework/widgets/Breadcrumbs.php +++ b/framework/widgets/Breadcrumbs.php @@ -22,7 +22,7 @@ use yii\helpers\Html; * * 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 @@ -36,18 +36,18 @@ use yii\helpers\Html; * 'Edit', * ], * ]); - * ~~~ + * ``` * * Because breadcrumbs usually appears in nearly every page of a website, you may consider placing it in a layout view. * 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'] : [], * ]); - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 diff --git a/framework/widgets/DetailView.php b/framework/widgets/DetailView.php index 45492ca..cfd7ea2 100644 --- a/framework/widgets/DetailView.php +++ b/framework/widgets/DetailView.php @@ -29,7 +29,7 @@ use yii\helpers\Inflector; * * A typical usage of DetailView is as follows: * - * ~~~ + * ```php * echo DetailView::widget([ * 'model' => $model, * 'attributes' => [ @@ -42,7 +42,7 @@ use yii\helpers\Inflector; * 'created_at:datetime', // creation date formatted as datetime * ], * ]); - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0 @@ -82,9 +82,9 @@ 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) - * ~~~ + * ``` * * where `$attribute` refer to the specification of the attribute being rendered, `$index` is the zero-based * index of the attribute in the [[attributes]] array, and `$widget` refers to this widget instance. diff --git a/framework/widgets/FragmentCache.php b/framework/widgets/FragmentCache.php index fe92e0e..e81f5b8 100644 --- a/framework/widgets/FragmentCache.php +++ b/framework/widgets/FragmentCache.php @@ -41,12 +41,12 @@ class FragmentCache extends Widget * 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', * ] - * ~~~ + * ``` * * would make the output cache depends on the last modified time of all posts. * If any post has its modification time changed, the cached content would be invalidated. @@ -58,10 +58,11 @@ class FragmentCache extends Widget * The following variation setting will cause the content to be cached in different versions * according to the current application language: * - * ~~~ + * ```php * [ * Yii::$app->language, * ] + * ``` */ public $variations; /** diff --git a/framework/widgets/ListView.php b/framework/widgets/ListView.php index c38fd63..29b5a11 100644 --- a/framework/widgets/ListView.php +++ b/framework/widgets/ListView.php @@ -42,9 +42,9 @@ class ListView extends BaseListView * * If this property is specified as a callback, it should have the following signature: * - * ~~~ + * ```php * function ($model, $key, $index, $widget) - * ~~~ + * ``` */ public $itemView; /** diff --git a/framework/widgets/Menu.php b/framework/widgets/Menu.php index e1bbc1d..75a31b4 100644 --- a/framework/widgets/Menu.php +++ b/framework/widgets/Menu.php @@ -27,7 +27,7 @@ use yii\helpers\Html; * * The following example shows how to use Menu: * - * ~~~ + * ```php * echo Menu::widget([ * 'items' => [ * // Important: you need to specify url as 'controller/action', @@ -41,7 +41,7 @@ use yii\helpers\Html; * ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest], * ], * ]); - * ~~~ + * ``` * * @author Qiang Xue * @since 2.0