Skip to content

Commit

Permalink
Fix types (#19332)
Browse files Browse the repository at this point in the history
* Migration::upsert() returns void

* Unneeded `@property` tags

* Add missing `null` param/return types

* Null types for db\Query + db\ActiveQuery

* Fixed testSelect
  • Loading branch information
brandonkelly committed Mar 30, 2022
1 parent 4cfdfc0 commit 4628b91
Show file tree
Hide file tree
Showing 117 changed files with 318 additions and 328 deletions.
4 changes: 2 additions & 2 deletions framework/BaseYii.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static function getRootAlias($alias)
* @param string $alias the alias name (e.g. "@yii"). It must start with a '@' character.
* It may contain the forward-slash '/' which serves as a boundary character when performing
* alias translation by [[getAlias()]].
* @param string $path the path corresponding to the alias. If this is null, the alias will
* @param string|null $path the path corresponding to the alias. If this is null, the alias will
* be removed. Trailing '/' and '\' characters will be trimmed. This can be
*
* - a directory or a file path (e.g. `/tmp`, `/tmp/main.txt`)
Expand Down Expand Up @@ -528,7 +528,7 @@ public static function powered()
* @param string $category the message category.
* @param string $message the message to be translated.
* @param array $params the parameters that will be used to replace the corresponding placeholders in the message.
* @param string $language the language code (e.g. `en-US`, `en`). If this is null, the current
* @param string|null $language the language code (e.g. `en-US`, `en`). If this is null, the current
* [[\yii\base\Application::language|application language]] will be used.
* @return string the translated message.
*/
Expand Down
6 changes: 3 additions & 3 deletions framework/base/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ abstract class Application extends Module
*/
public $requestedRoute;
/**
* @var Action the requested Action. If null, it means the request cannot be resolved into an action.
* @var Action|null the requested Action. If null, it means the request cannot be resolved into an action.
*/
public $requestedAction;
/**
Expand Down Expand Up @@ -517,7 +517,7 @@ public function getErrorHandler()

/**
* Returns the cache component.
* @return \yii\caching\CacheInterface the cache application component. Null if the component is not enabled.
* @return \yii\caching\CacheInterface|null the cache application component. Null if the component is not enabled.
*/
public function getCache()
{
Expand Down Expand Up @@ -643,7 +643,7 @@ public function coreComponents()
* This method replaces the `exit()` function by ensuring the application life cycle is completed
* before terminating the application.
* @param int $status the exit status (value 0 means normal exit while other values mean abnormal exit).
* @param Response $response the response to be sent. If not set, the default application [[response]] component will be used.
* @param Response|null $response the response to be sent. If not set, the default application [[response]] component will be used.
* @throws ExitException if the application is in testing mode
*/
public function end($status = 0, $response = null)
Expand Down
6 changes: 3 additions & 3 deletions framework/base/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public function on($name, $handler, $data = null, $append = true)
* wildcard will be removed, while handlers registered with plain names matching this wildcard will remain.
*
* @param string $name event name
* @param callable $handler the event handler to be removed.
* @param callable|null $handler the event handler to be removed.
* If it is null, all handlers attached to the named event will be removed.
* @return bool if a handler is found and detached
* @see on()
Expand Down Expand Up @@ -645,7 +645,7 @@ public function trigger($name, Event $event = null)
/**
* Returns the named behavior object.
* @param string $name the behavior name
* @return null|Behavior the behavior object, or null if the behavior does not exist
* @return Behavior|null the behavior object, or null if the behavior does not exist
*/
public function getBehavior($name)
{
Expand Down Expand Up @@ -703,7 +703,7 @@ public function attachBehaviors($behaviors)
* Detaches a behavior from the component.
* The behavior's [[Behavior::detach()]] method will be invoked.
* @param string $name the behavior's name.
* @return null|Behavior the detached behavior. Null if the behavior does not exist.
* @return Behavior|null the detached behavior. Null if the behavior does not exist.
*/
public function detachBehavior($name)
{
Expand Down
2 changes: 1 addition & 1 deletion framework/base/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Controller extends Component implements ViewContextInterface
*/
public $defaultAction = 'index';
/**
* @var null|string|false the name of the layout to be applied to this controller's views.
* @var string|null|false the name of the layout to be applied to this controller's views.
* This property mainly affects the behavior of [[render()]].
* Defaults to null, meaning the actual layout value should inherit that from [[module]]'s layout value.
* If false, no layout will be applied.
Expand Down
2 changes: 1 addition & 1 deletion framework/base/ErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ErrorException extends \ErrorException
* @param int $severity [optional]
* @param string $filename [optional]
* @param int $lineno [optional]
* @param \Throwable|\Exception $previous [optional]
* @param \Throwable|\Exception|null $previous [optional]
*/
public function __construct($message = '', $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, $previous = null)
{
Expand Down
6 changes: 3 additions & 3 deletions framework/base/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Event extends BaseObject
*/
public $name;
/**
* @var object the sender of this event. If not set, this property will be
* @var object|null the sender of this event. If not set, this property will be
* set as the object whose `trigger()` method is called.
* This property may also be a `null` when this event is a
* class-level event which is triggered in a static context.
Expand Down Expand Up @@ -130,7 +130,7 @@ public static function on($class, $name, $handler, $data = null, $append = true)
*
* @param string $class the fully qualified class name from which the event handler needs to be detached.
* @param string $name the event name.
* @param callable $handler the event handler to be removed.
* @param callable|null $handler the event handler to be removed.
* If it is `null`, all handlers attached to the named event will be removed.
* @return bool whether a handler is found and detached.
* @see on()
Expand Down Expand Up @@ -257,7 +257,7 @@ class_implements($class, true)
* for the specified class and all its parent classes.
* @param string|object $class the object or the fully qualified class name specifying the class-level event.
* @param string $name the event name.
* @param Event $event the event parameter. If not set, a default [[Event]] object will be created.
* @param Event|null $event the event parameter. If not set, a default [[Event]] object will be created.
*/
public static function trigger($class, $name, $event = null)
{
Expand Down
2 changes: 1 addition & 1 deletion framework/base/ExitException.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ExitException extends \Exception
* @param int $status the exit status code
* @param string $message error message
* @param int $code error code
* @param \Throwable|\Exception $previous The previous exception used for the exception chaining.
* @param \Throwable|\Exception|null $previous The previous exception used for the exception chaining.
*/
public function __construct($status = 0, $message = null, $code = 0, $previous = null)
{
Expand Down
2 changes: 1 addition & 1 deletion framework/base/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Module extends ServiceLocator
/**
* Constructor.
* @param string $id the ID of this module.
* @param Module $parent the parent module (if any).
* @param Module|null $parent the parent module (if any).
* @param array $config name-value pairs that will be used to initialize the object properties.
*/
public function __construct($id, $parent = null, $config = [])
Expand Down
10 changes: 5 additions & 5 deletions framework/base/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function encryptByPassword($data, $password)
* to hash input or output data.
* @param string $data the data to encrypt
* @param string $inputKey the input to use for encryption and authentication
* @param string $info optional context and application specific information, see [[hkdf()]]
* @param string|null $info optional context and application specific information, see [[hkdf()]]
* @return string the encrypted data as byte string
* @see decryptByKey()
* @see encryptByPassword()
Expand All @@ -172,7 +172,7 @@ public function decryptByPassword($data, $password)
* Verifies and decrypts data encrypted with [[encryptByKey()]].
* @param string $data the encrypted data to decrypt
* @param string $inputKey the input to use for encryption and authentication
* @param string $info optional context and application specific information, see [[hkdf()]]
* @param string|null $info optional context and application specific information, see [[hkdf()]]
* @return bool|string the decrypted data or false on authentication failure
* @see encryptByKey()
*/
Expand Down Expand Up @@ -286,8 +286,8 @@ protected function decrypt($data, $passwordBased, $secret, $info)
* Recommend use one of the SHA-2 hash algorithms: sha224, sha256, sha384 or sha512.
* @param string $algo a hash algorithm supported by `hash_hmac()`, e.g. 'SHA-256'
* @param string $inputKey the source key
* @param string $salt the random salt
* @param string $info optional info to bind the derived key material to application-
* @param string|null $salt the random salt
* @param string|null $info optional info to bind the derived key material to application-
* and context-specific information, e.g. a user ID or API version, see
* [RFC 5869](https://tools.ietf.org/html/rfc5869)
* @param int $length length of the output key in bytes. If 0, the output key is
Expand Down Expand Up @@ -529,7 +529,7 @@ public function generateRandomString($length = 32)
* ```
*
* @param string $password The password to be hashed.
* @param int $cost Cost parameter used by the Blowfish hash algorithm.
* @param int|null $cost Cost parameter used by the Blowfish hash algorithm.
* The higher the value of cost,
* the longer it takes to generate the hash and to verify a password against it. Higher cost
* therefore slows down a brute-force attack. For best protection against brute-force attacks,
Expand Down
10 changes: 5 additions & 5 deletions framework/base/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class View extends Component implements DynamicContentAwareInterface
*/
public $params = [];
/**
* @var array a list of available renderers indexed by their corresponding supported file extensions.
* @var array|null a list of available renderers indexed by their corresponding supported file extensions.
* 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:
*
Expand All @@ -74,7 +74,7 @@ class View extends Component implements DynamicContentAwareInterface
*/
public $defaultExtension = 'php';
/**
* @var Theme|array|string the theme object or the configuration for creating the theme object.
* @var Theme|array|string|null the theme object or the configuration for creating the theme object.
* If not set, it means theming is not enabled.
*/
public $theme;
Expand Down Expand Up @@ -142,7 +142,7 @@ public function init()
*
* @param string $view the view name.
* @param array $params the parameters (name-value pairs) that will be extracted and made available in the view file.
* @param object $context the context to be assigned to the view and can later be accessed via [[context]]
* @param object|null $context the context to be assigned to the view and can later be accessed via [[context]]
* in the view. If the context implements [[ViewContextInterface]], it may also be used to locate
* the view file corresponding to a relative view name.
* @return string the rendering result
Expand All @@ -160,7 +160,7 @@ public function render($view, $params = [], $context = null)
* Finds the view file based on the given view name.
* @param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to [[render()]]
* on how to specify this parameter.
* @param object $context the context to be assigned to the view and can later be accessed via [[context]]
* @param object|null $context the context to be assigned to the view and can later be accessed via [[context]]
* in the view. If the context implements [[ViewContextInterface]], it may also be used to locate
* the view file corresponding to a relative view name.
* @return string the view file path. Note that the file may not exist.
Expand Down Expand Up @@ -215,7 +215,7 @@ protected function findViewFile($view, $context = null)
*
* @param string $viewFile the view file. This can be either an absolute file path or an alias of it.
* @param array $params the parameters (name-value pairs) that will be extracted and made available in the view file.
* @param object $context the context that the view should use for rendering the view. If null,
* @param object|null $context the context that the view should use for rendering the view. If null,
* existing [[context]] will be used.
* @return string the rendering result
* @throws ViewNotFoundException if the view file does not exist
Expand Down
2 changes: 1 addition & 1 deletion framework/behaviors/AttributeTypecastBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function attach($owner)

/**
* Typecast owner attributes according to [[attributeTypes]].
* @param array $attributeNames list of attribute names that should be type-casted.
* @param array|null $attributeNames list of attribute names that should be type-casted.
* If this parameter is empty, it means any attribute listed in the [[attributeTypes]]
* should be type-casted.
*/
Expand Down
24 changes: 12 additions & 12 deletions framework/caching/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ abstract class Cache extends Component implements CacheInterface
*/
public $keyPrefix;
/**
* @var null|array|false the functions used to serialize and unserialize cached data. Defaults to null, meaning
* @var array|null|false the functions used to serialize and unserialize cached data. Defaults to null, meaning
* using the default PHP `serialize()` and `unserialize()` functions. If you want to use some more efficient
* serializer (e.g. [igbinary](https://pecl.php.net/package/igbinary)), you may configure this property with
* a two-element array. The first element specifies the serialization function, and the second the deserialization
Expand Down Expand Up @@ -229,9 +229,9 @@ public function multiGet($keys)
* @param mixed $key a key identifying the value to be cached. This can be a simple string or
* a complex data structure consisting of factors representing the key.
* @param mixed $value the value to be cached
* @param int $duration default duration in seconds before the cache will expire. If not set,
* @param int|null $duration default duration in seconds before the cache will expire. If not set,
* default [[defaultDuration]] value is used.
* @param Dependency $dependency dependency of the cached item. If the dependency changes,
* @param Dependency|null $dependency dependency of the cached item. If the dependency changes,
* the corresponding value in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return bool whether the value is successfully stored into cache
Expand Down Expand Up @@ -261,9 +261,9 @@ public function set($key, $value, $duration = null, $dependency = null)
* expiration time will be replaced with the new ones, respectively.
*
* @param array $items the items to be cached, as key-value pairs.
* @param int $duration default duration in seconds before the cache will expire. If not set,
* @param int|null $duration default duration in seconds before the cache will expire. If not set,
* default [[defaultDuration]] value is used.
* @param Dependency $dependency dependency of the cached items. If the dependency changes,
* @param Dependency|null $dependency dependency of the cached items. If the dependency changes,
* the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return array array of failed keys
Expand All @@ -280,9 +280,9 @@ public function mset($items, $duration = null, $dependency = null)
* expiration time will be replaced with the new ones, respectively.
*
* @param array $items the items to be cached, as key-value pairs.
* @param int $duration default duration in seconds before the cache will expire. If not set,
* @param int|null $duration default duration in seconds before the cache will expire. If not set,
* default [[defaultDuration]] value is used.
* @param Dependency $dependency dependency of the cached items. If the dependency changes,
* @param Dependency|null $dependency dependency of the cached items. If the dependency changes,
* the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return array array of failed keys
Expand Down Expand Up @@ -319,7 +319,7 @@ public function multiSet($items, $duration = null, $dependency = null)
*
* @param array $items the items to be cached, as key-value pairs.
* @param int $duration default number of seconds in which the cached values will expire. 0 means never expire.
* @param Dependency $dependency dependency of the cached items. If the dependency changes,
* @param Dependency|null $dependency dependency of the cached items. If the dependency changes,
* the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return array array of failed keys
Expand All @@ -336,7 +336,7 @@ public function madd($items, $duration = 0, $dependency = null)
*
* @param array $items the items to be cached, as key-value pairs.
* @param int $duration default number of seconds in which the cached values will expire. 0 means never expire.
* @param Dependency $dependency dependency of the cached items. If the dependency changes,
* @param Dependency|null $dependency dependency of the cached items. If the dependency changes,
* the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return array array of failed keys
Expand Down Expand Up @@ -370,7 +370,7 @@ public function multiAdd($items, $duration = 0, $dependency = null)
* a complex data structure consisting of factors representing the key.
* @param mixed $value the value to be cached
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
* @param Dependency $dependency dependency of the cached item. If the dependency changes,
* @param Dependency|null $dependency dependency of the cached item. If the dependency changes,
* the corresponding value in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return bool whether the value is successfully stored into cache
Expand Down Expand Up @@ -590,9 +590,9 @@ public function offsetUnset($key)
* If you use $callable that can return `false`, then keep in mind that [[getOrSet()]] may work inefficiently
* because the [[yii\caching\Cache::get()]] method uses `false` return value to indicate the data item is not found
* in the cache. Thus, caching of `false` value will lead to unnecessary internal calls.
* @param int $duration default duration in seconds before the cache will expire. If not set,
* @param int|null $duration default duration in seconds before the cache will expire. If not set,
* [[defaultDuration]] value will be used.
* @param Dependency $dependency dependency of the cached item. If the dependency changes,
* @param Dependency|null $dependency dependency of the cached item. If the dependency changes,
* the corresponding value in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is `false`.
* @return mixed result of $callable execution
Expand Down
Loading

0 comments on commit 4628b91

Please sign in to comment.