diff --git a/BaseYii.php b/BaseYii.php index 0b23ae0d1..253205bba 100644 --- a/BaseYii.php +++ b/BaseYii.php @@ -93,7 +93,7 @@ class BaseYii */ public static function getVersion() { - return '2.0.54-dev'; + return '22.0.x-dev'; } /** @@ -417,18 +417,6 @@ public static function debug($message, $category = 'application') } } - /** - * Alias of [[debug()]]. - * @param string|array $message the message to be logged. This can be a simple string or a more - * complex data structure, such as an array. - * @param string $category the category of the message. - * @deprecated since 2.0.14. Use [[debug()]] instead. - */ - public static function trace($message, $category = 'application') - { - static::debug($message, $category); - } - /** * Logs an error message. * An error message is typically logged when an unrecoverable error occurs @@ -503,18 +491,6 @@ public static function endProfile($token, $category = 'application') static::getLogger()->log($token, Logger::LEVEL_PROFILE_END, $category); } - /** - * Returns an HTML hyperlink that can be displayed on your Web page showing "Powered by Yii Framework" information. - * @return string an HTML hyperlink that can be displayed on your Web page showing "Powered by Yii Framework" information - * @deprecated since 2.0.14, this method will be removed in 2.1.0. - */ - public static function powered() - { - return \Yii::t('yii', 'Powered by {yii}', [ - 'yii' => '' . \Yii::t('yii', 'Yii Framework') . '', - ]); - } - /** * Translates a message to the specified language. * diff --git a/CHANGELOG.md b/CHANGELOG.md index 8451b1875..b14ebe6d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,30 @@ Yii Framework 2 Change Log ========================== +22.0 under development +------------------------ + +- Chg #19902: Remove support for CUBRID (mtangoo) +- Chg #19891: Remove XCache and ZendDataCache support (mtangoo) +- Enh #20368: Refactor asset management: Migrate from `Bower` to `NPM` for package dependencies and update related documentation (terabytesoftw) +- Chg #20402: Remove unsed code `E_STRICT` handling in `ErrorException` class and update tests to reflect changes (terabytesoftw) +- Chg #20403: Remove unsed code in `ErrorHandler` class (terabytesoftw) +- Chg #20408: Remove unsed code in `Model` in `formName()` method to enforce explicit definition for anonymous models (terabytesoftw) +- Chg #20421: Remove `PHP_VERSION_ID` check in `pbkdf2` method for `hash_pbkdf2` function (terabytesoftw) +- Chg #20422: Remove `PHP_VERSION_ID` checks from `AttributeTypecastBehavior` and its tests for enum typecasting (terabytesoftw) +- Chg #20427: Remove `PHP_VERSION_ID` and `PHP_MAJOR_VERSION` checks from console `Controller` class (terabytesoftw) +- Chg #20444: Remove `PHP_VERSION_ID` checks from db `ColumnSchema` class (terabytesoftw) +- Chg #20445: Remove `PHP_VERSION_ID` checks from db `Connection` class (terabytesoftw) +- Chg #20446: Remove deprecated method `convertExceptionToError()` in `ErrorHandler` class and clean tests (terabytesoftw) +- Chg #20448: Remove `PHP_VERSION_ID` checks from di `Container` class (terabytesoftw) +- Chg #20450: Remove `PHP_VERSION_ID` checks from validators `EmailValidator` class (terabytesoftw) +- Chg #20449: Remove `PHP_VERSION_ID` checks from helpers `BaseJson` class (terabytesoftw) +- Chg #20452: Remove `PHP_VERSION_ID` checks from web `Controller` class (terabytesoftw) +- Chg #20451: Remove `PHP_VERSION_ID` checks from validators `UrlValidator` class (terabytesoftw) +- Chg #20455: Remove `PHP_VERSION_ID` checks from web `Request` class (terabytesoftw) +- Chg #20465: Remove `PHP_VERSION_ID` checks from web `Session` class (terabytesoftw) +- Chg #20464: Remove `PHP_VERSION_ID` checks from web `Response` class (terabytesoftw) + 2.0.54 under development ------------------------ @@ -8,6 +32,10 @@ Yii Framework 2 Change Log - Bug #20437: Fix PHPStan/Psalm annotations for `BaseArrayHelper::merge` (max-s-lab) - Enh #20434: Added PHPStan/Psalm annotations for `hasMany` and `hasOne` methods (max-s-lab) - Enh #20433: Added PHPStan/Psalm annotations for some controllers methods: `beforeAction`, `afterAction` and `bindActionParams` (max-s-lab) +- Enh #20442: Add PHPStan/Psalm annotations for `yii\base\Controller` methods: `runAction`, `run`, `render`, `renderPartial` and `renderFile` (max-s-lab) +- Bug #20453: Fix PHPStan/Psalm types in `yii\web\View` (max-s-lab) +- Enh #20461: Add PHPStan/Psalm annotations for `yii\filters\auth\AuthInterface` (max-s-lab) +- Bug #20459: Fix return type in `RequestParserInterface::parse` (max-s-lab) 2.0.53 June 27, 2025 diff --git a/UPGRADE.md b/UPGRADE.md index dc51988ec..2dce7a096 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -51,10 +51,10 @@ if you want to upgrade from version A to version C and there is version B between A and C, you need to follow the instructions for both A and B. -Upgrade from Yii 2.0.53 +Upgrade from Yii 2.0.52 ----------------------- -* `ErrorHandler::convertExceptionToError()` has been deprecated and will be removed in version 22.0. +* `ErrorHandler::convertExceptionToError()` has been deprecated and will be removed in version 2.2.0. This method was deprecated due to `PHP 8.4` deprecating the use of `E_USER_ERROR` with `trigger_error()`. The framework now handles exceptions in `__toString()` methods more appropriately based on the PHP version. @@ -86,8 +86,6 @@ Upgrade from Yii 2.0.53 } ``` -Upgrade from Yii 2.0.52 ------------------------ * There was a bug when loading fixtures into PostgreSQL database, the table sequences were not reset. If you used a work-around or if you depended on this behavior, you are advised to review your code. Upgrade from Yii 2.0.51 @@ -102,109 +100,109 @@ Upgrade from Yii 2.0.50 * Correcting the behavior for `JSON` column type in `MariaDb`. -Example usage of `JSON` column type in `db`: - -```php -db; -$command = $db->createCommand(); - -// Create a table with a JSON column -$command->createTable( - 'products', - [ - 'id' => Schema::TYPE_PK, - 'details' => Schema::TYPE_JSON, - ], -)->execute(); - -// Insert a new product -$command->insert( - 'products', - [ - 'details' => [ - 'name' => 'apple', - 'price' => 100, - 'color' => 'blue', - 'size' => 'small', - ], - ], -)->execute(); - -// Read all products -$records = $db->createCommand('SELECT * FROM products')->queryAll(); -``` - -Example usage of `JSON` column type in `ActiveRecord`: - -```php -details = [ - 'name' => 'windows', - 'color' => 'red', - 'price' => 200, - 'size' => 'large', -]; - -// Save the product -$product->save(); - -// Read the first product -$product = ProductModel::findOne(1); - -// Get the product details -$details = $product->details; - -echo 'Name: ' . $details['name']; -echo 'Color: ' . $details['color']; -echo 'Size: ' . $details['size']; - -// Read all products with color red -$products = ProductModel::find() - ->where(new \yii\db\Expression('JSON_EXTRACT(details, "$.color") = :color', [':color' => 'red'])) - ->all(); - -// Loop through all products -foreach ($products as $product) { - $details = $product->details; - echo 'Name: ' . $details['name']; - echo 'Color: ' . $details['color']; - echo 'Size: ' . $details['size']; -} -``` + Example usage of `JSON` column type in `db`: + + ```php + db; + $command = $db->createCommand(); + + // Create a table with a JSON column + $command->createTable( + 'products', + [ + 'id' => Schema::TYPE_PK, + 'details' => Schema::TYPE_JSON, + ], + )->execute(); + + // Insert a new product + $command->insert( + 'products', + [ + 'details' => [ + 'name' => 'apple', + 'price' => 100, + 'color' => 'blue', + 'size' => 'small', + ], + ], + )->execute(); + + // Read all products + $records = $db->createCommand('SELECT * FROM products')->queryAll(); + ``` + + Example usage of `JSON` column type in `ActiveRecord`: + + ```php + details = [ + 'name' => 'windows', + 'color' => 'red', + 'price' => 200, + 'size' => 'large', + ]; + + // Save the product + $product->save(); + + // Read the first product + $product = ProductModel::findOne(1); + + // Get the product details + $details = $product->details; + + echo 'Name: ' . $details['name']; + echo 'Color: ' . $details['color']; + echo 'Size: ' . $details['size']; + + // Read all products with color red + $products = ProductModel::find() + ->where(new \yii\db\Expression('JSON_EXTRACT(details, "$.color") = :color', [':color' => 'red'])) + ->all(); + + // Loop through all products + foreach ($products as $product) { + $details = $product->details; + echo 'Name: ' . $details['name']; + echo 'Color: ' . $details['color']; + echo 'Size: ' . $details['size']; + } + ``` Upgrade from Yii 2.0.48 ----------------------- @@ -451,7 +449,7 @@ Upgrade from Yii 2.0.34 public function rules() { return [ - ['attribute', 'each', 'rule' => ['exist', 'targetClass' => static::className(), 'targetAttribute' => 'id']], + ['attribute', 'each', 'rule' => ['exist', 'targetClass' => static::class, 'targetAttribute' => 'id']], ]; } ``` @@ -680,13 +678,11 @@ Upgrade from Yii 2.0.13 * Log targets (like `yii\log\EmailTarget`) are now throwing `yii\log\LogRuntimeException` in case log can not be properly exported. -* You can start preparing your application for Yii 2.1 by doing the following: +* You can start preparing your application for Yii 2.2 by doing the following: - - Replace `::className()` calls with `::class` (if you’re running PHP 5.5+). - Replace usages of `yii\base\InvalidParamException` with `yii\base\InvalidArgumentException`. - Replace calls to `Yii::trace()` with `Yii::debug()`. - Remove calls to `yii\BaseYii::powered()`. - - If you are using XCache or Zend data cache, those are going away in 2.1 so you might want to start looking for an alternative. * In case you aren't using CSRF cookies (REST APIs etc.) you should turn them off explicitly by setting `\yii\web\Request::$enableCsrfCookie` to `false` in your config file. diff --git a/base/Application.php b/base/Application.php index 10c24c823..39acc24b5 100644 --- a/base/Application.php +++ b/base/Application.php @@ -462,8 +462,7 @@ public function setVendorPath($path) { $this->_vendorPath = Yii::getAlias($path); Yii::setAlias('@vendor', $this->_vendorPath); - Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower'); - Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm'); + Yii::setAlias('@npm', $this->getBasePath() . DIRECTORY_SEPARATOR . 'node_modules'); } /** diff --git a/base/BaseObject.php b/base/BaseObject.php index 8ef2f1566..6a87b4aed 100644 --- a/base/BaseObject.php +++ b/base/BaseObject.php @@ -76,16 +76,6 @@ */ class BaseObject implements Configurable { - /** - * Returns the fully qualified name of this class. - * @return string the fully qualified name of this class. - * @deprecated since 2.0.14. On PHP >=5.5, use `::class` instead. - */ - public static function className() - { - return get_called_class(); - } - /** * Constructor. * @@ -295,4 +285,14 @@ public function hasMethod($name) { return method_exists($this, $name); } + + /** + * Returns the fully qualified name of this class. + * + * @return string the fully qualified name of this class. + */ + public static function className(): string + { + return static::class; + } } diff --git a/base/Component.php b/base/Component.php index 8fd7c6fa6..bfccadbd6 100644 --- a/base/Component.php +++ b/base/Component.php @@ -462,8 +462,8 @@ public function hasMethod($name, $checkBehaviors = true) * * @return array the behavior configurations. * - * @phpstan-return array - * @psalm-return array + * @phpstan-return array + * @psalm-return array */ public function behaviors() { diff --git a/base/Controller.php b/base/Controller.php index d57177226..0eec3adb4 100644 --- a/base/Controller.php +++ b/base/Controller.php @@ -105,8 +105,8 @@ public function __construct($id, $module, $config = []) public function init() { parent::init(); - $this->request = Instance::ensure($this->request, Request::className()); - $this->response = Instance::ensure($this->response, Response::className()); + $this->request = Instance::ensure($this->request, Request::class); + $this->response = Instance::ensure($this->response, Response::class); } /** @@ -147,6 +147,9 @@ public function actions() * @return mixed the result of the action. * @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully. * @see createAction() + * + * @phpstan-param array $params + * @psalm-param array $params */ public function runAction($id, $params = []) { @@ -208,6 +211,9 @@ public function runAction($id, $params = []) * @param array $params the parameters to be passed to the action. * @return mixed the result of the action. * @see runAction() + * + * @phpstan-param array $params + * @psalm-param array $params */ public function run($route, $params = []) { @@ -422,6 +428,9 @@ public function getRoute() * These parameters will not be available in the layout. * @return string the rendering result. * @throws InvalidArgumentException if the view file or the layout file does not exist. + * + * @phpstan-param array $params + * @psalm-param array $params */ public function render($view, $params = []) { @@ -453,6 +462,9 @@ public function renderContent($content) * @param array $params the parameters (name-value pairs) that should be made available in the view. * @return string the rendering result. * @throws InvalidArgumentException if the view file does not exist. + * + * @phpstan-param array $params + * @psalm-param array $params */ public function renderPartial($view, $params = []) { @@ -465,6 +477,9 @@ public function renderPartial($view, $params = []) * @param array $params the parameters (name-value pairs) that should be made available in the view. * @return string the rendering result. * @throws InvalidArgumentException if the view file does not exist. + * + * @phpstan-param array $params + * @psalm-param array $params */ public function renderFile($file, $params = []) { diff --git a/base/ErrorException.php b/base/ErrorException.php index a5af2a802..3eb1f42f5 100644 --- a/base/ErrorException.php +++ b/base/ErrorException.php @@ -130,7 +130,7 @@ public function getName() E_USER_WARNING => 'PHP User Warning', E_WARNING => 'PHP Warning', self::E_HHVM_FATAL_ERROR => 'HHVM Fatal Error', - ] + (PHP_VERSION_ID < 80400 ? [E_STRICT => 'PHP Strict Warning'] : []); + ]; return $names[$this->getCode()] ?? 'Error'; } diff --git a/base/ErrorHandler.php b/base/ErrorHandler.php index 74eb02c68..71a7162f0 100644 --- a/base/ErrorHandler.php +++ b/base/ErrorHandler.php @@ -251,24 +251,8 @@ public function handleError($code, $message, $file, $line) if (!class_exists('yii\\base\\ErrorException', false)) { require_once __DIR__ . '/ErrorException.php'; } - $exception = new ErrorException($message, $code, $code, $file, $line); - - if (PHP_VERSION_ID < 70400) { - // prior to PHP 7.4 we can't throw exceptions inside of __toString() - it will result a fatal error - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - array_shift($trace); - foreach ($trace as $frame) { - if ($frame['function'] === '__toString') { - $this->handleException($exception); - if (defined('HHVM_VERSION')) { - flush(); - } - exit(1); - } - } - } - throw $exception; + throw new ErrorException($message, $code, $code, $file, $line); } return false; @@ -371,24 +355,6 @@ public function clearOutput() } } - /** - * Converts an exception into a PHP error. - * - * This method can be used to convert exceptions inside of methods like `__toString()` - * to PHP errors because exceptions cannot be thrown inside of them. - * @param \Throwable $exception the exception to convert to a PHP error. - * @return never - * - * @deprecated since 2.0.53. Use conditional exception throwing in `__toString()` methods instead. - * For PHP < 7.4: use `trigger_error()` directly with `convertExceptionToString()` method. - * For PHP >= 7.4: throw the exception directly as `__toString()` supports exceptions. - * This method will be removed in 2.2.0. - */ - public static function convertExceptionToError($exception) - { - trigger_error(static::convertExceptionToString($exception), E_USER_ERROR); - } - /** * Converts an exception into a simple string. * @param \Throwable $exception the exception being converted diff --git a/base/InvalidArgumentException.php b/base/InvalidArgumentException.php index 20a7c6c75..428d73b58 100644 --- a/base/InvalidArgumentException.php +++ b/base/InvalidArgumentException.php @@ -13,7 +13,7 @@ * @author Qiang Xue * @since 2.0.14 */ -class InvalidArgumentException extends InvalidParamException +class InvalidArgumentException extends \BadMethodCallException { /** * @return string the user-friendly name of this exception diff --git a/base/InvalidParamException.php b/base/InvalidParamException.php deleted file mode 100644 index 0024602ec..000000000 --- a/base/InvalidParamException.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @since 2.0 - * @deprecated since 2.0.14. Use [[InvalidArgumentException]] instead. - */ -class InvalidParamException extends \BadMethodCallException -{ - /** - * @return string the user-friendly name of this exception - */ - public function getName() - { - return 'Invalid Parameter'; - } -} diff --git a/base/Model.php b/base/Model.php index afa74646e..244e9ad16 100644 --- a/base/Model.php +++ b/base/Model.php @@ -161,8 +161,8 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg * @return array validation rules * @see scenarios() * - * @phpstan-return array[] - * @psalm-return array[] + * @phpstan-return array[] + * @psalm-return array[] */ public function rules() { @@ -266,9 +266,11 @@ public function scenarios() public function formName() { $reflector = new ReflectionClass($this); - if (PHP_VERSION_ID >= 70000 && $reflector->isAnonymous()) { + + if ($reflector->isAnonymous()) { throw new InvalidConfigException('The "formName()" method should be explicitly defined for anonymous models'); } + return $reflector->getShortName(); } diff --git a/base/Security.php b/base/Security.php index 85faf50e5..63e7e9516 100644 --- a/base/Security.php +++ b/base/Security.php @@ -72,16 +72,6 @@ class Security extends Component * Set as high as possible to hinder dictionary password attacks. */ public $derivationIterations = 100000; - /** - * @var string strategy, which should be used to generate password hash. - * Available strategies: - * - 'password_hash' - use of PHP `password_hash()` function with PASSWORD_DEFAULT algorithm. - * This option is recommended, but it requires PHP version >= 5.5.0 - * - 'crypt' - use PHP `crypt()` function. - * @deprecated since version 2.0.7, [[generatePasswordHash()]] ignores [[passwordHashStrategy]] and - * uses `password_hash()` when available or `crypt()` when not. - */ - public $passwordHashStrategy; /** * @var int Default cost used for password hashing. * Allowed value is between 4 and 31. @@ -353,7 +343,7 @@ public function hkdf($algo, $inputKey, $salt = null, $info = null, $length = 0) */ public function pbkdf2($algo, $password, $salt, $iterations, $length = 0) { - if (function_exists('hash_pbkdf2') && PHP_VERSION_ID >= 50500) { + if (function_exists('hash_pbkdf2')) { $outputKey = hash_pbkdf2($algo, $password, $salt, $iterations, $length, true); if ($outputKey === false) { throw new InvalidArgumentException('Invalid parameters to hash_pbkdf2()'); diff --git a/behaviors/AttributeTypecastBehavior.php b/behaviors/AttributeTypecastBehavior.php index d3a177b3d..3d55d7ba7 100644 --- a/behaviors/AttributeTypecastBehavior.php +++ b/behaviors/AttributeTypecastBehavior.php @@ -269,7 +269,7 @@ protected function typecastValue($value, $type) return (string) $value; } - if (PHP_VERSION_ID >= 80100 && is_subclass_of($type, \BackedEnum::class)) { + if (is_subclass_of($type, \BackedEnum::class)) { if ($value instanceof $type) { return $value; } diff --git a/behaviors/SluggableBehavior.php b/behaviors/SluggableBehavior.php index 9e2ffed91..4b9ec90a7 100644 --- a/behaviors/SluggableBehavior.php +++ b/behaviors/SluggableBehavior.php @@ -242,7 +242,7 @@ protected function validateSlug($slug) /** @var UniqueValidator $validator */ $validator = Yii::createObject(array_merge( [ - 'class' => UniqueValidator::className(), + 'class' => UniqueValidator::class, ], $this->uniqueValidator )); diff --git a/caching/Cache.php b/caching/Cache.php index d6d363c6d..390494271 100644 --- a/caching/Cache.php +++ b/caching/Cache.php @@ -166,23 +166,6 @@ public function exists($key) return $value !== false; } - /** - * Retrieves multiple values from cache with the specified keys. - * Some caches (such as memcache, apc) allow retrieving multiple cached values at the same time, - * which may improve the performance. In case a cache does not support this feature natively, - * this method will try to simulate it. - * - * @param string[] $keys list of string keys identifying the cached values - * @return array list of cached values corresponding to the specified keys. The array - * is returned in terms of (key, value) pairs. - * If a value is not cached or expired, the corresponding array value will be false. - * @deprecated This method is an alias for [[multiGet()]] and will be removed in 2.1.0. - */ - public function mget($keys) - { - return $this->multiGet($keys); - } - /** * Retrieves multiple values from cache with the specified keys. * Some caches (such as memcache, apc) allow retrieving multiple cached values at the same time, @@ -255,25 +238,6 @@ public function set($key, $value, $duration = null, $dependency = null) return $this->setValue($key, $value, $duration); } - /** - * Stores multiple items in cache. Each item contains a value identified by a key. - * If the cache already contains such a key, the existing value and - * expiration time will be replaced with the new ones, respectively. - * - * @param array $items the items to be cached, as key-value pairs. - * @param int|null $duration default duration in seconds before the cache will expire. If not set, - * default [[defaultDuration]] value is used. - * @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 - * @deprecated This method is an alias for [[multiSet()]] and will be removed in 2.1.0. - */ - public function mset($items, $duration = null, $dependency = null) - { - return $this->multiSet($items, $duration, $dependency); - } - /** * Stores multiple items in cache. Each item contains a value identified by a key. * If the cache already contains such a key, the existing value and @@ -299,23 +263,6 @@ public function multiSet($items, $duration = null, $dependency = null) return $this->setValues($data, $duration); } - /** - * Stores multiple items in cache. Each item contains a value identified by a key. - * If the cache already contains such a key, the existing value and expiration time will be preserved. - * - * @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|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 - * @deprecated This method is an alias for [[multiAdd()]] and will be removed in 2.1.0. - */ - public function madd($items, $duration = 0, $dependency = null) - { - return $this->multiAdd($items, $duration, $dependency); - } - /** * Stores multiple items in cache. Each item contains a value identified by a key. * If the cache already contains such a key, the existing value and expiration time will be preserved. diff --git a/caching/DbCache.php b/caching/DbCache.php index d707ba41a..45f172969 100644 --- a/caching/DbCache.php +++ b/caching/DbCache.php @@ -95,7 +95,7 @@ class DbCache extends Cache public function init() { parent::init(); - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); } /** diff --git a/caching/Dependency.php b/caching/Dependency.php index e558bfef8..c4de5078a 100644 --- a/caching/Dependency.php +++ b/caching/Dependency.php @@ -57,17 +57,6 @@ public function evaluateDependency($cache) } } - /** - * Returns a value indicating whether the dependency has changed. - * @deprecated since version 2.0.11. Will be removed in version 2.1. Use [[isChanged()]] instead. - * @param CacheInterface $cache the cache component that is currently evaluating this dependency - * @return bool whether the dependency has changed. - */ - public function getHasChanged($cache) - { - return $this->isChanged($cache); - } - /** * Checks whether the dependency is changed. * @param CacheInterface $cache the cache component that is currently evaluating this dependency diff --git a/caching/XCache.php b/caching/XCache.php deleted file mode 100644 index 06c305de2..000000000 --- a/caching/XCache.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @since 2.0 - * @deprecated since 2.0.14. This class will be removed in 2.1.0. - */ -class XCache extends Cache -{ - /** - * Checks whether a specified key exists in the cache. - * This can be faster than getting the value from the cache if the data is big. - * Note that this method does not check whether the dependency associated - * with the cached data, if there is any, has changed. So a call to [[get]] - * may return false while exists returns true. - * @param mixed $key a key identifying the cached value. This can be a simple string or - * a complex data structure consisting of factors representing the key. - * @return bool true if a value exists in cache, false if the value is not in the cache or expired. - */ - public function exists($key) - { - $key = $this->buildKey($key); - - return xcache_isset($key); - } - - /** - * Retrieves a value from cache with a specified key. - * This is the implementation of the method declared in the parent class. - * @param string $key a unique key identifying the cached value - * @return mixed|false the value stored in cache, false if the value is not in the cache or expired. - */ - protected function getValue($key) - { - return xcache_isset($key) ? xcache_get($key) : false; - } - - /** - * Stores a value identified by a key in cache. - * This is the implementation of the method declared in the parent class. - * - * @param string $key the key identifying the value to be cached - * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]], - * it could be something else. - * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. - * @return bool true if the value is successfully stored into cache, false otherwise - */ - protected function setValue($key, $value, $duration) - { - return xcache_set($key, $value, $duration); - } - - /** - * Stores a value identified by a key into cache if the cache does not contain this key. - * This is the implementation of the method declared in the parent class. - * - * @param string $key the key identifying the value to be cached - * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]], - * it could be something else. - * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. - * @return bool true if the value is successfully stored into cache, false otherwise - */ - protected function addValue($key, $value, $duration) - { - return !xcache_isset($key) ? $this->setValue($key, $value, $duration) : false; - } - - /** - * Deletes a value with the specified key from cache - * This is the implementation of the method declared in the parent class. - * @param string $key the key of the value to be deleted - * @return bool if no error happens during deletion - */ - protected function deleteValue($key) - { - return xcache_unset($key); - } - - /** - * Deletes all values from cache. - * This is the implementation of the method declared in the parent class. - * @return bool whether the flush operation was successful. - */ - protected function flushValues() - { - for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) { - if (xcache_clear_cache(XC_TYPE_VAR, $i) === false) { - return false; - } - } - - return true; - } -} diff --git a/caching/ZendDataCache.php b/caching/ZendDataCache.php deleted file mode 100644 index 0f49501db..000000000 --- a/caching/ZendDataCache.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @since 2.0 - * @deprecated since 2.0.14. This class will be removed in 2.1.0. - */ -class ZendDataCache extends Cache -{ - /** - * Retrieves a value from cache with a specified key. - * This is the implementation of the method declared in the parent class. - * @param string $key a unique key identifying the cached value - * @return mixed|false the value stored in cache, false if the value is not in the cache or expired. - */ - protected function getValue($key) - { - $result = zend_shm_cache_fetch($key); - - return $result === null ? false : $result; - } - - /** - * Stores a value identified by a key in cache. - * This is the implementation of the method declared in the parent class. - * - * @param string $key the key identifying the value to be cached - * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]], - * it could be something else. - * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. - * @return bool true if the value is successfully stored into cache, false otherwise - */ - protected function setValue($key, $value, $duration) - { - return zend_shm_cache_store($key, $value, $duration); - } - - /** - * Stores a value identified by a key into cache if the cache does not contain this key. - * This is the implementation of the method declared in the parent class. - * - * @param string $key the key identifying the value to be cached - * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]], - * it could be something else. - * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. - * @return bool true if the value is successfully stored into cache, false otherwise - */ - protected function addValue($key, $value, $duration) - { - return zend_shm_cache_fetch($key) === null ? $this->setValue($key, $value, $duration) : false; - } - - /** - * Deletes a value with the specified key from cache - * This is the implementation of the method declared in the parent class. - * @param string $key the key of the value to be deleted - * @return bool if no error happens during deletion - */ - protected function deleteValue($key) - { - return zend_shm_cache_delete($key); - } - - /** - * Deletes all values from cache. - * This is the implementation of the method declared in the parent class. - * @return bool whether the flush operation was successful. - */ - protected function flushValues() - { - return zend_shm_cache_clear(); - } -} diff --git a/classes.php b/classes.php index 03b69c92a..a5758b0c0 100644 --- a/classes.php +++ b/classes.php @@ -36,7 +36,6 @@ 'yii\base\InvalidArgumentException' => YII2_PATH . '/base/InvalidArgumentException.php', 'yii\base\InvalidCallException' => YII2_PATH . '/base/InvalidCallException.php', 'yii\base\InvalidConfigException' => YII2_PATH . '/base/InvalidConfigException.php', - 'yii\base\InvalidParamException' => YII2_PATH . '/base/InvalidParamException.php', 'yii\base\InvalidRouteException' => YII2_PATH . '/base/InvalidRouteException.php', 'yii\base\InvalidValueException' => YII2_PATH . '/base/InvalidValueException.php', 'yii\base\Model' => YII2_PATH . '/base/Model.php', @@ -86,8 +85,6 @@ 'yii\caching\MemCacheServer' => YII2_PATH . '/caching/MemCacheServer.php', 'yii\caching\TagDependency' => YII2_PATH . '/caching/TagDependency.php', 'yii\caching\WinCache' => YII2_PATH . '/caching/WinCache.php', - 'yii\caching\XCache' => YII2_PATH . '/caching/XCache.php', - 'yii\caching\ZendDataCache' => YII2_PATH . '/caching/ZendDataCache.php', 'yii\captcha\Captcha' => YII2_PATH . '/captcha/Captcha.php', 'yii\captcha\CaptchaAction' => YII2_PATH . '/captcha/CaptchaAction.php', 'yii\captcha\CaptchaAsset' => YII2_PATH . '/captcha/CaptchaAsset.php', @@ -169,10 +166,6 @@ 'yii\db\conditions\OrCondition' => YII2_PATH . '/db/conditions/OrCondition.php', 'yii\db\conditions\SimpleCondition' => YII2_PATH . '/db/conditions/SimpleCondition.php', 'yii\db\conditions\SimpleConditionBuilder' => YII2_PATH . '/db/conditions/SimpleConditionBuilder.php', - 'yii\db\cubrid\ColumnSchemaBuilder' => YII2_PATH . '/db/cubrid/ColumnSchemaBuilder.php', - 'yii\db\cubrid\QueryBuilder' => YII2_PATH . '/db/cubrid/QueryBuilder.php', - 'yii\db\cubrid\Schema' => YII2_PATH . '/db/cubrid/Schema.php', - 'yii\db\cubrid\conditions\LikeConditionBuilder' => YII2_PATH . '/db/cubrid/conditions/LikeConditionBuilder.php', 'yii\db\mssql\ColumnSchema' => YII2_PATH . '/db/mssql/ColumnSchema.php', 'yii\db\mssql\ColumnSchemaBuilder' => YII2_PATH . '/db/mssql/ColumnSchemaBuilder.php', 'yii\db\mssql\DBLibPDO' => YII2_PATH . '/db/mssql/DBLibPDO.php', diff --git a/composer.json b/composer.json index 72e5079cd..e8d02272a 100644 --- a/composer.json +++ b/composer.json @@ -63,17 +63,13 @@ "source": "https://github.com/yiisoft/yii2" }, "require": { - "php": ">=7.3.0", + "php": ">=8.1", "ext-mbstring": "*", "ext-ctype": "*", "lib-pcre": "*", "yiisoft/yii2-composer": "~2.0.4", "ezyang/htmlpurifier": "^4.17", - "cebe/markdown": "~1.0.0 | ~1.1.0 | ~1.2.0", - "bower-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable", - "bower-asset/inputmask": "^5.0.8 ", - "bower-asset/punycode": "^1.4", - "bower-asset/yii2-pjax": "~2.0.1" + "cebe/markdown": "~1.0.0 | ~1.1.0 | ~1.2.0" }, "autoload": { "psr-4": {"yii\\": ""} @@ -82,8 +78,6 @@ "yii" ], "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } + "foxy": true } } diff --git a/console/Controller.php b/console/Controller.php index 721124b10..ebf0a512c 100644 --- a/console/Controller.php +++ b/console/Controller.php @@ -38,15 +38,6 @@ */ class Controller extends \yii\base\Controller { - /** - * @deprecated since 2.0.13. Use [[ExitCode::OK]] instead. - */ - const EXIT_CODE_NORMAL = 0; - /** - * @deprecated since 2.0.13. Use [[ExitCode::UNSPECIFIED_ERROR]] instead. - */ - const EXIT_CODE_ERROR = 1; - /** * @var bool whether to run the command interactively. */ @@ -232,11 +223,7 @@ public function bindActionParams($action, $params) unset($params[$jKey]); } } else { - if (PHP_VERSION_ID >= 80000) { - $isArray = ($type = $param->getType()) instanceof \ReflectionNamedType && $type->getName() === 'array'; - } else { - $isArray = $param->isArray(); - } + $isArray = ($type = $param->getType()) instanceof \ReflectionNamedType && $type->getName() === 'array'; if ($isArray) { $params[$key] = $params[$key] === '' ? [] : preg_split('/\s*,\s*/', $params[$key]); } @@ -244,8 +231,7 @@ public function bindActionParams($action, $params) unset($params[$key]); } } elseif ( - PHP_VERSION_ID >= 70100 - && ($type = $param->getType()) !== null + ($type = $param->getType()) !== null && $type instanceof \ReflectionNamedType && !$type->isBuiltin() ) { @@ -601,17 +587,13 @@ public function getActionArgsHelp($action) foreach ($method->getParameters() as $i => $parameter) { $type = null; $comment = ''; - if (PHP_MAJOR_VERSION > 5 && $parameter->hasType()) { + if ($parameter->hasType()) { $reflectionType = $parameter->getType(); - if (PHP_VERSION_ID >= 70100) { - $types = method_exists($reflectionType, 'getTypes') ? $reflectionType->getTypes() : [$reflectionType]; - foreach ($types as $key => $reflectionType) { - $types[$key] = $reflectionType->getName(); - } - $type = implode('|', $types); - } else { - $type = (string) $reflectionType; + $types = method_exists($reflectionType, 'getTypes') ? $reflectionType->getTypes() : [$reflectionType]; + foreach ($types as $key => $reflectionType) { + $types[$key] = $reflectionType->getName(); } + $type = implode('|', $types); } // find PhpDoc tag by property name or position $key = isset($phpDocParams[$parameter->name]) ? $parameter->name : (isset($phpDocParams[$i]) ? $i : null); diff --git a/console/controllers/CacheController.php b/console/controllers/CacheController.php index d5d0a756e..4a2fabff7 100644 --- a/console/controllers/CacheController.php +++ b/console/controllers/CacheController.php @@ -300,6 +300,6 @@ private function isCacheClass($className) */ private function canBeFlushed($className) { - return !is_a($className, ApcCache::className(), true) || PHP_SAPI !== 'cli'; + return !is_a($className, ApcCache::class, true) || PHP_SAPI !== 'cli'; } } diff --git a/console/controllers/FixtureController.php b/console/controllers/FixtureController.php index caba5d271..9187ea517 100644 --- a/console/controllers/FixtureController.php +++ b/console/controllers/FixtureController.php @@ -8,8 +8,8 @@ namespace yii\console\controllers; use Yii; +use yii\base\InvalidArgumentException; use yii\base\InvalidConfigException; -use yii\base\InvalidParamException; use yii\console\Controller; use yii\console\Exception; use yii\console\ExitCode; @@ -258,7 +258,7 @@ private function notifyLoaded($fixtures) $fixtureClassNames = []; foreach ($fixtures as $fixture) { - $fixtureClassNames[] = $fixture::className(); + $fixtureClassNames[] = $fixture::class; } $this->outputList($fixtureClassNames); @@ -536,7 +536,7 @@ private function getFixturePath() { try { return Yii::getAlias('@' . str_replace('\\', '/', $this->namespace)); - } catch (InvalidParamException $e) { + } catch (InvalidArgumentException $e) { throw new InvalidConfigException('Invalid fixture namespace: "' . $this->namespace . '". Please, check your FixtureController::namespace parameter'); } } diff --git a/console/controllers/MessageController.php b/console/controllers/MessageController.php index 63d3aa10b..baffa797c 100644 --- a/console/controllers/MessageController.php +++ b/console/controllers/MessageController.php @@ -318,7 +318,7 @@ public function actionExtract($configFile = null) } } elseif ($this->config['format'] === 'db') { /** @var Connection $db */ - $db = Instance::ensure($this->config['db'], Connection::className()); + $db = Instance::ensure($this->config['db'], Connection::class); $sourceMessageTable = isset($this->config['sourceMessageTable']) ? $this->config['sourceMessageTable'] : '{{%source_message}}'; $messageTable = isset($this->config['messageTable']) ? $this->config['messageTable'] : '{{%message}}'; $this->saveMessagesToDb( diff --git a/console/controllers/MigrateController.php b/console/controllers/MigrateController.php index 104c68657..2f2d1dd17 100644 --- a/console/controllers/MigrateController.php +++ b/console/controllers/MigrateController.php @@ -180,7 +180,7 @@ public function optionAliases() public function beforeAction($action) { if (parent::beforeAction($action)) { - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); return true; } @@ -468,7 +468,7 @@ protected function generateMigrationSourceCode($params) if ($relatedColumn === null) { $relatedColumn = 'id'; try { - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); $relatedTableSchema = $this->db->getTableSchema($relatedTable); if ($relatedTableSchema !== null) { $primaryKeyCount = count($relatedTableSchema->primaryKey); diff --git a/data/BaseDataProvider.php b/data/BaseDataProvider.php index 9339972c5..abecb7c42 100644 --- a/data/BaseDataProvider.php +++ b/data/BaseDataProvider.php @@ -211,7 +211,7 @@ public function getPagination() public function setPagination($value) { if (is_array($value)) { - $config = ['class' => Pagination::className()]; + $config = ['class' => Pagination::class]; if ($this->id !== null) { $config['pageParam'] = $this->id . '-page'; $config['pageSizeParam'] = $this->id . '-per-page'; @@ -252,7 +252,7 @@ public function getSort() public function setSort($value) { if (is_array($value)) { - $config = ['class' => Sort::className()]; + $config = ['class' => Sort::class]; if ($this->id !== null) { $config['sortParam'] = $this->id . '-sort'; } diff --git a/data/DataFilter.php b/data/DataFilter.php index 057509203..587b7b10a 100644 --- a/data/DataFilter.php +++ b/data/DataFilter.php @@ -288,7 +288,7 @@ public function getSearchModel() if (!is_object($this->_searchModel) || $this->_searchModel instanceof \Closure) { $model = Yii::createObject($this->_searchModel); if (!$model instanceof Model) { - throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::className() . '` or its DI compatible configuration.'); + throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::class . '` or its DI compatible configuration.'); } $this->_searchModel = $model; } @@ -302,7 +302,7 @@ public function getSearchModel() public function setSearchModel($model) { if (is_object($model) && !$model instanceof Model && !$model instanceof \Closure) { - throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::className() . '` or its DI compatible configuration.'); + throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::class . '` or its DI compatible configuration.'); } $this->_searchModel = $model; } diff --git a/data/SqlDataProvider.php b/data/SqlDataProvider.php index a0fe4bc29..e8620ff34 100644 --- a/data/SqlDataProvider.php +++ b/data/SqlDataProvider.php @@ -95,7 +95,7 @@ class SqlDataProvider extends BaseDataProvider public function init() { parent::init(); - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); if ($this->sql === null) { throw new InvalidConfigException('The "sql" property must be set.'); } diff --git a/db/ActiveRecord.php b/db/ActiveRecord.php index 1df1b4de8..5e195a9d0 100644 --- a/db/ActiveRecord.php +++ b/db/ActiveRecord.php @@ -414,7 +414,7 @@ public static function deleteAll($condition = null, $params = []) */ public static function find() { - return Yii::createObject(ActiveQuery::className(), [get_called_class()]); + return Yii::createObject(ActiveQuery::class, [get_called_class()]); } /** diff --git a/db/BaseActiveRecord.php b/db/BaseActiveRecord.php index 846734dde..6ecad432a 100644 --- a/db/BaseActiveRecord.php +++ b/db/BaseActiveRecord.php @@ -11,7 +11,6 @@ use yii\base\InvalidArgumentException; use yii\base\InvalidCallException; use yii\base\InvalidConfigException; -use yii\base\InvalidParamException; use yii\base\Model; use yii\base\ModelEvent; use yii\base\NotSupportedException; @@ -1693,7 +1692,7 @@ public function getAttributeHint($attribute) } else { try { $relation = $relatedModel->getRelation($relationName); - } catch (InvalidParamException $e) { + } catch (InvalidArgumentException $e) { return ''; } /** @var ActiveRecordInterface $modelClass */ diff --git a/db/ColumnSchema.php b/db/ColumnSchema.php index ef3c9b06d..6fef531ab 100644 --- a/db/ColumnSchema.php +++ b/db/ColumnSchema.php @@ -166,13 +166,13 @@ protected function typecast($value) return $value; } - if (PHP_VERSION_ID >= 80100 && is_object($value) && $value instanceof \BackedEnum) { + if (is_object($value) && $value instanceof \BackedEnum) { return (string) $value->value; } return (string) $value; case 'integer': - if (PHP_VERSION_ID >= 80100 && is_object($value) && $value instanceof \BackedEnum) { + if (is_object($value) && $value instanceof \BackedEnum) { return (int) $value->value; } return (int) $value; diff --git a/db/ColumnSchemaBuilder.php b/db/ColumnSchemaBuilder.php index 02ca9f2fe..d041d4573 100644 --- a/db/ColumnSchemaBuilder.php +++ b/db/ColumnSchemaBuilder.php @@ -225,7 +225,7 @@ public function unsigned() /** * Adds an `AFTER` constraint to the column. - * Note: MySQL, Oracle and Cubrid support only. + * Note: MySQL and Oracle support only. * @param string $after the column after which $this column will be added. * @return $this * @since 2.0.8 @@ -238,7 +238,7 @@ public function after($after) /** * Adds an `FIRST` constraint to the column. - * Note: MySQL, Oracle and Cubrid support only. + * Note: MySQL and Oracle support only. * @return $this * @since 2.0.8 */ diff --git a/db/Connection.php b/db/Connection.php index 51f0ee750..7457c7dd2 100644 --- a/db/Connection.php +++ b/db/Connection.php @@ -238,7 +238,7 @@ class Connection extends Component public $queryCache = 'cache'; /** * @var string|null the charset used for database connection. The property is only used - * for MySQL, PostgreSQL and CUBRID databases. Defaults to null, meaning using default charset + * for MySQL and PostgreSQL databases. Defaults to null, meaning using default charset * as configured by the database. * * For Oracle Database, the charset must be specified in the [[dsn]], for example for UTF-8 by appending `;charset=UTF-8` @@ -282,22 +282,12 @@ class Connection extends Component 'oci' => 'yii\db\oci\Schema', // Oracle driver 'mssql' => 'yii\db\mssql\Schema', // older MSSQL driver on MS Windows hosts 'dblib' => 'yii\db\mssql\Schema', // dblib drivers on GNU/Linux (and maybe other OSes) hosts - 'cubrid' => 'yii\db\cubrid\Schema', // CUBRID ]; /** * @var string|null Custom PDO wrapper class. If not set, it will use [[PDO]] or [[\yii\db\mssql\PDO]] when MSSQL is used. * @see pdo */ public $pdoClass; - /** - * @var string the class used to create new database [[Command]] objects. If you want to extend the [[Command]] class, - * you may configure this property to use your extended version of the class. - * Since version 2.0.14 [[$commandMap]] is used if this property is set to its default value. - * @see createCommand - * @since 2.0.7 - * @deprecated since 2.0.14. Use [[$commandMap]] for precise configuration. - */ - public $commandClass = 'yii\db\Command'; /** * @var array mapping between PDO driver names and [[Command]] classes. * The keys of the array are PDO driver names while the values are either the corresponding @@ -319,7 +309,6 @@ class Connection extends Component 'oci' => 'yii\db\oci\Command', // Oracle driver 'mssql' => 'yii\db\Command', // older MSSQL driver on MS Windows hosts 'dblib' => 'yii\db\Command', // dblib drivers on GNU/Linux (and maybe other OSes) hosts - 'cubrid' => 'yii\db\Command', // CUBRID ]; /** * @var bool whether to enable [savepoint](https://en.wikipedia.org/wiki/Savepoint). @@ -738,14 +727,14 @@ protected function initConnection() } } - if (PHP_VERSION_ID >= 80100 && $this->getDriverName() === 'sqlite') { + if ($this->getDriverName() === 'sqlite') { $this->pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); } if (!$this->isSybase && in_array($this->getDriverName(), ['mssql', 'dblib'], true)) { $this->pdo->exec('SET ANSI_NULL_DFLT_ON ON'); } - if ($this->charset !== null && in_array($this->getDriverName(), ['pgsql', 'mysql', 'mysqli', 'cubrid'], true)) { + if ($this->charset !== null && in_array($this->getDriverName(), ['pgsql', 'mysql', 'mysqli'], true)) { $this->pdo->exec('SET NAMES ' . $this->pdo->quote($this->charset)); } $this->trigger(self::EVENT_AFTER_OPEN); @@ -761,9 +750,7 @@ public function createCommand($sql = null, $params = []) { $driver = $this->getDriverName(); $config = ['class' => 'yii\db\Command']; - if ($this->commandClass !== $config['class']) { - $config['class'] = $this->commandClass; - } elseif (isset($this->commandMap[$driver])) { + if (isset($this->commandMap[$driver])) { $config = !is_array($this->commandMap[$driver]) ? ['class' => $this->commandMap[$driver]] : $this->commandMap[$driver]; } $config['db'] = $this; diff --git a/db/Migration.php b/db/Migration.php index e9af02dcc..5b864f225 100644 --- a/db/Migration.php +++ b/db/Migration.php @@ -87,7 +87,7 @@ class Migration extends Component implements MigrationInterface public function init() { parent::init(); - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); $this->db->getSchema()->refresh(); $this->db->enableSlaves = false; } diff --git a/db/Query.php b/db/Query.php index 1819c9c31..f44a1c447 100644 --- a/db/Query.php +++ b/db/Query.php @@ -198,7 +198,7 @@ public function prepare($builder) public function batch($batchSize = 100, $db = null) { return Yii::createObject([ - 'class' => BatchQueryResult::className(), + 'class' => BatchQueryResult::class, 'query' => $this, 'batchSize' => $batchSize, 'db' => $db, @@ -226,7 +226,7 @@ public function batch($batchSize = 100, $db = null) public function each($batchSize = 100, $db = null) { return Yii::createObject([ - 'class' => BatchQueryResult::className(), + 'class' => BatchQueryResult::class, 'query' => $this, 'batchSize' => $batchSize, 'db' => $db, @@ -715,59 +715,6 @@ protected function normalizeSelect($columns) return $select; } - /** - * Returns unique column names excluding duplicates. - * Columns to be removed: - * - if column definition already present in SELECT part with same alias - * - if column definition without alias already present in SELECT part without alias too - * @param array $columns the columns to be merged to the select. - * @since 2.0.14 - * @deprecated in 2.0.21 - */ - protected function getUniqueColumns($columns) - { - $unaliasedColumns = $this->getUnaliasedColumnsFromSelect(); - - $result = []; - foreach ($columns as $columnAlias => $columnDefinition) { - if (!$columnDefinition instanceof Query) { - if (is_string($columnAlias)) { - $existsInSelect = isset($this->select[$columnAlias]) && $this->select[$columnAlias] === $columnDefinition; - if ($existsInSelect) { - continue; - } - } elseif (is_int($columnAlias)) { - $existsInSelect = in_array($columnDefinition, $unaliasedColumns, true); - $existsInResultSet = in_array($columnDefinition, $result, true); - if ($existsInSelect || $existsInResultSet) { - continue; - } - } - } - - $result[$columnAlias] = $columnDefinition; - } - return $result; - } - - /** - * @return array List of columns without aliases from SELECT statement. - * @since 2.0.14 - * @deprecated in 2.0.21 - */ - protected function getUnaliasedColumnsFromSelect() - { - $result = []; - if (is_array($this->select)) { - foreach ($this->select as $name => $value) { - if (is_int($name)) { - $result[] = $value; - } - } - } - return array_unique($result); - } - /** * Sets the value indicating whether to SELECT DISTINCT or not. * @param bool $value whether to SELECT DISTINCT or not. diff --git a/db/QueryBuilder.php b/db/QueryBuilder.php index 9d243abe1..92f97aa9f 100644 --- a/db/QueryBuilder.php +++ b/db/QueryBuilder.php @@ -53,12 +53,6 @@ class QueryBuilder extends \yii\base\BaseObject */ public $typeMap = []; - /** - * @var array map of query condition to builder methods. - * These methods are used by [[buildCondition]] to build SQL conditions from array syntax. - * @deprecated since 2.0.14. Is not used, will be dropped in 2.1.0. - */ - protected $conditionBuilders = []; /** * @var array map of condition aliases to condition classes. For example: * @@ -1610,139 +1604,6 @@ public function createConditionFromArray($condition) return new HashCondition($condition); } - /** - * Creates a condition based on column-value pairs. - * @param array $condition the condition specification. - * @param array $params the binding parameters to be populated - * @return string the generated SQL expression - * @deprecated since 2.0.14. Use `buildCondition()` instead. - */ - public function buildHashCondition($condition, &$params) - { - return $this->buildCondition(new HashCondition($condition), $params); - } - - /** - * Connects two or more SQL expressions with the `AND` or `OR` operator. - * @param string $operator the operator to use for connecting the given operands - * @param array $operands the SQL expressions to connect. - * @param array $params the binding parameters to be populated - * @return string the generated SQL expression - * @deprecated since 2.0.14. Use `buildCondition()` instead. - */ - public function buildAndCondition($operator, $operands, &$params) - { - array_unshift($operands, $operator); - return $this->buildCondition($operands, $params); - } - - /** - * Inverts an SQL expressions with `NOT` operator. - * @param string $operator the operator to use for connecting the given operands - * @param array $operands the SQL expressions to connect. - * @param array $params the binding parameters to be populated - * @return string the generated SQL expression - * @throws InvalidArgumentException if wrong number of operands have been given. - * @deprecated since 2.0.14. Use `buildCondition()` instead. - */ - public function buildNotCondition($operator, $operands, &$params) - { - array_unshift($operands, $operator); - return $this->buildCondition($operands, $params); - } - - /** - * Creates an SQL expressions with the `BETWEEN` operator. - * @param string $operator the operator to use (e.g. `BETWEEN` or `NOT BETWEEN`) - * @param array $operands the first operand is the column name. The second and third operands - * describe the interval that column value should be in. - * @param array $params the binding parameters to be populated - * @return string the generated SQL expression - * @throws InvalidArgumentException if wrong number of operands have been given. - * @deprecated since 2.0.14. Use `buildCondition()` instead. - */ - public function buildBetweenCondition($operator, $operands, &$params) - { - array_unshift($operands, $operator); - return $this->buildCondition($operands, $params); - } - - /** - * Creates an SQL expressions with the `IN` operator. - * @param string $operator the operator to use (e.g. `IN` or `NOT IN`) - * @param array $operands the first operand is the column name. If it is an array - * a composite IN condition will be generated. - * The second operand is an array of values that column value should be among. - * If it is an empty array the generated expression will be a `false` value if - * operator is `IN` and empty if operator is `NOT IN`. - * @param array $params the binding parameters to be populated - * @return string the generated SQL expression - * @throws Exception if wrong number of operands have been given. - * @deprecated since 2.0.14. Use `buildCondition()` instead. - */ - public function buildInCondition($operator, $operands, &$params) - { - array_unshift($operands, $operator); - return $this->buildCondition($operands, $params); - } - - /** - * Creates an SQL expressions with the `LIKE` operator. - * @param string $operator the operator to use (e.g. `LIKE`, `NOT LIKE`, `OR LIKE` or `OR NOT LIKE`) - * @param array $operands an array of two or three operands - * - * - The first operand is the column name. - * - The second operand is a single value or an array of values that column value - * should be compared with. If it is an empty array the generated expression will - * be a `false` value if operator is `LIKE` or `OR LIKE`, and empty if operator - * is `NOT LIKE` or `OR NOT LIKE`. - * - An optional third operand can also be provided to specify how to escape special characters - * in the value(s). The operand should be an array of mappings from the special characters to their - * escaped counterparts. If this operand is not provided, a default escape mapping will be used. - * You may use `false` or an empty array to indicate the values are already escaped and no escape - * should be applied. Note that when using an escape mapping (or the third operand is not provided), - * the values will be automatically enclosed within a pair of percentage characters. - * @param array $params the binding parameters to be populated - * @return string the generated SQL expression - * @throws InvalidArgumentException if wrong number of operands have been given. - * @deprecated since 2.0.14. Use `buildCondition()` instead. - */ - public function buildLikeCondition($operator, $operands, &$params) - { - array_unshift($operands, $operator); - return $this->buildCondition($operands, $params); - } - - /** - * Creates an SQL expressions with the `EXISTS` operator. - * @param string $operator the operator to use (e.g. `EXISTS` or `NOT EXISTS`) - * @param array $operands contains only one element which is a [[Query]] object representing the sub-query. - * @param array $params the binding parameters to be populated - * @return string the generated SQL expression - * @throws InvalidArgumentException if the operand is not a [[Query]] object. - * @deprecated since 2.0.14. Use `buildCondition()` instead. - */ - public function buildExistsCondition($operator, $operands, &$params) - { - array_unshift($operands, $operator); - return $this->buildCondition($operands, $params); - } - - /** - * Creates an SQL expressions like `"column" operator value`. - * @param string $operator the operator to use. Anything could be used e.g. `>`, `<=`, etc. - * @param array $operands contains two column names. - * @param array $params the binding parameters to be populated - * @return string the generated SQL expression - * @throws InvalidArgumentException if wrong number of operands have been given. - * @deprecated since 2.0.14. Use `buildCondition()` instead. - */ - public function buildSimpleCondition($operator, $operands, &$params) - { - array_unshift($operands, $operator); - return $this->buildCondition($operands, $params); - } - /** * Creates a SELECT EXISTS() SQL statement. * @param string $rawSql the subquery in a raw form to select from. diff --git a/db/Schema.php b/db/Schema.php index 6e7dd20be..5f54b5ab2 100644 --- a/db/Schema.php +++ b/db/Schema.php @@ -313,7 +313,7 @@ public function refreshTableSchema($name) */ public function createQueryBuilder() { - return Yii::createObject(QueryBuilder::className(), [$this->db]); + return Yii::createObject(QueryBuilder::class, [$this->db]); } /** @@ -328,7 +328,7 @@ public function createQueryBuilder() */ public function createColumnSchemaBuilder($type, $length = null) { - return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length]); + return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length]); } /** @@ -516,6 +516,10 @@ protected function getTableNameParts($name) */ public function quoteColumnName($name) { + if ($name === null) { + return ''; + } + if (strpos($name, '(') !== false || strpos($name, '[[') !== false) { return $name; } diff --git a/db/conditions/ConditionInterface.php b/db/conditions/ConditionInterface.php index fc8146940..96d63548c 100644 --- a/db/conditions/ConditionInterface.php +++ b/db/conditions/ConditionInterface.php @@ -7,7 +7,7 @@ namespace yii\db\conditions; -use yii\base\InvalidParamException; +use InvalidArgumentException; use yii\db\ExpressionInterface; /** @@ -27,7 +27,7 @@ interface ConditionInterface extends ExpressionInterface * @param array $operands array of corresponding operands * * @return $this - * @throws InvalidParamException if input parameters are not suitable for this condition + * @throws InvalidArgumentException if input parameters are not suitable for this condition */ public static function fromArrayDefinition($operator, $operands); } diff --git a/db/cubrid/ColumnSchemaBuilder.php b/db/cubrid/ColumnSchemaBuilder.php deleted file mode 100644 index e3f402b03..000000000 --- a/db/cubrid/ColumnSchemaBuilder.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @since 2.0.8 - */ -class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder -{ - /** - * {@inheritdoc} - */ - protected function buildUnsignedString() - { - return $this->isUnsigned ? ' UNSIGNED' : ''; - } - - /** - * {@inheritdoc} - */ - protected function buildAfterString() - { - return $this->after !== null ? - ' AFTER ' . $this->db->quoteColumnName($this->after) : - ''; - } - - /** - * {@inheritdoc} - */ - protected function buildFirstString() - { - return $this->isFirst ? ' FIRST' : ''; - } - - /** - * {@inheritdoc} - */ - protected function buildCommentString() - { - return $this->comment !== null ? ' COMMENT ' . $this->db->quoteValue($this->comment) : ''; - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - switch ($this->getTypeCategory()) { - case self::CATEGORY_PK: - $format = '{type}{check}{comment}{append}{pos}'; - break; - case self::CATEGORY_NUMERIC: - $format = '{type}{length}{unsigned}{notnull}{unique}{default}{check}{comment}{append}{pos}'; - break; - default: - $format = '{type}{length}{notnull}{unique}{default}{check}{comment}{append}{pos}'; - } - - return $this->buildCompleteString($format); - } -} diff --git a/db/cubrid/QueryBuilder.php b/db/cubrid/QueryBuilder.php deleted file mode 100644 index 72ac4df6e..000000000 --- a/db/cubrid/QueryBuilder.php +++ /dev/null @@ -1,294 +0,0 @@ - - * @since 2.0 - */ -class QueryBuilder extends \yii\db\QueryBuilder -{ - /** - * @var array mapping from abstract column types (keys) to physical column types (values). - */ - public $typeMap = [ - Schema::TYPE_PK => 'int NOT NULL AUTO_INCREMENT PRIMARY KEY', - Schema::TYPE_UPK => 'int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', - Schema::TYPE_BIGPK => 'bigint NOT NULL AUTO_INCREMENT PRIMARY KEY', - Schema::TYPE_UBIGPK => 'bigint UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY', - Schema::TYPE_CHAR => 'char(1)', - Schema::TYPE_STRING => 'varchar(255)', - Schema::TYPE_TEXT => 'varchar', - Schema::TYPE_TINYINT => 'smallint', - Schema::TYPE_SMALLINT => 'smallint', - Schema::TYPE_INTEGER => 'int', - Schema::TYPE_BIGINT => 'bigint', - Schema::TYPE_FLOAT => 'float(7)', - Schema::TYPE_DOUBLE => 'double(15)', - Schema::TYPE_DECIMAL => 'decimal(10,0)', - Schema::TYPE_DATETIME => 'datetime', - Schema::TYPE_TIMESTAMP => 'timestamp', - Schema::TYPE_TIME => 'time', - Schema::TYPE_DATE => 'date', - Schema::TYPE_BINARY => 'blob', - Schema::TYPE_BOOLEAN => 'smallint', - Schema::TYPE_MONEY => 'decimal(19,4)', - ]; - - - /** - * {@inheritdoc} - */ - protected function defaultExpressionBuilders() - { - return array_merge(parent::defaultExpressionBuilders(), [ - 'yii\db\conditions\LikeCondition' => 'yii\db\cubrid\conditions\LikeConditionBuilder', - ]); - } - - /** - * {@inheritdoc} - * @see https://www.cubrid.org/manual/en/9.3.0/sql/query/merge.html - */ - public function upsert($table, $insertColumns, $updateColumns, &$params) - { - /** @var Constraint[] $constraints */ - list($uniqueNames, $insertNames, $updateNames) = $this->prepareUpsertColumns($table, $insertColumns, $updateColumns, $constraints); - if (empty($uniqueNames)) { - return $this->insert($table, $insertColumns, $params); - } - if ($updateNames === []) { - // there are no columns to update - $updateColumns = false; - } - - $onCondition = ['or']; - $quotedTableName = $this->db->quoteTableName($table); - foreach ($constraints as $constraint) { - $constraintCondition = ['and']; - foreach ($constraint->columnNames as $name) { - $quotedName = $this->db->quoteColumnName($name); - $constraintCondition[] = "$quotedTableName.$quotedName=\"EXCLUDED\".$quotedName"; - } - $onCondition[] = $constraintCondition; - } - $on = $this->buildCondition($onCondition, $params); - list(, $placeholders, $values, $params) = $this->prepareInsertValues($table, $insertColumns, $params); - $mergeSql = 'MERGE INTO ' . $this->db->quoteTableName($table) . ' ' - . 'USING (' . (!empty($placeholders) ? 'VALUES (' . implode(', ', $placeholders) . ')' : ltrim($values, ' ')) . ') AS "EXCLUDED" (' . implode(', ', $insertNames) . ') ' - . "ON ($on)"; - $insertValues = []; - foreach ($insertNames as $name) { - $quotedName = $this->db->quoteColumnName($name); - if (strrpos($quotedName, '.') === false) { - $quotedName = '"EXCLUDED".' . $quotedName; - } - $insertValues[] = $quotedName; - } - $insertSql = 'INSERT (' . implode(', ', $insertNames) . ')' - . ' VALUES (' . implode(', ', $insertValues) . ')'; - if ($updateColumns === false) { - return "$mergeSql WHEN NOT MATCHED THEN $insertSql"; - } - - if ($updateColumns === true) { - $updateColumns = []; - foreach ($updateNames as $name) { - $quotedName = $this->db->quoteColumnName($name); - if (strrpos($quotedName, '.') === false) { - $quotedName = '"EXCLUDED".' . $quotedName; - } - $updateColumns[$name] = new Expression($quotedName); - } - } - list($updates, $params) = $this->prepareUpdateSets($table, $updateColumns, $params); - $updateSql = 'UPDATE SET ' . implode(', ', $updates); - return "$mergeSql WHEN MATCHED THEN $updateSql WHEN NOT MATCHED THEN $insertSql"; - } - - /** - * Creates a SQL statement for resetting the sequence value of a table's primary key. - * The sequence will be reset such that the primary key of the next new row inserted - * will have the specified value or 1. - * @param string $tableName the name of the table whose primary key sequence will be reset - * @param mixed $value the value for the primary key of the next new row inserted. If this is not set, - * the next new row's primary key will have a value 1. - * @return string the SQL statement for resetting sequence - * @throws InvalidArgumentException if the table does not exist or there is no sequence associated with the table. - */ - public function resetSequence($tableName, $value = null) - { - $table = $this->db->getTableSchema($tableName); - if ($table !== null && $table->sequenceName !== null) { - $tableName = $this->db->quoteTableName($tableName); - if ($value === null) { - $key = reset($table->primaryKey); - $value = (int) $this->db->createCommand("SELECT MAX(`$key`) FROM " . $this->db->schema->quoteTableName($tableName))->queryScalar() + 1; - } else { - $value = (int) $value; - } - - return 'ALTER TABLE ' . $this->db->schema->quoteTableName($tableName) . " AUTO_INCREMENT=$value;"; - } elseif ($table === null) { - throw new InvalidArgumentException("Table not found: $tableName"); - } - - throw new InvalidArgumentException("There is not sequence associated with table '$tableName'."); - } - - /** - * {@inheritdoc} - */ - public function buildLimit($limit, $offset) - { - $sql = ''; - // limit is not optional in CUBRID - // https://www.cubrid.org/manual/en/9.3.0/sql/query/select.html#limit-clause - // "You can specify a very big integer for row_count to display to the last row, starting from a specific row." - if ($this->hasLimit($limit)) { - $sql = 'LIMIT ' . $limit; - if ($this->hasOffset($offset)) { - $sql .= ' OFFSET ' . $offset; - } - } elseif ($this->hasOffset($offset)) { - $sql = "LIMIT 9223372036854775807 OFFSET $offset"; // 2^63-1 - } - - return $sql; - } - - /** - * {@inheritdoc} - * @since 2.0.8 - */ - public function selectExists($rawSql) - { - return 'SELECT CASE WHEN EXISTS(' . $rawSql . ') THEN 1 ELSE 0 END'; - } - - /** - * {@inheritdoc} - * @see https://www.cubrid.org/manual/en/9.3.0/sql/schema/table.html#drop-index-clause - */ - public function dropIndex($name, $table) - { - /** @var Schema $schema */ - $schema = $this->db->getSchema(); - foreach ($schema->getTableUniques($table) as $unique) { - if ($unique->name === $name) { - return $this->dropUnique($name, $table); - } - } - - return 'DROP INDEX ' . $this->db->quoteTableName($name) . ' ON ' . $this->db->quoteTableName($table); - } - - /** - * {@inheritdoc} - * @throws NotSupportedException this is not supported by CUBRID. - */ - public function addCheck($name, $table, $expression) - { - throw new NotSupportedException(__METHOD__ . ' is not supported by CUBRID.'); - } - - /** - * {@inheritdoc} - * @throws NotSupportedException this is not supported by CUBRID. - */ - public function dropCheck($name, $table) - { - throw new NotSupportedException(__METHOD__ . ' is not supported by CUBRID.'); - } - - /** - * {@inheritdoc} - * @since 2.0.8 - */ - public function addCommentOnColumn($table, $column, $comment) - { - $definition = $this->getColumnDefinition($table, $column); - $definition = trim(preg_replace("/COMMENT '(.*?)'/i", '', $definition)); - - return 'ALTER TABLE ' . $this->db->quoteTableName($table) - . ' CHANGE ' . $this->db->quoteColumnName($column) - . ' ' . $this->db->quoteColumnName($column) - . (empty($definition) ? '' : ' ' . $definition) - . ' COMMENT ' . $this->db->quoteValue($comment); - } - - /** - * {@inheritdoc} - * @since 2.0.8 - */ - public function addCommentOnTable($table, $comment) - { - return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' COMMENT ' . $this->db->quoteValue($comment); - } - - /** - * {@inheritdoc} - * @since 2.0.8 - */ - public function dropCommentFromColumn($table, $column) - { - return $this->addCommentOnColumn($table, $column, ''); - } - - /** - * {@inheritdoc} - * @since 2.0.8 - */ - public function dropCommentFromTable($table) - { - return $this->addCommentOnTable($table, ''); - } - - - /** - * Gets column definition. - * - * @param string $table table name - * @param string $column column name - * @return string|null the column definition - * @throws Exception in case when table does not contain column - * @since 2.0.8 - */ - private function getColumnDefinition($table, $column) - { - $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->db->quoteTableName($table))->queryOne(); - if ($row === false) { - throw new Exception("Unable to find column '$column' in table '$table'."); - } - if (isset($row['Create Table'])) { - $sql = $row['Create Table']; - } else { - $row = array_values($row); - $sql = $row[1]; - } - $sql = preg_replace('/^[^(]+\((.*)\).*$/', '\1', $sql); - $sql = str_replace(', [', ",\n[", $sql); - if (preg_match_all('/^\s*\[(.*?)\]\s+(.*?),?$/m', $sql, $matches)) { - foreach ($matches[1] as $i => $c) { - if ($c === $column) { - return $matches[2][$i]; - } - } - } - - return null; - } -} diff --git a/db/cubrid/Schema.php b/db/cubrid/Schema.php deleted file mode 100644 index b50206d4d..000000000 --- a/db/cubrid/Schema.php +++ /dev/null @@ -1,420 +0,0 @@ - - * @since 2.0 - */ -class Schema extends \yii\db\Schema implements ConstraintFinderInterface -{ - use ConstraintFinderTrait; - - /** - * @var array mapping from physical column types (keys) to abstract column types (values) - * Please refer to [CUBRID manual](https://www.cubrid.org/manual/en/9.3.0/sql/datatype.html) for - * details on data types. - */ - public $typeMap = [ - // Numeric data types - 'short' => self::TYPE_SMALLINT, - 'smallint' => self::TYPE_SMALLINT, - 'int' => self::TYPE_INTEGER, - 'integer' => self::TYPE_INTEGER, - 'bigint' => self::TYPE_BIGINT, - 'numeric' => self::TYPE_DECIMAL, - 'decimal' => self::TYPE_DECIMAL, - 'float' => self::TYPE_FLOAT, - 'real' => self::TYPE_FLOAT, - 'double' => self::TYPE_DOUBLE, - 'double precision' => self::TYPE_DOUBLE, - 'monetary' => self::TYPE_MONEY, - // Date/Time data types - 'date' => self::TYPE_DATE, - 'time' => self::TYPE_TIME, - 'timestamp' => self::TYPE_TIMESTAMP, - 'datetime' => self::TYPE_DATETIME, - // String data types - 'char' => self::TYPE_CHAR, - 'varchar' => self::TYPE_STRING, - 'char varying' => self::TYPE_STRING, - 'nchar' => self::TYPE_CHAR, - 'nchar varying' => self::TYPE_STRING, - 'string' => self::TYPE_STRING, - // BLOB/CLOB data types - 'blob' => self::TYPE_BINARY, - 'clob' => self::TYPE_BINARY, - // Bit string data types - 'bit' => self::TYPE_INTEGER, - 'bit varying' => self::TYPE_INTEGER, - // Collection data types (considered strings for now) - 'set' => self::TYPE_STRING, - 'multiset' => self::TYPE_STRING, - 'list' => self::TYPE_STRING, - 'sequence' => self::TYPE_STRING, - 'enum' => self::TYPE_STRING, - ]; - /** - * @var array map of DB errors and corresponding exceptions - * If left part is found in DB error message exception class from the right part is used. - */ - public $exceptionMap = [ - 'Operation would have caused one or more unique constraint violations' => 'yii\db\IntegrityException', - ]; - - /** - * {@inheritdoc} - */ - protected $tableQuoteCharacter = '"'; - - - /** - * {@inheritdoc} - */ - protected function findTableNames($schema = '') - { - $pdo = $this->db->getSlavePdo(true); - $tables = $pdo->cubrid_schema(\PDO::CUBRID_SCH_TABLE); - $tableNames = []; - foreach ($tables as $table) { - // do not list system tables - if ($table['TYPE'] != 0) { - $tableNames[] = $table['NAME']; - } - } - - return $tableNames; - } - - /** - * {@inheritdoc} - */ - protected function loadTableSchema($name) - { - $pdo = $this->db->getSlavePdo(true); - - $tableInfo = $pdo->cubrid_schema(\PDO::CUBRID_SCH_TABLE, $name); - - if (!isset($tableInfo[0]['NAME'])) { - return null; - } - - $table = new TableSchema(); - $table->fullName = $table->name = $tableInfo[0]['NAME']; - - $sql = 'SHOW FULL COLUMNS FROM ' . $this->quoteSimpleTableName($table->name); - $columns = $this->db->createCommand($sql)->queryAll(); - - foreach ($columns as $info) { - $column = $this->loadColumnSchema($info); - $table->columns[$column->name] = $column; - } - - $primaryKeys = $pdo->cubrid_schema(\PDO::CUBRID_SCH_PRIMARY_KEY, $table->name); - foreach ($primaryKeys as $key) { - $column = $table->columns[$key['ATTR_NAME']]; - $column->isPrimaryKey = true; - $table->primaryKey[] = $column->name; - if ($column->autoIncrement) { - $table->sequenceName = ''; - } - } - - $foreignKeys = $pdo->cubrid_schema(\PDO::CUBRID_SCH_IMPORTED_KEYS, $table->name); - foreach ($foreignKeys as $key) { - if (isset($table->foreignKeys[$key['FK_NAME']])) { - $table->foreignKeys[$key['FK_NAME']][$key['FKCOLUMN_NAME']] = $key['PKCOLUMN_NAME']; - } else { - $table->foreignKeys[$key['FK_NAME']] = [ - $key['PKTABLE_NAME'], - $key['FKCOLUMN_NAME'] => $key['PKCOLUMN_NAME'], - ]; - } - } - - return $table; - } - - /** - * {@inheritdoc} - */ - protected function loadTablePrimaryKey($tableName) - { - $primaryKey = $this->db->getSlavePdo(true)->cubrid_schema(\PDO::CUBRID_SCH_PRIMARY_KEY, $tableName); - if (empty($primaryKey)) { - return null; - } - - ArrayHelper::multisort($primaryKey, 'KEY_SEQ', SORT_ASC, SORT_NUMERIC); - return new Constraint([ - 'name' => $primaryKey[0]['KEY_NAME'], - 'columnNames' => ArrayHelper::getColumn($primaryKey, 'ATTR_NAME'), - ]); - } - - /** - * {@inheritdoc} - */ - protected function loadTableForeignKeys($tableName) - { - static $actionTypes = [ - 0 => 'CASCADE', - 1 => 'RESTRICT', - 2 => 'NO ACTION', - 3 => 'SET NULL', - ]; - - $foreignKeys = $this->db->getSlavePdo(true)->cubrid_schema(\PDO::CUBRID_SCH_IMPORTED_KEYS, $tableName); - $foreignKeys = ArrayHelper::index($foreignKeys, null, 'FK_NAME'); - ArrayHelper::multisort($foreignKeys, 'KEY_SEQ', SORT_ASC, SORT_NUMERIC); - $result = []; - foreach ($foreignKeys as $name => $foreignKey) { - $result[] = new ForeignKeyConstraint([ - 'name' => $name, - 'columnNames' => ArrayHelper::getColumn($foreignKey, 'FKCOLUMN_NAME'), - 'foreignTableName' => $foreignKey[0]['PKTABLE_NAME'], - 'foreignColumnNames' => ArrayHelper::getColumn($foreignKey, 'PKCOLUMN_NAME'), - 'onDelete' => isset($actionTypes[$foreignKey[0]['DELETE_RULE']]) ? $actionTypes[$foreignKey[0]['DELETE_RULE']] : null, - 'onUpdate' => isset($actionTypes[$foreignKey[0]['UPDATE_RULE']]) ? $actionTypes[$foreignKey[0]['UPDATE_RULE']] : null, - ]); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - protected function loadTableIndexes($tableName) - { - return $this->loadTableConstraints($tableName, 'indexes'); - } - - /** - * {@inheritdoc} - */ - protected function loadTableUniques($tableName) - { - return $this->loadTableConstraints($tableName, 'uniques'); - } - - /** - * {@inheritdoc} - * @throws NotSupportedException if this method is called. - */ - protected function loadTableChecks($tableName) - { - throw new NotSupportedException('CUBRID does not support check constraints.'); - } - - /** - * {@inheritdoc} - * @throws NotSupportedException if this method is called. - */ - protected function loadTableDefaultValues($tableName) - { - throw new NotSupportedException('CUBRID does not support default value constraints.'); - } - - /** - * {@inheritdoc} - */ - public function releaseSavepoint($name) - { - // does nothing as cubrid does not support this - } - - /** - * Creates a query builder for the CUBRID database. - * @return QueryBuilder query builder instance - */ - public function createQueryBuilder() - { - return Yii::createObject(QueryBuilder::className(), [$this->db]); - } - - /** - * Loads the column information into a [[ColumnSchema]] object. - * @param array $info column information - * @return \yii\db\ColumnSchema the column schema object - */ - protected function loadColumnSchema($info) - { - $column = $this->createColumnSchema(); - - $column->name = $info['Field']; - $column->allowNull = $info['Null'] === 'YES'; - $column->isPrimaryKey = false; // primary key will be set by loadTableSchema() later - $column->autoIncrement = stripos($info['Extra'], 'auto_increment') !== false; - - $column->dbType = $info['Type']; - $column->unsigned = strpos($column->dbType, 'unsigned') !== false; - - $column->type = self::TYPE_STRING; - if (preg_match('/^([\w ]+)(?:\(([^\)]+)\))?$/', $column->dbType, $matches)) { - $type = strtolower($matches[1]); - $column->dbType = $type . (isset($matches[2]) ? "({$matches[2]})" : ''); - if (isset($this->typeMap[$type])) { - $column->type = $this->typeMap[$type]; - } - if (!empty($matches[2])) { - if ($type === 'enum') { - $values = preg_split('/\s*,\s*/', $matches[2]); - foreach ($values as $i => $value) { - $values[$i] = trim($value, "'"); - } - $column->enumValues = $values; - } else { - $values = explode(',', $matches[2]); - $column->size = $column->precision = (int) $values[0]; - if (isset($values[1])) { - $column->scale = (int) $values[1]; - } - if ($column->size === 1 && $type === 'bit') { - $column->type = 'boolean'; - } elseif ($type === 'bit') { - if ($column->size > 32) { - $column->type = 'bigint'; - } elseif ($column->size === 32) { - $column->type = 'integer'; - } - } - } - } - } - - $column->phpType = $this->getColumnPhpType($column); - - if ($column->isPrimaryKey) { - return $column; - } - - if ( - $column->type === 'timestamp' && $info['Default'] === 'SYS_TIMESTAMP' || - $column->type === 'datetime' && $info['Default'] === 'SYS_DATETIME' || - $column->type === 'date' && $info['Default'] === 'SYS_DATE' || - $column->type === 'time' && $info['Default'] === 'SYS_TIME' - ) { - $column->defaultValue = new Expression($info['Default']); - } elseif (isset($type) && $type === 'bit') { - $column->defaultValue = hexdec(trim($info['Default'], 'X\'')); - } else { - $column->defaultValue = $column->phpTypecast($info['Default']); - } - - return $column; - } - - /** - * Determines the PDO type for the given PHP data value. - * @param mixed $data the data whose PDO type is to be determined - * @return int the PDO type - * @see https://www.php.net/manual/en/pdo.constants.php - */ - public function getPdoType($data) - { - static $typeMap = [ - // php type => PDO type - 'boolean' => \PDO::PARAM_INT, // PARAM_BOOL is not supported by CUBRID PDO - 'integer' => \PDO::PARAM_INT, - 'string' => \PDO::PARAM_STR, - 'resource' => \PDO::PARAM_LOB, - 'NULL' => \PDO::PARAM_NULL, - ]; - $type = gettype($data); - - return isset($typeMap[$type]) ? $typeMap[$type] : \PDO::PARAM_STR; - } - - /** - * {@inheritdoc} - * @see https://www.cubrid.org/manual/en/9.3.0/sql/transaction.html#database-concurrency - */ - public function setTransactionIsolationLevel($level) - { - // translate SQL92 levels to CUBRID levels: - switch ($level) { - case Transaction::SERIALIZABLE: - $level = '6'; // SERIALIZABLE - break; - case Transaction::REPEATABLE_READ: - $level = '5'; // REPEATABLE READ CLASS with REPEATABLE READ INSTANCES - break; - case Transaction::READ_COMMITTED: - $level = '4'; // REPEATABLE READ CLASS with READ COMMITTED INSTANCES - break; - case Transaction::READ_UNCOMMITTED: - $level = '3'; // REPEATABLE READ CLASS with READ UNCOMMITTED INSTANCES - break; - } - parent::setTransactionIsolationLevel($level); - } - - /** - * {@inheritdoc} - */ - public function createColumnSchemaBuilder($type, $length = null) - { - return new ColumnSchemaBuilder($type, $length, $this->db); - } - - /** - * Loads multiple types of constraints and returns the specified ones. - * @param string $tableName table name. - * @param string $returnType return type: - * - indexes - * - uniques - * @return mixed constraints. - */ - private function loadTableConstraints($tableName, $returnType) - { - $constraints = $this->db->getSlavePdo(true)->cubrid_schema(\PDO::CUBRID_SCH_CONSTRAINT, $tableName); - $constraints = ArrayHelper::index($constraints, null, ['TYPE', 'NAME']); - ArrayHelper::multisort($constraints, 'KEY_ORDER', SORT_ASC, SORT_NUMERIC); - $result = [ - 'indexes' => [], - 'uniques' => [], - ]; - foreach ($constraints as $type => $names) { - foreach ($names as $name => $constraint) { - $isUnique = in_array((int) $type, [0, 2], true); - $result['indexes'][] = new IndexConstraint([ - 'isPrimary' => (bool) $constraint[0]['PRIMARY_KEY'], - 'isUnique' => $isUnique, - 'name' => $name, - 'columnNames' => ArrayHelper::getColumn($constraint, 'ATTR_NAME'), - ]); - if ($isUnique) { - $result['uniques'][] = new Constraint([ - 'name' => $name, - 'columnNames' => ArrayHelper::getColumn($constraint, 'ATTR_NAME'), - ]); - } - } - } - foreach ($result as $type => $data) { - $this->setTableMetadata($tableName, $type, $data); - } - - return $result[$returnType]; - } -} diff --git a/db/cubrid/conditions/LikeConditionBuilder.php b/db/cubrid/conditions/LikeConditionBuilder.php deleted file mode 100644 index 80cd27173..000000000 --- a/db/cubrid/conditions/LikeConditionBuilder.php +++ /dev/null @@ -1,29 +0,0 @@ - '!%', - '_' => '!_', - '!' => '!!', - ]; -} diff --git a/db/mssql/QueryBuilder.php b/db/mssql/QueryBuilder.php index d2fbb3b7b..2c4d438c9 100644 --- a/db/mssql/QueryBuilder.php +++ b/db/mssql/QueryBuilder.php @@ -430,17 +430,6 @@ protected function getAllColumnNames($modelClass = null) return array_keys($schema->columns); } - /** - * @return bool whether the version of the MSSQL being used is older than 2012. - * @throws \yii\base\InvalidConfigException - * @throws \yii\db\Exception - * @deprecated 2.0.14 Use [[Schema::getServerVersion]] with [[\version_compare()]]. - */ - protected function isOldMssql() - { - return version_compare($this->db->getSchema()->getServerVersion(), '11', '<'); - } - /** * {@inheritdoc} * @since 2.0.8 diff --git a/db/mssql/Schema.php b/db/mssql/Schema.php index 1b1fb267e..a8d6045d5 100644 --- a/db/mssql/Schema.php +++ b/db/mssql/Schema.php @@ -332,7 +332,7 @@ public function rollBackSavepoint($name) */ public function createQueryBuilder() { - return Yii::createObject(QueryBuilder::className(), [$this->db]); + return Yii::createObject(QueryBuilder::class, [$this->db]); } /** @@ -387,10 +387,11 @@ protected function loadColumnSchema($info) $column->isComputed = (bool)$info['is_computed']; $column->unsigned = stripos($column->dbType, 'unsigned') !== false; $column->comment = $info['comment'] === null ? '' : $info['comment']; - $column->type = self::TYPE_STRING; + if (preg_match('/^(\w+)(?:\(([^\)]+)\))?/', $column->dbType, $matches)) { $type = $matches[1]; + if (isset($this->typeMap[$type])) { $column->type = $this->typeMap[$type]; } @@ -821,6 +822,6 @@ public function insert($table, $columns) */ public function createColumnSchemaBuilder($type, $length = null) { - return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length, $this->db]); + return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length, $this->db]); } } diff --git a/db/mysql/ColumnSchema.php b/db/mysql/ColumnSchema.php index ca9c48703..074335688 100644 --- a/db/mysql/ColumnSchema.php +++ b/db/mysql/ColumnSchema.php @@ -18,17 +18,6 @@ */ class ColumnSchema extends \yii\db\ColumnSchema { - /** - * @var bool whether the column schema should OMIT using JSON support feature. - * You can use this property to make upgrade to Yii 2.0.14 easier. - * Default to `false`, meaning JSON support is enabled. - * - * @since 2.0.14.1 - * @deprecated Since 2.0.14.1 and will be removed in 2.1. - */ - public $disableJsonSupport = false; - - /** * {@inheritdoc} */ @@ -42,7 +31,7 @@ public function dbTypecast($value) return $value; } - if (!$this->disableJsonSupport && $this->dbType === Schema::TYPE_JSON) { + if ($this->dbType === Schema::TYPE_JSON) { return new JsonExpression($value, $this->type); } @@ -58,7 +47,7 @@ public function phpTypecast($value) return null; } - if (!$this->disableJsonSupport && $this->type === Schema::TYPE_JSON) { + if ($this->type === Schema::TYPE_JSON) { return json_decode($value, true); } diff --git a/db/mysql/Schema.php b/db/mysql/Schema.php index 5e0fd9e21..4c47aadeb 100644 --- a/db/mysql/Schema.php +++ b/db/mysql/Schema.php @@ -258,7 +258,7 @@ protected function loadTableDefaultValues($tableName) */ public function createQueryBuilder() { - return Yii::createObject(QueryBuilder::className(), [$this->db]); + return Yii::createObject(QueryBuilder::class, [$this->db]); } /** @@ -519,7 +519,7 @@ public function findUniqueIndexes($table) */ public function createColumnSchemaBuilder($type, $length = null) { - return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length, $this->db]); + return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length, $this->db]); } /** diff --git a/db/oci/Schema.php b/db/oci/Schema.php index e0e4c05e2..05b3cb5ea 100644 --- a/db/oci/Schema.php +++ b/db/oci/Schema.php @@ -262,7 +262,7 @@ public function quoteSimpleTableName($name) */ public function createQueryBuilder() { - return Yii::createObject(QueryBuilder::className(), [$this->db]); + return Yii::createObject(QueryBuilder::class, [$this->db]); } /** @@ -270,7 +270,7 @@ public function createQueryBuilder() */ public function createColumnSchemaBuilder($type, $length = null) { - return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length]); + return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length]); } /** diff --git a/db/pgsql/ColumnSchema.php b/db/pgsql/ColumnSchema.php index 33d97bbdf..271c5f30c 100644 --- a/db/pgsql/ColumnSchema.php +++ b/db/pgsql/ColumnSchema.php @@ -22,33 +22,6 @@ class ColumnSchema extends \yii\db\ColumnSchema * @var int the dimension of array. Defaults to 0, means this column is not an array. */ public $dimension = 0; - /** - * @var bool whether the column schema should OMIT using JSON support feature. - * You can use this property to make upgrade to Yii 2.0.14 easier. - * Default to `false`, meaning JSON support is enabled. - * - * @since 2.0.14.1 - * @deprecated Since 2.0.14.1 and will be removed in 2.1. - */ - public $disableJsonSupport = false; - /** - * @var bool whether the column schema should OMIT using PgSQL Arrays support feature. - * You can use this property to make upgrade to Yii 2.0.14 easier. - * Default to `false`, meaning Arrays support is enabled. - * - * @since 2.0.14.1 - * @deprecated Since 2.0.14.1 and will be removed in 2.1. - */ - public $disableArraySupport = false; - /** - * @var bool whether the Array column value should be unserialized to an [[ArrayExpression]] object. - * You can use this property to make upgrade to Yii 2.0.14 easier. - * Default to `true`, meaning arrays are unserialized to [[ArrayExpression]] objects. - * - * @since 2.0.14.1 - * @deprecated Since 2.0.14.1 and will be removed in 2.1. - */ - public $deserializeArrayColumnToArrayExpression = true; /** * @var string name of associated sequence if column is auto-incremental * @since 2.0.29 @@ -70,11 +43,9 @@ public function dbTypecast($value) } if ($this->dimension > 0) { - return $this->disableArraySupport - ? (string) $value - : new ArrayExpression($value, $this->dbType, $this->dimension); + return new ArrayExpression($value, $this->dbType, $this->dimension); } - if (!$this->disableJsonSupport && in_array($this->dbType, [Schema::TYPE_JSON, Schema::TYPE_JSONB], true)) { + if (in_array($this->dbType, [Schema::TYPE_JSON, Schema::TYPE_JSONB], true)) { return new JsonExpression($value, $this->dbType); } @@ -87,9 +58,6 @@ public function dbTypecast($value) public function phpTypecast($value) { if ($this->dimension > 0) { - if ($this->disableArraySupport) { - return $value; - } if (!is_array($value)) { $value = $this->getArrayParser()->parse($value); } @@ -101,9 +69,7 @@ public function phpTypecast($value) return null; } - return $this->deserializeArrayColumnToArrayExpression - ? new ArrayExpression($value, $this->dbType, $this->dimension) - : $value; + return $value; } return $this->phpTypecastValue($value); @@ -133,7 +99,7 @@ protected function phpTypecastValue($value) } return (bool) $value; case Schema::TYPE_JSON: - return $this->disableJsonSupport ? $value : json_decode($value, true); + return json_decode($value, true); } return parent::phpTypecast($value); diff --git a/db/pgsql/Schema.php b/db/pgsql/Schema.php index 46547318b..62f91dac5 100644 --- a/db/pgsql/Schema.php +++ b/db/pgsql/Schema.php @@ -289,7 +289,7 @@ protected function loadTableDefaultValues($tableName) */ public function createQueryBuilder() { - return Yii::createObject(QueryBuilder::className(), [$this->db]); + return Yii::createObject(QueryBuilder::class, [$this->db]); } /** diff --git a/db/sqlite/Schema.php b/db/sqlite/Schema.php index 719f4e770..8163c0b0b 100644 --- a/db/sqlite/Schema.php +++ b/db/sqlite/Schema.php @@ -207,7 +207,7 @@ protected function loadTableDefaultValues($tableName) */ public function createQueryBuilder() { - return Yii::createObject(QueryBuilder::className(), [$this->db]); + return Yii::createObject(QueryBuilder::class, [$this->db]); } /** @@ -216,7 +216,7 @@ public function createQueryBuilder() */ public function createColumnSchemaBuilder($type, $length = null) { - return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length]); + return Yii::createObject(ColumnSchemaBuilder::class, [$type, $length]); } /** diff --git a/di/Container.php b/di/Container.php index 9c88b6186..07f70cae1 100644 --- a/di/Container.php +++ b/di/Container.php @@ -523,38 +523,17 @@ protected function getDependencies($class) $constructor = $reflection->getConstructor(); if ($constructor !== null) { foreach ($constructor->getParameters() as $param) { - if (PHP_VERSION_ID >= 50600 && $param->isVariadic()) { + if ($param->isVariadic()) { break; } - if (PHP_VERSION_ID >= 80000) { - $c = $param->getType(); - $isClass = false; - if ($c instanceof ReflectionNamedType) { - $isClass = !$c->isBuiltin(); - } - } else { - try { - $c = $param->getClass(); - } catch (ReflectionException $e) { - if (!$this->isNulledParam($param)) { - $notInstantiableClass = null; - if (PHP_VERSION_ID >= 70000) { - $type = $param->getType(); - if ($type instanceof ReflectionNamedType) { - $notInstantiableClass = $type->getName(); - } - } - throw new NotInstantiableException( - $notInstantiableClass, - $notInstantiableClass === null ? 'Can not instantiate unknown class.' : null - ); - } else { - $c = null; - } - } - $isClass = $c !== null; + $c = $param->getType(); + $isClass = false; + + if ($c instanceof ReflectionNamedType) { + $isClass = !$c->isBuiltin(); } + $className = $isClass ? $c->getName() : null; if ($className !== null) { @@ -579,7 +558,7 @@ protected function getDependencies($class) */ private function isNulledParam($param) { - return $param->isOptional() || (PHP_VERSION_ID >= 70100 && $param->getType()->allowsNull()); + return $param->isOptional() || $param->getType()->allowsNull(); } /** @@ -669,28 +648,25 @@ public function resolveCallableDependencies(callable $callback, $params = []) foreach ($reflection->getParameters() as $param) { $name = $param->getName(); - if (PHP_VERSION_ID >= 80000) { - $class = $param->getType(); - if ($class instanceof \ReflectionUnionType || (PHP_VERSION_ID >= 80100 && $class instanceof \ReflectionIntersectionType)) { - $isClass = false; - foreach ($class->getTypes() as $type) { - if (!$type->isBuiltin()) { - $class = $type; - $isClass = true; - break; - } + $class = $param->getType(); + + if ($class instanceof \ReflectionUnionType || $class instanceof \ReflectionIntersectionType) { + $isClass = false; + foreach ($class->getTypes() as $type) { + if (!$type->isBuiltin()) { + $class = $type; + $isClass = true; + break; } - } else { - $isClass = $class !== null && !$class->isBuiltin(); } } else { - $class = $param->getClass(); - $isClass = $class !== null; + $isClass = $class !== null && !$class->isBuiltin(); } if ($isClass) { $className = $class->getName(); - if (PHP_VERSION_ID >= 50600 && $param->isVariadic()) { + + if ($param->isVariadic()) { $args = array_merge($args, array_values($params)); break; } diff --git a/filters/AccessControl.php b/filters/AccessControl.php index d031a20e1..1785f5e79 100644 --- a/filters/AccessControl.php +++ b/filters/AccessControl.php @@ -99,7 +99,7 @@ public function init() { parent::init(); if ($this->user !== false) { - $this->user = Instance::ensure($this->user, User::className()); + $this->user = Instance::ensure($this->user, User::class); } foreach ($this->rules as $i => $rule) { if (is_array($rule)) { diff --git a/filters/auth/AuthInterface.php b/filters/auth/AuthInterface.php index 76b13057f..86834405f 100644 --- a/filters/auth/AuthInterface.php +++ b/filters/auth/AuthInterface.php @@ -28,6 +28,9 @@ interface AuthInterface * @param Response $response * @return IdentityInterface|null the authenticated user identity. If authentication information is not provided, null will be returned. * @throws UnauthorizedHttpException if authentication information is provided but is invalid. + * + * @phpstan-param User $user + * @psalm-param User $user */ public function authenticate($user, $request, $response); diff --git a/grid/GridView.php b/grid/GridView.php index 8e4401f90..452a7b0f3 100644 --- a/grid/GridView.php +++ b/grid/GridView.php @@ -547,7 +547,7 @@ protected function initColumns() $column = $this->createDataColumn($column); } else { $column = Yii::createObject(array_merge([ - 'class' => $this->dataColumnClass ?: DataColumn::className(), + 'class' => $this->dataColumnClass ?: DataColumn::class, 'grid' => $this, ], $column)); } @@ -572,7 +572,7 @@ protected function createDataColumn($text) } return Yii::createObject([ - 'class' => $this->dataColumnClass ?: DataColumn::className(), + 'class' => $this->dataColumnClass ?: DataColumn::class, 'grid' => $this, 'attribute' => $matches[1], 'format' => isset($matches[3]) ? $matches[3] : 'text', diff --git a/helpers/BaseJson.php b/helpers/BaseJson.php index a2821ad9f..f70ef2cf8 100644 --- a/helpers/BaseJson.php +++ b/helpers/BaseJson.php @@ -143,17 +143,7 @@ protected static function handleJsonError($lastError) return; } - if (PHP_VERSION_ID >= 50500) { - throw new InvalidArgumentException(json_last_error_msg(), $lastError); - } - - foreach (static::$jsonErrorMessages as $const => $message) { - if (defined($const) && constant($const) === $lastError) { - throw new InvalidArgumentException($message, $lastError); - } - } - - throw new InvalidArgumentException('Unknown JSON encoding/decoding error.'); + throw new InvalidArgumentException(json_last_error_msg(), $lastError); } /** diff --git a/i18n/DbMessageSource.php b/i18n/DbMessageSource.php index e7934be35..9630699f0 100644 --- a/i18n/DbMessageSource.php +++ b/i18n/DbMessageSource.php @@ -38,12 +38,6 @@ */ class DbMessageSource extends MessageSource { - /** - * Prefix which would be used when generating cache key. - * @deprecated This constant has never been used and will be removed in 2.1.0. - */ - const CACHE_KEY_PREFIX = 'DbMessageSource'; - /** * @var Connection|array|string the DB connection object or the application component ID of the DB connection. * @@ -95,7 +89,7 @@ class DbMessageSource extends MessageSource public function init() { parent::init(); - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); if ($this->enableCaching) { $this->cache = Instance::ensure($this->cache, 'yii\caching\CacheInterface'); } diff --git a/log/DbTarget.php b/log/DbTarget.php index d32c292c4..dadb08f4d 100644 --- a/log/DbTarget.php +++ b/log/DbTarget.php @@ -52,7 +52,7 @@ class DbTarget extends Target public function init() { parent::init(); - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); } /** diff --git a/log/FileTarget.php b/log/FileTarget.php index d860c4014..8b9851901 100644 --- a/log/FileTarget.php +++ b/log/FileTarget.php @@ -20,9 +20,6 @@ * files are moved backwards by one place, i.e., '.2' to '.3', '.1' to '.2', and so on. * The property [[maxLogFiles]] specifies how many history files to keep. * - * Since 2.0.46 rotation of the files is done only by copy and the - * `rotateByCopy` property is deprecated. - * * @author Qiang Xue * @since 2.0 */ @@ -61,22 +58,6 @@ class FileTarget extends Target * but read-only for other users. */ public $dirMode = 0775; - /** - * @var bool Whether to rotate log files by copy and truncate in contrast to rotation by - * renaming files. Defaults to `true` to be more compatible with log tailers and windows - * systems which do not play well with rename on open files. Rotation by renaming however is - * a bit faster. - * - * The problem with windows systems where the [rename()](https://www.php.net/manual/en/function.rename.php) - * function does not work with files that are opened by some process is described in a - * [comment by Martin Pelletier](https://www.php.net/manual/en/function.rename.php#102274) in - * the PHP documentation. By setting rotateByCopy to `true` you can work - * around this. - * @deprecated since 2.0.46 and setting it to false has no effect anymore - * since rotating is now always done by copy. - */ - public $rotateByCopy = true; - /** * Initializes the route. diff --git a/mail/BaseMailer.php b/mail/BaseMailer.php index c5f76fb75..e334d74aa 100644 --- a/mail/BaseMailer.php +++ b/mail/BaseMailer.php @@ -142,7 +142,7 @@ public function getView() protected function createView(array $config) { if (!array_key_exists('class', $config)) { - $config['class'] = View::className(); + $config['class'] = View::class; } return Yii::createObject($config); diff --git a/mail/BaseMessage.php b/mail/BaseMessage.php index 5ea187242..f18639203 100644 --- a/mail/BaseMessage.php +++ b/mail/BaseMessage.php @@ -60,12 +60,6 @@ public function __toString() try { return $this->toString(); } catch (\Throwable $e) { - if (PHP_VERSION_ID < 70400) { - trigger_error(ErrorHandler::convertExceptionToString($e), E_USER_ERROR); - - return ''; - } - throw $e; } } diff --git a/mutex/DbMutex.php b/mutex/DbMutex.php index 593cff4e0..a19a1adf8 100644 --- a/mutex/DbMutex.php +++ b/mutex/DbMutex.php @@ -37,6 +37,6 @@ abstract class DbMutex extends Mutex public function init() { parent::init(); - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); } } diff --git a/package.json b/package.json new file mode 100644 index 000000000..09a66d2bc --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "yii2", + "description": "a modern PHP framework designed for professional Web development", + "dependencies": { + "inputmask": "^5.0.8", + "jquery-pjax": "^2.0.1", + "jquery": "~3.6.4", + "punycode": "^1.4.0", + "yii2-pjax": "^2.0.8" + }, + "keywords": [ + "php", + "framework" + ], + "license": "BSD-3-Clause", + "bugs": { + "url": "https://github.com/yiisoft/yii2/issues" + }, + "homepage": "https://github.com/yiisoft/yii2" +} diff --git a/rbac/CheckAccessInterface.php b/rbac/CheckAccessInterface.php index 38d86ee7a..7f4dce00b 100644 --- a/rbac/CheckAccessInterface.php +++ b/rbac/CheckAccessInterface.php @@ -23,7 +23,7 @@ interface CheckAccessInterface * @param array $params name-value pairs that will be passed to the rules associated * with the roles and permissions assigned to the user. * @return bool whether the user has the specified permission. - * @throws \yii\base\InvalidParamException if $permissionName does not refer to an existing permission + * @throws \yii\base\InvalidArgumentException if $permissionName does not refer to an existing permission */ public function checkAccess($userId, $permissionName, $params = []); } diff --git a/rbac/DbManager.php b/rbac/DbManager.php index 2685ad5a1..240914838 100644 --- a/rbac/DbManager.php +++ b/rbac/DbManager.php @@ -119,7 +119,7 @@ class DbManager extends BaseManager public function init() { parent::init(); - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); if ($this->cache !== null) { $this->cache = Instance::ensure($this->cache, 'yii\caching\CacheInterface'); } @@ -449,7 +449,7 @@ protected function getItems($type) */ protected function populateItem($row) { - $class = $row['type'] == Item::TYPE_PERMISSION ? Permission::className() : Role::className(); + $class = $row['type'] == Item::TYPE_PERMISSION ? Permission::class : Role::class; if (!isset($row['data']) || ($data = @unserialize(is_resource($row['data']) ? stream_get_contents($row['data']) : $row['data'])) === false) { $data = null; diff --git a/rbac/ManagerInterface.php b/rbac/ManagerInterface.php index e4d2c7029..fec06fdc0 100644 --- a/rbac/ManagerInterface.php +++ b/rbac/ManagerInterface.php @@ -83,7 +83,7 @@ public function getRolesByUser($userId); * @param string $roleName name of the role to file child roles for * @return Role[] Child roles. The array is indexed by the role names. * First element is an instance of the parent Role itself. - * @throws \yii\base\InvalidParamException if Role was not found that are getting by $roleName + * @throws \yii\base\InvalidArgumentException if Role was not found that are getting by $roleName * @since 2.0.10 */ public function getChildRoles($roleName); diff --git a/rbac/PhpManager.php b/rbac/PhpManager.php index e09d23c15..03c828dab 100644 --- a/rbac/PhpManager.php +++ b/rbac/PhpManager.php @@ -724,7 +724,7 @@ protected function load() $rules = $this->loadFromFile($this->ruleFile); foreach ($items as $name => $item) { - $class = $item['type'] == Item::TYPE_PERMISSION ? Permission::className() : Role::className(); + $class = $item['type'] == Item::TYPE_PERMISSION ? Permission::class : Role::class; $this->items[$name] = new $class([ 'name' => $name, diff --git a/rest/Controller.php b/rest/Controller.php index 9512ee75e..3705417ac 100644 --- a/rest/Controller.php +++ b/rest/Controller.php @@ -49,21 +49,21 @@ public function behaviors() { return [ 'contentNegotiator' => [ - 'class' => ContentNegotiator::className(), + 'class' => ContentNegotiator::class, 'formats' => [ 'application/json' => Response::FORMAT_JSON, 'application/xml' => Response::FORMAT_XML, ], ], 'verbFilter' => [ - 'class' => VerbFilter::className(), + 'class' => VerbFilter::class, 'actions' => $this->verbs(), ], 'authenticator' => [ - 'class' => CompositeAuth::className(), + 'class' => CompositeAuth::class, ], 'rateLimiter' => [ - 'class' => RateLimiter::className(), + 'class' => RateLimiter::class, ], ]; } diff --git a/rest/IndexAction.php b/rest/IndexAction.php index f1f177b30..8b0891917 100644 --- a/rest/IndexAction.php +++ b/rest/IndexAction.php @@ -183,7 +183,7 @@ protected function prepareDataProvider() } return Yii::createObject([ - 'class' => ActiveDataProvider::className(), + 'class' => ActiveDataProvider::class, 'query' => $query, 'pagination' => $pagination, 'sort' => $sort, diff --git a/rest/UrlRule.php b/rest/UrlRule.php index 18855eb3f..1d595592c 100644 --- a/rest/UrlRule.php +++ b/rest/UrlRule.php @@ -233,7 +233,7 @@ public function parseRequest($manager, $request) Yii::debug([ 'rule' => method_exists($rule, '__toString') ? $rule->__toString() : get_class($rule), 'match' => $result !== false, - 'parent' => self::className(), + 'parent' => self::class, ], __METHOD__); } if ($result !== false) { diff --git a/test/DbFixture.php b/test/DbFixture.php index d5a6322f9..0a9b090e9 100644 --- a/test/DbFixture.php +++ b/test/DbFixture.php @@ -38,6 +38,6 @@ abstract class DbFixture extends Fixture public function init() { parent::init(); - $this->db = Instance::ensure($this->db, BaseObject::className()); + $this->db = Instance::ensure($this->db, BaseObject::class); } } diff --git a/validators/EmailValidator.php b/validators/EmailValidator.php index 3c56c58f2..7d502f257 100644 --- a/validators/EmailValidator.php +++ b/validators/EmailValidator.php @@ -155,11 +155,6 @@ private function hasDNSRecord($domain, $isMX) private function idnToAscii($idn) { - if (PHP_VERSION_ID < 50600) { - // TODO: drop old PHP versions support - return idn_to_ascii($idn); - } - return idn_to_ascii($idn, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); } diff --git a/validators/PunycodeAsset.php b/validators/PunycodeAsset.php index 8d928838c..0e5917a5b 100644 --- a/validators/PunycodeAsset.php +++ b/validators/PunycodeAsset.php @@ -17,7 +17,7 @@ */ class PunycodeAsset extends AssetBundle { - public $sourcePath = '@bower/punycode'; + public $sourcePath = '@npm/punycode'; public $js = [ 'punycode.js', ]; diff --git a/validators/UniqueValidator.php b/validators/UniqueValidator.php index 8c99955c9..e29cc7144 100644 --- a/validators/UniqueValidator.php +++ b/validators/UniqueValidator.php @@ -189,7 +189,11 @@ private function modelExists($targetClass, $conditions, $model) /** @var ActiveRecordInterface|\yii\base\BaseObject $targetClass $query */ $query = $this->prepareQuery($targetClass, $conditions); - if (!$model instanceof ActiveRecordInterface || $model->getIsNewRecord() || $model::className() !== $targetClass::className()) { + if ( + !$model instanceof ActiveRecordInterface || + $model->getIsNewRecord() || + !$model instanceof $targetClass + ) { // if current $model isn't in the database yet, then it's OK just to call exists() // also there's no need to run check based on primary keys, when $targetClass is not the same as $model's class $exists = $query->exists(); diff --git a/validators/UrlValidator.php b/validators/UrlValidator.php index 463e01f4f..650bf2b5c 100644 --- a/validators/UrlValidator.php +++ b/validators/UrlValidator.php @@ -110,11 +110,6 @@ protected function validateValue($value) private function idnToAscii($idn) { - if (PHP_VERSION_ID < 50600) { - // TODO: drop old PHP versions support - return idn_to_ascii($idn); - } - return idn_to_ascii($idn, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); } diff --git a/web/AssetBundle.php b/web/AssetBundle.php index 785262d54..c6bdbed08 100644 --- a/web/AssetBundle.php +++ b/web/AssetBundle.php @@ -102,8 +102,8 @@ class AssetBundle extends BaseObject * * Note that only a forward slash "/" should be used as directory separator. * - * @phpstan-var (string|array)[] - * @psalm-var (string|array)[] + * @phpstan-var (string|array)[] + * @psalm-var (string|array)[] */ public $js = []; /** @@ -112,8 +112,8 @@ class AssetBundle extends BaseObject * * Note that only a forward slash "/" should be used as directory separator. * - * @phpstan-var (string|array)[] - * @psalm-var (string|array)[] + * @phpstan-var (string|array)[] + * @psalm-var (string|array)[] */ public $css = []; /** diff --git a/web/AssetManager.php b/web/AssetManager.php index b61607199..3266336d9 100644 --- a/web/AssetManager.php +++ b/web/AssetManager.php @@ -412,10 +412,10 @@ protected function resolveAsset($bundle, $asset) public function getConverter() { if ($this->_converter === null) { - $this->_converter = Yii::createObject(AssetConverter::className()); + $this->_converter = Yii::createObject(AssetConverter::class); } elseif (is_array($this->_converter) || is_string($this->_converter)) { if (is_array($this->_converter) && !isset($this->_converter['class'])) { - $this->_converter['class'] = AssetConverter::className(); + $this->_converter['class'] = AssetConverter::class; } $this->_converter = Yii::createObject($this->_converter); } diff --git a/web/CompositeUrlRule.php b/web/CompositeUrlRule.php index dd711cc1f..c0057196d 100644 --- a/web/CompositeUrlRule.php +++ b/web/CompositeUrlRule.php @@ -60,7 +60,7 @@ public function parseRequest($manager, $request) Yii::debug([ 'rule' => method_exists($rule, '__toString') ? $rule->__toString() : get_class($rule), 'match' => $result !== false, - 'parent' => self::className(), + 'parent' => self::class, ], __METHOD__); } if ($result !== false) { diff --git a/web/Controller.php b/web/Controller.php index 3508bfe0c..f7dc12101 100644 --- a/web/Controller.php +++ b/web/Controller.php @@ -160,8 +160,7 @@ public function bindActionParams($action, $params) $args[] = $actionParams[$name] = $params[$name]; unset($params[$name]); } elseif ( - PHP_VERSION_ID >= 70100 - && ($type = $param->getType()) !== null + ($type = $param->getType()) !== null && $type instanceof \ReflectionNamedType && !$type->isBuiltin() ) { @@ -214,12 +213,11 @@ private function filterSingleTypeActionParam($param, $type) } if ( - PHP_VERSION_ID >= 70000 - && method_exists($type, 'isBuiltin') + method_exists($type, 'isBuiltin') && $type->isBuiltin() && ($param !== null || !$type->allowsNull()) ) { - $typeName = PHP_VERSION_ID >= 70100 ? $type->getName() : (string)$type; + $typeName = $type->getName(); if ($param === '' && $type->allowsNull()) { if ($typeName !== 'string') { // for old string behavior compatibility return [null, true]; @@ -256,7 +254,7 @@ private function filterUnionTypeActionParam($param, $type) ) { continue; } - $typeName = PHP_VERSION_ID >= 70100 ? $partialType->getName() : (string)$partialType; + $typeName = $partialType->getName(); if ($typeName === 'string') { return ['', true]; } @@ -277,7 +275,7 @@ private function filterUnionTypeActionParam($param, $type) continue; } $foundBuiltinType = true; - $typeName = PHP_VERSION_ID >= 70100 ? $partialType->getName() : (string)$partialType; + $typeName = $partialType->getName(); $canBeArray |= $typeName === 'array'; $canBeString |= $typeName === 'string'; if (is_array($param)) { diff --git a/web/DbSession.php b/web/DbSession.php index 1ef79cb7c..b2e48b9ef 100644 --- a/web/DbSession.php +++ b/web/DbSession.php @@ -90,7 +90,7 @@ class DbSession extends MultiFieldSession public function init() { parent::init(); - $this->db = Instance::ensure($this->db, Connection::className()); + $this->db = Instance::ensure($this->db, Connection::class); } /** diff --git a/web/ErrorHandler.php b/web/ErrorHandler.php index 570a84b41..201eaef9d 100644 --- a/web/ErrorHandler.php +++ b/web/ErrorHandler.php @@ -487,7 +487,7 @@ public function argumentsToString($args) */ public function getExceptionName($exception) { - if ($exception instanceof \yii\base\Exception || $exception instanceof \yii\base\InvalidCallException || $exception instanceof \yii\base\InvalidParamException || $exception instanceof \yii\base\UnknownMethodException) { + if ($exception instanceof \yii\base\Exception || $exception instanceof \yii\base\InvalidCallException || $exception instanceof \yii\base\InvalidArgumentException || $exception instanceof \yii\base\UnknownMethodException) { return $exception->getName(); } diff --git a/web/JqueryAsset.php b/web/JqueryAsset.php index df365d768..e7a534671 100644 --- a/web/JqueryAsset.php +++ b/web/JqueryAsset.php @@ -15,7 +15,7 @@ */ class JqueryAsset extends AssetBundle { - public $sourcePath = '@bower/jquery/dist'; + public $sourcePath = '@npm/jquery/dist'; public $js = [ 'jquery.js', ]; diff --git a/web/Request.php b/web/Request.php index 7b9645d53..a1e0ea937 100644 --- a/web/Request.php +++ b/web/Request.php @@ -95,11 +95,6 @@ class Request extends \yii\base\Request * Default name of the HTTP header for sending CSRF token. */ const CSRF_HEADER = 'X-CSRF-Token'; - /** - * The length of the CSRF token mask. - * @deprecated since 2.0.12. The mask length is now equal to the token length. - */ - const CSRF_MASK_LENGTH = 8; /** * @var bool whether to enable CSRF (Cross-Site Request Forgery) validation. Defaults to true. @@ -1767,11 +1762,7 @@ protected function loadCookies() if ($data === false) { continue; } - if (defined('PHP_VERSION_ID') && PHP_VERSION_ID >= 70000) { - $data = @unserialize($data, ['allowed_classes' => false]); - } else { - $data = @unserialize($data); - } + $data = @unserialize($data, ['allowed_classes' => false]); if (is_array($data) && isset($data[0], $data[1]) && $data[0] === $name) { $cookies[$name] = Yii::createObject([ 'class' => 'yii\web\Cookie', diff --git a/web/RequestParserInterface.php b/web/RequestParserInterface.php index 44a1051a6..c79b77838 100644 --- a/web/RequestParserInterface.php +++ b/web/RequestParserInterface.php @@ -19,7 +19,7 @@ interface RequestParserInterface * Parses a HTTP request body. * @param string $rawBody the raw HTTP request body. * @param string $contentType the content type specified for the request body. - * @return array parameters parsed from the request body + * @return array|object parameters parsed from the request body */ public function parse($rawBody, $contentType); } diff --git a/web/Response.php b/web/Response.php index 172443880..b39363485 100644 --- a/web/Response.php +++ b/web/Response.php @@ -413,24 +413,14 @@ protected function sendCookies() if ($expire != 1 && isset($validationKey)) { $value = Yii::$app->getSecurity()->hashData(serialize([$cookie->name, $value]), $validationKey); } - if (PHP_VERSION_ID >= 70300) { - setcookie($cookie->name, $value, [ - 'expires' => $expire, - 'path' => $cookie->path, - 'domain' => $cookie->domain, - 'secure' => $cookie->secure, - 'httpOnly' => $cookie->httpOnly, - 'sameSite' => !empty($cookie->sameSite) ? $cookie->sameSite : null, - ]); - } else { - // Work around for setting sameSite cookie prior PHP 7.3 - // https://stackoverflow.com/questions/39750906/php-setcookie-samesite-strict/46971326#46971326 - $cookiePath = $cookie->path; - if (!is_null($cookie->sameSite)) { - $cookiePath .= '; samesite=' . $cookie->sameSite; - } - setcookie($cookie->name, $value, $expire, $cookiePath, $cookie->domain, $cookie->secure, $cookie->httpOnly); - } + setcookie($cookie->name, $value, [ + 'expires' => $expire, + 'path' => $cookie->path, + 'domain' => $cookie->domain, + 'secure' => $cookie->secure, + 'httpOnly' => $cookie->httpOnly, + 'sameSite' => !empty($cookie->sameSite) ? $cookie->sameSite : null, + ]); } } diff --git a/web/Session.php b/web/Session.php index 3b2e74753..0d7c1607e 100644 --- a/web/Session.php +++ b/web/Session.php @@ -417,14 +417,7 @@ private function setCookieParamsInternal() { $data = $this->getCookieParams(); if (isset($data['lifetime'], $data['path'], $data['domain'], $data['secure'], $data['httponly'])) { - if (PHP_VERSION_ID >= 70300) { - session_set_cookie_params($data); - } else { - if (!empty($data['samesite'])) { - $data['path'] .= '; samesite=' . $data['samesite']; - } - session_set_cookie_params($data['lifetime'], $data['path'], $data['domain'], $data['secure'], $data['httponly']); - } + session_set_cookie_params($data); } else { throw new InvalidArgumentException('Please make sure cookieParams contains these elements: lifetime, path, domain, secure and httponly.'); } @@ -556,17 +549,9 @@ public function setTimeout($value) */ public function setUseStrictMode($value) { - if (PHP_VERSION_ID < 50502) { - if ($this->getUseCustomStorage() || !$value) { - self::$_useStrictModePolyfill = $value; - } else { - throw new InvalidConfigException('Enabling `useStrictMode` on PHP < 5.5.2 is only supported with custom storage classes.'); - } - } else { - $this->freeze(); - ini_set('session.use_strict_mode', $value ? '1' : '0'); - $this->unfreeze(); - } + $this->freeze(); + ini_set('session.use_strict_mode', $value ? '1' : '0'); + $this->unfreeze(); } /** @@ -576,10 +561,6 @@ public function setUseStrictMode($value) */ public function getUseStrictMode() { - if (PHP_VERSION_ID < 50502) { - return self::$_useStrictModePolyfill; - } - return (bool)ini_get('session.use_strict_mode'); } diff --git a/web/UrlManager.php b/web/UrlManager.php index fe324effc..b2b7c6703 100644 --- a/web/UrlManager.php +++ b/web/UrlManager.php @@ -178,7 +178,7 @@ public function init() if ($this->normalizer !== false) { $this->normalizer = Yii::createObject($this->normalizer); if (!$this->normalizer instanceof UrlNormalizer) { - throw new InvalidConfigException('`' . get_class($this) . '::normalizer` should be an instance of `' . UrlNormalizer::className() . '` or its DI compatible configuration.'); + throw new InvalidConfigException('`' . get_class($this) . '::normalizer` should be an instance of `' . UrlNormalizer::class . '` or its DI compatible configuration.'); } } diff --git a/web/UrlRule.php b/web/UrlRule.php index da4aef3f4..07c9ec1da 100644 --- a/web/UrlRule.php +++ b/web/UrlRule.php @@ -197,7 +197,7 @@ public function init() throw new InvalidConfigException('UrlRule::route must be set.'); } if (is_array($this->normalizer)) { - $normalizerConfig = array_merge(['class' => UrlNormalizer::className()], $this->normalizer); + $normalizerConfig = array_merge(['class' => UrlNormalizer::class], $this->normalizer); $this->normalizer = Yii::createObject($normalizerConfig); } if ($this->normalizer !== null && $this->normalizer !== false && !$this->normalizer instanceof UrlNormalizer) { diff --git a/web/User.php b/web/User.php index 215097a5a..f48b04021 100644 --- a/web/User.php +++ b/web/User.php @@ -819,20 +819,6 @@ public function checkRedirectAcceptable() return false; } - /** - * Returns auth manager associated with the user component. - * - * By default this is the `authManager` application component. - * You may override this method to return a different auth manager instance if needed. - * @return \yii\rbac\ManagerInterface - * @since 2.0.6 - * @deprecated since version 2.0.9, to be removed in 2.1. Use [[getAccessChecker()]] instead. - */ - protected function getAuthManager() - { - return Yii::$app->getAuthManager(); - } - /** * Returns the access checker used for checking access. * @return CheckAccessInterface @@ -840,6 +826,6 @@ protected function getAuthManager() */ protected function getAccessChecker() { - return $this->accessChecker !== null ? $this->accessChecker : $this->getAuthManager(); + return $this->accessChecker !== null ? $this->accessChecker : Yii::$app->getAuthManager(); } } diff --git a/web/View.php b/web/View.php index 335a14086..4cf53dad0 100644 --- a/web/View.php +++ b/web/View.php @@ -45,23 +45,27 @@ * @phpstan-type RegisterJsFileOptions array{ * depends?: class-string[], * position?: int, - * appendTimestamp?: boolean + * appendTimestamp?: bool, + * ... * } * * @psalm-type RegisterJsFileOptions = array{ * depends?: class-string[], * position?: int, - * appendTimestamp?: boolean + * appendTimestamp?: bool, + * ... * } * * @phpstan-type RegisterCssFileOptions array{ * depends?: class-string[], - * appendTimestamp?: boolean + * appendTimestamp?: bool, + * ... * } * * @psalm-type RegisterCssFileOptions = array{ * depends?: class-string[], - * appendTimestamp?: boolean + * appendTimestamp?: bool, + * ... * } */ class View extends \yii\base\View @@ -556,7 +560,7 @@ private function registerFile($type, $url, $options = [], $key = null) } } else { $this->getAssetManager()->bundles[$key] = Yii::createObject([ - 'class' => AssetBundle::className(), + 'class' => AssetBundle::class, 'baseUrl' => '', 'basePath' => '@webroot', (string)$type => [ArrayHelper::merge([!Url::isRelative($url) ? $url : ltrim($url, '/')], $originalOptions)], diff --git a/widgets/ActiveField.php b/widgets/ActiveField.php index 1761b8566..54712d7a3 100644 --- a/widgets/ActiveField.php +++ b/widgets/ActiveField.php @@ -175,12 +175,6 @@ public function __toString() try { return $this->render(); } catch (\Throwable $e) { - if (PHP_VERSION_ID < 70400) { - trigger_error(ErrorHandler::convertExceptionToString($e), E_USER_ERROR); - - return ''; - } - throw $e; } } diff --git a/widgets/MaskedInputAsset.php b/widgets/MaskedInputAsset.php index 473f4315f..2a0a6a197 100644 --- a/widgets/MaskedInputAsset.php +++ b/widgets/MaskedInputAsset.php @@ -19,7 +19,7 @@ */ class MaskedInputAsset extends AssetBundle { - public $sourcePath = '@bower/inputmask/dist'; + public $sourcePath = '@npm/inputmask/dist'; public $js = [ 'jquery.inputmask.js', ]; diff --git a/widgets/PjaxAsset.php b/widgets/PjaxAsset.php index 47795f683..c084763f9 100644 --- a/widgets/PjaxAsset.php +++ b/widgets/PjaxAsset.php @@ -17,7 +17,7 @@ */ class PjaxAsset extends AssetBundle { - public $sourcePath = '@bower/yii2-pjax'; + public $sourcePath = '@npm/yii2-pjax'; public $js = [ 'jquery.pjax.js', ]; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy