diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9399c093f37..17e514f9588 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,4 +1,4 @@ -name: Code Quality +name: lint on: [push, pull_request] diff --git a/framework/behaviors/AttributeTypecastBehavior.php b/framework/behaviors/AttributeTypecastBehavior.php index 6bb8ccc3a28..e2bde1b9a98 100644 --- a/framework/behaviors/AttributeTypecastBehavior.php +++ b/framework/behaviors/AttributeTypecastBehavior.php @@ -185,7 +185,7 @@ class AttributeTypecastBehavior extends Behavior * @var array internal static cache for auto detected [[attributeTypes]] values * in format: ownerClassName => attributeTypes */ - private static $autoDetectedAttributeTypes = []; + private static $_autoDetectedAttributeTypes = []; /** @@ -194,7 +194,7 @@ class AttributeTypecastBehavior extends Behavior */ public static function clearAutoDetectedAttributeTypes() { - self::$autoDetectedAttributeTypes = []; + self::$_autoDetectedAttributeTypes = []; } /** @@ -206,10 +206,10 @@ public function attach($owner) if ($this->attributeTypes === null) { $ownerClass = get_class($this->owner); - if (!isset(self::$autoDetectedAttributeTypes[$ownerClass])) { - self::$autoDetectedAttributeTypes[$ownerClass] = $this->detectAttributeTypes(); + if (!isset(self::$_autoDetectedAttributeTypes[$ownerClass])) { + self::$_autoDetectedAttributeTypes[$ownerClass] = $this->detectAttributeTypes(); } - $this->attributeTypes = self::$autoDetectedAttributeTypes[$ownerClass]; + $this->attributeTypes = self::$_autoDetectedAttributeTypes[$ownerClass]; } } diff --git a/framework/db/BatchQueryResult.php b/framework/db/BatchQueryResult.php index 9792891b027..c80ed82b5cf 100644 --- a/framework/db/BatchQueryResult.php +++ b/framework/db/BatchQueryResult.php @@ -42,6 +42,11 @@ class BatchQueryResult extends Component implements \Iterator * @since 2.0.41 */ const EVENT_FINISH = 'finish'; + /** + * MSSQL error code for exception that is thrown when last batch is size less than specified batch size + * @see https://github.com/yiisoft/yii2/issues/10023 + */ + const MSSQL_NO_MORE_ROWS_ERROR_CODE = -13; /** * @var Connection|null the DB connection to be used when performing batch query. @@ -79,11 +84,6 @@ class BatchQueryResult extends Component implements \Iterator * @var string|int the key for the current iteration */ private $_key; - /** - * @var int MSSQL error code for exception that is thrown when last batch is size less than specified batch size - * @see https://github.com/yiisoft/yii2/issues/10023 - */ - private $mssqlNoMoreRowsErrorCode = -13; /** @@ -187,7 +187,7 @@ protected function getRows() } } catch (\PDOException $e) { $errorCode = isset($e->errorInfo[1]) ? $e->errorInfo[1] : null; - if ($this->getDbDriverName() !== 'sqlsrv' || $errorCode !== $this->mssqlNoMoreRowsErrorCode) { + if ($this->getDbDriverName() !== 'sqlsrv' || $errorCode !== self::MSSQL_NO_MORE_ROWS_ERROR_CODE) { throw $e; } } diff --git a/framework/log/migrations/m141106_185632_log_init.php b/framework/log/migrations/m141106_185632_log_init.php index 5e3db767ab8..ee73b6ff2d4 100644 --- a/framework/log/migrations/m141106_185632_log_init.php +++ b/framework/log/migrations/m141106_185632_log_init.php @@ -25,7 +25,7 @@ class m141106_185632_log_init extends Migration /** * @var DbTarget[] Targets to create log table for */ - private $dbTargets = []; + private $_dbTargets = []; /** * @throws InvalidConfigException @@ -33,7 +33,7 @@ class m141106_185632_log_init extends Migration */ protected function getDbTargets() { - if ($this->dbTargets === []) { + if ($this->_dbTargets === []) { $log = Yii::$app->getLog(); $usedTargets = []; @@ -46,17 +46,17 @@ protected function getDbTargets() if (!in_array($currentTarget, $usedTargets, true)) { // do not create same table twice $usedTargets[] = $currentTarget; - $this->dbTargets[] = $target; + $this->_dbTargets[] = $target; } } } - if ($this->dbTargets === []) { + if ($this->_dbTargets === []) { throw new InvalidConfigException('You should configure "log" component to use one or more database targets before executing this migration.'); } } - return $this->dbTargets; + return $this->_dbTargets; } public function up() diff --git a/framework/web/Session.php b/framework/web/Session.php index 1702c21fb9b..2fbd1229e75 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -105,8 +105,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co /** * @var array|null is used for saving session between recreations due to session parameters update. */ - private $frozenSessionData; - + private $_frozenSessionData; /** * Initializes the application component. @@ -1016,7 +1015,7 @@ protected function freeze() { if ($this->getIsActive()) { if (isset($_SESSION)) { - $this->frozenSessionData = $_SESSION; + $this->_frozenSessionData = $_SESSION; } $this->close(); Yii::info('Session frozen', __METHOD__); @@ -1029,7 +1028,7 @@ protected function freeze() */ protected function unfreeze() { - if (null !== $this->frozenSessionData) { + if (null !== $this->_frozenSessionData) { YII_DEBUG ? session_start() : @session_start(); if ($this->getIsActive()) { @@ -1040,8 +1039,8 @@ protected function unfreeze() Yii::error($message, __METHOD__); } - $_SESSION = $this->frozenSessionData; - $this->frozenSessionData = null; + $_SESSION = $this->_frozenSessionData; + $this->_frozenSessionData = null; } }