Skip to content

Commit

Permalink
Refactor private vars with underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanphp committed Mar 18, 2024
1 parent 3c26a78 commit 8620cbc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Quality
name: lint

on: [push, pull_request]

Expand Down
10 changes: 5 additions & 5 deletions framework/behaviors/AttributeTypecastBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];


/**
Expand All @@ -194,7 +194,7 @@ class AttributeTypecastBehavior extends Behavior
*/
public static function clearAutoDetectedAttributeTypes()
{
self::$autoDetectedAttributeTypes = [];
self::$_autoDetectedAttributeTypes = [];
}

/**
Expand All @@ -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];
}
}

Expand Down
12 changes: 6 additions & 6 deletions framework/db/BatchQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;


/**
Expand Down Expand Up @@ -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;
}
}
Expand Down
10 changes: 5 additions & 5 deletions framework/log/migrations/m141106_185632_log_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class m141106_185632_log_init extends Migration
/**
* @var DbTarget[] Targets to create log table for
*/
private $dbTargets = [];
private $_dbTargets = [];

/**
* @throws InvalidConfigException
* @return DbTarget[]
*/
protected function getDbTargets()
{
if ($this->dbTargets === []) {
if ($this->_dbTargets === []) {
$log = Yii::$app->getLog();

$usedTargets = [];
Expand All @@ -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()
Expand Down
11 changes: 5 additions & 6 deletions framework/web/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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__);
Expand All @@ -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()) {
Expand All @@ -1040,8 +1039,8 @@ protected function unfreeze()
Yii::error($message, __METHOD__);
}

$_SESSION = $this->frozenSessionData;
$this->frozenSessionData = null;
$_SESSION = $this->_frozenSessionData;
$this->_frozenSessionData = null;
}
}

Expand Down

0 comments on commit 8620cbc

Please sign in to comment.