|
26 | 26 | use Magento\Framework\Stdlib\DateTime; |
27 | 27 | use Magento\Framework\Stdlib\StringUtils; |
28 | 28 |
|
| 29 | +// @codingStandardsIgnoreStart |
29 | 30 | /** |
30 | 31 | * MySQL database adapter |
31 | 32 | * |
32 | 33 | * @SuppressWarnings(PHPMD.ExcessivePublicCount) |
33 | 34 | * @SuppressWarnings(PHPMD.TooManyFields) |
34 | 35 | * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
35 | 36 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
36 | | - * @codingStandardsIgnoreFile |
37 | 37 | */ |
38 | 38 | class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface |
39 | 39 | { |
| 40 | + // @codingStandardsIgnoreEnd |
| 41 | + |
40 | 42 | const TIMESTAMP_FORMAT = 'Y-m-d H:i:s'; |
41 | 43 | const DATETIME_FORMAT = 'Y-m-d H:i:s'; |
42 | 44 | const DATE_FORMAT = 'Y-m-d'; |
@@ -520,7 +522,9 @@ protected function _query($sql, $bind = []) |
520 | 522 | $pdoException = null; |
521 | 523 | if ($e instanceof \PDOException) { |
522 | 524 | $pdoException = $e; |
523 | | - } elseif (($e instanceof \Zend_Db_Statement_Exception) && ($e->getPrevious() instanceof \PDOException)) { |
| 525 | + } elseif (($e instanceof \Zend_Db_Statement_Exception) |
| 526 | + && ($e->getPrevious() instanceof \PDOException) |
| 527 | + ) { |
524 | 528 | $pdoException = $e->getPrevious(); |
525 | 529 | } |
526 | 530 |
|
@@ -749,7 +753,6 @@ public function setQueryHook($hook) |
749 | 753 | * @return array |
750 | 754 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) |
751 | 755 | * @SuppressWarnings(PHPMD.NPathComplexity) |
752 | | -
|
753 | 756 | * @deprecated |
754 | 757 | */ |
755 | 758 | protected function _splitMultiQuery($sql) |
@@ -1640,9 +1643,7 @@ public function getColumnCreateByDescribe($columnData) |
1640 | 1643 | if ($columnData['PRIMARY'] === true) { |
1641 | 1644 | $options['primary'] = true; |
1642 | 1645 | } |
1643 | | - if (!is_null($columnData['DEFAULT']) |
1644 | | - && $type != Table::TYPE_TEXT |
1645 | | - ) { |
| 1646 | + if ($columnData['DEFAULT'] !== null && $type != Table::TYPE_TEXT) { |
1646 | 1647 | $options['default'] = $this->quote($columnData['DEFAULT']); |
1647 | 1648 | } |
1648 | 1649 | if (strlen($columnData['SCALE']) > 0) { |
@@ -1747,7 +1748,7 @@ public function modifyColumnByDdl($tableName, $columnName, $definition, $flushDa |
1747 | 1748 | { |
1748 | 1749 | $definition = array_change_key_case($definition, CASE_UPPER); |
1749 | 1750 | $definition['COLUMN_TYPE'] = $this->_getColumnTypeByDdl($definition); |
1750 | | - if (array_key_exists('DEFAULT', $definition) && is_null($definition['DEFAULT'])) { |
| 1751 | + if (array_key_exists('DEFAULT', $definition) && $definition['DEFAULT'] === null) { |
1751 | 1752 | unset($definition['DEFAULT']); |
1752 | 1753 | } |
1753 | 1754 |
|
@@ -2441,7 +2442,7 @@ protected function _getColumnDefinition($options, $ddlType = null) |
2441 | 2442 | } else { |
2442 | 2443 | $cDefault = false; |
2443 | 2444 | } |
2444 | | - } elseif (is_null($cDefault) && $cNullable) { |
| 2445 | + } elseif ($cDefault === null && $cNullable) { |
2445 | 2446 | $cDefault = new \Zend_Db_Expr('NULL'); |
2446 | 2447 | } |
2447 | 2448 |
|
@@ -2937,7 +2938,7 @@ public function prepareColumnValue(array $column, $value) |
2937 | 2938 | } |
2938 | 2939 |
|
2939 | 2940 | // return null |
2940 | | - if (is_null($value) && $column['NULLABLE']) { |
| 2941 | + if ($value === null && $column['NULLABLE']) { |
2941 | 2942 | return null; |
2942 | 2943 | } |
2943 | 2944 |
|
@@ -3202,7 +3203,7 @@ public function getDatePartSql($date) |
3202 | 3203 | */ |
3203 | 3204 | public function getSubstringSql($stringExpression, $pos, $len = null) |
3204 | 3205 | { |
3205 | | - if (is_null($len)) { |
| 3206 | + if ($len === null) { |
3206 | 3207 | return new \Zend_Db_Expr(sprintf('SUBSTRING(%s, %s)', $stringExpression, $pos)); |
3207 | 3208 | } |
3208 | 3209 | return new \Zend_Db_Expr(sprintf('SUBSTRING(%s, %s, %s)', $stringExpression, $pos, $len)); |
@@ -3826,7 +3827,7 @@ public function __destruct() |
3826 | 3827 | */ |
3827 | 3828 | public function getTables($likeCondition = null) |
3828 | 3829 | { |
3829 | | - $sql = is_null($likeCondition) ? 'SHOW TABLES' : sprintf("SHOW TABLES LIKE '%s'", $likeCondition); |
| 3830 | + $sql = ($likeCondition === null) ? 'SHOW TABLES' : sprintf("SHOW TABLES LIKE '%s'", $likeCondition); |
3830 | 3831 | $result = $this->query($sql); |
3831 | 3832 | $tables = []; |
3832 | 3833 | while ($row = $result->fetchColumn()) { |
|
0 commit comments