From 91d68c4c335cc7684146720c75b5b9a3d8c31edd Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Thu, 14 Mar 2019 06:45:02 -0700 Subject: [PATCH 01/45] Added some typehints --- src/Sql/AbstractExpression.php | 25 +++- src/Sql/AbstractPreparableSql.php | 11 +- src/Sql/AbstractSql.php | 138 +++++++++++------- src/Sql/Combine.php | 39 +++-- src/Sql/Ddl/AlterTable.php | 43 ++++-- src/Sql/Ddl/Column/AbstractLengthColumn.php | 11 +- .../Ddl/Column/AbstractPrecisionColumn.php | 28 ++-- .../Ddl/Column/AbstractTimestampColumn.php | 5 +- src/Sql/Ddl/Column/BigInteger.php | 3 + src/Sql/Ddl/Column/Binary.php | 2 + src/Sql/Ddl/Column/Blob.php | 3 + src/Sql/Ddl/Column/Boolean.php | 5 +- src/Sql/Ddl/Column/Char.php | 2 + src/Sql/Ddl/Column/Column.php | 34 +++-- src/Sql/Ddl/Column/ColumnInterface.php | 9 +- src/Sql/Ddl/Column/Date.php | 3 + src/Sql/Ddl/Column/Datetime.php | 3 + src/Sql/Ddl/Column/Decimal.php | 3 + src/Sql/Ddl/Column/Float.php | 2 + src/Sql/Ddl/Column/Floating.php | 3 + src/Sql/Ddl/Column/Integer.php | 5 +- src/Sql/Ddl/Column/Text.php | 3 + src/Sql/Ddl/Column/Time.php | 3 + src/Sql/Ddl/Column/Timestamp.php | 3 + src/Sql/Ddl/Column/Varbinary.php | 3 + src/Sql/Ddl/Column/Varchar.php | 3 + src/Sql/Ddl/Constraint/AbstractConstraint.php | 19 ++- src/Sql/Ddl/Constraint/Check.php | 13 +- .../Ddl/Constraint/ConstraintInterface.php | 3 + src/Sql/Ddl/Constraint/ForeignKey.php | 35 +++-- src/Sql/Ddl/Constraint/PrimaryKey.php | 3 + src/Sql/Ddl/Constraint/UniqueKey.php | 3 + src/Sql/Ddl/CreateTable.php | 45 +++--- src/Sql/Ddl/DropTable.php | 5 +- src/Sql/Ddl/SqlInterface.php | 3 + src/Sql/Delete.php | 20 ++- src/Sql/Exception/ExceptionInterface.php | 3 + .../Exception/InvalidArgumentException.php | 3 + src/Sql/Exception/RuntimeException.php | 3 + src/Sql/Expression.php | 30 +++- src/Sql/ExpressionInterface.php | 3 + src/Sql/Having.php | 2 + src/Sql/Insert.php | 3 + src/Sql/Platform/AbstractPlatform.php | 20 ++- src/Sql/Platform/IbmDb2/IbmDb2.php | 3 + src/Sql/Platform/IbmDb2/SelectDecorator.php | 36 +++-- .../Mysql/Ddl/AlterTableDecorator.php | 30 +++- .../Mysql/Ddl/CreateTableDecorator.php | 12 +- src/Sql/Platform/Mysql/Mysql.php | 3 + src/Sql/Platform/Mysql/SelectDecorator.php | 16 +- src/Sql/Platform/Oracle/Oracle.php | 3 + src/Sql/Platform/Oracle/SelectDecorator.php | 26 ++-- src/Sql/Platform/Platform.php | 37 +++-- .../Platform/PlatformDecoratorInterface.php | 3 + .../Platform/SqlServer/SelectDecorator.php | 3 +- src/Sql/Platform/Sqlite/SelectDecorator.php | 17 ++- src/Sql/Platform/Sqlite/Sqlite.php | 3 + src/Sql/Predicate/Between.php | 30 ++-- src/Sql/Predicate/Expression.php | 7 +- src/Sql/Predicate/In.php | 16 +- src/Sql/Predicate/IsNotNull.php | 3 + src/Sql/Predicate/IsNull.php | 19 ++- src/Sql/Predicate/Like.php | 23 ++- src/Sql/Predicate/Literal.php | 3 + src/Sql/Predicate/NotBetween.php | 6 + src/Sql/Predicate/NotIn.php | 6 + src/Sql/Predicate/NotLike.php | 6 + src/Sql/Predicate/Operator.php | 29 ++-- src/Sql/Predicate/Predicate.php | 110 ++++++++++---- src/Sql/Predicate/PredicateInterface.php | 3 + src/Sql/Predicate/PredicateSet.php | 39 ++++- src/Sql/Select.php | 9 +- src/Sql/Sql.php | 2 +- src/Sql/SqlInterface.php | 5 +- src/Sql/TableIdentifier.php | 10 +- 75 files changed, 798 insertions(+), 328 deletions(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index 3fbee7c1c6..3dc5fb757b 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -1,4 +1,7 @@ buildNormalizedArgument($argument, self::TYPE_VALUE); @@ -57,7 +72,7 @@ protected function normalizeArgument($argument, $defaultType = self::TYPE_VALUE) return $this->buildNormalizedArgument($key, $value); } - throw new Exception\InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '$argument should be %s or %s or %s or %s or %s, "%s" given', 'null', 'scalar', @@ -72,14 +87,14 @@ protected function normalizeArgument($argument, $defaultType = self::TYPE_VALUE) * @param mixed $argument * @param string $argumentType * - * @return array + * @return mixed[] * * @throws Exception\InvalidArgumentException */ - private function buildNormalizedArgument($argument, $argumentType) + private function buildNormalizedArgument($argument, string $argumentType) : array { if (! in_array($argumentType, $this->allowedTypes)) { - throw new Exception\InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( 'Argument type should be in array(%s)', implode(',', $this->allowedTypes) )); diff --git a/src/Sql/AbstractPreparableSql.php b/src/Sql/AbstractPreparableSql.php index 6d95f90d84..a45e1cdfa4 100644 --- a/src/Sql/AbstractPreparableSql.php +++ b/src/Sql/AbstractPreparableSql.php @@ -1,4 +1,7 @@ getParameterContainer(); if (! $parameterContainer instanceof ParameterContainer) { diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index f8935ca44e..3b4a87cbe1 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -1,4 +1,7 @@ '', 'subselectCount' => 0]; @@ -37,7 +51,7 @@ abstract class AbstractSql implements SqlInterface /** * {@inheritDoc} */ - public function getSqlString(PlatformInterface $adapterPlatform = null) + public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { $adapterPlatform = ($adapterPlatform) ?: new DefaultAdapterPlatform; return $this->buildSqlString($adapterPlatform); @@ -47,11 +61,12 @@ public function getSqlString(PlatformInterface $adapterPlatform = null) * @param PlatformInterface $platform * @param null|DriverInterface $driver * @param null|ParameterContainer $parameterContainer - * @return string + * + * @return string|void */ protected function buildSqlString( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null ) { $this->localizeVariables(); @@ -87,38 +102,43 @@ protected function buildSqlString( * * @todo move TableIdentifier concatenation here * @param string $table - * @param string $alias + * @param string|null $alias + * * @return string */ - protected function renderTable($table, $alias = null) + protected function renderTable(string $table, ?string $alias = null) : string { return $table . ($alias ? ' AS ' . $alias : ''); } /** * @staticvar int $runtimeExpressionPrefix + * * @param ExpressionInterface $expression * @param PlatformInterface $platform * @param null|DriverInterface $driver * @param null|ParameterContainer $parameterContainer * @param null|string $namedParameterPrefix + * * @return string + * * @throws Exception\RuntimeException */ protected function processExpression( ExpressionInterface $expression, - PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null, - $namedParameterPrefix = null - ) { + PlatformInterface $platform, + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null, + ?string $namedParameterPrefix = null + ) : string { $namedParameterPrefix = ! $namedParameterPrefix ? $namedParameterPrefix : $this->processInfo['paramPrefix'] . $namedParameterPrefix; + // static counter for the number of times this method was invoked across the PHP runtime static $runtimeExpressionPrefix = 0; - if ($parameterContainer && ((! is_string($namedParameterPrefix) || $namedParameterPrefix == ''))) { + if ($parameterContainer && (! is_string($namedParameterPrefix) || $namedParameterPrefix == '')) { $namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix); } else { $namedParameterPrefix = preg_replace('/\s/', '__', $namedParameterPrefix); @@ -151,7 +171,7 @@ protected function processExpression( } if (! is_array($part)) { - throw new Exception\RuntimeException( + throw new RuntimeException( 'Elements returned from getExpressionData() array must be a string or array.' ); } @@ -159,7 +179,8 @@ protected function processExpression( // Process values and types (the middle and last position of the // expression data) $values = $part[1]; - $types = isset($part[2]) ? $part[2] : []; + $types = isset($part[2]) ? $part[2] : []; + foreach ($values as $vIndex => $value) { if (! isset($types[$vIndex])) { continue; @@ -214,7 +235,7 @@ protected function processExpression( * * @throws Exception\RuntimeException */ - protected function createSqlFromSpecificationAndParameters($specifications, $parameters) + protected function createSqlFromSpecificationAndParameters($specifications, array $parameters) : string { if (is_string($specifications)) { return vsprintf($specifications, $parameters); @@ -231,7 +252,7 @@ protected function createSqlFromSpecificationAndParameters($specifications, $par } if (! isset($specificationString)) { - throw new Exception\RuntimeException( + throw new RuntimeException( 'A number of parameters was found that is not supported by this specification' ); } @@ -248,7 +269,7 @@ protected function createSqlFromSpecificationAndParameters($specifications, $par } if (! isset($paramSpecs[$position][$ppCount])) { - throw new Exception\RuntimeException(sprintf( + throw new RuntimeException(sprintf( 'A number of parameters (%d) was found that is not supported by this specification', $ppCount )); @@ -259,7 +280,7 @@ protected function createSqlFromSpecificationAndParameters($specifications, $par } elseif ($paramSpecs[$position] !== null) { $ppCount = count($paramsForPosition); if (! isset($paramSpecs[$position][$ppCount])) { - throw new Exception\RuntimeException(sprintf( + throw new RuntimeException(sprintf( 'A number of parameters (%d) was found that is not supported by this specification', $ppCount )); @@ -269,21 +290,23 @@ protected function createSqlFromSpecificationAndParameters($specifications, $par $topParameters[] = $paramsForPosition; } } + return vsprintf($specificationString, $topParameters); } /** - * @param Select $subselect - * @param PlatformInterface $platform - * @param null|DriverInterface $driver + * @param Select $subselect + * @param PlatformInterface $platform + * @param null|DriverInterface $driver * @param null|ParameterContainer $parameterContainer + * * @return string */ protected function processSubSelect( - Select $subselect, - PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + Select $subselect, + PlatformInterface $platform, + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this instanceof PlatformDecoratorInterface) { $decorator = clone $this; @@ -304,6 +327,7 @@ protected function processSubSelect( // copy count $this->processInfo['subselectCount'] = $decorator->processInfo['subselectCount']; + return $sql; } @@ -311,19 +335,20 @@ protected function processSubSelect( } /** - * @param Join[] $joins + * @param Join $joins * @param PlatformInterface $platform * @param null|DriverInterface $driver * @param null|ParameterContainer $parameterContainer - * @return null|string[] Null if no joins present, array of JOIN statements + * + * @return string[]|void|null * otherwise * @throws Exception\InvalidArgumentException for invalid JOIN table names. */ protected function processJoin( - Join $joins, - PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + Join $joins, + PlatformInterface $platform, + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if (! $joins->count()) { return; @@ -331,6 +356,7 @@ protected function processJoin( // process joins $joinSpecArgArray = []; + foreach ($joins->getJoins() as $j => $join) { $joinName = null; $joinAs = null; @@ -355,7 +381,7 @@ protected function processJoin( } elseif (is_string($joinName) || (is_object($joinName) && is_callable([$joinName, '__toString']))) { $joinName = $platform->quoteIdentifier($joinName); } else { - throw new Exception\InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( 'Join name expected to be Expression|TableIdentifier|Select|string, "%s" given', gettype($joinName) )); @@ -391,19 +417,20 @@ protected function processJoin( /** * @param null|array|ExpressionInterface|Select $column - * @param PlatformInterface $platform - * @param null|DriverInterface $driver - * @param null|string $namedParameterPrefix - * @param null|ParameterContainer $parameterContainer + * @param PlatformInterface $platform + * @param null|DriverInterface $driver + * @param null|ParameterContainer $parameterContainer + * @param null|string $namedParameterPrefix + * * @return string */ protected function resolveColumnValue( - $column, - PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null, - $namedParameterPrefix = null - ) { + ?$column, + PlatformInterface $platform, + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null, + ?string $namedParameterPrefix = null + ) : string { $namedParameterPrefix = ! $namedParameterPrefix ? $namedParameterPrefix : $this->processInfo['paramPrefix'] . $namedParameterPrefix; @@ -422,12 +449,16 @@ protected function resolveColumnValue( if ($column instanceof ExpressionInterface) { return $this->processExpression($column, $platform, $driver, $parameterContainer, $namedParameterPrefix); } + if ($column instanceof Select) { return '(' . $this->processSubSelect($column, $platform, $driver, $parameterContainer) . ')'; } + if ($column === null) { return 'NULL'; } + + /** @var string $column */ return $isIdentifier ? $fromTable . $platform->quoteIdentifierInFragment($column) : $platform->quoteValue($column); @@ -435,18 +466,20 @@ protected function resolveColumnValue( /** * @param string|TableIdentifier|Select $table - * @param PlatformInterface $platform - * @param DriverInterface $driver - * @param ParameterContainer $parameterContainer + * @param PlatformInterface $platform + * @param DriverInterface $driver + * @param ParameterContainer $parameterContainer + * * @return string */ protected function resolveTable( $table, - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null - ) { + ) : string { $schema = null; + if ($table instanceof TableIdentifier) { list($table, $schema) = $table->getTableAndSchema(); } @@ -457,16 +490,17 @@ protected function resolveTable( $table = $platform->quoteIdentifier($table); } - if ($schema && $table) { + if (is_string($schema) && $table) { $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; } + return $table; } /** * Copy variables from the subject into the local properties */ - protected function localizeVariables() + protected function localizeVariables() : void { if (! $this instanceof PlatformDecoratorInterface) { return; diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index bedb170f2c..8cdd0acaf3 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -1,4 +1,7 @@ combine($select, $type, $modifier); @@ -59,7 +70,7 @@ public function __construct($select = null, $type = self::COMBINE_UNION, $modifi * * @throws Exception\InvalidArgumentException */ - public function combine($select, $type = self::COMBINE_UNION, $modifier = '') + public function combine($select, ?string $type = self::COMBINE_UNION, ?string $modifier = '') : self { if (is_array($select)) { foreach ($select as $combine) { @@ -88,6 +99,7 @@ public function combine($select, $type = self::COMBINE_UNION, $modifier = '') 'type' => $type, 'modifier' => $modifier ]; + return $this; } @@ -99,7 +111,7 @@ public function combine($select, $type = self::COMBINE_UNION, $modifier = '') * * @return self */ - public function union($select, $modifier = '') + public function union($select, ?string $modifier = '') : self { return $this->combine($select, self::COMBINE_UNION, $modifier); } @@ -112,7 +124,7 @@ public function union($select, $modifier = '') * * @return self */ - public function except($select, $modifier = '') + public function except($select, ?string $modifier = '') : self { return $this->combine($select, self::COMBINE_EXCEPT, $modifier); } @@ -122,9 +134,10 @@ public function except($select, $modifier = '') * * @param Select|array $select * @param string $modifier + * * @return self */ - public function intersect($select, $modifier = '') + public function intersect($select, ?string $modifier = '') : self { return $this->combine($select, self::COMBINE_INTERSECT, $modifier); } @@ -136,11 +149,11 @@ public function intersect($select, $modifier = '') * @param DriverInterface $driver * @param ParameterContainer $parameterContainer * - * @return string + * @return string|void */ protected function buildSqlString( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null ) { if (! $this->combine) { @@ -148,6 +161,7 @@ protected function buildSqlString( } $sql = ''; + foreach ($this->combine as $i => $combine) { $type = $i == 0 ? '' @@ -159,13 +173,14 @@ protected function buildSqlString( $select ); } + return trim($sql, ' '); } /** * @return self Provides a fluent interface */ - public function alignColumns() + public function alignColumns() : self { if (! $this->combine) { return $this; @@ -189,6 +204,7 @@ public function alignColumns() } $combine['select']->columns($aligned, false); } + return $this; } @@ -199,7 +215,7 @@ public function alignColumns() * * @return array */ - public function getRawState($key = null) + public function getRawState(?string $key = null) : array { $rawState = [ self::COMBINE => $this->combine, @@ -207,6 +223,7 @@ public function getRawState($key = null) ? $this->combine[0]['select']->getRawState(self::COLUMNS) : [], ]; + return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } } diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index bee08f9996..fc2eeb0c17 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -1,4 +1,7 @@ table = $name; @@ -105,10 +111,11 @@ public function setTable($name) } /** - * @param Column\ColumnInterface $column + * @param ColumnInterface $column + * * @return self Provides a fluent interface */ - public function addColumn(Column\ColumnInterface $column) + public function addColumn(ColumnInterface $column) : self { $this->addColumns[] = $column; @@ -117,10 +124,11 @@ public function addColumn(Column\ColumnInterface $column) /** * @param string $name - * @param Column\ColumnInterface $column + * @param ColumnInterface $column + * * @return self Provides a fluent interface */ - public function changeColumn($name, Column\ColumnInterface $column) + public function changeColumn(string $name, ColumnInterface $column) : self { $this->changeColumns[$name] = $column; @@ -129,9 +137,10 @@ public function changeColumn($name, Column\ColumnInterface $column) /** * @param string $name + * * @return self Provides a fluent interface */ - public function dropColumn($name) + public function dropColumn(string $name) : self { $this->dropColumns[] = $name; @@ -140,9 +149,10 @@ public function dropColumn($name) /** * @param string $name + * * @return self Provides a fluent interface */ - public function dropConstraint($name) + public function dropConstraint(string $name) : self { $this->dropConstraints[] = $name; @@ -150,10 +160,11 @@ public function dropConstraint($name) } /** - * @param Constraint\ConstraintInterface $constraint + * @param ConstraintInterface $constraint + * * @return self Provides a fluent interface */ - public function addConstraint(Constraint\ConstraintInterface $constraint) + public function addConstraint(ConstraintInterface $constraint) : self { $this->addConstraints[] = $constraint; @@ -164,7 +175,7 @@ public function addConstraint(Constraint\ConstraintInterface $constraint) * @param string|null $key * @return array */ - public function getRawState($key = null) + public function getRawState(?string $key = null) : array { $rawState = [ self::TABLE => $this->table, @@ -178,12 +189,12 @@ public function getRawState($key = null) return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } - protected function processTable(PlatformInterface $adapterPlatform = null) + protected function processTable(?PlatformInterface $adapterPlatform = null) : array { return [$this->resolveTable($this->table, $adapterPlatform)]; } - protected function processAddColumns(PlatformInterface $adapterPlatform = null) + protected function processAddColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; foreach ($this->addColumns as $column) { @@ -193,7 +204,7 @@ protected function processAddColumns(PlatformInterface $adapterPlatform = null) return [$sqls]; } - protected function processChangeColumns(PlatformInterface $adapterPlatform = null) + protected function processChangeColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; foreach ($this->changeColumns as $name => $column) { @@ -206,7 +217,7 @@ protected function processChangeColumns(PlatformInterface $adapterPlatform = nul return [$sqls]; } - protected function processDropColumns(PlatformInterface $adapterPlatform = null) + protected function processDropColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; foreach ($this->dropColumns as $column) { @@ -216,7 +227,7 @@ protected function processDropColumns(PlatformInterface $adapterPlatform = null) return [$sqls]; } - protected function processAddConstraints(PlatformInterface $adapterPlatform = null) + protected function processAddConstraints(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; foreach ($this->addConstraints as $constraint) { @@ -226,7 +237,7 @@ protected function processAddConstraints(PlatformInterface $adapterPlatform = nu return [$sqls]; } - protected function processDropConstraints(PlatformInterface $adapterPlatform = null) + protected function processDropConstraints(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; foreach ($this->dropConstraints as $constraint) { diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index 59e499d12e..df821353c7 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -1,4 +1,7 @@ length = (int) $length; @@ -42,7 +45,7 @@ public function setLength($length) /** * @return int */ - public function getLength() + public function getLength() : int { return $this->length; } @@ -50,7 +53,7 @@ public function getLength() /** * @return string */ - protected function getLengthExpression() + protected function getLengthExpression() : string { return (string) $this->length; } @@ -58,7 +61,7 @@ protected function getLengthExpression() /** * @return array */ - public function getExpressionData() + public function getExpressionData() : array { $data = parent::getExpressionData(); diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index 3edba684c5..abc962f7ac 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -1,4 +1,7 @@ setDecimal($decimal); @@ -40,7 +43,7 @@ public function __construct( * * @return self */ - public function setDigits($digits) + public function setDigits(int $digits) : self { return $this->setLength($digits); } @@ -48,16 +51,17 @@ public function setDigits($digits) /** * @return int */ - public function getDigits() + public function getDigits() : int { return $this->getLength(); } /** * @param int|null $decimal + * * @return self Provides a fluent interface */ - public function setDecimal($decimal) + public function setDecimal(?int $decimal) : self { $this->decimal = null === $decimal ? null : (int) $decimal; @@ -67,7 +71,7 @@ public function setDecimal($decimal) /** * @return int|null */ - public function getDecimal() + public function getDecimal() : ?int { return $this->decimal; } @@ -75,12 +79,12 @@ public function getDecimal() /** * {@inheritDoc} */ - protected function getLengthExpression() + protected function getLengthExpression() : string { if ($this->decimal !== null) { return $this->length . ',' . $this->decimal; } - return $this->length; + return (string) $this->length; } } diff --git a/src/Sql/Ddl/Column/AbstractTimestampColumn.php b/src/Sql/Ddl/Column/AbstractTimestampColumn.php index e71d3791d4..837be0daf4 100644 --- a/src/Sql/Ddl/Column/AbstractTimestampColumn.php +++ b/src/Sql/Ddl/Column/AbstractTimestampColumn.php @@ -1,4 +1,7 @@ specification; diff --git a/src/Sql/Ddl/Column/BigInteger.php b/src/Sql/Ddl/Column/BigInteger.php index 83463381d0..00a307cfd5 100644 --- a/src/Sql/Ddl/Column/BigInteger.php +++ b/src/Sql/Ddl/Column/BigInteger.php @@ -1,4 +1,7 @@ setName($name); $this->setNullable($nullable); @@ -64,18 +67,20 @@ public function __construct($name = null, $nullable = false, $default = null, ar /** * @param string $name + * * @return self Provides a fluent interface */ - public function setName($name) + public function setName($name) : self { $this->name = (string) $name; + return $this; } /** * @return null|string */ - public function getName() + public function getName() : ?string { return $this->name; } @@ -84,27 +89,30 @@ public function getName() * @param bool $nullable * @return self Provides a fluent interface */ - public function setNullable($nullable) + public function setNullable(bool $nullable) : self { $this->isNullable = (bool) $nullable; + return $this; } /** * @return bool */ - public function isNullable() + public function isNullable() : bool { return $this->isNullable; } /** * @param null|string|int $default + * * @return self Provides a fluent interface */ - public function setDefault($default) + public function setDefault(?$default) : self { $this->default = $default; + return $this; } @@ -118,29 +126,33 @@ public function getDefault() /** * @param array $options + * * @return self Provides a fluent interface */ - public function setOptions(array $options) + public function setOptions(array $options) : self { $this->options = $options; + return $this; } /** * @param string $name * @param string $value + * * @return self Provides a fluent interface */ - public function setOption($name, $value) + public function setOption(string $name, string $value) : self { $this->options[$name] = $value; + return $this; } /** * @return array */ - public function getOptions() + public function getOptions() : array { return $this->options; } @@ -150,7 +162,7 @@ public function getOptions() * * @return self Provides a fluent interface */ - public function addConstraint(ConstraintInterface $constraint) + public function addConstraint(ConstraintInterface $constraint) : self { $this->constraints[] = $constraint; @@ -160,7 +172,7 @@ public function addConstraint(ConstraintInterface $constraint) /** * @return array */ - public function getExpressionData() + public function getExpressionData() : array { $spec = $this->specification; diff --git a/src/Sql/Ddl/Column/ColumnInterface.php b/src/Sql/Ddl/Column/ColumnInterface.php index ff38b5a080..a5a2ce3330 100644 --- a/src/Sql/Ddl/Column/ColumnInterface.php +++ b/src/Sql/Ddl/Column/ColumnInterface.php @@ -1,4 +1,7 @@ getOptions(); diff --git a/src/Sql/Ddl/Column/Text.php b/src/Sql/Ddl/Column/Text.php index 53ceafaa02..a6ac9a9834 100644 --- a/src/Sql/Ddl/Column/Text.php +++ b/src/Sql/Ddl/Column/Text.php @@ -1,4 +1,7 @@ setColumns($columns); @@ -51,27 +54,30 @@ public function __construct($columns = null, $name = null) /** * @param string $name + * * @return self Provides a fluent interface */ - public function setName($name) + public function setName(string $name) : self { $this->name = (string) $name; + return $this; } /** * @return string */ - public function getName() + public function getName() : string { return $this->name; } /** * @param null|string|array $columns + * * @return self Provides a fluent interface */ - public function setColumns($columns) + public function setColumns(?$columns) : self { $this->columns = (array) $columns; @@ -80,9 +86,10 @@ public function setColumns($columns) /** * @param string $column + * * @return self Provides a fluent interface */ - public function addColumn($column) + public function addColumn(string $column) : self { $this->columns[] = $column; return $this; @@ -99,7 +106,7 @@ public function getColumns() /** * {@inheritDoc} */ - public function getExpressionData() + public function getExpressionData() : array { $colCount = count($this->columns); $newSpecTypes = []; diff --git a/src/Sql/Ddl/Constraint/Check.php b/src/Sql/Ddl/Constraint/Check.php index df3917b0e8..bebda96c72 100644 --- a/src/Sql/Ddl/Constraint/Check.php +++ b/src/Sql/Ddl/Constraint/Check.php @@ -1,4 +1,7 @@ expression = $expression; $this->name = $name; @@ -34,7 +39,7 @@ public function __construct($expression, $name) /** * {@inheritDoc} */ - public function getExpressionData() + public function getExpressionData() : array { $newSpecTypes = [self::TYPE_LITERAL]; $values = [$this->expression]; diff --git a/src/Sql/Ddl/Constraint/ConstraintInterface.php b/src/Sql/Ddl/Constraint/ConstraintInterface.php index aaa092022a..07a1f58006 100644 --- a/src/Sql/Ddl/Constraint/ConstraintInterface.php +++ b/src/Sql/Ddl/Constraint/ConstraintInterface.php @@ -1,4 +1,7 @@ setName($name); $this->setColumns($columns); @@ -76,18 +79,20 @@ public function __construct( /** * @param string $referenceTable + * * @return self Provides a fluent interface */ - public function setReferenceTable($referenceTable) + public function setReferenceTable(string $referenceTable) : self { $this->referenceTable = (string) $referenceTable; + return $this; } /** * @return string */ - public function getReferenceTable() + public function getReferenceTable() : string { return $this->referenceTable; } @@ -96,7 +101,7 @@ public function getReferenceTable() * @param null|string|array $referenceColumn * @return self Provides a fluent interface */ - public function setReferenceColumn($referenceColumn) + public function setReferenceColumn(?$referenceColumn) : self { $this->referenceColumn = (array) $referenceColumn; @@ -106,7 +111,7 @@ public function setReferenceColumn($referenceColumn) /** * @return array */ - public function getReferenceColumn() + public function getReferenceColumn() : array { return $this->referenceColumn; } @@ -115,7 +120,7 @@ public function getReferenceColumn() * @param string $onDeleteRule * @return self Provides a fluent interface */ - public function setOnDeleteRule($onDeleteRule) + public function setOnDeleteRule(string $onDeleteRule) : self { $this->onDeleteRule = (string) $onDeleteRule; @@ -125,7 +130,7 @@ public function setOnDeleteRule($onDeleteRule) /** * @return string */ - public function getOnDeleteRule() + public function getOnDeleteRule() : string { return $this->onDeleteRule; } @@ -134,7 +139,7 @@ public function getOnDeleteRule() * @param string $onUpdateRule * @return self Provides a fluent interface */ - public function setOnUpdateRule($onUpdateRule) + public function setOnUpdateRule(string $onUpdateRule) : self { $this->onUpdateRule = (string) $onUpdateRule; @@ -144,7 +149,7 @@ public function setOnUpdateRule($onUpdateRule) /** * @return string */ - public function getOnUpdateRule() + public function getOnUpdateRule() : string { return $this->onUpdateRule; } @@ -152,7 +157,7 @@ public function getOnUpdateRule() /** * @return array */ - public function getExpressionData() + public function getExpressionData() : array { $data = parent::getExpressionData(); $colCount = count($this->referenceColumn); diff --git a/src/Sql/Ddl/Constraint/PrimaryKey.php b/src/Sql/Ddl/Constraint/PrimaryKey.php index 9775bb018f..62aeed812e 100644 --- a/src/Sql/Ddl/Constraint/PrimaryKey.php +++ b/src/Sql/Ddl/Constraint/PrimaryKey.php @@ -1,4 +1,7 @@ table = $table; $this->setTemporary($isTemporary); @@ -70,18 +75,20 @@ public function __construct($table = '', $isTemporary = false) /** * @param bool $temporary + * * @return self Provides a fluent interface */ - public function setTemporary($temporary) + public function setTemporary(bool $temporary) : self { $this->isTemporary = (bool) $temporary; + return $this; } /** * @return bool */ - public function isTemporary() + public function isTemporary() : bool { return $this->isTemporary; } @@ -90,37 +97,41 @@ public function isTemporary() * @param string $name * @return self Provides a fluent interface */ - public function setTable($name) + public function setTable(string $name) : self { $this->table = $name; + return $this; } /** - * @param Column\ColumnInterface $column + * @param ColumnInterface $column * @return self Provides a fluent interface */ - public function addColumn(Column\ColumnInterface $column) + public function addColumn(ColumnInterface $column) : self { $this->columns[] = $column; + return $this; } /** - * @param Constraint\ConstraintInterface $constraint + * @param ConstraintInterface $constraint * @return self Provides a fluent interface */ - public function addConstraint(Constraint\ConstraintInterface $constraint) + public function addConstraint(ConstraintInterface $constraint) : self { $this->constraints[] = $constraint; + return $this; } /** * @param string|null $key + * * @return array */ - public function getRawState($key = null) + public function getRawState(?string $key = null) : array { $rawState = [ self::COLUMNS => $this->columns, @@ -136,7 +147,7 @@ public function getRawState($key = null) * * @return string[] */ - protected function processTable(PlatformInterface $adapterPlatform = null) + protected function processTable(?PlatformInterface $adapterPlatform = null) : array { return [ $this->isTemporary ? 'TEMPORARY ' : '', @@ -147,9 +158,9 @@ protected function processTable(PlatformInterface $adapterPlatform = null) /** * @param PlatformInterface $adapterPlatform * - * @return string[][]|null + * @return string[][]|void */ - protected function processColumns(PlatformInterface $adapterPlatform = null) + protected function processColumns(?PlatformInterface $adapterPlatform = null) { if (! $this->columns) { return; @@ -167,9 +178,9 @@ protected function processColumns(PlatformInterface $adapterPlatform = null) /** * @param PlatformInterface $adapterPlatform * - * @return array|string + * @return array|string|void */ - protected function processCombinedby(PlatformInterface $adapterPlatform = null) + protected function processCombinedby(?PlatformInterface $adapterPlatform = null) { if ($this->constraints && $this->columns) { return $this->specifications['combinedBy']; @@ -179,9 +190,9 @@ protected function processCombinedby(PlatformInterface $adapterPlatform = null) /** * @param PlatformInterface $adapterPlatform * - * @return string[][]|null + * @return string[][]|void */ - protected function processConstraints(PlatformInterface $adapterPlatform = null) + protected function processConstraints(?PlatformInterface $adapterPlatform = null) { if (! $this->constraints) { return; @@ -201,7 +212,7 @@ protected function processConstraints(PlatformInterface $adapterPlatform = null) * * @return string[] */ - protected function processStatementEnd(PlatformInterface $adapterPlatform = null) + protected function processStatementEnd(?PlatformInterface $adapterPlatform = null) : array { return ["\n)"]; } diff --git a/src/Sql/Ddl/DropTable.php b/src/Sql/Ddl/DropTable.php index c42f8399cb..fc9fde36a7 100644 --- a/src/Sql/Ddl/DropTable.php +++ b/src/Sql/Ddl/DropTable.php @@ -1,4 +1,7 @@ table = $table; } - protected function processTable(PlatformInterface $adapterPlatform = null) + protected function processTable(?PlatformInterface $adapterPlatform = null) : array { return [$this->resolveTable($this->table, $adapterPlatform)]; } diff --git a/src/Sql/Ddl/SqlInterface.php b/src/Sql/Ddl/SqlInterface.php index 0f8660f452..67803f1266 100644 --- a/src/Sql/Ddl/SqlInterface.php +++ b/src/Sql/Ddl/SqlInterface.php @@ -1,4 +1,7 @@ table = $table; + return $this; } @@ -92,6 +97,7 @@ public function getRawState($key = null) 'set' => $this->set, 'where' => $this->where ]; + return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } @@ -103,7 +109,7 @@ public function getRawState($key = null) * * @return self Provides a fluent interface */ - public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) + public function where($predicate, ?string $combination = Predicate\PredicateSet::OP_AND) : self { if ($predicate instanceof Where) { $this->where = $predicate; @@ -124,7 +130,7 @@ protected function processDelete( PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null - ) { + ) : string { return sprintf( $this->specifications[static::SPECIFICATION_DELETE], $this->resolveTable($this->table, $platform, $driver, $parameterContainer) @@ -136,12 +142,12 @@ protected function processDelete( * @param DriverInterface|null $driver * @param ParameterContainer|null $parameterContainer * - * @return null|string + * @return void|string */ protected function processWhere( - PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + PlatformInterface $platform, + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->where->count() == 0) { return; diff --git a/src/Sql/Exception/ExceptionInterface.php b/src/Sql/Exception/ExceptionInterface.php index 138f7e4d62..70286c310f 100644 --- a/src/Sql/Exception/ExceptionInterface.php +++ b/src/Sql/Exception/ExceptionInterface.php @@ -1,4 +1,7 @@ setExpression($expression); @@ -62,52 +65,62 @@ public function __construct($expression = '', $parameters = null, array $types = } /** - * @param $expression + * @param string $expression + * * @return self Provides a fluent interface + * * @throws Exception\InvalidArgumentException */ - public function setExpression($expression) + public function setExpression(string $expression) : self { if (! is_string($expression) || $expression == '') { throw new Exception\InvalidArgumentException('Supplied expression must be a string.'); } + $this->expression = $expression; + return $this; } /** * @return string */ - public function getExpression() + public function getExpression() : string { return $this->expression; } /** * @param $parameters + * * @return self Provides a fluent interface + * * @throws Exception\InvalidArgumentException */ - public function setParameters($parameters) + public function setParameters($parameters) : self { if (! is_scalar($parameters) && ! is_array($parameters)) { throw new Exception\InvalidArgumentException('Expression parameters must be a scalar or array.'); } + $this->parameters = $parameters; + return $this; } /** * @return array */ - public function getParameters() + public function getParameters() : array { return $this->parameters; } /** * @deprecated + * * @param array $types + * * @return self Provides a fluent interface */ public function setTypes(array $types) @@ -118,6 +131,7 @@ public function setTypes(array $types) /** * @deprecated + * * @return array */ public function getTypes() @@ -127,9 +141,10 @@ public function getTypes() /** * @return array + * * @throws Exception\RuntimeException */ - public function getExpressionData() + public function getExpressionData() : array { $parameters = (is_scalar($this->parameters)) ? [$this->parameters] : $this->parameters; $parametersCount = count($parameters); @@ -155,6 +170,7 @@ public function getExpressionData() foreach ($parameters as $parameter) { list($values[], $types[]) = $this->normalizeArgument($parameter, self::TYPE_VALUE); } + return [[ $expression, $values, diff --git a/src/Sql/ExpressionInterface.php b/src/Sql/ExpressionInterface.php index 282b408683..d3eb2c4dc9 100644 --- a/src/Sql/ExpressionInterface.php +++ b/src/Sql/ExpressionInterface.php @@ -1,4 +1,7 @@ decorators[$type] = $decorator; } /** * @param PreparableSqlInterface|SqlInterface $subject + * * @return PlatformDecoratorInterface|PreparableSqlInterface|SqlInterface */ public function getTypeDecorator($subject) @@ -67,7 +71,7 @@ public function getTypeDecorator($subject) } /** - * @return array|PlatformDecoratorInterface[] + * @return array|PlatformDecoratorInterface */ public function getDecorators() { @@ -77,12 +81,12 @@ public function getDecorators() /** * {@inheritDoc} * - * @throws Exception\RuntimeException + * @throws RuntimeException */ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) { if (! $this->subject instanceof PreparableSqlInterface) { - throw new Exception\RuntimeException( + throw new RuntimeException( 'The subject does not appear to implement Zend\Db\Sql\PreparableSqlInterface, thus calling ' . 'prepareStatement() has no effect' ); @@ -96,12 +100,12 @@ public function prepareStatement(AdapterInterface $adapter, StatementContainerIn /** * {@inheritDoc} * - * @throws Exception\RuntimeException + * @throws RuntimeException */ - public function getSqlString(PlatformInterface $adapterPlatform = null) + public function getSqlString(PlatformInterface $adapterPlatform = null) : string { if (! $this->subject instanceof SqlInterface) { - throw new Exception\RuntimeException( + throw new RuntimeException( 'The subject does not appear to implement Zend\Db\Sql\SqlInterface, thus calling ' . 'prepareStatement() has no effect' ); diff --git a/src/Sql/Platform/IbmDb2/IbmDb2.php b/src/Sql/Platform/IbmDb2/IbmDb2.php index 35ddc2c768..6fbf9d11dd 100644 --- a/src/Sql/Platform/IbmDb2/IbmDb2.php +++ b/src/Sql/Platform/IbmDb2/IbmDb2.php @@ -1,4 +1,7 @@ isSelectContainDistinct; } /** - * @param boolean $isSelectContainDistinct + * @param bool $isSelectContainDistinct */ - public function setIsSelectContainDistinct($isSelectContainDistinct) + public function setIsSelectContainDistinct(bool $isSelectContainDistinct) : void { $this->isSelectContainDistinct = $isSelectContainDistinct; } @@ -60,7 +70,7 @@ public function setSubject($select) /** * @return bool */ - public function getSupportsLimitOffset() + public function getSupportsLimitOffset() : bool { return $this->supportsLimitOffset; } @@ -68,20 +78,20 @@ public function getSupportsLimitOffset() /** * @param bool $supportsLimitOffset */ - public function setSupportsLimitOffset($supportsLimitOffset) + public function setSupportsLimitOffset(bool $supportsLimitOffset) : void { $this->supportsLimitOffset = $supportsLimitOffset; } /** - * @see Select::renderTable + * {@inheritDoc} */ - protected function renderTable($table, $alias = null) + protected function renderTable(string $table, ?string $alias = null) : string { return $table . ' ' . $alias; } - protected function localizeVariables() + protected function localizeVariables() : void { parent::localizeVariables(); // set specifications @@ -99,12 +109,12 @@ protected function localizeVariables() * @param array $parameters */ protected function processLimitOffset( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null, - &$sqls, - &$parameters - ) { + array &$sqls, + array &$parameters + ) : void { if ($this->limit === null && $this->offset === null) { return; } diff --git a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php index ea3176532d..ec90d66244 100644 --- a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -1,4 +1,7 @@ subject = $subject; @@ -49,9 +62,10 @@ public function setSubject($subject) /** * @param string $sql + * * @return array */ - protected function getSqlInsertOffsets($sql) + protected function getSqlInsertOffsets(string $sql) : array { $sqlLength = strlen($sql); $insertStart = []; @@ -83,9 +97,10 @@ protected function getSqlInsertOffsets($sql) /** * @param PlatformInterface $adapterPlatform + * * @return array */ - protected function processAddColumns(PlatformInterface $adapterPlatform = null) + protected function processAddColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; @@ -152,11 +167,13 @@ protected function processAddColumns(PlatformInterface $adapterPlatform = null) /** * @param PlatformInterface $adapterPlatform + * * @return array */ - protected function processChangeColumns(PlatformInterface $adapterPlatform = null) + protected function processChangeColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; + foreach ($this->changeColumns as $name => $column) { $sql = $this->processExpression($column, $adapterPlatform); $insertStart = $this->getSqlInsertOffsets($sql); @@ -210,6 +227,7 @@ protected function processChangeColumns(PlatformInterface $adapterPlatform = nul } } } + $sqls[] = [ $adapterPlatform->quoteIdentifier($name), $sql @@ -224,7 +242,7 @@ protected function processChangeColumns(PlatformInterface $adapterPlatform = nul * * @return string */ - private function normalizeColumnOption($name) + private function normalizeColumnOption(string $name) : string { return strtolower(str_replace(['-', '_', ' '], '', $name)); } @@ -236,7 +254,7 @@ private function normalizeColumnOption($name) * * @return int */ - private function compareColumnOptions($columnA, $columnB) + private function compareColumnOptions(string $columnA, string $columnB) : int { $columnA = $this->normalizeColumnOption($columnA); $columnA = isset($this->columnOptionSortOrder[$columnA]) diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index fa8815a9a1..948d5087d5 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -1,4 +1,7 @@ normalizeColumnOption($columnA); $columnA = isset($this->columnOptionSortOrder[$columnA]) diff --git a/src/Sql/Platform/Mysql/Mysql.php b/src/Sql/Platform/Mysql/Mysql.php index 3e1611b87f..da53d5ceef 100644 --- a/src/Sql/Platform/Mysql/Mysql.php +++ b/src/Sql/Platform/Mysql/Mysql.php @@ -1,4 +1,7 @@ subject = $select; } - protected function localizeVariables() + protected function localizeVariables() : void { parent::localizeVariables(); if ($this->limit === null && $this->offset !== null) { @@ -39,19 +42,22 @@ protected function localizeVariables() } protected function processLimit( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null ) { if ($this->limit === null && $this->offset !== null) { return ['']; } + if ($this->limit === null) { return; } + if ($parameterContainer) { $paramPrefix = $this->processInfo['paramPrefix']; $parameterContainer->offsetSet($paramPrefix . 'limit', $this->limit, ParameterContainer::TYPE_INTEGER); + return [$driver->formatParameterName($paramPrefix . 'limit')]; } @@ -59,8 +65,8 @@ protected function processLimit( } protected function processOffset( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null ) { if ($this->offset === null) { diff --git a/src/Sql/Platform/Oracle/Oracle.php b/src/Sql/Platform/Oracle/Oracle.php index bf1dc31df5..75a4998de3 100644 --- a/src/Sql/Platform/Oracle/Oracle.php +++ b/src/Sql/Platform/Oracle/Oracle.php @@ -1,4 +1,7 @@ specifications[self::LIMIT]); @@ -53,15 +60,16 @@ protected function localizeVariables() * @param ParameterContainer $parameterContainer * @param array $sqls * @param array $parameters - * @return null + * + * @return void */ protected function processLimitOffset( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null, - &$sqls = [], - &$parameters = [] - ) { + array &$sqls = [], + array &$parameters = [] + ) : void { if ($this->limit === null && $this->offset === null) { return; } diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index e702caac46..dc5566e4de 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -1,4 +1,7 @@ resolvePlatformName($adapterOrPlatform); $this->decorators[$platformName][$type] = $decorator; } @@ -59,6 +67,7 @@ public function setTypeDecorator($type, PlatformDecoratorInterface $decorator, $ /** * @param PreparableSqlInterface|SqlInterface $subject * @param AdapterInterface|PlatformInterface|null $adapterOrPlatform + * * @return PlatformDecoratorInterface|PreparableSqlInterface|SqlInterface */ public function getTypeDecorator($subject, $adapterOrPlatform = null) @@ -69,6 +78,7 @@ public function getTypeDecorator($subject, $adapterOrPlatform = null) foreach ($this->decorators[$platformName] as $type => $decorator) { if ($subject instanceof $type && is_a($decorator, $type, true)) { $decorator->setSubject($subject); + return $decorator; } } @@ -78,23 +88,24 @@ public function getTypeDecorator($subject, $adapterOrPlatform = null) } /** - * @return array|PlatformDecoratorInterface[] + * @return array|PlatformDecoratorInterface */ public function getDecorators() { $platformName = $this->resolvePlatformName($this->getDefaultPlatform()); + return $this->decorators[$platformName]; } /** * {@inheritDoc} * - * @throws Exception\RuntimeException + * @throws RuntimeException */ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) { if (! $this->subject instanceof PreparableSqlInterface) { - throw new Exception\RuntimeException( + throw new RuntimeException( 'The subject does not appear to implement Zend\Db\Sql\PreparableSqlInterface, thus calling ' . 'prepareStatement() has no effect' ); @@ -108,12 +119,12 @@ public function prepareStatement(AdapterInterface $adapter, StatementContainerIn /** * {@inheritDoc} * - * @throws Exception\RuntimeException + * @throws RuntimeException */ - public function getSqlString(PlatformInterface $adapterPlatform = null) + public function getSqlString(PlatformInterface $adapterPlatform = null) : string { if (! $this->subject instanceof SqlInterface) { - throw new Exception\RuntimeException( + throw new RuntimeException( 'The subject does not appear to implement Zend\Db\Sql\SqlInterface, thus calling ' . 'prepareStatement() has no effect' ); @@ -134,7 +145,7 @@ protected function resolvePlatformName($adapterOrPlatform) * * @return PlatformInterface * - * @throws Exception\InvalidArgumentException + * @throws InvalidArgumentException */ protected function resolvePlatform($adapterOrPlatform) { @@ -150,7 +161,7 @@ protected function resolvePlatform($adapterOrPlatform) return $adapterOrPlatform; } - throw new Exception\InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '$adapterOrPlatform should be null, %s, or %s', 'Zend\Db\Adapter\AdapterInterface', 'Zend\Db\Adapter\Platform\PlatformInterface' @@ -160,12 +171,12 @@ protected function resolvePlatform($adapterOrPlatform) /** * @return PlatformInterface * - * @throws Exception\RuntimeException + * @throws RuntimeException */ protected function getDefaultPlatform() { if (! $this->defaultPlatform) { - throw new Exception\RuntimeException('$this->defaultPlatform was not set'); + throw new RuntimeException('$this->defaultPlatform was not set'); } return $this->defaultPlatform; diff --git a/src/Sql/Platform/PlatformDecoratorInterface.php b/src/Sql/Platform/PlatformDecoratorInterface.php index f06c4340d2..2eef5b5761 100644 --- a/src/Sql/Platform/PlatformDecoratorInterface.php +++ b/src/Sql/Platform/PlatformDecoratorInterface.php @@ -1,4 +1,7 @@ subject = $select; } - protected function localizeVariables() + protected function localizeVariables() : void { parent::localizeVariables(); // set specifications @@ -46,6 +46,7 @@ protected function localizeVariables() * @param ParameterContainer $parameterContainer * @param $sqls * @param $parameters + * * @return null */ protected function processLimitOffset( diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index a1b3d6c508..79e1f50926 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -1,4 +1,6 @@ specifications[self::COMBINE] = '%1$s %2$s'; @@ -56,8 +59,8 @@ protected function processStatementStart( } protected function processLimit( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null ) { if ($this->limit === null && $this->offset !== null) { @@ -76,8 +79,8 @@ protected function processLimit( } protected function processOffset( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null ) { if ($this->offset === null) { @@ -96,8 +99,8 @@ protected function processOffset( * {@inheritDoc} */ protected function processStatementEnd( - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null ) { return ''; diff --git a/src/Sql/Platform/Sqlite/Sqlite.php b/src/Sql/Platform/Sqlite/Sqlite.php index 00712dded1..08f57c2e10 100644 --- a/src/Sql/Platform/Sqlite/Sqlite.php +++ b/src/Sql/Platform/Sqlite/Sqlite.php @@ -1,4 +1,7 @@ setIdentifier($identifier); } + if ($minValue !== null) { $this->setMinValue($minValue); } + if ($maxValue !== null) { $this->setMaxValue($maxValue); } @@ -42,11 +46,13 @@ public function __construct($identifier = null, $minValue = null, $maxValue = nu * Set identifier for comparison * * @param string $identifier + * * @return self Provides a fluent interface */ - public function setIdentifier($identifier) + public function setIdentifier(string $identifier) : self { $this->identifier = $identifier; + return $this; } @@ -55,7 +61,7 @@ public function setIdentifier($identifier) * * @return null|string */ - public function getIdentifier() + public function getIdentifier() : ?string { return $this->identifier; } @@ -64,11 +70,13 @@ public function getIdentifier() * Set minimum boundary for comparison * * @param int|float|string $minValue + * * @return self Provides a fluent interface */ - public function setMinValue($minValue) + public function setMinValue($minValue) : self { $this->minValue = $minValue; + return $this; } @@ -86,11 +94,13 @@ public function getMinValue() * Set maximum boundary for comparison * * @param int|float|string $maxValue + * * @return self Provides a fluent interface */ - public function setMaxValue($maxValue) + public function setMaxValue($maxValue) : self { $this->maxValue = $maxValue; + return $this; } @@ -108,11 +118,13 @@ public function getMaxValue() * Set specification string to use in forming SQL predicate * * @param string $specification + * * @return self Provides a fluent interface */ - public function setSpecification($specification) + public function setSpecification(string $specification) : self { $this->specification = $specification; + return $this; } @@ -121,7 +133,7 @@ public function setSpecification($specification) * * @return string */ - public function getSpecification() + public function getSpecification() : string { return $this->specification; } @@ -129,9 +141,9 @@ public function getSpecification() /** * Return "where" parts * - * @return array + * @return mixed[][] */ - public function getExpressionData() + public function getExpressionData() : array { list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); list($values[], $types[]) = $this->normalizeArgument($this->minValue, self::TYPE_VALUE); diff --git a/src/Sql/Predicate/Expression.php b/src/Sql/Predicate/Expression.php index e9b5363f24..8f2d51be68 100644 --- a/src/Sql/Predicate/Expression.php +++ b/src/Sql/Predicate/Expression.php @@ -1,4 +1,7 @@ setExpression($expression); diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index 0c62189cf0..a217d411f9 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -1,4 +1,7 @@ setIdentifier($identifier); } + if ($valueSet !== null) { $this->setValueSet($valueSet); } @@ -42,9 +46,10 @@ public function __construct($identifier = null, $valueSet = null) * Set identifier for comparison * * @param string|array $identifier + * * @return self Provides a fluent interface */ - public function setIdentifier($identifier) + public function setIdentifier($identifier) : self { $this->identifier = $identifier; @@ -64,17 +69,20 @@ public function getIdentifier() /** * Set set of values for IN comparison * - * @param array|Select $valueSet + * @param array|Select $valueSet + * * @return self Provides a fluent interface + * * @throws Exception\InvalidArgumentException */ - public function setValueSet($valueSet) + public function setValueSet($valueSet) : self { if (! is_array($valueSet) && ! $valueSet instanceof Select) { throw new Exception\InvalidArgumentException( '$valueSet must be either an array or a Zend\Db\Sql\Select object, ' . gettype($valueSet) . ' given' ); } + $this->valueSet = $valueSet; return $this; @@ -95,7 +103,7 @@ public function getValueSet() * * @return array */ - public function getExpressionData() + public function getExpressionData() : array { $identifier = $this->getIdentifier(); $values = $this->getValueSet(); diff --git a/src/Sql/Predicate/IsNotNull.php b/src/Sql/Predicate/IsNotNull.php index e42c9aa5b5..eef4d9e40d 100644 --- a/src/Sql/Predicate/IsNotNull.php +++ b/src/Sql/Predicate/IsNotNull.php @@ -1,4 +1,7 @@ setIdentifier($identifier); @@ -39,11 +42,13 @@ public function __construct($identifier = null) * Set identifier for comparison * * @param string $identifier + * * @return self Provides a fluent interface */ - public function setIdentifier($identifier) + public function setIdentifier(string $identifier) : self { $this->identifier = $identifier; + return $this; } @@ -52,7 +57,7 @@ public function setIdentifier($identifier) * * @return null|string */ - public function getIdentifier() + public function getIdentifier() : ?string { return $this->identifier; } @@ -61,11 +66,13 @@ public function getIdentifier() * Set specification string to use in forming SQL predicate * * @param string $specification + * * @return self Provides a fluent interface */ - public function setSpecification($specification) + public function setSpecification(string $specification) : self { $this->specification = $specification; + return $this; } @@ -74,7 +81,7 @@ public function setSpecification($specification) * * @return string */ - public function getSpecification() + public function getSpecification() : string { return $this->specification; } @@ -84,7 +91,7 @@ public function getSpecification() * * @return array */ - public function getExpressionData() + public function getExpressionData() : array { $identifier = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); return [[ diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index 2f1ffde79b..f55f6ea49d 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -1,4 +1,7 @@ identifier = $identifier; + return $this; } /** * @return string */ - public function getIdentifier() + public function getIdentifier() : string { return $this->identifier; } /** * @param string $like + * * @return self Provides a fluent interface */ - public function setLike($like) + public function setLike(string $like) : self { $this->like = $like; + return $this; } /** * @return string */ - public function getLike() + public function getLike() : string { return $this->like; } /** * @param string $specification + * * @return self Provides a fluent interface */ - public function setSpecification($specification) + public function setSpecification(string $specification) : self { $this->specification = $specification; + return $this; } /** * @return string */ - public function getSpecification() + public function getSpecification() : string { return $this->specification; } @@ -99,7 +108,7 @@ public function getSpecification() /** * @return array */ - public function getExpressionData() + public function getExpressionData() : array { list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); list($values[], $types[]) = $this->normalizeArgument($this->like, self::TYPE_VALUE); diff --git a/src/Sql/Predicate/Literal.php b/src/Sql/Predicate/Literal.php index d4b509fc93..1d9bb4f49e 100644 --- a/src/Sql/Predicate/Literal.php +++ b/src/Sql/Predicate/Literal.php @@ -1,4 +1,7 @@ setLeft($left); @@ -109,7 +114,7 @@ public function __construct( * * @return self Provides a fluent interface */ - public function setLeft($left) + public function setLeft($left) : self { $this->left = $left; @@ -140,7 +145,7 @@ public function getLeft() * * @throws Exception\InvalidArgumentException */ - public function setLeftType($type) + public function setLeftType($type) : self { if (! in_array($type, $this->allowedTypes)) { throw new Exception\InvalidArgumentException(sprintf( @@ -161,7 +166,7 @@ public function setLeftType($type) * * @return string */ - public function getLeftType() + public function getLeftType() : string { return $this->leftType; } @@ -196,7 +201,7 @@ public function getOperator() * * @return self Provides a fluent interface */ - public function setRight($right) + public function setRight($right) : self { $this->right = $right; @@ -222,10 +227,12 @@ public function getRight() * Set parameter type for right side of operator * * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} + * * @return self Provides a fluent interface + * * @throws Exception\InvalidArgumentException */ - public function setRightType($type) + public function setRightType(string $type) : self { if (! in_array($type, $this->allowedTypes)) { throw new Exception\InvalidArgumentException(sprintf( @@ -246,7 +253,7 @@ public function setRightType($type) * * @return string */ - public function getRightType() + public function getRightType() : string { return $this->rightType; } @@ -256,7 +263,7 @@ public function getRightType() * * @return array */ - public function getExpressionData() + public function getExpressionData() : array { list($values[], $types[]) = $this->normalizeArgument($this->left, $this->leftType); list($values[], $types[]) = $this->normalizeArgument($this->right, $this->rightType); diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index a7d901d7bf..c49ff675ea 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -10,6 +10,7 @@ namespace Zend\Db\Sql\Predicate; use Zend\Db\Sql\Exception\RuntimeException; +use Zend\Db\Sql\Select; /** * @property Predicate $and @@ -29,7 +30,7 @@ class Predicate extends PredicateSet * * @return Predicate */ - public function nest() + public function nest() : Predicate { $predicateSet = new Predicate(); $predicateSet->setUnnest($this); @@ -42,9 +43,10 @@ public function nest() * Indicate what predicate will be unnested * * @param Predicate $predicate + * * @return void */ - public function setUnnest(Predicate $predicate) + public function setUnnest(Predicate $predicate) : void { $this->unnest = $predicate; } @@ -53,15 +55,17 @@ public function setUnnest(Predicate $predicate) * Indicate end of nested predicate * * @return Predicate + * * @throws RuntimeException */ - public function unnest() + public function unnest() : Predicate { if ($this->unnest === null) { throw new RuntimeException('Not nested'); } $unnest = $this->unnest; $this->unnest = null; + return $unnest; } @@ -74,10 +78,14 @@ public function unnest() * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * * @return self Provides a fluent interface */ - public function equalTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE) - { + public function equalTo( + $left, $right, + ?string $leftType = self::TYPE_IDENTIFIER, + ?string$rightType = self::TYPE_VALUE + ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_EQUAL_TO, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination @@ -96,10 +104,15 @@ public function equalTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $right * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * * @return self Provides a fluent interface */ - public function notEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE) - { + public function notEqualTo( + $left, + $right, + ?string $leftType = self::TYPE_IDENTIFIER, + ?string $rightType = self::TYPE_VALUE + ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_NOT_EQUAL_TO, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination @@ -118,10 +131,15 @@ public function notEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $ri * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * * @return self Provides a fluent interface */ - public function lessThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE) - { + public function lessThan( + $left, + $right, + ?string $leftType = self::TYPE_IDENTIFIER, + ?string $rightType = self::TYPE_VALUE + ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_LESS_THAN, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination @@ -140,10 +158,15 @@ public function lessThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $righ * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * * @return self Provides a fluent interface */ - public function greaterThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE) - { + public function greaterThan( + $left, + $right, + ?string $leftType = self::TYPE_IDENTIFIER, + ?string $rightType = self::TYPE_VALUE + ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_GREATER_THAN, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination @@ -162,10 +185,15 @@ public function greaterThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $r * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * * @return self Provides a fluent interface */ - public function lessThanOrEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE) - { + public function lessThanOrEqualTo( + $left, + $right, + ?string $leftType = self::TYPE_IDENTIFIER, + ?string $rightType = self::TYPE_VALUE + ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_LESS_THAN_OR_EQUAL_TO, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination @@ -184,14 +212,15 @@ public function lessThanOrEqualTo($left, $right, $leftType = self::TYPE_IDENTIFI * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * * @return self Provides a fluent interface */ public function greaterThanOrEqualTo( $left, $right, - $leftType = self::TYPE_IDENTIFIER, - $rightType = self::TYPE_VALUE - ) { + ?string $leftType = self::TYPE_IDENTIFIER, + ?string $rightType = self::TYPE_VALUE + ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination @@ -208,14 +237,16 @@ public function greaterThanOrEqualTo( * * @param string|Expression $identifier * @param string $like + * * @return self Provides a fluent interface */ - public function like($identifier, $like) + public function like($identifier, string $like) : self { $this->addPredicate( new Like($identifier, $like), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -227,15 +258,18 @@ public function like($identifier, $like) * * @param string|Expression $identifier * @param string $notLike + * * @return self Provides a fluent interface */ - public function notLike($identifier, $notLike) + public function notLike($identifier, string $notLike) : self { $this->addPredicate( new NotLike($identifier, $notLike), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; + return $this; } @@ -244,14 +278,16 @@ public function notLike($identifier, $notLike) * * @param $expression * @param $parameters + * * @return self Provides a fluent interface */ - public function expression($expression, $parameters = null) + public function expression($expression, $parameters = null) : self { $this->addPredicate( new Expression($expression, $parameters), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -263,9 +299,10 @@ public function expression($expression, $parameters = null) * Literal predicate, for parameters, use expression() * * @param string $literal + * * @return self Provides a fluent interface */ - public function literal($literal) + public function literal(string $literal) : self { // process deprecated parameters from previous literal($literal, $parameters = null) signature if (func_num_args() >= 2) { @@ -282,6 +319,7 @@ public function literal($literal) $predicate, ($this->nextPredicateCombineOperator) ?: $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -293,14 +331,16 @@ public function literal($literal) * Utilizes IsNull predicate * * @param string|Expression $identifier + * * @return self Provides a fluent interface */ - public function isNull($identifier) + public function isNull($identifier) : self { $this->addPredicate( new IsNull($identifier), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -312,14 +352,16 @@ public function isNull($identifier) * Utilizes IsNotNull predicate * * @param string|Expression $identifier + * * @return self Provides a fluent interface */ - public function isNotNull($identifier) + public function isNotNull($identifier) : self { $this->addPredicate( new IsNotNull($identifier), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -331,15 +373,17 @@ public function isNotNull($identifier) * Utilizes In predicate * * @param string|Expression $identifier - * @param array|\Zend\Db\Sql\Select $valueSet + * @param array|Select $valueSet + * * @return self Provides a fluent interface */ - public function in($identifier, $valueSet = null) + public function in($identifier, $valueSet = null) : self { $this->addPredicate( new In($identifier, $valueSet), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -351,10 +395,11 @@ public function in($identifier, $valueSet = null) * Utilizes NotIn predicate * * @param string|Expression $identifier - * @param array|\Zend\Db\Sql\Select $valueSet + * @param array|Select $valueSet + * * @return self Provides a fluent interface */ - public function notIn($identifier, $valueSet = null) + public function notIn($identifier, $valueSet = null) : self { $this->addPredicate( new NotIn($identifier, $valueSet), @@ -373,14 +418,16 @@ public function notIn($identifier, $valueSet = null) * @param string|Expression $identifier * @param int|float|string $minValue * @param int|float|string $maxValue + * * @return self Provides a fluent interface */ - public function between($identifier, $minValue, $maxValue) + public function between($identifier, $minValue, $maxValue) : self { $this->addPredicate( new Between($identifier, $minValue, $maxValue), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -394,14 +441,16 @@ public function between($identifier, $minValue, $maxValue) * @param string|Expression $identifier * @param int|float|string $minValue * @param int|float|string $maxValue + * * @return self Provides a fluent interface */ - public function notBetween($identifier, $minValue, $maxValue) + public function notBetween($identifier, $minValue, $maxValue) : self { $this->addPredicate( new NotBetween($identifier, $minValue, $maxValue), ($this->nextPredicateCombineOperator) ?: $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -415,9 +464,10 @@ public function notBetween($identifier, $minValue, $maxValue) * used fluently within where chains as any other concrete predicate. * * @param PredicateInterface $predicate + * * @return self Provides a fluent interface */ - public function predicate(PredicateInterface $predicate) + public function predicate(PredicateInterface $predicate) : self { $this->addPredicate( $predicate, @@ -434,6 +484,7 @@ public function predicate(PredicateInterface $predicate) * Overloads "or", "and", "nest", and "unnest" * * @param string $name + * * @return self Provides a fluent interface */ public function __get($name) @@ -450,6 +501,7 @@ public function __get($name) case 'unnest': return $this->unnest(); } + return $this; } } diff --git a/src/Sql/Predicate/PredicateInterface.php b/src/Sql/Predicate/PredicateInterface.php index b8d6c84baf..a08d5e3f6b 100644 --- a/src/Sql/Predicate/PredicateInterface.php +++ b/src/Sql/Predicate/PredicateInterface.php @@ -1,4 +1,7 @@ defaultCombination = $defaultCombination; + if ($predicates) { foreach ($predicates as $predicate) { $this->addPredicate($predicate); @@ -44,9 +48,10 @@ public function __construct(array $predicates = null, $defaultCombination = self * * @param PredicateInterface $predicate * @param string $combination + * * @return self Provides a fluent interface */ - public function addPredicate(PredicateInterface $predicate, $combination = null) + public function addPredicate(PredicateInterface $predicate, ?string $combination = null) : self { if ($combination === null || ! in_array($combination, [self::OP_AND, self::OP_OR])) { $combination = $this->defaultCombination; @@ -54,10 +59,12 @@ public function addPredicate(PredicateInterface $predicate, $combination = null) if ($combination == self::OP_OR) { $this->orPredicate($predicate); + return $this; } $this->andPredicate($predicate); + return $this; } @@ -66,29 +73,38 @@ public function addPredicate(PredicateInterface $predicate, $combination = null) * * @param PredicateInterface|\Closure|string|array $predicates * @param string $combination + * * @return self Provides a fluent interface + * * @throws Exception\InvalidArgumentException */ - public function addPredicates($predicates, $combination = self::OP_AND) + public function addPredicates($predicates, ?string $combination = self::OP_AND) : self { if ($predicates === null) { throw new Exception\InvalidArgumentException('Predicate cannot be null'); } + if ($predicates instanceof PredicateInterface) { $this->addPredicate($predicates, $combination); + return $this; } + if ($predicates instanceof \Closure) { $predicates($this); + return $this; } + if (is_string($predicates)) { // String $predicate should be passed as an expression $predicates = (strpos($predicates, Expression::PLACEHOLDER) !== false) ? new Expression($predicates) : new Literal($predicates); $this->addPredicate($predicates, $combination); + return $this; } + if (is_array($predicates)) { foreach ($predicates as $pkey => $pvalue) { // loop through predicates @@ -120,9 +136,11 @@ public function addPredicates($predicates, $combination = self::OP_AND) $predicates = (strpos($pvalue, Expression::PLACEHOLDER) !== false) ? new Expression($pvalue) : new Literal($pvalue); } + $this->addPredicate($predicates, $combination); } } + return $this; } @@ -131,7 +149,7 @@ public function addPredicates($predicates, $combination = self::OP_AND) * * @return PredicateInterface[] */ - public function getPredicates() + public function getPredicates() : array { return $this->predicates; } @@ -140,11 +158,13 @@ public function getPredicates() * Add predicate using OR operator * * @param PredicateInterface $predicate + * * @return self Provides a fluent interface */ - public function orPredicate(PredicateInterface $predicate) + public function orPredicate(PredicateInterface $predicate) : self { $this->predicates[] = [self::OP_OR, $predicate]; + return $this; } @@ -152,11 +172,13 @@ public function orPredicate(PredicateInterface $predicate) * Add predicate using AND operator * * @param PredicateInterface $predicate + * * @return self Provides a fluent interface */ - public function andPredicate(PredicateInterface $predicate) + public function andPredicate(PredicateInterface $predicate) : self { $this->predicates[] = [self::OP_AND, $predicate]; + return $this; } @@ -165,7 +187,7 @@ public function andPredicate(PredicateInterface $predicate) * * @return array */ - public function getExpressionData() + public function getExpressionData() : array { $parts = []; for ($i = 0, $count = count($this->predicates); $i < $count; $i++) { @@ -186,6 +208,7 @@ public function getExpressionData() $parts[] = sprintf(' %s ', $this->predicates[$i + 1][0]); } } + return $parts; } @@ -194,7 +217,7 @@ public function getExpressionData() * * @return int */ - public function count() + public function count() : int { return count($this->predicates); } diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 321eb5b6b4..28fa7fae40 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -798,14 +798,15 @@ public function __clone() * @param PlatformInterface $platform * @param DriverInterface $driver * @param ParameterContainer $parameterContainer - * @return string + * + * @return mixed[] */ protected function resolveTable( $table, - PlatformInterface $platform, - DriverInterface $driver = null, + PlatformInterface $platform, + DriverInterface $driver = null, ParameterContainer $parameterContainer = null - ) { + ) : string { $alias = null; if (is_array($table)) { diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 2cc1428204..2f4a731279 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -39,7 +39,7 @@ public function __construct(AdapterInterface $adapter, $table = null, Platform\A } /** - * @return null|\Zend\Db\Adapter\AdapterInterface + * @return null|AdapterInterface */ public function getAdapter() { diff --git a/src/Sql/SqlInterface.php b/src/Sql/SqlInterface.php index 551a458c98..3b45cc5c7d 100644 --- a/src/Sql/SqlInterface.php +++ b/src/Sql/SqlInterface.php @@ -1,4 +1,7 @@ table; } @@ -83,7 +83,7 @@ public function getTable() /** * @return bool */ - public function hasSchema() + public function hasSchema() : bool { return ($this->schema !== null); } @@ -101,12 +101,12 @@ public function setSchema($schema) /** * @return null|string */ - public function getSchema() + public function getSchema() : ?string { return $this->schema; } - public function getTableAndSchema() + public function getTableAndSchema() : array { return [$this->table, $this->schema]; } From 42e8770b527b035158a525a0da40fa2772d24cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 17:38:08 +0100 Subject: [PATCH 02/45] Added access modifiers for class constants --- src/Sql/Combine.php | 10 +++--- src/Sql/Ddl/AlterTable.php | 12 +++---- src/Sql/Ddl/CreateTable.php | 6 ++-- src/Sql/Ddl/DropTable.php | 2 +- src/Sql/Delete.php | 4 +-- src/Sql/Expression.php | 2 +- src/Sql/ExpressionInterface.php | 8 ++--- src/Sql/Insert.php | 8 ++--- src/Sql/Join.php | 12 +++---- src/Sql/Predicate/Operator.php | 24 ++++++------- src/Sql/Predicate/PredicateSet.php | 8 ++--- src/Sql/Select.php | 56 +++++++++++++++--------------- src/Sql/Update.php | 12 +++---- 13 files changed, 82 insertions(+), 82 deletions(-) diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 8cdd0acaf3..87399c22cb 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -29,11 +29,11 @@ */ class Combine extends AbstractPreparableSql { - const COLUMNS = 'columns'; - const COMBINE = 'combine'; - const COMBINE_UNION = 'union'; - const COMBINE_EXCEPT = 'except'; - const COMBINE_INTERSECT = 'intersect'; + public const COLUMNS = 'columns'; + public const COMBINE = 'combine'; + public const COMBINE_UNION = 'union'; + public const COMBINE_EXCEPT = 'except'; + public const COMBINE_INTERSECT = 'intersect'; /** * @var string[] diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index fc2eeb0c17..20f417968b 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -20,12 +20,12 @@ class AlterTable extends AbstractSql implements SqlInterface { - const ADD_COLUMNS = 'addColumns'; - const ADD_CONSTRAINTS = 'addConstraints'; - const CHANGE_COLUMNS = 'changeColumns'; - const DROP_COLUMNS = 'dropColumns'; - const DROP_CONSTRAINTS = 'dropConstraints'; - const TABLE = 'table'; + public const ADD_COLUMNS = 'addColumns'; + public const ADD_CONSTRAINTS = 'addConstraints'; + public const CHANGE_COLUMNS = 'changeColumns'; + public const DROP_COLUMNS = 'dropColumns'; + public const DROP_CONSTRAINTS = 'dropConstraints'; + public const TABLE = 'table'; /** * @var array diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index aa55aa5d49..55649cfe04 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -20,9 +20,9 @@ class CreateTable extends AbstractSql implements SqlInterface { - const COLUMNS = 'columns'; - const CONSTRAINTS = 'constraints'; - const TABLE = 'table'; + public const COLUMNS = 'columns'; + public const CONSTRAINTS = 'constraints'; + public const TABLE = 'table'; /** * @var Column\ColumnInterface[] diff --git a/src/Sql/Ddl/DropTable.php b/src/Sql/Ddl/DropTable.php index fc9fde36a7..ce45ca36d9 100644 --- a/src/Sql/Ddl/DropTable.php +++ b/src/Sql/Ddl/DropTable.php @@ -18,7 +18,7 @@ class DropTable extends AbstractSql implements SqlInterface { - const TABLE = 'table'; + public const TABLE = 'table'; /** * @var array diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 5d9aa13f53..918a769e6a 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -25,8 +25,8 @@ class Delete extends AbstractPreparableSql /**@#+ * @const */ - const SPECIFICATION_DELETE = 'delete'; - const SPECIFICATION_WHERE = 'where'; + public const SPECIFICATION_DELETE = 'delete'; + public const SPECIFICATION_WHERE = 'where'; /**@#-*/ /** diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index a39c0e2874..32c0621e88 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -17,7 +17,7 @@ class Expression extends AbstractExpression /** * @const */ - const PLACEHOLDER = '?'; + public const PLACEHOLDER = '?'; /** * @var string diff --git a/src/Sql/ExpressionInterface.php b/src/Sql/ExpressionInterface.php index d3eb2c4dc9..00d326220a 100644 --- a/src/Sql/ExpressionInterface.php +++ b/src/Sql/ExpressionInterface.php @@ -14,10 +14,10 @@ interface ExpressionInterface { - const TYPE_IDENTIFIER = 'identifier'; - const TYPE_VALUE = 'value'; - const TYPE_LITERAL = 'literal'; - const TYPE_SELECT = 'select'; + public const TYPE_IDENTIFIER = 'identifier'; + public const TYPE_VALUE = 'value'; + public const TYPE_LITERAL = 'literal'; + public const TYPE_SELECT = 'select'; /** * @abstract diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 7bdcbbbb19..399a9a1b6e 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -24,10 +24,10 @@ class Insert extends AbstractPreparableSql * * @const */ - const SPECIFICATION_INSERT = 'insert'; - const SPECIFICATION_SELECT = 'select'; - const VALUES_MERGE = 'merge'; - const VALUES_SET = 'set'; + public const SPECIFICATION_INSERT = 'insert'; + public const SPECIFICATION_SELECT = 'select'; + public const VALUES_MERGE = 'merge'; + public const VALUES_SET = 'set'; /**#@-*/ /** diff --git a/src/Sql/Join.php b/src/Sql/Join.php index 12e8599663..29acfa3616 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -24,12 +24,12 @@ */ class Join implements Iterator, Countable { - const JOIN_INNER = 'inner'; - const JOIN_OUTER = 'outer'; - const JOIN_LEFT = 'left'; - const JOIN_RIGHT = 'right'; - const JOIN_RIGHT_OUTER = 'right outer'; - const JOIN_LEFT_OUTER = 'left outer'; + public const JOIN_INNER = 'inner'; + public const JOIN_OUTER = 'outer'; + public const JOIN_LEFT = 'left'; + public const JOIN_RIGHT = 'right'; + public const JOIN_RIGHT_OUTER = 'right outer'; + public const JOIN_LEFT_OUTER = 'left outer'; /** * Current iterator position. diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 77bfcf3264..9b2282deb7 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -19,23 +19,23 @@ class Operator extends AbstractExpression implements PredicateInterface { - const OPERATOR_EQUAL_TO = '='; - const OP_EQ = '='; + public const OPERATOR_EQUAL_TO = '='; + public const OP_EQ = '='; - const OPERATOR_NOT_EQUAL_TO = '!='; - const OP_NE = '!='; + public const OPERATOR_NOT_EQUAL_TO = '!='; + public const OP_NE = '!='; - const OPERATOR_LESS_THAN = '<'; - const OP_LT = '<'; + public const OPERATOR_LESS_THAN = '<'; + public const OP_LT = '<'; - const OPERATOR_LESS_THAN_OR_EQUAL_TO = '<='; - const OP_LTE = '<='; + public const OPERATOR_LESS_THAN_OR_EQUAL_TO = '<='; + public const OP_LTE = '<='; - const OPERATOR_GREATER_THAN = '>'; - const OP_GT = '>'; + public const OPERATOR_GREATER_THAN = '>'; + public const OP_GT = '>'; - const OPERATOR_GREATER_THAN_OR_EQUAL_TO = '>='; - const OP_GTE = '>='; + public const OPERATOR_GREATER_THAN_OR_EQUAL_TO = '>='; + public const OP_GTE = '>='; /** * {@inheritDoc} diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index 2bf1e4e053..dca51ac78a 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -17,11 +17,11 @@ class PredicateSet implements PredicateInterface, Countable { - const COMBINED_BY_AND = 'AND'; - const OP_AND = 'AND'; + public const COMBINED_BY_AND = 'AND'; + public const OP_AND = 'AND'; - const COMBINED_BY_OR = 'OR'; - const OP_OR = 'OR'; + public const COMBINED_BY_OR = 'OR'; + public const OP_OR = 'OR'; protected $defaultCombination = self::COMBINED_BY_AND; protected $predicates = []; diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 28fa7fae40..c534411e4e 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -24,43 +24,43 @@ class Select extends AbstractPreparableSql * Constant * @const */ - const SELECT = 'select'; - const QUANTIFIER = 'quantifier'; - const COLUMNS = 'columns'; - const TABLE = 'table'; - const JOINS = 'joins'; - const WHERE = 'where'; - const GROUP = 'group'; - const HAVING = 'having'; - const ORDER = 'order'; - const LIMIT = 'limit'; - const OFFSET = 'offset'; - const QUANTIFIER_DISTINCT = 'DISTINCT'; - const QUANTIFIER_ALL = 'ALL'; - const JOIN_INNER = Join::JOIN_INNER; - const JOIN_OUTER = Join::JOIN_OUTER; - const JOIN_LEFT = Join::JOIN_LEFT; - const JOIN_RIGHT = Join::JOIN_RIGHT; - const JOIN_RIGHT_OUTER = Join::JOIN_RIGHT_OUTER; - const JOIN_LEFT_OUTER = Join::JOIN_LEFT_OUTER; - const SQL_STAR = '*'; - const ORDER_ASCENDING = 'ASC'; - const ORDER_DESCENDING = 'DESC'; - const COMBINE = 'combine'; - const COMBINE_UNION = 'union'; - const COMBINE_EXCEPT = 'except'; - const COMBINE_INTERSECT = 'intersect'; + public const SELECT = 'select'; + public const QUANTIFIER = 'quantifier'; + public const COLUMNS = 'columns'; + public const TABLE = 'table'; + public const JOINS = 'joins'; + public const WHERE = 'where'; + public const GROUP = 'group'; + public const HAVING = 'having'; + public const ORDER = 'order'; + public const LIMIT = 'limit'; + public const OFFSET = 'offset'; + public const QUANTIFIER_DISTINCT = 'DISTINCT'; + public const QUANTIFIER_ALL = 'ALL'; + public const JOIN_INNER = Join::JOIN_INNER; + public const JOIN_OUTER = Join::JOIN_OUTER; + public const JOIN_LEFT = Join::JOIN_LEFT; + public const JOIN_RIGHT = Join::JOIN_RIGHT; + public const JOIN_RIGHT_OUTER = Join::JOIN_RIGHT_OUTER; + public const JOIN_LEFT_OUTER = Join::JOIN_LEFT_OUTER; + public const SQL_STAR = '*'; + public const ORDER_ASCENDING = 'ASC'; + public const ORDER_DESCENDING = 'DESC'; + public const COMBINE = 'combine'; + public const COMBINE_UNION = 'union'; + public const COMBINE_EXCEPT = 'except'; + public const COMBINE_INTERSECT = 'intersect'; /**#@-*/ /** * @deprecated use JOIN_LEFT_OUTER instead */ - const JOIN_OUTER_LEFT = 'outer left'; + public const JOIN_OUTER_LEFT = 'outer left'; /** * @deprecated use JOIN_LEFT_OUTER instead */ - const JOIN_OUTER_RIGHT = 'outer right'; + public const JOIN_OUTER_RIGHT = 'outer right'; /** * @var array Specifications diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 09563cf528..5aa7750e01 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -24,13 +24,13 @@ class Update extends AbstractPreparableSql /**@#++ * @const */ - const SPECIFICATION_UPDATE = 'update'; - const SPECIFICATION_SET = 'set'; - const SPECIFICATION_WHERE = 'where'; - const SPECIFICATION_JOIN = 'joins'; + public const SPECIFICATION_UPDATE = 'update'; + public const SPECIFICATION_SET = 'set'; + public const SPECIFICATION_WHERE = 'where'; + public const SPECIFICATION_JOIN = 'joins'; - const VALUES_MERGE = 'merge'; - const VALUES_SET = 'set'; + public const VALUES_MERGE = 'merge'; + public const VALUES_SET = 'set'; /**@#-**/ protected $specifications = [ From ae5c5567b6fac76bd5747c1d36d4659d25cf6237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 17:49:03 +0100 Subject: [PATCH 03/45] Updated return type declarations --- src/Sql/AbstractSql.php | 2 +- src/Sql/Ddl/Constraint/AbstractConstraint.php | 2 +- src/Sql/Ddl/Index/Index.php | 2 +- src/Sql/Expression.php | 4 +- src/Sql/ExpressionInterface.php | 2 +- src/Sql/Insert.php | 10 ++--- src/Sql/Join.php | 18 ++++----- src/Sql/Literal.php | 6 +-- .../Mysql/Ddl/CreateTableDecorator.php | 2 +- src/Sql/Platform/Platform.php | 4 +- .../SqlServer/Ddl/CreateTableDecorator.php | 4 +- .../Platform/SqlServer/SelectDecorator.php | 2 +- src/Sql/Platform/Sqlite/SelectDecorator.php | 2 +- src/Sql/Predicate/Operator.php | 4 +- src/Sql/Select.php | 38 +++++++++---------- src/Sql/Sql.php | 22 +++++------ src/Sql/TableIdentifier.php | 4 +- src/Sql/Update.php | 8 ++-- 18 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 3b4a87cbe1..b9d5dc04a2 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -307,7 +307,7 @@ protected function processSubSelect( PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null - ) { + ) : string { if ($this instanceof PlatformDecoratorInterface) { $decorator = clone $this; $decorator->setSubject($subselect); diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index d93d8a0f39..8172343d64 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -98,7 +98,7 @@ public function addColumn(string $column) : self /** * {@inheritDoc} */ - public function getColumns() + public function getColumns() : array { return $this->columns; } diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index a0239089a4..23fdb9ffa4 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -50,7 +50,7 @@ public function __construct($columns, $name = null, array $lengths = []) * ) * */ - public function getExpressionData() + public function getExpressionData() : array { $colCount = count($this->columns); $values = []; diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 32c0621e88..f464e88619 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -123,7 +123,7 @@ public function getParameters() : array * * @return self Provides a fluent interface */ - public function setTypes(array $types) + public function setTypes(array $types) : self { $this->types = $types; return $this; @@ -134,7 +134,7 @@ public function setTypes(array $types) * * @return array */ - public function getTypes() + public function getTypes() : array { return $this->types; } diff --git a/src/Sql/ExpressionInterface.php b/src/Sql/ExpressionInterface.php index 00d326220a..d9b10b31cb 100644 --- a/src/Sql/ExpressionInterface.php +++ b/src/Sql/ExpressionInterface.php @@ -36,5 +36,5 @@ interface ExpressionInterface * ) * */ - public function getExpressionData(); + public function getExpressionData() : array; } diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 399a9a1b6e..9a58b96d2b 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -67,7 +67,7 @@ public function __construct($table = null) * @param string|TableIdentifier $table * @return self Provides a fluent interface */ - public function into($table) + public function into($table) : self { $this->table = $table; return $this; @@ -79,7 +79,7 @@ public function into($table) * @param array $columns * @return self Provides a fluent interface */ - public function columns(array $columns) + public function columns(array $columns) : self { $this->columns = array_flip($columns); return $this; @@ -93,7 +93,7 @@ public function columns(array $columns) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function values($values, $flag = self::VALUES_SET) + public function values($values, $flag = self::VALUES_SET) : self { if ($values instanceof Select) { if ($flag == self::VALUES_MERGE) { @@ -138,7 +138,7 @@ public function values($values, $flag = self::VALUES_SET) * @param array $array * @return bool */ - private function isAssocativeArray(array $array) + private function isAssocativeArray(array $array) : bool { return array_keys($array) !== range(0, count($array) - 1); } @@ -149,7 +149,7 @@ private function isAssocativeArray(array $array) * @param Select $select * @return self */ - public function select(Select $select) + public function select(Select $select) : self { return $this->values($select); } diff --git a/src/Sql/Join.php b/src/Sql/Join.php index 29acfa3616..67af2cf3a0 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -56,7 +56,7 @@ public function __construct() /** * Rewind iterator. */ - public function rewind() + public function rewind() : void { $this->position = 0; } @@ -66,7 +66,7 @@ public function rewind() * * @return array */ - public function current() + public function current() : array { return $this->joins[$this->position]; } @@ -76,7 +76,7 @@ public function current() * * @return int */ - public function key() + public function key() : int { return $this->position; } @@ -84,7 +84,7 @@ public function key() /** * Advance to the next JOIN specification. */ - public function next() + public function next() : void { ++$this->position; } @@ -94,7 +94,7 @@ public function next() * * @return bool */ - public function valid() + public function valid() : bool { return isset($this->joins[$this->position]); } @@ -102,7 +102,7 @@ public function valid() /** * @return array */ - public function getJoins() + public function getJoins() : array { return $this->joins; } @@ -118,7 +118,7 @@ public function getJoins() * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException for invalid $name values. */ - public function join($name, $on, $columns = [Select::SQL_STAR], $type = Join::JOIN_INNER) + public function join($name, $on, $columns = [Select::SQL_STAR], $type = Join::JOIN_INNER) : self { if (is_array($name) && (! is_string(key($name)) || count($name) !== 1)) { throw new Exception\InvalidArgumentException( @@ -145,7 +145,7 @@ public function join($name, $on, $columns = [Select::SQL_STAR], $type = Join::JO * * @return self Provides a fluent interface */ - public function reset() + public function reset() : self { $this->joins = []; return $this; @@ -156,7 +156,7 @@ public function reset() * * @return int */ - public function count() + public function count() : int { return count($this->joins); } diff --git a/src/Sql/Literal.php b/src/Sql/Literal.php index a04b0f16de..c9a5619eb6 100644 --- a/src/Sql/Literal.php +++ b/src/Sql/Literal.php @@ -28,7 +28,7 @@ public function __construct($literal = '') * @param string $literal * @return self Provides a fluent interface */ - public function setLiteral($literal) + public function setLiteral($literal) : self { $this->literal = $literal; return $this; @@ -37,7 +37,7 @@ public function setLiteral($literal) /** * @return string */ - public function getLiteral() + public function getLiteral() : string { return $this->literal; } @@ -45,7 +45,7 @@ public function getLiteral() /** * @return array */ - public function getExpressionData() + public function getExpressionData() : array { return [[ str_replace('%', '%%', $this->literal), diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index 948d5087d5..2965f7e6e0 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -45,7 +45,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter * * @return self Provides a fluent interface */ - public function setSubject($subject) + public function setSubject($subject) : self { $this->subject = $subject; diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index dc5566e4de..0d62dd734c 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -147,7 +147,7 @@ protected function resolvePlatformName($adapterOrPlatform) * * @throws InvalidArgumentException */ - protected function resolvePlatform($adapterOrPlatform) + protected function resolvePlatform($adapterOrPlatform) : PlatformInterface { if (! $adapterOrPlatform) { return $this->getDefaultPlatform(); @@ -173,7 +173,7 @@ protected function resolvePlatform($adapterOrPlatform) * * @throws RuntimeException */ - protected function getDefaultPlatform() + protected function getDefaultPlatform() : PlatformInterface { if (! $this->defaultPlatform) { throw new RuntimeException('$this->defaultPlatform was not set'); diff --git a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index 0618682b26..14060bf38a 100644 --- a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -24,7 +24,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter * @param CreateTable $subject * @return self Provides a fluent interface */ - public function setSubject($subject) + public function setSubject($subject) : self { $this->subject = $subject; return $this; @@ -34,7 +34,7 @@ public function setSubject($subject) * @param PlatformInterface $adapterPlatform * @return array */ - protected function processTable(PlatformInterface $adapterPlatform = null) + protected function processTable(PlatformInterface $adapterPlatform = null) : array { $table = ($this->isTemporary ? '#' : '') . ltrim($this->table, '#'); return [ diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index b87229d653..d1bb3712a0 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -55,7 +55,7 @@ protected function processLimitOffset( ParameterContainer $parameterContainer = null, &$sqls, &$parameters - ) { + ) : void { if ($this->limit === null && $this->offset === null) { return; } diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index 79e1f50926..4a320dba7f 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -31,7 +31,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface * * @return self Provides a fluent interface */ - public function setSubject($select) + public function setSubject($select) : self { $this->subject = $select; diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 9b2282deb7..348db6f7e5 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -177,7 +177,7 @@ public function getLeftType() : string * @param string $operator * @return self Provides a fluent interface */ - public function setOperator($operator) + public function setOperator($operator) : self { $this->operator = $operator; @@ -189,7 +189,7 @@ public function setOperator($operator) * * @return string */ - public function getOperator() + public function getOperator() : string { return $this->operator; } diff --git a/src/Sql/Select.php b/src/Sql/Select.php index c534411e4e..4deda90318 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -193,7 +193,7 @@ public function __construct($table = null) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function from($table) + public function from($table) : self { if ($this->tableReadOnly) { throw new Exception\InvalidArgumentException( @@ -222,7 +222,7 @@ public function from($table) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function quantifier($quantifier) + public function quantifier($quantifier) : self { if (! is_string($quantifier) && ! $quantifier instanceof ExpressionInterface) { throw new Exception\InvalidArgumentException( @@ -252,7 +252,7 @@ public function quantifier($quantifier) * @param bool $prefixColumnsWithTable * @return self Provides a fluent interface */ - public function columns(array $columns, $prefixColumnsWithTable = true) + public function columns(array $columns, $prefixColumnsWithTable = true) : self { $this->columns = $columns; $this->prefixColumnsWithTable = (bool) $prefixColumnsWithTable; @@ -269,7 +269,7 @@ public function columns(array $columns, $prefixColumnsWithTable = true) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function join($name, $on, $columns = self::SQL_STAR, $type = self::JOIN_INNER) + public function join($name, $on, $columns = self::SQL_STAR, $type = self::JOIN_INNER) : self { $this->joins->join($name, $on, $columns, $type); @@ -284,7 +284,7 @@ public function join($name, $on, $columns = self::SQL_STAR, $type = self::JOIN_I * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) + public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) : self { if ($predicate instanceof Where) { $this->where = $predicate; @@ -298,7 +298,7 @@ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) * @param mixed $group * @return self Provides a fluent interface */ - public function group($group) + public function group($group) : self { if (is_array($group)) { foreach ($group as $o) { @@ -317,7 +317,7 @@ public function group($group) * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return self Provides a fluent interface */ - public function having($predicate, $combination = Predicate\PredicateSet::OP_AND) + public function having($predicate, $combination = Predicate\PredicateSet::OP_AND) : self { if ($predicate instanceof Having) { $this->having = $predicate; @@ -331,7 +331,7 @@ public function having($predicate, $combination = Predicate\PredicateSet::OP_AND * @param string|array $order * @return self Provides a fluent interface */ - public function order($order) + public function order($order) : self { if (is_string($order)) { if (strpos($order, ',') !== false) { @@ -357,7 +357,7 @@ public function order($order) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function limit($limit) + public function limit($limit) : self { if (! is_numeric($limit)) { throw new Exception\InvalidArgumentException(sprintf( @@ -376,7 +376,7 @@ public function limit($limit) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function offset($offset) + public function offset($offset) : self { if (! is_numeric($offset)) { throw new Exception\InvalidArgumentException(sprintf( @@ -397,7 +397,7 @@ public function offset($offset) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function combine(Select $select, $type = self::COMBINE_UNION, $modifier = '') + public function combine(Select $select, $type = self::COMBINE_UNION, $modifier = '') : self { if ($this->combine !== []) { throw new Exception\InvalidArgumentException( @@ -417,7 +417,7 @@ public function combine(Select $select, $type = self::COMBINE_UNION, $modifier = * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function reset($part) + public function reset($part) : self { switch ($part) { case self::TABLE: @@ -467,7 +467,7 @@ public function reset($part) * @param $specification * @return self Provides a fluent interface */ - public function setSpecification($index, $specification) + public function setSpecification($index, $specification) : self { if (! method_exists($this, 'process' . $index)) { throw new Exception\InvalidArgumentException('Not a valid specification name.'); @@ -499,7 +499,7 @@ public function getRawState($key = null) * * @return bool */ - public function isTableReadOnly() + public function isTableReadOnly() : bool { return $this->tableReadOnly; } @@ -508,7 +508,7 @@ protected function processStatementStart( PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null - ) { + ) : ?array { if ($this->combine !== []) { return ['(']; } @@ -518,7 +518,7 @@ protected function processStatementEnd( PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null - ) { + ) : ?array { if ($this->combine !== []) { return [')']; } @@ -536,7 +536,7 @@ protected function processSelect( PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null - ) { + ) : ?array { $expr = 1; list($table, $fromTable) = $this->resolveTable($this->table, $platform, $driver, $parameterContainer); @@ -676,9 +676,9 @@ protected function processOrder( PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null - ) { + ) : ?array { if (empty($this->order)) { - return; + return null; } $orders = []; foreach ($this->order as $k => $v) { diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 2f4a731279..b6f1e25999 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -41,12 +41,12 @@ public function __construct(AdapterInterface $adapter, $table = null, Platform\A /** * @return null|AdapterInterface */ - public function getAdapter() + public function getAdapter() : ?AdapterInterface { return $this->adapter; } - public function hasTable() + public function hasTable() : bool { return ($this->table !== null); } @@ -56,7 +56,7 @@ public function hasTable() * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function setTable($table) + public function setTable($table) : self { if (is_string($table) || is_array($table) || $table instanceof TableIdentifier) { $this->table = $table; @@ -73,12 +73,12 @@ public function getTable() return $this->table; } - public function getSqlPlatform() + public function getSqlPlatform() : Platform\Platform { return $this->sqlPlatform; } - public function select($table = null) + public function select($table = null) : Select { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -89,7 +89,7 @@ public function select($table = null) return new Select(($table) ?: $this->table); } - public function insert($table = null) + public function insert($table = null) : Insert { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -100,7 +100,7 @@ public function insert($table = null) return new Insert(($table) ?: $this->table); } - public function update($table = null) + public function update($table = null) : Update { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -111,7 +111,7 @@ public function update($table = null) return new Update(($table) ?: $this->table); } - public function delete($table = null) + public function delete($table = null) : Delete { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -133,7 +133,7 @@ public function prepareStatementForSqlObject( PreparableSqlInterface $sqlObject, StatementInterface $statement = null, AdapterInterface $adapter = null - ) { + ) : StatementInterface { $adapter = $adapter ?: $this->adapter; $statement = $statement ?: $adapter->getDriver()->createStatement(); @@ -150,7 +150,7 @@ public function prepareStatementForSqlObject( * * @deprecated Deprecated in 2.4. Use buildSqlString() instead */ - public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterface $platform = null) + public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterface $platform = null) : string { $platform = ($platform) ?: $this->adapter->getPlatform(); return $this->sqlPlatform->setSubject($sqlObject)->getSqlString($platform); @@ -164,7 +164,7 @@ public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterf * * @throws Exception\InvalidArgumentException */ - public function buildSqlString(SqlInterface $sqlObject, AdapterInterface $adapter = null) + public function buildSqlString(SqlInterface $sqlObject, AdapterInterface $adapter = null) : string { return $this ->sqlPlatform diff --git a/src/Sql/TableIdentifier.php b/src/Sql/TableIdentifier.php index 4d91bda524..3a12126f44 100644 --- a/src/Sql/TableIdentifier.php +++ b/src/Sql/TableIdentifier.php @@ -67,7 +67,7 @@ public function __construct(string $table, ?string $schema = null) * * @deprecated please use the constructor and build a new {@see TableIdentifier} instead */ - public function setTable($table) + public function setTable($table) : void { $this->table = $table; } @@ -93,7 +93,7 @@ public function hasSchema() : bool * * @deprecated please use the constructor and build a new {@see TableIdentifier} instead */ - public function setSchema($schema) + public function setSchema($schema) : void { $this->schema = $schema; } diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 5aa7750e01..f2df787703 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -91,7 +91,7 @@ public function __construct($table = null) * @param string|TableIdentifier $table * @return self Provides a fluent interface */ - public function table($table) + public function table($table) : self { $this->table = $table; return $this; @@ -105,7 +105,7 @@ public function table($table) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function set(array $values, $flag = self::VALUES_SET) + public function set(array $values, $flag = self::VALUES_SET) : self { if ($values === null) { throw new Exception\InvalidArgumentException('set() expects an array of values'); @@ -132,7 +132,7 @@ public function set(array $values, $flag = self::VALUES_SET) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) + public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) : self { if ($predicate instanceof Where) { $this->where = $predicate; @@ -151,7 +151,7 @@ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function join($name, $on, $type = Join::JOIN_INNER) + public function join($name, $on, $type = Join::JOIN_INNER) : self { $this->joins->join($name, $on, [], $type); From 4a084faf2e8c764c33b6a179dc237ff2170264f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 20:33:49 +0100 Subject: [PATCH 04/45] Use ::class instead --- src/Sql/AbstractExpression.php | 6 ++++-- src/Sql/Platform/IbmDb2/IbmDb2.php | 3 ++- src/Sql/Platform/Mysql/Mysql.php | 9 ++++++--- src/Sql/Platform/Oracle/Oracle.php | 3 ++- src/Sql/Platform/Platform.php | 4 ++-- src/Sql/Platform/SqlServer/SqlServer.php | 6 ++++-- src/Sql/Platform/Sqlite/Sqlite.php | 3 ++- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index 3dc5fb757b..c882a8b04e 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -23,6 +23,8 @@ use function is_object; use function is_scalar; use function key; +use Zend\Db\Sql\SqlInterface; +use Zend\Db\Sql\ExpressionInterface; abstract class AbstractExpression implements ExpressionInterface { @@ -77,8 +79,8 @@ protected function normalizeArgument($argument, ?string $defaultType = self::TYP 'null', 'scalar', 'array', - 'Zend\Db\Sql\ExpressionInterface', - 'Zend\Db\Sql\SqlInterface', + ExpressionInterface::class, + SqlInterface::class, is_object($argument) ? get_class($argument) : gettype($argument) )); } diff --git a/src/Sql/Platform/IbmDb2/IbmDb2.php b/src/Sql/Platform/IbmDb2/IbmDb2.php index 6fbf9d11dd..13194afd69 100644 --- a/src/Sql/Platform/IbmDb2/IbmDb2.php +++ b/src/Sql/Platform/IbmDb2/IbmDb2.php @@ -13,6 +13,7 @@ namespace Zend\Db\Sql\Platform\IbmDb2; use Zend\Db\Sql\Platform\AbstractPlatform; +use Zend\Db\Sql\Select; class IbmDb2 extends AbstractPlatform { @@ -21,6 +22,6 @@ class IbmDb2 extends AbstractPlatform */ public function __construct(SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator('Zend\Db\Sql\Select', ($selectDecorator) ?: new SelectDecorator()); + $this->setTypeDecorator(Select::class, ($selectDecorator) ?: new SelectDecorator()); } } diff --git a/src/Sql/Platform/Mysql/Mysql.php b/src/Sql/Platform/Mysql/Mysql.php index da53d5ceef..57525fa485 100644 --- a/src/Sql/Platform/Mysql/Mysql.php +++ b/src/Sql/Platform/Mysql/Mysql.php @@ -13,13 +13,16 @@ namespace Zend\Db\Sql\Platform\Mysql; use Zend\Db\Sql\Platform\AbstractPlatform; +use Zend\Db\Sql\Ddl\AlterTable; +use Zend\Db\Sql\Ddl\CreateTable; +use Zend\Db\Sql\Select; class Mysql extends AbstractPlatform { public function __construct() { - $this->setTypeDecorator('Zend\Db\Sql\Select', new SelectDecorator()); - $this->setTypeDecorator('Zend\Db\Sql\Ddl\CreateTable', new Ddl\CreateTableDecorator()); - $this->setTypeDecorator('Zend\Db\Sql\Ddl\AlterTable', new Ddl\AlterTableDecorator()); + $this->setTypeDecorator(Select::class, new SelectDecorator()); + $this->setTypeDecorator(CreateTable::class, new Ddl\CreateTableDecorator()); + $this->setTypeDecorator(AlterTable::class, new Ddl\AlterTableDecorator()); } } diff --git a/src/Sql/Platform/Oracle/Oracle.php b/src/Sql/Platform/Oracle/Oracle.php index 75a4998de3..f6e26fa206 100644 --- a/src/Sql/Platform/Oracle/Oracle.php +++ b/src/Sql/Platform/Oracle/Oracle.php @@ -13,11 +13,12 @@ namespace Zend\Db\Sql\Platform\Oracle; use Zend\Db\Sql\Platform\AbstractPlatform; +use Zend\Db\Sql\Select; class Oracle extends AbstractPlatform { public function __construct(SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator('Zend\Db\Sql\Select', ($selectDecorator) ?: new SelectDecorator()); + $this->setTypeDecorator(Select::class, ($selectDecorator) ?: new SelectDecorator()); } } diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index 0d62dd734c..84951770f5 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -163,8 +163,8 @@ protected function resolvePlatform($adapterOrPlatform) : PlatformInterface throw new InvalidArgumentException(sprintf( '$adapterOrPlatform should be null, %s, or %s', - 'Zend\Db\Adapter\AdapterInterface', - 'Zend\Db\Adapter\Platform\PlatformInterface' + AdapterInterface::class, + PlatformInterface::class )); } diff --git a/src/Sql/Platform/SqlServer/SqlServer.php b/src/Sql/Platform/SqlServer/SqlServer.php index 0dc383d0be..e1e8a2ca82 100644 --- a/src/Sql/Platform/SqlServer/SqlServer.php +++ b/src/Sql/Platform/SqlServer/SqlServer.php @@ -10,12 +10,14 @@ namespace Zend\Db\Sql\Platform\SqlServer; use Zend\Db\Sql\Platform\AbstractPlatform; +use Zend\Db\Sql\Ddl\CreateTable; +use Zend\Db\Sql\Select; class SqlServer extends AbstractPlatform { public function __construct(SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator('Zend\Db\Sql\Select', ($selectDecorator) ?: new SelectDecorator()); - $this->setTypeDecorator('Zend\Db\Sql\Ddl\CreateTable', new Ddl\CreateTableDecorator()); + $this->setTypeDecorator(Select::class, ($selectDecorator) ?: new SelectDecorator()); + $this->setTypeDecorator(CreateTable::class, new Ddl\CreateTableDecorator()); } } diff --git a/src/Sql/Platform/Sqlite/Sqlite.php b/src/Sql/Platform/Sqlite/Sqlite.php index 08f57c2e10..0e83a19186 100644 --- a/src/Sql/Platform/Sqlite/Sqlite.php +++ b/src/Sql/Platform/Sqlite/Sqlite.php @@ -13,6 +13,7 @@ namespace Zend\Db\Sql\Platform\Sqlite; use Zend\Db\Sql\Platform\AbstractPlatform; +use Zend\Db\Sql\Select; class Sqlite extends AbstractPlatform { @@ -23,6 +24,6 @@ class Sqlite extends AbstractPlatform */ public function __construct() { - $this->setTypeDecorator('Zend\Db\Sql\Select', new SelectDecorator()); + $this->setTypeDecorator(Select::class, new SelectDecorator()); } } From bda3610c05f4f588d4406d0ab1131cf2fca428d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 20:34:54 +0100 Subject: [PATCH 05/45] Use short list syntax --- src/Sql/AbstractSql.php | 2 +- src/Sql/Expression.php | 2 +- src/Sql/Predicate/Between.php | 6 +++--- src/Sql/Predicate/In.php | 2 +- src/Sql/Predicate/Like.php | 4 ++-- src/Sql/Predicate/Operator.php | 4 ++-- src/Sql/Select.php | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index b9d5dc04a2..e4ca94a40c 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -481,7 +481,7 @@ protected function resolveTable( $schema = null; if ($table instanceof TableIdentifier) { - list($table, $schema) = $table->getTableAndSchema(); + [$table, $schema] = $table->getTableAndSchema(); } if ($table instanceof Select) { diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index f464e88619..66bdf660f3 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -168,7 +168,7 @@ public function getExpressionData() : array } foreach ($parameters as $parameter) { - list($values[], $types[]) = $this->normalizeArgument($parameter, self::TYPE_VALUE); + [$values[], $types[]] = $this->normalizeArgument($parameter, self::TYPE_VALUE); } return [[ diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index 4f45d0a890..3005b20623 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -145,9 +145,9 @@ public function getSpecification() : string */ public function getExpressionData() : array { - list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); - list($values[], $types[]) = $this->normalizeArgument($this->minValue, self::TYPE_VALUE); - list($values[], $types[]) = $this->normalizeArgument($this->maxValue, self::TYPE_VALUE); + [$values[], $types[]] = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); + [$values[], $types[]] = $this->normalizeArgument($this->minValue, self::TYPE_VALUE); + [$values[], $types[]] = $this->normalizeArgument($this->maxValue, self::TYPE_VALUE); return [ [ $this->getSpecification(), diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index a217d411f9..f62fc0e3b3 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -129,7 +129,7 @@ public function getExpressionData() : array $types[] = self::TYPE_VALUE; } else { foreach ($values as $argument) { - list($replacements[], $types[]) = $this->normalizeArgument($argument, self::TYPE_VALUE); + [$replacements[], $types[]] = $this->normalizeArgument($argument, self::TYPE_VALUE); } $countValues = count($values); $valuePlaceholders = $countValues > 0 ? array_fill(0, $countValues, '%s') : []; diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index f55f6ea49d..fc022699c0 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -110,8 +110,8 @@ public function getSpecification() : string */ public function getExpressionData() : array { - list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); - list($values[], $types[]) = $this->normalizeArgument($this->like, self::TYPE_VALUE); + [$values[], $types[]] = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); + [$values[], $types[]] = $this->normalizeArgument($this->like, self::TYPE_VALUE); return [ [ $this->specification, diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 348db6f7e5..73cf04abe3 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -265,8 +265,8 @@ public function getRightType() : string */ public function getExpressionData() : array { - list($values[], $types[]) = $this->normalizeArgument($this->left, $this->leftType); - list($values[], $types[]) = $this->normalizeArgument($this->right, $this->rightType); + [$values[], $types[]] = $this->normalizeArgument($this->left, $this->leftType); + [$values[], $types[]] = $this->normalizeArgument($this->right, $this->rightType); return [[ '%s ' . $this->operator . ' %s', diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 4deda90318..72004c0392 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -539,7 +539,7 @@ protected function processSelect( ) : ?array { $expr = 1; - list($table, $fromTable) = $this->resolveTable($this->table, $platform, $driver, $parameterContainer); + [$table, $fromTable] = $this->resolveTable($this->table, $platform, $driver, $parameterContainer); // process table columns $columns = []; foreach ($this->columns as $columnIndexOrAs => $column) { @@ -690,7 +690,7 @@ protected function processOrder( } if (is_int($k)) { if (strpos($v, ' ') !== false) { - list($k, $v) = preg_split('# #', $v, 2); + [$k, $v] = preg_split('# #', $v, 2); } else { $k = $v; $v = self::ORDER_ASCENDING; From fdc61301d422ee473042e29279e16ae3131990ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 20:35:45 +0100 Subject: [PATCH 06/45] Use origin function --- src/Sql/AbstractExpression.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index c882a8b04e..35031310cb 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -67,7 +67,7 @@ protected function normalizeArgument($argument, ?string $defaultType = self::TYP $key = key($argument); - if (is_integer($key) && ! in_array($value, $this->allowedTypes)) { + if (is_int($key) && ! in_array($value, $this->allowedTypes)) { return $this->buildNormalizedArgument($value, $defaultType); } From 45241047646d02bd8479588ad65e6752c017cc39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 20:43:15 +0100 Subject: [PATCH 07/45] Removed misusage of array_push() --- src/Sql/Platform/IbmDb2/SelectDecorator.php | 18 ++++++------- src/Sql/Platform/Oracle/SelectDecorator.php | 27 +++++++------------ .../Platform/SqlServer/SelectDecorator.php | 10 +++---- 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 14055a56d5..ef9e600725 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -128,11 +128,11 @@ protected function processLimitOffset( $offset = (int) $this->offset; if ($offset) { - array_push($sqls, sprintf("LIMIT %s OFFSET %s", $limit, $offset)); + $sqls[] = sprintf("LIMIT %s OFFSET %s", $limit, $offset); return; } - array_push($sqls, sprintf("LIMIT %s", $limit)); + $sqls[] = sprintf("LIMIT %s", $limit); return; } @@ -169,13 +169,13 @@ protected function processLimitOffset( $limitParamName = $driver->formatParameterName('limit'); $offsetParamName = $driver->formatParameterName('offset'); - array_push($sqls, sprintf( - // @codingStandardsIgnoreStart + $sqls[] = sprintf( + // @codingStandardsIgnoreStart ") AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN %s AND %s", // @codingStandardsIgnoreEnd $offsetParamName, $limitParamName - )); + ); if ((int) $this->offset > 0) { $parameterContainer->offsetSet('offset', (int) $this->offset + 1); @@ -191,13 +191,13 @@ protected function processLimitOffset( $offset = (int) $this->offset; } - array_push($sqls, sprintf( - // @codingStandardsIgnoreStart + $sqls[] = sprintf( + // @codingStandardsIgnoreStart ") AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN %d AND %d", // @codingStandardsIgnoreEnd $offset, - (int) $this->limit + (int) $this->offset - )); + (int)$this->limit + (int)$this->offset + ); } if (isset($sqls[self::ORDER])) { diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index cee9a2b50a..502842f46f 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -105,10 +105,7 @@ protected function processLimitOffset( $number = $this->processInfo['subselectCount'] ? $this->processInfo['subselectCount'] : ''; if ($this->limit === null) { - array_push( - $sqls, - ') b ) WHERE b_rownum > (:offset' . $number . ')' - ); + $sqls[] = ') b ) WHERE b_rownum > (:offset' . $number . ')'; $parameterContainer->offsetSet( 'offset' . $number, $this->offset, @@ -116,16 +113,13 @@ protected function processLimitOffset( ); } else { // create bottom part of query, with offset and limit using row_number - array_push( - $sqls, - ') b WHERE rownum <= (:offset' + $sqls[] = ') b WHERE rownum <= (:offset' . $number . '+:limit' . $number . ')) WHERE b_rownum >= (:offset' . $number - . ' + 1)' - ); + . ' + 1)'; $parameterContainer->offsetSet( 'offset' . $number, $this->offset, @@ -140,18 +134,15 @@ protected function processLimitOffset( $this->processInfo['subselectCount']++; } else { if ($this->limit === null) { - array_push($sqls, ') b ) WHERE b_rownum > (' . (int) $this->offset . ')'); + $sqls[] = ') b ) WHERE b_rownum > (' . (int)$this->offset . ')'; } else { - array_push( - $sqls, - ') b WHERE rownum <= (' - . (int) $this->offset + $sqls[] = ') b WHERE rownum <= (' + . (int)$this->offset . '+' - . (int) $this->limit + . (int)$this->limit . ')) WHERE b_rownum >= (' - . (int) $this->offset - . ' + 1)' - ); + . (int)$this->offset + . ' + 1)'; } } diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index d1bb3712a0..9a990f91ef 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -97,17 +97,17 @@ protected function processLimitOffset( $offsetParamName = $driver->formatParameterName('offset'); $offsetForSumParamName = $driver->formatParameterName('offsetForSum'); // @codingStandardsIgnoreStart - array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' - . $offsetParamName . '+1 AND ' . $limitParamName . '+' . $offsetForSumParamName); + $sqls[] = ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' + . $offsetParamName . '+1 AND ' . $limitParamName . '+' . $offsetForSumParamName; // @codingStandardsIgnoreEnd $parameterContainer->offsetSet('offset', $this->offset); $parameterContainer->offsetSet('limit', $this->limit); $parameterContainer->offsetSetReference('offsetForSum', 'offset'); } else { // @codingStandardsIgnoreStart - array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' - . (int) $this->offset . '+1 AND ' - . (int) $this->limit . '+' . (int) $this->offset); + $sqls[] = ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' + . (int)$this->offset . '+1 AND ' + . (int)$this->limit . '+' . (int)$this->offset; // @codingStandardsIgnoreEnd } From a55d7fdd97022573dac8e9dd3c092c35fc0f84c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 20:45:40 +0100 Subject: [PATCH 08/45] Removed assignments where written value is same as default one --- src/Sql/Ddl/Column/Boolean.php | 5 ----- src/Sql/Join.php | 8 -------- 2 files changed, 13 deletions(-) diff --git a/src/Sql/Ddl/Column/Boolean.php b/src/Sql/Ddl/Column/Boolean.php index 36fdb01571..46c2eadf75 100644 --- a/src/Sql/Ddl/Column/Boolean.php +++ b/src/Sql/Ddl/Column/Boolean.php @@ -19,11 +19,6 @@ class Boolean extends Column */ protected $type = 'BOOLEAN'; - /** - * {@inheritDoc} - */ - protected $isNullable = false; - /** * {@inheritDoc} */ diff --git a/src/Sql/Join.php b/src/Sql/Join.php index 67af2cf3a0..8e59cd7cc7 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -45,14 +45,6 @@ class Join implements Iterator, Countable */ protected $joins = []; - /** - * Initialize iterator position. - */ - public function __construct() - { - $this->position = 0; - } - /** * Rewind iterator. */ From 18986fcb19c4c6b50dc8317b5fa1019859f94e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 20:50:14 +0100 Subject: [PATCH 09/45] Removed superfluous null assignments on class property initialization --- src/Sql/Delete.php | 2 +- src/Sql/Insert.php | 4 ++-- src/Sql/Platform/IbmDb2/SelectDecorator.php | 2 +- src/Sql/Platform/Mysql/SelectDecorator.php | 2 +- src/Sql/Platform/Oracle/SelectDecorator.php | 2 +- src/Sql/Platform/Platform.php | 2 +- src/Sql/Platform/SqlServer/SelectDecorator.php | 2 +- src/Sql/Platform/Sqlite/SelectDecorator.php | 2 +- src/Sql/Predicate/Between.php | 6 +++--- src/Sql/Predicate/Predicate.php | 4 ++-- src/Sql/Select.php | 16 ++++++++-------- src/Sql/Sql.php | 6 +++--- src/Sql/Update.php | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 918a769e6a..07681ce61c 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -55,7 +55,7 @@ class Delete extends AbstractPreparableSql /** * @var null|string|Where */ - protected $where = null; + protected $where; /** * Constructor diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 9a58b96d2b..29508a7d12 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -41,13 +41,13 @@ class Insert extends AbstractPreparableSql /** * @var string|TableIdentifier */ - protected $table = null; + protected $table; protected $columns = []; /** * @var array|Select */ - protected $select = null; + protected $select; /** * Constructor diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index ef9e600725..8520c22975 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -35,7 +35,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $subject = null; + protected $subject; /** * @var bool diff --git a/src/Sql/Platform/Mysql/SelectDecorator.php b/src/Sql/Platform/Mysql/SelectDecorator.php index e9904f2b72..cbd2c13d61 100644 --- a/src/Sql/Platform/Mysql/SelectDecorator.php +++ b/src/Sql/Platform/Mysql/SelectDecorator.php @@ -23,7 +23,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $subject = null; + protected $subject; /** * @param Select $select diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index 502842f46f..82bf1af66f 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -27,7 +27,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $subject = null; + protected $subject; /** * @param Select $select diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index 84951770f5..55c3bd631c 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -26,7 +26,7 @@ class Platform extends AbstractPlatform /** * @var AdapterInterface */ - protected $adapter = null; + protected $adapter; /** * @var PlatformInterface|null diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index 9a990f91ef..b7fd3a3142 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -20,7 +20,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $subject = null; + protected $subject; /** * @param Select $select diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index 4a320dba7f..04617776ce 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -22,7 +22,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @var Select */ - protected $subject = null; + protected $subject; /** * Set Subject diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index 3005b20623..648f616285 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -16,9 +16,9 @@ class Between extends AbstractExpression implements PredicateInterface { protected $specification = '%1$s BETWEEN %2$s AND %3$s'; - protected $identifier = null; - protected $minValue = null; - protected $maxValue = null; + protected $identifier; + protected $minValue; + protected $maxValue; /** * Constructor diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index c49ff675ea..c68e451373 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -22,8 +22,8 @@ */ class Predicate extends PredicateSet { - protected $unnest = null; - protected $nextPredicateCombineOperator = null; + protected $unnest; + protected $nextPredicateCombineOperator; /** * Begin nesting predicates diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 72004c0392..858bc0dba9 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -117,12 +117,12 @@ class Select extends AbstractPreparableSql /** * @var string|array|TableIdentifier */ - protected $table = null; + protected $table; /** * @var null|string|Expression */ - protected $quantifier = null; + protected $quantifier; /** * @var array @@ -132,12 +132,12 @@ class Select extends AbstractPreparableSql /** * @var null|Join */ - protected $joins = null; + protected $joins; /** * @var Where */ - protected $where = null; + protected $where; /** * @var array @@ -147,22 +147,22 @@ class Select extends AbstractPreparableSql /** * @var null|array */ - protected $group = null; + protected $group; /** * @var null|string|array */ - protected $having = null; + protected $having; /** * @var int|null */ - protected $limit = null; + protected $limit; /** * @var int|null */ - protected $offset = null; + protected $offset; /** * @var array diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index b6f1e25999..c5e18e283c 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -16,13 +16,13 @@ class Sql { /** @var AdapterInterface */ - protected $adapter = null; + protected $adapter; /** @var string|array|TableIdentifier */ - protected $table = null; + protected $table; /** @var Platform\Platform */ - protected $sqlPlatform = null; + protected $sqlPlatform; /** * @param AdapterInterface $adapter diff --git a/src/Sql/Update.php b/src/Sql/Update.php index f2df787703..93f77e867d 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -62,12 +62,12 @@ class Update extends AbstractPreparableSql /** * @var string|Where */ - protected $where = null; + protected $where; /** * @var null|Join */ - protected $joins = null; + protected $joins; /** * Constructor From e4868fa0c2ea58bd40a3fe0fecd7e2e7ed58d8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 21:00:22 +0100 Subject: [PATCH 10/45] Write single-line comments with @var as one-liners --- src/Sql/AbstractExpression.php | 4 +- src/Sql/AbstractSql.php | 8 +-- src/Sql/Combine.php | 8 +-- src/Sql/Ddl/AlterTable.php | 24 ++------ src/Sql/Ddl/Column/AbstractLengthColumn.php | 4 +- .../Ddl/Column/AbstractPrecisionColumn.php | 4 +- src/Sql/Ddl/Column/BigInteger.php | 4 +- src/Sql/Ddl/Column/Binary.php | 4 +- src/Sql/Ddl/Column/Blob.php | 4 +- src/Sql/Ddl/Column/Boolean.php | 4 +- src/Sql/Ddl/Column/Char.php | 4 +- src/Sql/Ddl/Column/Column.php | 28 +++------- src/Sql/Ddl/Column/Date.php | 4 +- src/Sql/Ddl/Column/Datetime.php | 4 +- src/Sql/Ddl/Column/Decimal.php | 4 +- src/Sql/Ddl/Column/Floating.php | 4 +- src/Sql/Ddl/Column/Text.php | 4 +- src/Sql/Ddl/Column/Time.php | 4 +- src/Sql/Ddl/Column/Timestamp.php | 4 +- src/Sql/Ddl/Column/Varbinary.php | 4 +- src/Sql/Ddl/Column/Varchar.php | 4 +- src/Sql/Ddl/Constraint/AbstractConstraint.php | 20 ++----- src/Sql/Ddl/Constraint/Check.php | 4 +- src/Sql/Ddl/Constraint/ForeignKey.php | 20 ++----- src/Sql/Ddl/Constraint/PrimaryKey.php | 4 +- src/Sql/Ddl/Constraint/UniqueKey.php | 4 +- src/Sql/Ddl/CreateTable.php | 16 ++---- src/Sql/Ddl/DropTable.php | 8 +-- src/Sql/Ddl/Index/Index.php | 8 +-- src/Sql/Delete.php | 16 ++---- src/Sql/Expression.php | 12 +--- src/Sql/Insert.php | 12 +--- src/Sql/Join.php | 12 +--- src/Sql/Literal.php | 4 +- src/Sql/Platform/AbstractPlatform.php | 8 +-- src/Sql/Platform/IbmDb2/SelectDecorator.php | 12 +--- .../Mysql/Ddl/AlterTableDecorator.php | 8 +-- .../Mysql/Ddl/CreateTableDecorator.php | 8 +-- src/Sql/Platform/Mysql/SelectDecorator.php | 4 +- src/Sql/Platform/Oracle/SelectDecorator.php | 4 +- src/Sql/Platform/Platform.php | 8 +-- .../SqlServer/Ddl/CreateTableDecorator.php | 4 +- .../Platform/SqlServer/SelectDecorator.php | 4 +- src/Sql/Platform/Sqlite/SelectDecorator.php | 4 +- src/Sql/Predicate/IsNull.php | 8 +-- src/Sql/Predicate/Like.php | 12 +--- src/Sql/Predicate/NotBetween.php | 4 +- src/Sql/Predicate/NotIn.php | 4 +- src/Sql/Predicate/NotLike.php | 4 +- src/Sql/Predicate/Operator.php | 20 ++----- src/Sql/Select.php | 56 +++++-------------- src/Sql/TableIdentifier.php | 8 +-- src/Sql/Update.php | 20 ++----- 53 files changed, 118 insertions(+), 358 deletions(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index 35031310cb..c15a5d5fc6 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -28,9 +28,7 @@ abstract class AbstractExpression implements ExpressionInterface { - /** - * @var string[] - */ + /** @var string[] */ protected $allowedTypes = [ self::TYPE_IDENTIFIER, self::TYPE_LITERAL, diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index e4ca94a40c..929bae0a1b 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -38,14 +38,10 @@ abstract class AbstractSql implements SqlInterface */ protected $specifications = []; - /** - * @var string[] - */ + /** @var string[] */ protected $processInfo = ['paramPrefix' => '', 'subselectCount' => 0]; - /** - * @var array - */ + /** @var array */ protected $instanceParameterIndex = []; /** diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 87399c22cb..5d829252a9 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -35,16 +35,12 @@ class Combine extends AbstractPreparableSql public const COMBINE_EXCEPT = 'except'; public const COMBINE_INTERSECT = 'intersect'; - /** - * @var string[] - */ + /** @var string[] */ protected $specifications = [ self::COMBINE => '%1$s (%2$s) ', ]; - /** - * @var Select[][] - */ + /** @var Select[][] */ private $combine = []; /** diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index 20f417968b..fb4ccb692a 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -27,29 +27,19 @@ class AlterTable extends AbstractSql implements SqlInterface public const DROP_CONSTRAINTS = 'dropConstraints'; public const TABLE = 'table'; - /** - * @var array - */ + /** @var array */ protected $addColumns = []; - /** - * @var array - */ + /** @var array */ protected $addConstraints = []; - /** - * @var array - */ + /** @var array */ protected $changeColumns = []; - /** - * @var array - */ + /** @var array */ protected $dropColumns = []; - /** - * @var array - */ + /** @var array */ protected $dropConstraints = []; /** @@ -85,9 +75,7 @@ class AlterTable extends AbstractSql implements SqlInterface ] ]; - /** - * @var string - */ + /** @var string */ protected $table = ''; /** diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index df821353c7..bede11f0f1 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -14,9 +14,7 @@ abstract class AbstractLengthColumn extends Column { - /** - * @var int - */ + /** @var int */ protected $length; /** diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index abc962f7ac..402ee8e865 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -14,9 +14,7 @@ abstract class AbstractPrecisionColumn extends AbstractLengthColumn { - /** - * @var int|null - */ + /** @var int|null */ protected $decimal; /** diff --git a/src/Sql/Ddl/Column/BigInteger.php b/src/Sql/Ddl/Column/BigInteger.php index 00a307cfd5..237021d866 100644 --- a/src/Sql/Ddl/Column/BigInteger.php +++ b/src/Sql/Ddl/Column/BigInteger.php @@ -14,8 +14,6 @@ class BigInteger extends Integer { - /** - * @var string - */ + /** @var string */ protected $type = 'BIGINT'; } diff --git a/src/Sql/Ddl/Column/Binary.php b/src/Sql/Ddl/Column/Binary.php index 92193ea34c..50bd15ff35 100644 --- a/src/Sql/Ddl/Column/Binary.php +++ b/src/Sql/Ddl/Column/Binary.php @@ -13,8 +13,6 @@ class Binary extends AbstractLengthColumn { - /** - * @var string - */ + /** @var string */ protected $type = 'BINARY'; } diff --git a/src/Sql/Ddl/Column/Blob.php b/src/Sql/Ddl/Column/Blob.php index 2dd280f9d3..9b91f9e058 100644 --- a/src/Sql/Ddl/Column/Blob.php +++ b/src/Sql/Ddl/Column/Blob.php @@ -14,8 +14,6 @@ class Blob extends AbstractLengthColumn { - /** - * @var string Change type to blob - */ + /** @var string Change type to blob */ protected $type = 'BLOB'; } diff --git a/src/Sql/Ddl/Column/Boolean.php b/src/Sql/Ddl/Column/Boolean.php index 46c2eadf75..fd1a43359b 100644 --- a/src/Sql/Ddl/Column/Boolean.php +++ b/src/Sql/Ddl/Column/Boolean.php @@ -14,9 +14,7 @@ class Boolean extends Column { - /** - * @var string - */ + /** @var string */ protected $type = 'BOOLEAN'; /** diff --git a/src/Sql/Ddl/Column/Char.php b/src/Sql/Ddl/Column/Char.php index 6f05111e2a..994875339f 100644 --- a/src/Sql/Ddl/Column/Char.php +++ b/src/Sql/Ddl/Column/Char.php @@ -13,8 +13,6 @@ class Char extends AbstractLengthColumn { - /** - * @var string - */ + /** @var string */ protected $type = 'CHAR'; } diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 185f647491..8875c4d8b1 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -16,39 +16,25 @@ class Column implements ColumnInterface { - /** - * @var null|string|int - */ + /** @var null|string|int */ protected $default; - /** - * @var bool - */ + /** @var bool */ protected $isNullable = false; - /** - * @var string - */ + /** @var string */ protected $name = ''; - /** - * @var array - */ + /** @var array */ protected $options = []; - /** - * @var ConstraintInterface[] - */ + /** @var ConstraintInterface[] */ protected $constraints = []; - /** - * @var string - */ + /** @var string */ protected $specification = '%s %s'; - /** - * @var string - */ + /** @var string */ protected $type = 'INTEGER'; /** diff --git a/src/Sql/Ddl/Column/Date.php b/src/Sql/Ddl/Column/Date.php index c62cd8d4e5..116ca0207f 100644 --- a/src/Sql/Ddl/Column/Date.php +++ b/src/Sql/Ddl/Column/Date.php @@ -14,8 +14,6 @@ class Date extends Column { - /** - * @var string - */ + /** @var string */ protected $type = 'DATE'; } diff --git a/src/Sql/Ddl/Column/Datetime.php b/src/Sql/Ddl/Column/Datetime.php index 7a969fb618..83c3468914 100644 --- a/src/Sql/Ddl/Column/Datetime.php +++ b/src/Sql/Ddl/Column/Datetime.php @@ -14,8 +14,6 @@ class Datetime extends Column { - /** - * @var string - */ + /** @var string */ protected $type = 'DATETIME'; } diff --git a/src/Sql/Ddl/Column/Decimal.php b/src/Sql/Ddl/Column/Decimal.php index ca7905a908..7a9d59b9f2 100644 --- a/src/Sql/Ddl/Column/Decimal.php +++ b/src/Sql/Ddl/Column/Decimal.php @@ -14,8 +14,6 @@ class Decimal extends AbstractPrecisionColumn { - /** - * @var string - */ + /** @var string */ protected $type = 'DECIMAL'; } diff --git a/src/Sql/Ddl/Column/Floating.php b/src/Sql/Ddl/Column/Floating.php index 8d64903902..c667c9b261 100644 --- a/src/Sql/Ddl/Column/Floating.php +++ b/src/Sql/Ddl/Column/Floating.php @@ -20,8 +20,6 @@ */ class Floating extends AbstractPrecisionColumn { - /** - * @var string - */ + /** @var string */ protected $type = 'FLOAT'; } diff --git a/src/Sql/Ddl/Column/Text.php b/src/Sql/Ddl/Column/Text.php index a6ac9a9834..c12cd8c120 100644 --- a/src/Sql/Ddl/Column/Text.php +++ b/src/Sql/Ddl/Column/Text.php @@ -14,8 +14,6 @@ class Text extends AbstractLengthColumn { - /** - * @var string - */ + /** @var string */ protected $type = 'TEXT'; } diff --git a/src/Sql/Ddl/Column/Time.php b/src/Sql/Ddl/Column/Time.php index 8262e7a97d..cf3dfabf77 100644 --- a/src/Sql/Ddl/Column/Time.php +++ b/src/Sql/Ddl/Column/Time.php @@ -14,8 +14,6 @@ class Time extends Column { - /** - * @var string - */ + /** @var string */ protected $type = 'TIME'; } diff --git a/src/Sql/Ddl/Column/Timestamp.php b/src/Sql/Ddl/Column/Timestamp.php index 157bcac365..0907bb4a9b 100644 --- a/src/Sql/Ddl/Column/Timestamp.php +++ b/src/Sql/Ddl/Column/Timestamp.php @@ -14,8 +14,6 @@ class Timestamp extends AbstractTimestampColumn { - /** - * @var string - */ + /** @var string */ protected $type = 'TIMESTAMP'; } diff --git a/src/Sql/Ddl/Column/Varbinary.php b/src/Sql/Ddl/Column/Varbinary.php index 405fb68ac8..4454febef3 100644 --- a/src/Sql/Ddl/Column/Varbinary.php +++ b/src/Sql/Ddl/Column/Varbinary.php @@ -14,8 +14,6 @@ class Varbinary extends AbstractLengthColumn { - /** - * @var string - */ + /** @var string */ protected $type = 'VARBINARY'; } diff --git a/src/Sql/Ddl/Column/Varchar.php b/src/Sql/Ddl/Column/Varchar.php index d6f7ea19ee..5ae62e21d9 100644 --- a/src/Sql/Ddl/Column/Varchar.php +++ b/src/Sql/Ddl/Column/Varchar.php @@ -14,8 +14,6 @@ class Varchar extends AbstractLengthColumn { - /** - * @var string - */ + /** @var string */ protected $type = 'VARCHAR'; } diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index 8172343d64..b70ad6b505 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -14,29 +14,19 @@ abstract class AbstractConstraint implements ConstraintInterface { - /** - * @var string - */ + /** @var string */ protected $columnSpecification = ' (%s)'; - /** - * @var string - */ + /** @var string */ protected $namedSpecification = 'CONSTRAINT %s '; - /** - * @var string - */ + /** @var string */ protected $specification = ''; - /** - * @var string - */ + /** @var string */ protected $name = ''; - /** - * @var array - */ + /** @var array */ protected $columns = []; /** diff --git a/src/Sql/Ddl/Constraint/Check.php b/src/Sql/Ddl/Constraint/Check.php index bebda96c72..7a7baeaaf1 100644 --- a/src/Sql/Ddl/Constraint/Check.php +++ b/src/Sql/Ddl/Constraint/Check.php @@ -16,9 +16,7 @@ class Check extends AbstractConstraint { - /** - * @var string|ExpressionInterface - */ + /** @var string|ExpressionInterface */ protected $expression; /** diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index 59baef6ea6..234d1c5df7 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -14,24 +14,16 @@ class ForeignKey extends AbstractConstraint { - /** - * @var string - */ + /** @var string */ protected $onDeleteRule = 'NO ACTION'; - /** - * @var string - */ + /** @var string */ protected $onUpdateRule = 'NO ACTION'; - /** - * @var string[] - */ + /** @var string[] */ protected $referenceColumn = []; - /** - * @var string - */ + /** @var string */ protected $referenceTable = ''; /** @@ -39,9 +31,7 @@ class ForeignKey extends AbstractConstraint */ protected $columnSpecification = 'FOREIGN KEY (%s) '; - /** - * @var string[] - */ + /** @var string[] */ protected $referenceSpecification = [ 'REFERENCES %s ', 'ON DELETE %s ON UPDATE %s' diff --git a/src/Sql/Ddl/Constraint/PrimaryKey.php b/src/Sql/Ddl/Constraint/PrimaryKey.php index 62aeed812e..e058255478 100644 --- a/src/Sql/Ddl/Constraint/PrimaryKey.php +++ b/src/Sql/Ddl/Constraint/PrimaryKey.php @@ -14,8 +14,6 @@ class PrimaryKey extends AbstractConstraint { - /** - * @var string - */ + /** @var string */ protected $specification = 'PRIMARY KEY'; } diff --git a/src/Sql/Ddl/Constraint/UniqueKey.php b/src/Sql/Ddl/Constraint/UniqueKey.php index 4813f42d1e..aff310c645 100644 --- a/src/Sql/Ddl/Constraint/UniqueKey.php +++ b/src/Sql/Ddl/Constraint/UniqueKey.php @@ -14,8 +14,6 @@ class UniqueKey extends AbstractConstraint { - /** - * @var string - */ + /** @var string */ protected $specification = 'UNIQUE'; } diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index 55649cfe04..0f25fa6b6a 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -24,19 +24,13 @@ class CreateTable extends AbstractSql implements SqlInterface public const CONSTRAINTS = 'constraints'; public const TABLE = 'table'; - /** - * @var Column\ColumnInterface[] - */ + /** @var Column\ColumnInterface[] */ protected $columns = []; - /** - * @var string[] - */ + /** @var string[] */ protected $constraints = []; - /** - * @var bool - */ + /** @var bool */ protected $isTemporary = false; /** @@ -58,9 +52,7 @@ class CreateTable extends AbstractSql implements SqlInterface 'statementEnd' => '%1$s', ]; - /** - * @var string - */ + /** @var string */ protected $table = ''; /** diff --git a/src/Sql/Ddl/DropTable.php b/src/Sql/Ddl/DropTable.php index ce45ca36d9..baf9e463c5 100644 --- a/src/Sql/Ddl/DropTable.php +++ b/src/Sql/Ddl/DropTable.php @@ -20,16 +20,12 @@ class DropTable extends AbstractSql implements SqlInterface { public const TABLE = 'table'; - /** - * @var array - */ + /** @var array */ protected $specifications = [ self::TABLE => 'DROP TABLE %1$s' ]; - /** - * @var string - */ + /** @var string */ protected $table = ''; /** diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index 23fdb9ffa4..36c3efff2f 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -11,14 +11,10 @@ class Index extends AbstractIndex { - /** - * @var string - */ + /** @var string */ protected $specification = 'INDEX %s(...)'; - /** - * @var array - */ + /** @var array */ protected $lengths; /** diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 07681ce61c..fb7781cf4f 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -37,24 +37,16 @@ class Delete extends AbstractPreparableSql self::SPECIFICATION_WHERE => 'WHERE %1$s' ]; - /** - * @var string|TableIdentifier - */ + /** @var string|TableIdentifier */ protected $table = ''; - /** - * @var bool - */ + /** @var bool */ protected $emptyWhereProtection = true; - /** - * @var array - */ + /** @var array */ protected $set = []; - /** - * @var null|string|Where - */ + /** @var null|string|Where */ protected $where; /** diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 66bdf660f3..dda55365de 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -19,19 +19,13 @@ class Expression extends AbstractExpression */ public const PLACEHOLDER = '?'; - /** - * @var string - */ + /** @var string */ protected $expression = ''; - /** - * @var array - */ + /** @var array */ protected $parameters = []; - /** - * @var array - */ + /** @var array */ protected $types = []; /** diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 29508a7d12..dbda6880e3 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -30,23 +30,17 @@ class Insert extends AbstractPreparableSql public const VALUES_SET = 'set'; /**#@-*/ - /** - * @var array Specification array - */ + /** @var array Specification array */ protected $specifications = [ self::SPECIFICATION_INSERT => 'INSERT INTO %1$s (%2$s) VALUES (%3$s)', self::SPECIFICATION_SELECT => 'INSERT INTO %1$s %2$s %3$s', ]; - /** - * @var string|TableIdentifier - */ + /** @var string|TableIdentifier */ protected $table; protected $columns = []; - /** - * @var array|Select - */ + /** @var array|Select */ protected $select; /** diff --git a/src/Sql/Join.php b/src/Sql/Join.php index 8e59cd7cc7..246d32639e 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -31,18 +31,10 @@ class Join implements Iterator, Countable public const JOIN_RIGHT_OUTER = 'right outer'; public const JOIN_LEFT_OUTER = 'left outer'; - /** - * Current iterator position. - * - * @var int - */ + /** @var int */ private $position = 0; - /** - * JOIN specifications - * - * @var array - */ + /** @var array */ protected $joins = []; /** diff --git a/src/Sql/Literal.php b/src/Sql/Literal.php index c9a5619eb6..23099bdb97 100644 --- a/src/Sql/Literal.php +++ b/src/Sql/Literal.php @@ -11,9 +11,7 @@ class Literal implements ExpressionInterface { - /** - * @var string - */ + /** @var string */ protected $literal = ''; /** diff --git a/src/Sql/Platform/AbstractPlatform.php b/src/Sql/Platform/AbstractPlatform.php index 98ea1ff11f..e2319331eb 100644 --- a/src/Sql/Platform/AbstractPlatform.php +++ b/src/Sql/Platform/AbstractPlatform.php @@ -21,14 +21,10 @@ class AbstractPlatform implements PlatformDecoratorInterface, PreparableSqlInterface, SqlInterface { - /** - * @var object|null - */ + /** @var object|null */ protected $subject; - /** - * @var PlatformDecoratorInterface[] - */ + /** @var PlatformDecoratorInterface[] */ protected $decorators = []; /** diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 8520c22975..b8e57572cc 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -27,19 +27,13 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface { - /** - * @var bool - */ + /** @var bool */ protected $isSelectContainDistinct = false; - /** - * @var Select - */ + /** @var Select */ protected $subject; - /** - * @var bool - */ + /** @var bool */ protected $supportsLimitOffset = false; diff --git a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php index ec90d66244..ca45d680aa 100644 --- a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -27,14 +27,10 @@ class AlterTableDecorator extends AlterTable implements PlatformDecoratorInterface { - /** - * @var AlterTable - */ + /** @var AlterTable */ protected $subject; - /** - * @var int[] - */ + /** @var int[] */ protected $columnOptionSortOrder = [ 'unsigned' => 0, 'zerofill' => 1, diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index 2965f7e6e0..a5c65fc6a2 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -20,14 +20,10 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInterface { - /** - * @var CreateTable - */ + /** @var CreateTable */ protected $subject; - /** - * @var int[] - */ + /** @var int[] */ protected $columnOptionSortOrder = [ 'unsigned' => 0, 'zerofill' => 1, diff --git a/src/Sql/Platform/Mysql/SelectDecorator.php b/src/Sql/Platform/Mysql/SelectDecorator.php index cbd2c13d61..d3969b9b84 100644 --- a/src/Sql/Platform/Mysql/SelectDecorator.php +++ b/src/Sql/Platform/Mysql/SelectDecorator.php @@ -20,9 +20,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface { - /** - * @var Select - */ + /** @var Select */ protected $subject; /** diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index 82bf1af66f..3aae8f8020 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -24,9 +24,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface { - /** - * @var Select - */ + /** @var Select */ protected $subject; /** diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index 55c3bd631c..bfadcf6efe 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -23,14 +23,10 @@ class Platform extends AbstractPlatform { - /** - * @var AdapterInterface - */ + /** @var AdapterInterface */ protected $adapter; - /** - * @var PlatformInterface|null - */ + /** @var PlatformInterface|null */ protected $defaultPlatform; public function __construct(AdapterInterface $adapter) diff --git a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index 14060bf38a..d1ffff2b54 100644 --- a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -15,9 +15,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInterface { - /** - * @var CreateTable - */ + /** @var CreateTable */ protected $subject; /** diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index b7fd3a3142..43945090fb 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -17,9 +17,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface { - /** - * @var Select - */ + /** @var Select */ protected $subject; /** diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index 04617776ce..64d78e4c0d 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -19,9 +19,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface { - /** - * @var Select - */ + /** @var Select */ protected $subject; /** diff --git a/src/Sql/Predicate/IsNull.php b/src/Sql/Predicate/IsNull.php index b37bcaabb6..46ca6f31df 100644 --- a/src/Sql/Predicate/IsNull.php +++ b/src/Sql/Predicate/IsNull.php @@ -16,14 +16,10 @@ class IsNull extends AbstractExpression implements PredicateInterface { - /** - * @var string - */ + /** @var string */ protected $specification = '%1$s IS NULL'; - /** - * @var - */ + /** @var null|string */ protected $identifier; /** diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index fc022699c0..b4106d45bf 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -16,19 +16,13 @@ class Like extends AbstractExpression implements PredicateInterface { - /** - * @var string - */ + /** @var string */ protected $specification = '%1$s LIKE %2$s'; - /** - * @var string - */ + /** @var string */ protected $identifier = ''; - /** - * @var string - */ + /** @var string */ protected $like = ''; /** diff --git a/src/Sql/Predicate/NotBetween.php b/src/Sql/Predicate/NotBetween.php index 31f43f4b96..578cf28a16 100644 --- a/src/Sql/Predicate/NotBetween.php +++ b/src/Sql/Predicate/NotBetween.php @@ -14,8 +14,6 @@ class NotBetween extends Between { - /** - * @var string - */ + /** @var string */ protected $specification = '%1$s NOT BETWEEN %2$s AND %3$s'; } diff --git a/src/Sql/Predicate/NotIn.php b/src/Sql/Predicate/NotIn.php index 7009848025..a139047473 100644 --- a/src/Sql/Predicate/NotIn.php +++ b/src/Sql/Predicate/NotIn.php @@ -14,8 +14,6 @@ class NotIn extends In { - /** - * @var string - */ + /** @var string */ protected $specification = '%s NOT IN %s'; } diff --git a/src/Sql/Predicate/NotLike.php b/src/Sql/Predicate/NotLike.php index 99840d5b69..d85b757e58 100644 --- a/src/Sql/Predicate/NotLike.php +++ b/src/Sql/Predicate/NotLike.php @@ -14,8 +14,6 @@ class NotLike extends Like { - /** - * @var string - */ + /** @var string */ protected $specification = '%1$s NOT LIKE %2$s'; } diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 73cf04abe3..b49ee40230 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -45,29 +45,19 @@ class Operator extends AbstractExpression implements PredicateInterface self::TYPE_VALUE, ]; - /** - * @var int|float|bool|string - */ + /** @var int|float|bool|string */ protected $left; - /** - * @var int|float|bool|string - */ + /** @var int|float|bool|string */ protected $right; - /** - * @var string - */ + /** @var string */ protected $leftType = self::TYPE_IDENTIFIER; - /** - * @var string - */ + /** @var string */ protected $rightType = self::TYPE_VALUE; - /** - * @var string - */ + /** @var string */ protected $operator = self::OPERATOR_EQUAL_TO; /** diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 858bc0dba9..678cb9769d 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -62,9 +62,7 @@ class Select extends AbstractPreparableSql */ public const JOIN_OUTER_RIGHT = 'outer right'; - /** - * @var array Specifications - */ + /** @var array Specifications */ protected $specifications = [ 'statementStart' => '%1$s', self::SELECT => [ @@ -104,69 +102,43 @@ class Select extends AbstractPreparableSql self::COMBINE => '%1$s ( %2$s )', ]; - /** - * @var bool - */ + /** @var bool */ protected $tableReadOnly = false; - /** - * @var bool - */ + /** @var bool */ protected $prefixColumnsWithTable = true; - /** - * @var string|array|TableIdentifier - */ + /** @var string|array|TableIdentifier */ protected $table; - /** - * @var null|string|Expression - */ + /** @var null|string|Expression */ protected $quantifier; - /** - * @var array - */ + /** @var array */ protected $columns = [self::SQL_STAR]; - /** - * @var null|Join - */ + /** @var null|Join */ protected $joins; - /** - * @var Where - */ + /** @var Where */ protected $where; - /** - * @var array - */ + /** @var array */ protected $order = []; - /** - * @var null|array - */ + /** @var null|array */ protected $group; - /** - * @var null|string|array - */ + /** @var null|string|array */ protected $having; - /** - * @var int|null - */ + /** @var int|null */ protected $limit; - /** - * @var int|null - */ + /** @var int|null */ protected $offset; - /** - * @var array - */ + /** @var array */ protected $combine = []; /** diff --git a/src/Sql/TableIdentifier.php b/src/Sql/TableIdentifier.php index 3a12126f44..12227605c8 100644 --- a/src/Sql/TableIdentifier.php +++ b/src/Sql/TableIdentifier.php @@ -13,14 +13,10 @@ */ class TableIdentifier { - /** - * @var string - */ + /** @var string */ protected $table; - /** - * @var null|string - */ + /** @var null|string */ protected $schema; /** diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 93f77e867d..ab0de2aa9d 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -44,29 +44,19 @@ class Update extends AbstractPreparableSql self::SPECIFICATION_WHERE => 'WHERE %1$s', ]; - /** - * @var string|TableIdentifier - */ + /** @var string|TableIdentifier */ protected $table = ''; - /** - * @var bool - */ + /** @var bool */ protected $emptyWhereProtection = true; - /** - * @var PriorityList - */ + /** @var PriorityList */ protected $set; - /** - * @var string|Where - */ + /** @var string|Where */ protected $where; - /** - * @var null|Join - */ + /** @var null|Join */ protected $joins; /** From b9ce140a3a1692d5d1035061ebd6786f53cb187f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 21:06:19 +0100 Subject: [PATCH 11/45] Updated file header comment, added strict_types declaration --- src/Sql/AbstractExpression.php | 13 +++++-------- src/Sql/AbstractPreparableSql.php | 13 +++++-------- src/Sql/AbstractSql.php | 13 +++++-------- src/Sql/Combine.php | 13 +++++-------- src/Sql/Ddl/AlterTable.php | 13 +++++-------- src/Sql/Ddl/Column/AbstractLengthColumn.php | 13 +++++-------- src/Sql/Ddl/Column/AbstractPrecisionColumn.php | 13 +++++-------- src/Sql/Ddl/Column/AbstractTimestampColumn.php | 13 +++++-------- src/Sql/Ddl/Column/BigInteger.php | 13 +++++-------- src/Sql/Ddl/Column/Binary.php | 12 +++++------- src/Sql/Ddl/Column/Blob.php | 13 +++++-------- src/Sql/Ddl/Column/Boolean.php | 13 +++++-------- src/Sql/Ddl/Column/Char.php | 12 +++++------- src/Sql/Ddl/Column/Column.php | 13 +++++-------- src/Sql/Ddl/Column/ColumnInterface.php | 13 +++++-------- src/Sql/Ddl/Column/Date.php | 13 +++++-------- src/Sql/Ddl/Column/Datetime.php | 13 +++++-------- src/Sql/Ddl/Column/Decimal.php | 13 +++++-------- src/Sql/Ddl/Column/Float.php | 12 +++++------- src/Sql/Ddl/Column/Floating.php | 13 +++++-------- src/Sql/Ddl/Column/Integer.php | 13 +++++-------- src/Sql/Ddl/Column/Text.php | 13 +++++-------- src/Sql/Ddl/Column/Time.php | 13 +++++-------- src/Sql/Ddl/Column/Timestamp.php | 13 +++++-------- src/Sql/Ddl/Column/Varbinary.php | 13 +++++-------- src/Sql/Ddl/Column/Varchar.php | 13 +++++-------- src/Sql/Ddl/Constraint/AbstractConstraint.php | 13 +++++-------- src/Sql/Ddl/Constraint/Check.php | 13 +++++-------- src/Sql/Ddl/Constraint/ConstraintInterface.php | 13 +++++-------- src/Sql/Ddl/Constraint/ForeignKey.php | 13 +++++-------- src/Sql/Ddl/Constraint/PrimaryKey.php | 13 +++++-------- src/Sql/Ddl/Constraint/UniqueKey.php | 13 +++++-------- src/Sql/Ddl/CreateTable.php | 13 +++++-------- src/Sql/Ddl/DropTable.php | 13 +++++-------- src/Sql/Ddl/Index/AbstractIndex.php | 10 ++++------ src/Sql/Ddl/Index/Index.php | 10 ++++------ src/Sql/Ddl/SqlInterface.php | 13 +++++-------- src/Sql/Delete.php | 13 +++++-------- src/Sql/Exception/ExceptionInterface.php | 13 +++++-------- src/Sql/Exception/InvalidArgumentException.php | 13 +++++-------- src/Sql/Exception/RuntimeException.php | 13 +++++-------- src/Sql/Expression.php | 13 +++++-------- src/Sql/ExpressionInterface.php | 13 +++++-------- src/Sql/Having.php | 12 +++++------- src/Sql/Insert.php | 13 +++++-------- src/Sql/Join.php | 8 +++++--- src/Sql/Literal.php | 10 +++++----- src/Sql/Platform/AbstractPlatform.php | 13 +++++-------- src/Sql/Platform/IbmDb2/IbmDb2.php | 13 +++++-------- src/Sql/Platform/IbmDb2/SelectDecorator.php | 13 +++++-------- src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php | 13 +++++-------- src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php | 13 +++++-------- src/Sql/Platform/Mysql/Mysql.php | 13 +++++-------- src/Sql/Platform/Mysql/SelectDecorator.php | 13 +++++-------- src/Sql/Platform/Oracle/Oracle.php | 13 +++++-------- src/Sql/Platform/Oracle/SelectDecorator.php | 13 +++++-------- src/Sql/Platform/Platform.php | 13 +++++-------- src/Sql/Platform/PlatformDecoratorInterface.php | 13 +++++-------- .../Platform/SqlServer/Ddl/CreateTableDecorator.php | 10 ++++------ src/Sql/Platform/SqlServer/SelectDecorator.php | 10 ++++------ src/Sql/Platform/SqlServer/SqlServer.php | 10 ++++------ src/Sql/Platform/Sqlite/SelectDecorator.php | 12 +++++------- src/Sql/Platform/Sqlite/Sqlite.php | 13 +++++-------- src/Sql/Predicate/Between.php | 12 +++++------- src/Sql/Predicate/Expression.php | 13 +++++-------- src/Sql/Predicate/In.php | 13 +++++-------- src/Sql/Predicate/IsNotNull.php | 13 +++++-------- src/Sql/Predicate/IsNull.php | 13 +++++-------- src/Sql/Predicate/Like.php | 13 +++++-------- src/Sql/Predicate/Literal.php | 13 +++++-------- src/Sql/Predicate/NotBetween.php | 13 +++++-------- src/Sql/Predicate/NotIn.php | 13 +++++-------- src/Sql/Predicate/NotLike.php | 13 +++++-------- src/Sql/Predicate/Operator.php | 13 +++++-------- src/Sql/Predicate/Predicate.php | 10 ++++------ src/Sql/Predicate/PredicateInterface.php | 13 +++++-------- src/Sql/Predicate/PredicateSet.php | 13 +++++-------- src/Sql/PreparableSqlInterface.php | 10 +++++----- src/Sql/Select.php | 10 +++++----- src/Sql/Sql.php | 10 +++++----- src/Sql/SqlInterface.php | 13 +++++-------- src/Sql/TableIdentifier.php | 12 +++++------- src/Sql/Update.php | 10 +++++----- src/Sql/Where.php | 10 +++++----- 84 files changed, 414 insertions(+), 630 deletions(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index c15a5d5fc6..d99daa701d 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -1,15 +1,12 @@ Date: Sat, 16 Mar 2019 21:07:32 +0100 Subject: [PATCH 12/45] Removed empty comment lines --- src/Sql/Ddl/Index/Index.php | 1 - src/Sql/Delete.php | 1 - src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php | 1 - src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php | 1 - src/Sql/Select.php | 1 - src/Sql/Update.php | 1 - 6 files changed, 6 deletions(-) diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index cd0c2713d8..4f45f8f1bc 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -29,7 +29,6 @@ public function __construct($columns, $name = null, array $lengths = []) } /** - * * @return array of array|string should return an array in the format: * * array ( diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index eed03602c6..bbef6911ae 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -14,7 +14,6 @@ use Zend\Db\Adapter\Driver\DriverInterface; /** - * * @property Where $where */ class Delete extends AbstractPreparableSql diff --git a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php index aee6b44828..908d993570 100644 --- a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -241,7 +241,6 @@ private function normalizeColumnOption(string $name) : string } /** - * * @param string $columnA * @param string $columnB * diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index 6c79ad2464..7c77487b04 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -162,7 +162,6 @@ private function normalizeColumnOption(string $name) : string } /** - * * @param string $columnA * @param string $columnB * diff --git a/src/Sql/Select.php b/src/Sql/Select.php index b7b254cac5..00238c06cd 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -14,7 +14,6 @@ use Zend\Db\Adapter\Platform\PlatformInterface; /** - * * @property Where $where * @property Having $having */ diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 4656caf9e6..1663745efc 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -16,7 +16,6 @@ use Zend\Stdlib\PriorityList; /** - * * @property Where $where */ class Update extends AbstractPreparableSql From 4ec4ee5d22400652e7e6f573e62ffd6d136602f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 21:40:12 +0100 Subject: [PATCH 13/45] Updated argument and return type declarations, removed method comments which do not add valuable information --- src/Sql/AbstractExpression.php | 2 +- src/Sql/AbstractPreparableSql.php | 5 - src/Sql/AbstractSql.php | 39 +----- src/Sql/Combine.php | 37 ++---- src/Sql/Delete.php | 44 ++----- src/Sql/Expression.php | 20 +-- src/Sql/Insert.php | 73 ++--------- src/Sql/Join.php | 36 +----- src/Sql/Literal.php | 20 +-- src/Sql/Platform/IbmDb2/SelectDecorator.php | 4 +- src/Sql/Platform/Mysql/SelectDecorator.php | 8 +- src/Sql/Platform/Oracle/SelectDecorator.php | 4 +- .../Platform/SqlServer/SelectDecorator.php | 4 +- src/Sql/Platform/Sqlite/SelectDecorator.php | 16 +-- src/Sql/PreparableSqlInterface.php | 6 - src/Sql/Select.php | 120 ++++++------------ src/Sql/Sql.php | 37 +++--- src/Sql/TableIdentifier.php | 4 +- src/Sql/Update.php | 30 ++--- 19 files changed, 136 insertions(+), 373 deletions(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index d99daa701d..7e5c4e509a 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -43,7 +43,7 @@ abstract class AbstractExpression implements ExpressionInterface * * @throws Exception\InvalidArgumentException */ - protected function normalizeArgument($argument, ?string $defaultType = self::TYPE_VALUE) : array + protected function normalizeArgument($argument, string $defaultType = self::TYPE_VALUE) : array { if ($argument instanceof ExpressionInterface || $argument instanceof SqlInterface) { return $this->buildNormalizedArgument($argument, self::TYPE_VALUE); diff --git a/src/Sql/AbstractPreparableSql.php b/src/Sql/AbstractPreparableSql.php index de8aa9c3a7..ca8654a04f 100644 --- a/src/Sql/AbstractPreparableSql.php +++ b/src/Sql/AbstractPreparableSql.php @@ -15,11 +15,6 @@ abstract class AbstractPreparableSql extends AbstractSql implements PreparableSqlInterface { - /** - * {@inheritDoc} - * - * @return StatementContainerInterface - */ public function prepareStatement( AdapterInterface $adapter, StatementContainerInterface $statementContainer diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 25b5ee2db1..d495dfdec3 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -50,18 +50,11 @@ public function getSqlString(?PlatformInterface $adapterPlatform = null) : strin return $this->buildSqlString($adapterPlatform); } - /** - * @param PlatformInterface $platform - * @param null|DriverInterface $driver - * @param null|ParameterContainer $parameterContainer - * - * @return string|void - */ protected function buildSqlString( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null - ) { + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null + ) : string { $this->localizeVariables(); $sqls = []; @@ -287,14 +280,6 @@ protected function createSqlFromSpecificationAndParameters($specifications, arra return vsprintf($specificationString, $topParameters); } - /** - * @param Select $subselect - * @param PlatformInterface $platform - * @param null|DriverInterface $driver - * @param null|ParameterContainer $parameterContainer - * - * @return string - */ protected function processSubSelect( Select $subselect, PlatformInterface $platform, @@ -327,24 +312,14 @@ protected function processSubSelect( return $decorator->buildSqlString($platform, $driver, $parameterContainer); } - /** - * @param Join $joins - * @param PlatformInterface $platform - * @param null|DriverInterface $driver - * @param null|ParameterContainer $parameterContainer - * - * @return string[]|void|null - * otherwise - * @throws Exception\InvalidArgumentException for invalid JOIN table names. - */ protected function processJoin( Join $joins, PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null - ) { + ) : ?array { if (! $joins->count()) { - return; + return null; } // process joins @@ -468,8 +443,8 @@ protected function resolveColumnValue( protected function resolveTable( $table, PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) : string { $schema = null; diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 42c0072090..1f78945fe3 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -45,7 +45,7 @@ class Combine extends AbstractPreparableSql * @param string $type * @param string $modifier */ - public function __construct($select = null, ?string $type = self::COMBINE_UNION, ?string $modifier = '') + public function __construct($select = null, string $type = self::COMBINE_UNION, string $modifier = '') { if ($select) { $this->combine($select, $type, $modifier); @@ -63,7 +63,7 @@ public function __construct($select = null, ?string $type = self::COMBINE_UNION, * * @throws Exception\InvalidArgumentException */ - public function combine($select, ?string $type = self::COMBINE_UNION, ?string $modifier = '') : self + public function combine($select, string $type = self::COMBINE_UNION, string $modifier = '') : self { if (is_array($select)) { foreach ($select as $combine) { @@ -104,7 +104,7 @@ public function combine($select, ?string $type = self::COMBINE_UNION, ?string $m * * @return self */ - public function union($select, ?string $modifier = '') : self + public function union($select, string $modifier = '') : self { return $this->combine($select, self::COMBINE_UNION, $modifier); } @@ -117,7 +117,7 @@ public function union($select, ?string $modifier = '') : self * * @return self */ - public function except($select, ?string $modifier = '') : self + public function except($select, string $modifier = '') : self { return $this->combine($select, self::COMBINE_EXCEPT, $modifier); } @@ -130,27 +130,18 @@ public function except($select, ?string $modifier = '') : self * * @return self */ - public function intersect($select, ?string $modifier = '') : self + public function intersect($select, string $modifier = '') : self { return $this->combine($select, self::COMBINE_INTERSECT, $modifier); } - /** - * Build sql string - * - * @param PlatformInterface $platform - * @param DriverInterface $driver - * @param ParameterContainer $parameterContainer - * - * @return string|void - */ protected function buildSqlString( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null - ) { + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null + ) : ?string { if (! $this->combine) { - return; + return null; } $sql = ''; @@ -170,9 +161,6 @@ protected function buildSqlString( return trim($sql, ' '); } - /** - * @return self Provides a fluent interface - */ public function alignColumns() : self { if (! $this->combine) { @@ -201,13 +189,6 @@ public function alignColumns() : self return $this; } - /** - * Get raw state - * - * @param string $key - * - * @return array - */ public function getRawState(?string $key = null) : array { $rawState = [ diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index bbef6911ae..5312eaaba5 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -72,12 +72,7 @@ public function from($table) : self return $this; } - /** - * @param null $key - * - * @return mixed - */ - public function getRawState($key = null) + public function getRawState(?string $key = null) { $rawState = [ 'emptyWhereProtection' => $this->emptyWhereProtection, @@ -97,7 +92,7 @@ public function getRawState($key = null) * * @return self Provides a fluent interface */ - public function where($predicate, ?string $combination = Predicate\PredicateSet::OP_AND) : self + public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self { if ($predicate instanceof Where) { $this->where = $predicate; @@ -107,17 +102,10 @@ public function where($predicate, ?string $combination = Predicate\PredicateSet: return $this; } - /** - * @param PlatformInterface $platform - * @param DriverInterface|null $driver - * @param ParameterContainer|null $parameterContainer - * - * @return string - */ protected function processDelete( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) : string { return sprintf( $this->specifications[static::SPECIFICATION_DELETE], @@ -125,20 +113,13 @@ protected function processDelete( ); } - /** - * @param PlatformInterface $platform - * @param DriverInterface|null $driver - * @param ParameterContainer|null $parameterContainer - * - * @return void|string - */ protected function processWhere( PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null - ) { - if ($this->where->count() == 0) { - return; + ) : ?string { + if ($this->where->count() === 0) { + return null; } return sprintf( @@ -147,16 +128,7 @@ protected function processWhere( ); } - /** - * Property overloading - * - * Overloads "where" only. - * - * @param string $name - * - * @return Where|null - */ - public function __get($name) + public function __get(string $name) : ?Where { switch (strtolower($name)) { case 'where': diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 036123591b..67be99074d 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -30,7 +30,7 @@ class Expression extends AbstractExpression * @param string|array $parameters * @param array $types @deprecated will be dropped in version 3.0.0 */ - public function __construct(?string $expression = '', $parameters = null, array $types = []) + public function __construct(string $expression = '', $parameters = null, array $types = []) { if ($expression !== '') { $this->setExpression($expression); @@ -55,13 +55,6 @@ public function __construct(?string $expression = '', $parameters = null, array } } - /** - * @param string $expression - * - * @return self Provides a fluent interface - * - * @throws Exception\InvalidArgumentException - */ public function setExpression(string $expression) : self { if (! is_string($expression) || $expression == '') { @@ -73,9 +66,6 @@ public function setExpression(string $expression) : self return $this; } - /** - * @return string - */ public function getExpression() : string { return $this->expression; @@ -99,9 +89,6 @@ public function setParameters($parameters) : self return $this; } - /** - * @return array - */ public function getParameters() : array { return $this->parameters; @@ -130,11 +117,6 @@ public function getTypes() : array return $this->types; } - /** - * @return array - * - * @throws Exception\RuntimeException - */ public function getExpressionData() : array { $parameters = (is_scalar($this->parameters)) ? [$this->parameters] : $this->parameters; diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index e9f1d91d57..e51bcdbe93 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -84,10 +84,10 @@ public function columns(array $columns) : self * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function values($values, $flag = self::VALUES_SET) : self + public function values($values, string $flag = self::VALUES_SET) : self { if ($values instanceof Select) { - if ($flag == self::VALUES_MERGE) { + if ($flag === self::VALUES_MERGE) { throw new Exception\InvalidArgumentException( 'A Zend\Db\Sql\Select instance cannot be provided with the merge flag' ); @@ -102,14 +102,14 @@ public function values($values, $flag = self::VALUES_SET) : self ); } - if ($this->select && $flag == self::VALUES_MERGE) { + if ($this->select && $flag === self::VALUES_MERGE) { throw new Exception\InvalidArgumentException( 'An array of values cannot be provided with the merge flag when a Zend\Db\Sql\Select instance already ' . 'exists as the value source' ); } - if ($flag == self::VALUES_SET) { + if ($flag === self::VALUES_SET) { $this->columns = $this->isAssocativeArray($values) ? $values : array_combine(array_keys($this->columns), array_values($values)); @@ -134,24 +134,12 @@ private function isAssocativeArray(array $array) : bool return array_keys($array) !== range(0, count($array) - 1); } - /** - * Create INTO SELECT clause - * - * @param Select $select - * @return self - */ public function select(Select $select) : self { return $this->values($select); } - /** - * Get raw state - * - * @param string $key - * @return mixed - */ - public function getRawState($key = null) + public function getRawState(?string $key = null) { $rawState = [ 'table' => $this->table, @@ -163,8 +151,8 @@ public function getRawState($key = null) protected function processInsert( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->select) { return; @@ -206,8 +194,8 @@ protected function processInsert( protected function processSelect( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if (! $this->select) { return; @@ -225,31 +213,13 @@ protected function processSelect( ); } - /** - * Overloading: variable setting - * - * Proxies to values, using VALUES_MERGE strategy - * - * @param string $name - * @param mixed $value - * @return self Provides a fluent interface - */ - public function __set($name, $value) + public function __set(string $name, $value) { $this->columns[$name] = $value; return $this; } - /** - * Overloading: variable unset - * - * Proxies to values and columns - * - * @param string $name - * @throws Exception\InvalidArgumentException - * @return void - */ - public function __unset($name) + public function __unset(string $name) { if (! array_key_exists($name, $this->columns)) { throw new Exception\InvalidArgumentException( @@ -260,29 +230,12 @@ public function __unset($name) unset($this->columns[$name]); } - /** - * Overloading: variable isset - * - * Proxies to columns; does a column of that name exist? - * - * @param string $name - * @return bool - */ - public function __isset($name) + public function __isset(string $name) { return array_key_exists($name, $this->columns); } - /** - * Overloading: variable retrieval - * - * Retrieves value by column name - * - * @param string $name - * @throws Exception\InvalidArgumentException - * @return mixed - */ - public function __get($name) + public function __get(string $name) { if (! array_key_exists($name, $this->columns)) { throw new Exception\InvalidArgumentException( diff --git a/src/Sql/Join.php b/src/Sql/Join.php index d5617eeb8a..27640fce8a 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -39,55 +39,31 @@ class Join implements Iterator, Countable /** @var array */ protected $joins = []; - /** - * Rewind iterator. - */ public function rewind() : void { $this->position = 0; } - /** - * Return current join specification. - * - * @return array - */ public function current() : array { return $this->joins[$this->position]; } - /** - * Return the current iterator index. - * - * @return int - */ public function key() : int { return $this->position; } - /** - * Advance to the next JOIN specification. - */ public function next() : void { ++$this->position; } - /** - * Is the iterator at a valid position? - * - * @return bool - */ public function valid() : bool { return isset($this->joins[$this->position]); } - /** - * @return array - */ public function getJoins() : array { return $this->joins; @@ -104,7 +80,7 @@ public function getJoins() : array * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException for invalid $name values. */ - public function join($name, $on, $columns = [Select::SQL_STAR], $type = Join::JOIN_INNER) : self + public function join($name, $on, $columns = [Select::SQL_STAR], string $type = Join::JOIN_INNER) : self { if (is_array($name) && (! is_string(key($name)) || count($name) !== 1)) { throw new Exception\InvalidArgumentException( @@ -126,22 +102,12 @@ public function join($name, $on, $columns = [Select::SQL_STAR], $type = Join::JO return $this; } - /** - * Reset to an empty list of JOIN specifications. - * - * @return self Provides a fluent interface - */ public function reset() : self { $this->joins = []; return $this; } - /** - * Get count of attached predicates - * - * @return int - */ public function count() : int { return count($this->joins); diff --git a/src/Sql/Literal.php b/src/Sql/Literal.php index 8b54a26463..98e7ad5dfc 100644 --- a/src/Sql/Literal.php +++ b/src/Sql/Literal.php @@ -11,38 +11,24 @@ class Literal implements ExpressionInterface { - /** @var string */ - protected $literal = ''; + protected $literal; - /** - * @param $literal - */ - public function __construct($literal = '') + public function __construct(string $literal = '') { $this->literal = $literal; } - /** - * @param string $literal - * @return self Provides a fluent interface - */ - public function setLiteral($literal) : self + public function setLiteral(string $literal) : self { $this->literal = $literal; return $this; } - /** - * @return string - */ public function getLiteral() : string { return $this->literal; } - /** - * @return array - */ public function getExpressionData() : array { return [[ diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 2d392b88d2..3861f46e86 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -101,8 +101,8 @@ protected function localizeVariables() : void */ protected function processLimitOffset( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null, + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null, array &$sqls, array &$parameters ) : void { diff --git a/src/Sql/Platform/Mysql/SelectDecorator.php b/src/Sql/Platform/Mysql/SelectDecorator.php index 50d838cd40..e4567fe2ef 100644 --- a/src/Sql/Platform/Mysql/SelectDecorator.php +++ b/src/Sql/Platform/Mysql/SelectDecorator.php @@ -38,8 +38,8 @@ protected function localizeVariables() : void protected function processLimit( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->limit === null && $this->offset !== null) { return ['']; @@ -61,8 +61,8 @@ protected function processLimit( protected function processOffset( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->offset === null) { return; diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index 134067d841..abc5d79ba7 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -60,8 +60,8 @@ protected function localizeVariables() : void */ protected function processLimitOffset( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null, + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null, array &$sqls = [], array &$parameters = [] ) : void { diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index e715f55eed..844528423f 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -47,8 +47,8 @@ protected function localizeVariables() : void */ protected function processLimitOffset( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null, + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null, &$sqls, &$parameters ) : void { diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index da7ecb1829..7f10910736 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -48,16 +48,16 @@ protected function localizeVariables() : void */ protected function processStatementStart( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { return ''; } protected function processLimit( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->limit === null && $this->offset !== null) { return ['']; @@ -76,8 +76,8 @@ protected function processLimit( protected function processOffset( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->offset === null) { return; @@ -96,8 +96,8 @@ protected function processOffset( */ protected function processStatementEnd( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { return ''; } diff --git a/src/Sql/PreparableSqlInterface.php b/src/Sql/PreparableSqlInterface.php index 720795caf9..d93464a3d3 100644 --- a/src/Sql/PreparableSqlInterface.php +++ b/src/Sql/PreparableSqlInterface.php @@ -14,11 +14,5 @@ interface PreparableSqlInterface { - /** - * @param AdapterInterface $adapter - * @param StatementContainerInterface $statementContainer - * - * @return void - */ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer); } diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 00238c06cd..74d90fdf36 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -223,7 +223,7 @@ public function quantifier($quantifier) : self * @param bool $prefixColumnsWithTable * @return self Provides a fluent interface */ - public function columns(array $columns, $prefixColumnsWithTable = true) : self + public function columns(array $columns, bool $prefixColumnsWithTable = true) : self { $this->columns = $columns; $this->prefixColumnsWithTable = (bool) $prefixColumnsWithTable; @@ -240,7 +240,7 @@ public function columns(array $columns, $prefixColumnsWithTable = true) : self * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function join($name, $on, $columns = self::SQL_STAR, $type = self::JOIN_INNER) : self + public function join($name, $on, $columns = self::SQL_STAR, string $type = self::JOIN_INNER) : self { $this->joins->join($name, $on, $columns, $type); @@ -255,7 +255,7 @@ public function join($name, $on, $columns = self::SQL_STAR, $type = self::JOIN_I * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) : self + public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self { if ($predicate instanceof Where) { $this->where = $predicate; @@ -288,7 +288,7 @@ public function group($group) : self * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return self Provides a fluent interface */ - public function having($predicate, $combination = Predicate\PredicateSet::OP_AND) : self + public function having($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self { if ($predicate instanceof Having) { $this->having = $predicate; @@ -328,16 +328,8 @@ public function order($order) : self * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function limit($limit) : self + public function limit(int $limit) : self { - if (! is_numeric($limit)) { - throw new Exception\InvalidArgumentException(sprintf( - '%s expects parameter to be numeric, "%s" given', - __METHOD__, - (is_object($limit) ? get_class($limit) : gettype($limit)) - )); - } - $this->limit = $limit; return $this; } @@ -347,28 +339,13 @@ public function limit($limit) : self * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function offset($offset) : self + public function offset(int $offset) : self { - if (! is_numeric($offset)) { - throw new Exception\InvalidArgumentException(sprintf( - '%s expects parameter to be numeric, "%s" given', - __METHOD__, - (is_object($offset) ? get_class($offset) : gettype($offset)) - )); - } - $this->offset = $offset; return $this; } - /** - * @param Select $select - * @param string $type - * @param string $modifier - * @return self Provides a fluent interface - * @throws Exception\InvalidArgumentException - */ - public function combine(Select $select, $type = self::COMBINE_UNION, $modifier = '') : self + public function combine(Select $select, string $type = self::COMBINE_UNION, string $modifier = '') : self { if ($this->combine !== []) { throw new Exception\InvalidArgumentException( @@ -383,12 +360,7 @@ public function combine(Select $select, $type = self::COMBINE_UNION, $modifier = return $this; } - /** - * @param string $part - * @return self Provides a fluent interface - * @throws Exception\InvalidArgumentException - */ - public function reset($part) : self + public function reset(string $part) : self { switch ($part) { case self::TABLE: @@ -434,11 +406,11 @@ public function reset($part) : self } /** - * @param $index - * @param $specification + * @param string $index + * @param array|string $specification * @return self Provides a fluent interface */ - public function setSpecification($index, $specification) : self + public function setSpecification(string $index, $specification) : self { if (! method_exists($this, 'process' . $index)) { throw new Exception\InvalidArgumentException('Not a valid specification name.'); @@ -447,7 +419,7 @@ public function setSpecification($index, $specification) : self return $this; } - public function getRawState($key = null) + public function getRawState(?string $key = null) { $rawState = [ self::TABLE => $this->table, @@ -477,8 +449,8 @@ public function isTableReadOnly() : bool protected function processStatementStart( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) : ?array { if ($this->combine !== []) { return ['(']; @@ -487,8 +459,8 @@ protected function processStatementStart( protected function processStatementEnd( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) : ?array { if ($this->combine !== []) { return [')']; @@ -505,8 +477,8 @@ protected function processStatementEnd( */ protected function processSelect( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) : ?array { $expr = 1; @@ -586,16 +558,16 @@ protected function processSelect( protected function processJoins( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { return $this->processJoin($this->joins, $platform, $driver, $parameterContainer); } protected function processWhere( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->where->count() == 0) { return; @@ -607,8 +579,8 @@ protected function processWhere( protected function processGroup( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->group === null) { return; @@ -632,8 +604,8 @@ protected function processGroup( protected function processHaving( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->having->count() == 0) { return; @@ -645,8 +617,8 @@ protected function processHaving( protected function processOrder( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) : ?array { if (empty($this->order)) { return null; @@ -678,8 +650,8 @@ protected function processOrder( protected function processLimit( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->limit === null) { return; @@ -694,8 +666,8 @@ protected function processLimit( protected function processOffset( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->offset === null) { return; @@ -711,8 +683,8 @@ protected function processOffset( protected function processCombine( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->combine == []) { return; @@ -729,14 +701,7 @@ protected function processCombine( ]; } - /** - * Variable overloading - * - * @param string $name - * @throws Exception\InvalidArgumentException - * @return mixed - */ - public function __get($name) + public function __get(string $name) { switch (strtolower($name)) { case 'where': @@ -750,13 +715,6 @@ public function __get($name) } } - /** - * __clone - * - * Resets the where object each time the Select is cloned. - * - * @return void - */ public function __clone() { $this->where = clone $this->where; @@ -770,14 +728,14 @@ public function __clone() * @param DriverInterface $driver * @param ParameterContainer $parameterContainer * - * @return mixed[] + * @return array */ protected function resolveTable( $table, PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null - ) : string { + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null + ) { $alias = null; if (is_array($table)) { diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 04193f9e27..4cc8a37556 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -78,6 +78,10 @@ public function getSqlPlatform() : Platform\Platform return $this->sqlPlatform; } + /** + * @param null|string|array|TableIdentifier $table + * @return Select + */ public function select($table = null) : Select { if ($this->table !== null && $table !== null) { @@ -89,6 +93,10 @@ public function select($table = null) : Select return new Select(($table) ?: $this->table); } + /** + * @param null|string|TableIdentifier $table + * @return Insert + */ public function insert($table = null) : Insert { if ($this->table !== null && $table !== null) { @@ -100,6 +108,10 @@ public function insert($table = null) : Insert return new Insert(($table) ?: $this->table); } + /** + * @param null|string|TableIdentifier $table + * @return Update + */ public function update($table = null) : Update { if ($this->table !== null && $table !== null) { @@ -111,6 +123,10 @@ public function update($table = null) : Update return new Update(($table) ?: $this->table); } + /** + * @param null|string|TableIdentifier $table + * @return Delete + */ public function delete($table = null) : Delete { if ($this->table !== null && $table !== null) { @@ -122,17 +138,10 @@ public function delete($table = null) : Delete return new Delete(($table) ?: $this->table); } - /** - * @param PreparableSqlInterface $sqlObject - * @param StatementInterface $statement - * @param AdapterInterface $adapter - * - * @return StatementInterface - */ public function prepareStatementForSqlObject( PreparableSqlInterface $sqlObject, - StatementInterface $statement = null, - AdapterInterface $adapter = null + ?StatementInterface $statement = null, + ?AdapterInterface $adapter = null ) : StatementInterface { $adapter = $adapter ?: $this->adapter; $statement = $statement ?: $adapter->getDriver()->createStatement(); @@ -156,15 +165,7 @@ public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterf return $this->sqlPlatform->setSubject($sqlObject)->getSqlString($platform); } - /** - * @param SqlInterface $sqlObject - * @param AdapterInterface $adapter - * - * @return string - * - * @throws Exception\InvalidArgumentException - */ - public function buildSqlString(SqlInterface $sqlObject, AdapterInterface $adapter = null) : string + public function buildSqlString(SqlInterface $sqlObject, ?AdapterInterface $adapter = null) : string { return $this ->sqlPlatform diff --git a/src/Sql/TableIdentifier.php b/src/Sql/TableIdentifier.php index 6d933767ff..eb04c513a6 100644 --- a/src/Sql/TableIdentifier.php +++ b/src/Sql/TableIdentifier.php @@ -61,7 +61,7 @@ public function __construct(string $table, ?string $schema = null) * * @deprecated please use the constructor and build a new {@see TableIdentifier} instead */ - public function setTable($table) : void + public function setTable(string $table) : void { $this->table = $table; } @@ -87,7 +87,7 @@ public function hasSchema() : bool * * @deprecated please use the constructor and build a new {@see TableIdentifier} instead */ - public function setSchema($schema) : void + public function setSchema(?string $schema) : void { $this->schema = $schema; } diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 1663745efc..cf016ac3cc 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -94,13 +94,13 @@ public function table($table) : self * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function set(array $values, $flag = self::VALUES_SET) : self + public function set(array $values, string $flag = self::VALUES_SET) : self { if ($values === null) { throw new Exception\InvalidArgumentException('set() expects an array of values'); } - if ($flag == self::VALUES_SET) { + if ($flag === self::VALUES_SET) { $this->set->clear(); } $priority = is_numeric($flag) ? $flag : 0; @@ -121,7 +121,7 @@ public function set(array $values, $flag = self::VALUES_SET) : self * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) : self + public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self { if ($predicate instanceof Where) { $this->where = $predicate; @@ -140,14 +140,14 @@ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND) * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ - public function join($name, $on, $type = Join::JOIN_INNER) : self + public function join($name, string $on, string $type = Join::JOIN_INNER) : self { $this->joins->join($name, $on, [], $type); return $this; } - public function getRawState($key = null) + public function getRawState(string $key = null) { $rawState = [ 'emptyWhereProtection' => $this->emptyWhereProtection, @@ -161,8 +161,8 @@ public function getRawState($key = null) protected function processUpdate( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { return sprintf( $this->specifications[static::SPECIFICATION_UPDATE], @@ -172,8 +172,8 @@ protected function processUpdate( protected function processSet( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { $setSql = []; $i = 0; @@ -216,8 +216,8 @@ protected function processSet( protected function processWhere( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { if ($this->where->count() == 0) { return; @@ -230,8 +230,8 @@ protected function processWhere( protected function processJoins( PlatformInterface $platform, - DriverInterface $driver = null, - ParameterContainer $parameterContainer = null + ?DriverInterface $driver = null, + ?ParameterContainer $parameterContainer = null ) { return $this->processJoin($this->joins, $platform, $driver, $parameterContainer); } @@ -244,9 +244,9 @@ protected function processJoins( * @param string $name * @return mixed */ - public function __get($name) + public function __get(string $name) { - if (strtolower($name) == 'where') { + if (strtolower($name) === 'where') { return $this->where; } } From 788d1bc3f77ac19376c81040e3ffe502d8116123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 21:51:41 +0100 Subject: [PATCH 14/45] Treat string class properties as not nullable where possible --- src/Sql/Ddl/Column/AbstractLengthColumn.php | 9 ++++++-- .../Ddl/Column/AbstractPrecisionColumn.php | 4 ++-- src/Sql/Ddl/Column/Column.php | 18 +++++---------- src/Sql/Ddl/Column/Float.php | 10 ++++----- src/Sql/Ddl/Constraint/AbstractConstraint.php | 11 +++------- src/Sql/Ddl/Constraint/Check.php | 4 ++-- src/Sql/Ddl/Constraint/ForeignKey.php | 2 +- src/Sql/Ddl/Index/Index.php | 6 ++--- src/Sql/Predicate/Predicate.php | 22 +++++++++---------- src/Sql/Predicate/PredicateSet.php | 4 ++-- 10 files changed, 41 insertions(+), 49 deletions(-) diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index 2157e8094d..d3c905fd65 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -19,8 +19,13 @@ abstract class AbstractLengthColumn extends Column * * @param int $length */ - public function __construct($name, $length = null, $nullable = false, $default = null, array $options = []) - { + public function __construct( + string $name = '', + ?int $length = null, + bool $nullable = false, + ?$default = null, + array $options = [] + ) { $this->setLength($length); parent::__construct($name, $nullable, $default, $options); diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index 3f6a67a6ac..3197b93cd5 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -21,8 +21,8 @@ abstract class AbstractPrecisionColumn extends AbstractLengthColumn * @param int|null $decimal */ public function __construct( - ?string $name, - int $digits = null, + string $name = '', + ?int $digits = null, ?int $decimal = null, bool $nullable = false, ?$default = null, diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 427483e857..18d76077b8 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -35,12 +35,12 @@ class Column implements ColumnInterface protected $type = 'INTEGER'; /** - * @param null|string $name + * @param string $name * @param bool $nullable * @param mixed|null $default * @param mixed[] $options */ - public function __construct(?string $name = null, bool $nullable = false, ?$default = null, array $options = []) + public function __construct(string $name = '', bool $nullable = false, ?$default = null, array $options = []) { $this->setName($name); $this->setNullable($nullable); @@ -48,22 +48,14 @@ public function __construct(?string $name = null, bool $nullable = false, ?$defa $this->setOptions($options); } - /** - * @param string $name - * - * @return self Provides a fluent interface - */ - public function setName($name) : self + public function setName(string $name) : self { - $this->name = (string) $name; + $this->name = $name; return $this; } - /** - * @return null|string - */ - public function getName() : ?string + public function getName() : string { return $this->name; } diff --git a/src/Sql/Ddl/Column/Float.php b/src/Sql/Ddl/Column/Float.php index ba2b63676a..d31224905b 100644 --- a/src/Sql/Ddl/Column/Float.php +++ b/src/Sql/Ddl/Column/Float.php @@ -27,11 +27,11 @@ class Float extends Floating * Raises a deprecation notice. */ public function __construct( - $name, - $digits = null, - $decimal = null, - $nullable = false, - $default = null, + string $name = '', + ?int $digits = null, + ?int $decimal = null, + bool $nullable = false, + ?$default = null, array $options = [] ) { trigger_error( diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index bc7637693d..a382262fad 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -28,9 +28,9 @@ abstract class AbstractConstraint implements ConstraintInterface /** * @param null|string|array $columns - * @param null|string $name + * @param string $name */ - public function __construct($columns = null, ?string $name = null) + public function __construct($columns = null, string $name = '') { if ($columns) { $this->setColumns($columns); @@ -39,14 +39,9 @@ public function __construct($columns = null, ?string $name = null) $this->setName($name); } - /** - * @param string $name - * - * @return self Provides a fluent interface - */ public function setName(string $name) : self { - $this->name = (string) $name; + $this->name = $name; return $this; } diff --git a/src/Sql/Ddl/Constraint/Check.php b/src/Sql/Ddl/Constraint/Check.php index e5f50a38de..cefc948f14 100644 --- a/src/Sql/Ddl/Constraint/Check.php +++ b/src/Sql/Ddl/Constraint/Check.php @@ -23,9 +23,9 @@ class Check extends AbstractConstraint /** * @param string|ExpressionInterface $expression - * @param null|string $name + * @param string $name */ - public function __construct($expression, ?string $name) + public function __construct($expression, string $name = '') { $this->expression = $expression; $this->name = $name; diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index d3f94744fc..26928cd030 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -43,7 +43,7 @@ class ForeignKey extends AbstractConstraint * @param null|string $onUpdateRule */ public function __construct( - ?string $name, + string $name, ?$columns, string $referenceTable, ?$referenceColumn, diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index 4f45f8f1bc..54e5f567a1 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -17,14 +17,14 @@ class Index extends AbstractIndex /** * @param string|array|null $columns - * @param null|string $name + * @param string $name * @param array $lengths */ - public function __construct($columns, $name = null, array $lengths = []) + public function __construct($columns, string $name = '', array $lengths = []) { $this->setColumns($columns); - $this->name = null === $name ? null : (string) $name; + $this->setName($name); $this->lengths = $lengths; } diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index a123e14b4f..69ad74417e 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -81,7 +81,7 @@ public function unnest() : Predicate */ public function equalTo( $left, $right, - ?string $leftType = self::TYPE_IDENTIFIER, + string $leftType = self::TYPE_IDENTIFIER, ?string$rightType = self::TYPE_VALUE ) : self { $this->addPredicate( @@ -108,8 +108,8 @@ public function equalTo( public function notEqualTo( $left, $right, - ?string $leftType = self::TYPE_IDENTIFIER, - ?string $rightType = self::TYPE_VALUE + string $leftType = self::TYPE_IDENTIFIER, + string $rightType = self::TYPE_VALUE ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_NOT_EQUAL_TO, $right, $leftType, $rightType), @@ -135,8 +135,8 @@ public function notEqualTo( public function lessThan( $left, $right, - ?string $leftType = self::TYPE_IDENTIFIER, - ?string $rightType = self::TYPE_VALUE + string $leftType = self::TYPE_IDENTIFIER, + string $rightType = self::TYPE_VALUE ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_LESS_THAN, $right, $leftType, $rightType), @@ -162,8 +162,8 @@ public function lessThan( public function greaterThan( $left, $right, - ?string $leftType = self::TYPE_IDENTIFIER, - ?string $rightType = self::TYPE_VALUE + string $leftType = self::TYPE_IDENTIFIER, + string $rightType = self::TYPE_VALUE ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_GREATER_THAN, $right, $leftType, $rightType), @@ -189,8 +189,8 @@ public function greaterThan( public function lessThanOrEqualTo( $left, $right, - ?string $leftType = self::TYPE_IDENTIFIER, - ?string $rightType = self::TYPE_VALUE + string $leftType = self::TYPE_IDENTIFIER, + string $rightType = self::TYPE_VALUE ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_LESS_THAN_OR_EQUAL_TO, $right, $leftType, $rightType), @@ -216,8 +216,8 @@ public function lessThanOrEqualTo( public function greaterThanOrEqualTo( $left, $right, - ?string $leftType = self::TYPE_IDENTIFIER, - ?string $rightType = self::TYPE_VALUE + string $leftType = self::TYPE_IDENTIFIER, + string $rightType = self::TYPE_VALUE ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $right, $leftType, $rightType), diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index 41ddd3568c..63393082dd 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -29,7 +29,7 @@ class PredicateSet implements PredicateInterface, Countable * @param null|array $predicates * @param string $defaultCombination */ - public function __construct(array $predicates = null, ?string $defaultCombination = self::COMBINED_BY_AND) + public function __construct(array $predicates = null, string $defaultCombination = self::COMBINED_BY_AND) { $this->defaultCombination = $defaultCombination; @@ -75,7 +75,7 @@ public function addPredicate(PredicateInterface $predicate, ?string $combination * * @throws Exception\InvalidArgumentException */ - public function addPredicates($predicates, ?string $combination = self::OP_AND) : self + public function addPredicates($predicates, string $combination = self::OP_AND) : self { if ($predicates === null) { throw new Exception\InvalidArgumentException('Predicate cannot be null'); From f97e6f70ceca22a984bd8826a5504ef9139fb3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 21:53:24 +0100 Subject: [PATCH 15/45] Comment tags @param, @throws and @return should not be aligned or contain multiple spaces between the tag, type and description --- src/Sql/Ddl/AlterTable.php | 16 ++-- src/Sql/Ddl/Column/AbstractLengthColumn.php | 2 +- .../Ddl/Column/AbstractPrecisionColumn.php | 2 +- src/Sql/Ddl/Column/Column.php | 10 +-- src/Sql/Ddl/Constraint/AbstractConstraint.php | 4 +- src/Sql/Ddl/Constraint/Check.php | 4 +- src/Sql/Ddl/Constraint/ForeignKey.php | 8 +- src/Sql/Ddl/CreateTable.php | 10 +-- src/Sql/Ddl/Index/Index.php | 4 +- src/Sql/Delete.php | 8 +- src/Sql/Insert.php | 10 +-- src/Sql/Platform/IbmDb2/SelectDecorator.php | 10 +-- src/Sql/Predicate/Between.php | 14 +-- src/Sql/Predicate/In.php | 4 +- src/Sql/Predicate/IsNull.php | 6 +- src/Sql/Predicate/Like.php | 6 +- src/Sql/Predicate/Operator.php | 10 +-- src/Sql/Predicate/Predicate.php | 88 +++++++++---------- src/Sql/Predicate/PredicateSet.php | 12 +-- src/Sql/Select.php | 24 ++--- src/Sql/Update.php | 20 ++--- 21 files changed, 136 insertions(+), 136 deletions(-) diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index b9d6788b0c..d4109c35c9 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -84,7 +84,7 @@ public function __construct($table = '') } /** - * @param string $name + * @param string $name * * @return self Provides a fluent interface */ @@ -96,7 +96,7 @@ public function setTable(string $name) : self } /** - * @param ColumnInterface $column + * @param ColumnInterface $column * * @return self Provides a fluent interface */ @@ -108,8 +108,8 @@ public function addColumn(ColumnInterface $column) : self } /** - * @param string $name - * @param ColumnInterface $column + * @param string $name + * @param ColumnInterface $column * * @return self Provides a fluent interface */ @@ -121,7 +121,7 @@ public function changeColumn(string $name, ColumnInterface $column) : self } /** - * @param string $name + * @param string $name * * @return self Provides a fluent interface */ @@ -133,7 +133,7 @@ public function dropColumn(string $name) : self } /** - * @param string $name + * @param string $name * * @return self Provides a fluent interface */ @@ -145,7 +145,7 @@ public function dropConstraint(string $name) : self } /** - * @param ConstraintInterface $constraint + * @param ConstraintInterface $constraint * * @return self Provides a fluent interface */ @@ -157,7 +157,7 @@ public function addConstraint(ConstraintInterface $constraint) : self } /** - * @param string|null $key + * @param string|null $key * @return array */ public function getRawState(?string $key = null) : array diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index d3c905fd65..d4d66e7203 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -32,7 +32,7 @@ public function __construct( } /** - * @param int $length + * @param int $length * @return self Provides a fluent interface */ public function setLength(int $length) : self diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index 3197b93cd5..977de61043 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -34,7 +34,7 @@ public function __construct( } /** - * @param int $digits + * @param int $digits * * @return self */ diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 18d76077b8..1799186c84 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -61,7 +61,7 @@ public function getName() : string } /** - * @param bool $nullable + * @param bool $nullable * @return self Provides a fluent interface */ public function setNullable(bool $nullable) : self @@ -80,7 +80,7 @@ public function isNullable() : bool } /** - * @param null|string|int $default + * @param null|string|int $default * * @return self Provides a fluent interface */ @@ -100,7 +100,7 @@ public function getDefault() } /** - * @param array $options + * @param array $options * * @return self Provides a fluent interface */ @@ -112,8 +112,8 @@ public function setOptions(array $options) : self } /** - * @param string $name - * @param string $value + * @param string $name + * @param string $value * * @return self Provides a fluent interface */ diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index a382262fad..6f873c4008 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -55,7 +55,7 @@ public function getName() : string } /** - * @param null|string|array $columns + * @param null|string|array $columns * * @return self Provides a fluent interface */ @@ -67,7 +67,7 @@ public function setColumns(?$columns) : self } /** - * @param string $column + * @param string $column * * @return self Provides a fluent interface */ diff --git a/src/Sql/Ddl/Constraint/Check.php b/src/Sql/Ddl/Constraint/Check.php index cefc948f14..1ab554dde6 100644 --- a/src/Sql/Ddl/Constraint/Check.php +++ b/src/Sql/Ddl/Constraint/Check.php @@ -22,8 +22,8 @@ class Check extends AbstractConstraint protected $specification = 'CHECK (%s)'; /** - * @param string|ExpressionInterface $expression - * @param string $name + * @param string|ExpressionInterface $expression + * @param string $name */ public function __construct($expression, string $name = '') { diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index 26928cd030..6d4eb60b09 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -65,7 +65,7 @@ public function __construct( } /** - * @param string $referenceTable + * @param string $referenceTable * * @return self Provides a fluent interface */ @@ -85,7 +85,7 @@ public function getReferenceTable() : string } /** - * @param null|string|array $referenceColumn + * @param null|string|array $referenceColumn * @return self Provides a fluent interface */ public function setReferenceColumn(?$referenceColumn) : self @@ -104,7 +104,7 @@ public function getReferenceColumn() : array } /** - * @param string $onDeleteRule + * @param string $onDeleteRule * @return self Provides a fluent interface */ public function setOnDeleteRule(string $onDeleteRule) : self @@ -123,7 +123,7 @@ public function getOnDeleteRule() : string } /** - * @param string $onUpdateRule + * @param string $onUpdateRule * @return self Provides a fluent interface */ public function setOnUpdateRule(string $onUpdateRule) : self diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index 786e0b18fe..0c87c77d89 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -63,7 +63,7 @@ public function __construct($table = '', bool $isTemporary = false) } /** - * @param bool $temporary + * @param bool $temporary * * @return self Provides a fluent interface */ @@ -83,7 +83,7 @@ public function isTemporary() : bool } /** - * @param string $name + * @param string $name * @return self Provides a fluent interface */ public function setTable(string $name) : self @@ -94,7 +94,7 @@ public function setTable(string $name) : self } /** - * @param ColumnInterface $column + * @param ColumnInterface $column * @return self Provides a fluent interface */ public function addColumn(ColumnInterface $column) : self @@ -105,7 +105,7 @@ public function addColumn(ColumnInterface $column) : self } /** - * @param ConstraintInterface $constraint + * @param ConstraintInterface $constraint * @return self Provides a fluent interface */ public function addConstraint(ConstraintInterface $constraint) : self @@ -116,7 +116,7 @@ public function addConstraint(ConstraintInterface $constraint) : self } /** - * @param string|null $key + * @param string|null $key * * @return array */ diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index 54e5f567a1..ba49e3f66c 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -16,8 +16,8 @@ class Index extends AbstractIndex protected $lengths; /** - * @param string|array|null $columns - * @param string $name + * @param string|array|null $columns + * @param string $name * @param array $lengths */ public function __construct($columns, string $name = '', array $lengths = []) diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 5312eaaba5..59a4c18b2b 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -48,7 +48,7 @@ class Delete extends AbstractPreparableSql /** * Constructor * - * @param null|string|TableIdentifier $table + * @param null|string|TableIdentifier $table */ public function __construct($table = null) { @@ -61,7 +61,7 @@ public function __construct($table = null) /** * Create from statement * - * @param string|TableIdentifier $table + * @param string|TableIdentifier $table * * @return self Provides a fluent interface */ @@ -87,8 +87,8 @@ public function getRawState(?string $key = null) /** * Create where clause * - * @param Where|\Closure|string|array $predicate - * @param string $combination One of the OP_* constants from Predicate\PredicateSet + * @param Where|\Closure|string|array $predicate + * @param string $combination One of the OP_* constants from Predicate\PredicateSet * * @return self Provides a fluent interface */ diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index e51bcdbe93..9fac19ccbe 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -43,7 +43,7 @@ class Insert extends AbstractPreparableSql /** * Constructor * - * @param null|string|TableIdentifier $table + * @param null|string|TableIdentifier $table */ public function __construct($table = null) { @@ -55,7 +55,7 @@ public function __construct($table = null) /** * Create INTO clause * - * @param string|TableIdentifier $table + * @param string|TableIdentifier $table * @return self Provides a fluent interface */ public function into($table) : self @@ -67,7 +67,7 @@ public function into($table) : self /** * Specify columns * - * @param array $columns + * @param array $columns * @return self Provides a fluent interface */ public function columns(array $columns) : self @@ -79,8 +79,8 @@ public function columns(array $columns) : self /** * Specify values to insert * - * @param array|Select $values - * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET + * @param array|Select $values + * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 3861f46e86..ec9687842d 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -93,11 +93,11 @@ protected function localizeVariables() : void } /** - * @param PlatformInterface $platform - * @param DriverInterface $driver - * @param ParameterContainer $parameterContainer - * @param array $sqls - * @param array $parameters + * @param PlatformInterface $platform + * @param DriverInterface $driver + * @param ParameterContainer $parameterContainer + * @param array $sqls + * @param array $parameters */ protected function processLimitOffset( PlatformInterface $platform, diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index 2c198318e7..588bbced48 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -21,9 +21,9 @@ class Between extends AbstractExpression implements PredicateInterface /** * Constructor * - * @param string $identifier - * @param int|float|string $minValue - * @param int|float|string $maxValue + * @param string $identifier + * @param int|float|string $minValue + * @param int|float|string $maxValue */ public function __construct(string $identifier = null, $minValue = null, $maxValue = null) { @@ -43,7 +43,7 @@ public function __construct(string $identifier = null, $minValue = null, $maxVal /** * Set identifier for comparison * - * @param string $identifier + * @param string $identifier * * @return self Provides a fluent interface */ @@ -67,7 +67,7 @@ public function getIdentifier() : ?string /** * Set minimum boundary for comparison * - * @param int|float|string $minValue + * @param int|float|string $minValue * * @return self Provides a fluent interface */ @@ -91,7 +91,7 @@ public function getMinValue() /** * Set maximum boundary for comparison * - * @param int|float|string $maxValue + * @param int|float|string $maxValue * * @return self Provides a fluent interface */ @@ -115,7 +115,7 @@ public function getMaxValue() /** * Set specification string to use in forming SQL predicate * - * @param string $specification + * @param string $specification * * @return self Provides a fluent interface */ diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index c4b6f58f0a..658cf6e835 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -42,7 +42,7 @@ public function __construct($identifier = null, $valueSet = null) /** * Set identifier for comparison * - * @param string|array $identifier + * @param string|array $identifier * * @return self Provides a fluent interface */ @@ -66,7 +66,7 @@ public function getIdentifier() /** * Set set of values for IN comparison * - * @param array|Select $valueSet + * @param array|Select $valueSet * * @return self Provides a fluent interface * diff --git a/src/Sql/Predicate/IsNull.php b/src/Sql/Predicate/IsNull.php index a540ec7516..55304a3b93 100644 --- a/src/Sql/Predicate/IsNull.php +++ b/src/Sql/Predicate/IsNull.php @@ -22,7 +22,7 @@ class IsNull extends AbstractExpression implements PredicateInterface /** * Constructor * - * @param string $identifier + * @param string $identifier */ public function __construct(string $identifier = null) { @@ -34,7 +34,7 @@ public function __construct(string $identifier = null) /** * Set identifier for comparison * - * @param string $identifier + * @param string $identifier * * @return self Provides a fluent interface */ @@ -58,7 +58,7 @@ public function getIdentifier() : ?string /** * Set specification string to use in forming SQL predicate * - * @param string $specification + * @param string $specification * * @return self Provides a fluent interface */ diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index 85225def9c..5b1936d96b 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -37,7 +37,7 @@ public function __construct($identifier = null, $like = null) } /** - * @param string $identifier + * @param string $identifier * * @return self Provides a fluent interface */ @@ -57,7 +57,7 @@ public function getIdentifier() : string } /** - * @param string $like + * @param string $like * * @return self Provides a fluent interface */ @@ -77,7 +77,7 @@ public function getLike() : string } /** - * @param string $specification + * @param string $specification * * @return self Provides a fluent interface */ diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 54adcc0480..f8b3059854 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -97,7 +97,7 @@ public function __construct( /** * Set left side of operator * - * @param int|float|bool|string $left + * @param int|float|bool|string $left * * @return self Provides a fluent interface */ @@ -126,7 +126,7 @@ public function getLeft() /** * Set parameter type for left side of operator * - * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} + * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} * * @return self Provides a fluent interface * @@ -161,7 +161,7 @@ public function getLeftType() : string /** * Set operator string * - * @param string $operator + * @param string $operator * @return self Provides a fluent interface */ public function setOperator($operator) : self @@ -184,7 +184,7 @@ public function getOperator() : string /** * Set right side of operator * - * @param int|float|bool|string $right + * @param int|float|bool|string $right * * @return self Provides a fluent interface */ @@ -213,7 +213,7 @@ public function getRight() /** * Set parameter type for right side of operator * - * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} + * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} * * @return self Provides a fluent interface * diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index 69ad74417e..b11e07cd7d 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -40,7 +40,7 @@ public function nest() : Predicate /** * Indicate what predicate will be unnested * - * @param Predicate $predicate + * @param Predicate $predicate * * @return void */ @@ -72,10 +72,10 @@ public function unnest() : Predicate * * Utilizes Operator predicate * - * @param int|float|bool|string $left - * @param int|float|bool|string $right - * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} - * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * @param int|float|bool|string $left + * @param int|float|bool|string $right + * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} + * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} * * @return self Provides a fluent interface */ @@ -98,10 +98,10 @@ public function equalTo( * * Utilizes Operator predicate * - * @param int|float|bool|string $left - * @param int|float|bool|string $right - * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} - * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * @param int|float|bool|string $left + * @param int|float|bool|string $right + * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} + * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} * * @return self Provides a fluent interface */ @@ -125,10 +125,10 @@ public function notEqualTo( * * Utilizes Operator predicate * - * @param int|float|bool|string $left - * @param int|float|bool|string $right - * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} - * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * @param int|float|bool|string $left + * @param int|float|bool|string $right + * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} + * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} * * @return self Provides a fluent interface */ @@ -152,10 +152,10 @@ public function lessThan( * * Utilizes Operator predicate * - * @param int|float|bool|string $left - * @param int|float|bool|string $right - * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} - * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * @param int|float|bool|string $left + * @param int|float|bool|string $right + * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} + * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} * * @return self Provides a fluent interface */ @@ -179,10 +179,10 @@ public function greaterThan( * * Utilizes Operator predicate * - * @param int|float|bool|string $left - * @param int|float|bool|string $right - * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} - * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * @param int|float|bool|string $left + * @param int|float|bool|string $right + * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} + * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} * * @return self Provides a fluent interface */ @@ -206,10 +206,10 @@ public function lessThanOrEqualTo( * * Utilizes Operator predicate * - * @param int|float|bool|string $left - * @param int|float|bool|string $right - * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} - * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} + * @param int|float|bool|string $left + * @param int|float|bool|string $right + * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} + * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} * * @return self Provides a fluent interface */ @@ -233,8 +233,8 @@ public function greaterThanOrEqualTo( * * Utilizes Like predicate * - * @param string|Expression $identifier - * @param string $like + * @param string|Expression $identifier + * @param string $like * * @return self Provides a fluent interface */ @@ -254,8 +254,8 @@ public function like($identifier, string $like) : self * * Utilizes In predicate * - * @param string|Expression $identifier - * @param string $notLike + * @param string|Expression $identifier + * @param string $notLike * * @return self Provides a fluent interface */ @@ -296,7 +296,7 @@ public function expression($expression, $parameters = null) : self * * Literal predicate, for parameters, use expression() * - * @param string $literal + * @param string $literal * * @return self Provides a fluent interface */ @@ -328,7 +328,7 @@ public function literal(string $literal) : self * * Utilizes IsNull predicate * - * @param string|Expression $identifier + * @param string|Expression $identifier * * @return self Provides a fluent interface */ @@ -349,7 +349,7 @@ public function isNull($identifier) : self * * Utilizes IsNotNull predicate * - * @param string|Expression $identifier + * @param string|Expression $identifier * * @return self Provides a fluent interface */ @@ -370,8 +370,8 @@ public function isNotNull($identifier) : self * * Utilizes In predicate * - * @param string|Expression $identifier - * @param array|Select $valueSet + * @param string|Expression $identifier + * @param array|Select $valueSet * * @return self Provides a fluent interface */ @@ -392,8 +392,8 @@ public function in($identifier, $valueSet = null) : self * * Utilizes NotIn predicate * - * @param string|Expression $identifier - * @param array|Select $valueSet + * @param string|Expression $identifier + * @param array|Select $valueSet * * @return self Provides a fluent interface */ @@ -413,9 +413,9 @@ public function notIn($identifier, $valueSet = null) : self * * Utilizes Between predicate * - * @param string|Expression $identifier - * @param int|float|string $minValue - * @param int|float|string $maxValue + * @param string|Expression $identifier + * @param int|float|string $minValue + * @param int|float|string $maxValue * * @return self Provides a fluent interface */ @@ -436,9 +436,9 @@ public function between($identifier, $minValue, $maxValue) : self * * Utilizes NotBetween predicate * - * @param string|Expression $identifier - * @param int|float|string $minValue - * @param int|float|string $maxValue + * @param string|Expression $identifier + * @param int|float|string $minValue + * @param int|float|string $maxValue * * @return self Provides a fluent interface */ @@ -461,7 +461,7 @@ public function notBetween($identifier, $minValue, $maxValue) : self * AND / OR combination operator, thus allowing generic predicates to be * used fluently within where chains as any other concrete predicate. * - * @param PredicateInterface $predicate + * @param PredicateInterface $predicate * * @return self Provides a fluent interface */ @@ -481,7 +481,7 @@ public function predicate(PredicateInterface $predicate) : self * * Overloads "or", "and", "nest", and "unnest" * - * @param string $name + * @param string $name * * @return self Provides a fluent interface */ diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index 63393082dd..aba5dfc343 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -26,8 +26,8 @@ class PredicateSet implements PredicateInterface, Countable /** * Constructor * - * @param null|array $predicates - * @param string $defaultCombination + * @param null|array $predicates + * @param string $defaultCombination */ public function __construct(array $predicates = null, string $defaultCombination = self::COMBINED_BY_AND) { @@ -43,8 +43,8 @@ public function __construct(array $predicates = null, string $defaultCombination /** * Add predicate to set * - * @param PredicateInterface $predicate - * @param string $combination + * @param PredicateInterface $predicate + * @param string $combination * * @return self Provides a fluent interface */ @@ -154,7 +154,7 @@ public function getPredicates() : array /** * Add predicate using OR operator * - * @param PredicateInterface $predicate + * @param PredicateInterface $predicate * * @return self Provides a fluent interface */ @@ -168,7 +168,7 @@ public function orPredicate(PredicateInterface $predicate) : self /** * Add predicate using AND operator * - * @param PredicateInterface $predicate + * @param PredicateInterface $predicate * * @return self Provides a fluent interface */ diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 74d90fdf36..fa68fbbc4c 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -143,7 +143,7 @@ class Select extends AbstractPreparableSql /** * Constructor * - * @param null|string|array|TableIdentifier $table + * @param null|string|array|TableIdentifier $table */ public function __construct($table = null) { @@ -160,7 +160,7 @@ public function __construct($table = null) /** * Create from clause * - * @param string|array|TableIdentifier $table + * @param string|array|TableIdentifier $table * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ @@ -219,8 +219,8 @@ public function quantifier($quantifier) : self * key string will be use as alias, * value can be string or Expression objects * - * @param array $columns - * @param bool $prefixColumnsWithTable + * @param array $columns + * @param bool $prefixColumnsWithTable * @return self Provides a fluent interface */ public function columns(array $columns, bool $prefixColumnsWithTable = true) : self @@ -233,10 +233,10 @@ public function columns(array $columns, bool $prefixColumnsWithTable = true) : s /** * Create join clause * - * @param string|array|TableIdentifier $name - * @param string|Predicate\Expression $on - * @param string|array $columns - * @param string $type one of the JOIN_* constants + * @param string|array|TableIdentifier $name + * @param string|Predicate\Expression $on + * @param string|array $columns + * @param string $type one of the JOIN_* constants * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ @@ -250,8 +250,8 @@ public function join($name, $on, $columns = self::SQL_STAR, string $type = self: /** * Create where clause * - * @param Where|\Closure|string|array|Predicate\PredicateInterface $predicate - * @param string $combination One of the OP_* constants from Predicate\PredicateSet + * @param Where|\Closure|string|array|Predicate\PredicateInterface $predicate + * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ @@ -284,8 +284,8 @@ public function group($group) : self /** * Create having clause * - * @param Where|\Closure|string|array $predicate - * @param string $combination One of the OP_* constants from Predicate\PredicateSet + * @param Where|\Closure|string|array $predicate + * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return self Provides a fluent interface */ public function having($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self diff --git a/src/Sql/Update.php b/src/Sql/Update.php index cf016ac3cc..cb8fec383b 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -61,7 +61,7 @@ class Update extends AbstractPreparableSql /** * Constructor * - * @param null|string|TableIdentifier $table + * @param null|string|TableIdentifier $table */ public function __construct($table = null) { @@ -77,7 +77,7 @@ public function __construct($table = null) /** * Specify table for statement * - * @param string|TableIdentifier $table + * @param string|TableIdentifier $table * @return self Provides a fluent interface */ public function table($table) : self @@ -89,8 +89,8 @@ public function table($table) : self /** * Set key/value pairs to update * - * @param array $values Associative array of key values - * @param string $flag One of the VALUES_* constants + * @param array $values Associative array of key values + * @param string $flag One of the VALUES_* constants * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ @@ -116,8 +116,8 @@ public function set(array $values, string $flag = self::VALUES_SET) : self /** * Create where clause * - * @param Where|\Closure|string|array $predicate - * @param string $combination One of the OP_* constants from Predicate\PredicateSet + * @param Where|\Closure|string|array $predicate + * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ @@ -134,9 +134,9 @@ public function where($predicate, string $combination = Predicate\PredicateSet:: /** * Create join clause * - * @param string|array $name - * @param string $on - * @param string $type one of the JOIN_* constants + * @param string|array $name + * @param string $on + * @param string $type one of the JOIN_* constants * @return self Provides a fluent interface * @throws Exception\InvalidArgumentException */ @@ -241,7 +241,7 @@ protected function processJoins( * * Proxies to "where" only * - * @param string $name + * @param string $name * @return mixed */ public function __get(string $name) From 956544254127503c1dcce82ec08eb5410787ce86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 21:57:06 +0100 Subject: [PATCH 16/45] Revert short list syntax where incompatible --- src/Sql/Predicate/In.php | 2 +- src/Sql/Predicate/Operator.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index 658cf6e835..8d979beea2 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -126,7 +126,7 @@ public function getExpressionData() : array $types[] = self::TYPE_VALUE; } else { foreach ($values as $argument) { - [$replacements[], $types[]] = $this->normalizeArgument($argument, self::TYPE_VALUE); + list($replacements[], $types[]) = $this->normalizeArgument($argument, self::TYPE_VALUE); } $countValues = count($values); $valuePlaceholders = $countValues > 0 ? array_fill(0, $countValues, '%s') : []; diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index f8b3059854..584438827e 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -252,8 +252,8 @@ public function getRightType() : string */ public function getExpressionData() : array { - [$values[], $types[]] = $this->normalizeArgument($this->left, $this->leftType); - [$values[], $types[]] = $this->normalizeArgument($this->right, $this->rightType); + list($values[], $types[]) = $this->normalizeArgument($this->left, $this->leftType); + list($values[], $types[]) = $this->normalizeArgument($this->right, $this->rightType); return [[ '%s ' . $this->operator . ' %s', From 9af735e0d84e926e864246c6ba551e7a601f1ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 21:58:20 +0100 Subject: [PATCH 17/45] Ignore IDE files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 245087af8a..c305605c0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ /clover.xml /coveralls-upload.json /docs/html/ From e057005a4a12155afbbe6009b258ce881e8eedc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:08:15 +0100 Subject: [PATCH 18/45] Ensure declarations are compatible with super, noted where type hints are impossible in current implementation --- 3.0.0.md | 8 ++++++++ src/Sql/AbstractSql.php | 4 ++-- src/Sql/Ddl/Column/Boolean.php | 5 +---- src/Sql/Ddl/Column/Column.php | 2 +- src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php | 2 +- src/Sql/Platform/Sqlite/SelectDecorator.php | 14 ++++---------- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/3.0.0.md b/3.0.0.md index b1c3abfb90..fd56b6c77e 100644 --- a/3.0.0.md +++ b/3.0.0.md @@ -28,3 +28,11 @@ Changed `setDriver(DriverInterface $driver)` for all the following platforms: - Zend\Db\Adapter\Platform\Postgresql - Zend\Db\Adapter\Platform\Sqlite - Zend\Db\Adapter\Platform\SqlServer + +- Zend\Db\Sql\Platform\PlatformDecoratorInterface + +`setSubject()` cannot be type hinted, since implementations use various types + +- Zend\Db\Sql\AbstractSql + +`Zend\Db\Sql\Select::resolveTable()` returns an array where as its parent returns a string diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index d495dfdec3..0690900182 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -54,7 +54,7 @@ protected function buildSqlString( PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null - ) : string { + ) : ?string { $this->localizeVariables(); $sqls = []; @@ -445,7 +445,7 @@ protected function resolveTable( PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null - ) : string { + ) { $schema = null; if ($table instanceof TableIdentifier) { diff --git a/src/Sql/Ddl/Column/Boolean.php b/src/Sql/Ddl/Column/Boolean.php index 4c95a5ae1e..1464f06349 100644 --- a/src/Sql/Ddl/Column/Boolean.php +++ b/src/Sql/Ddl/Column/Boolean.php @@ -14,10 +14,7 @@ class Boolean extends Column /** @var string */ protected $type = 'BOOLEAN'; - /** - * {@inheritDoc} - */ - public function setNullable($nullable) : self + public function setNullable(bool $nullable) : self { return parent::setNullable(false); } diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 1799186c84..5536ddf0bc 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -66,7 +66,7 @@ public function getName() : string */ public function setNullable(bool $nullable) : self { - $this->isNullable = (bool) $nullable; + $this->isNullable = $nullable; return $this; } diff --git a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php index 908d993570..db6a1d2c9a 100644 --- a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -46,7 +46,7 @@ class AlterTableDecorator extends AlterTable implements PlatformDecoratorInterfa * * @return self Provides a fluent interface */ - public function setSubject(AlterTable $subject) : self + public function setSubject($subject) : self { $this->subject = $subject; diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index 7f10910736..0a36f15c76 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -43,15 +43,12 @@ protected function localizeVariables() : void $this->specifications[self::COMBINE] = '%1$s %2$s'; } - /** - * {@inheritDoc} - */ protected function processStatementStart( PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null - ) { - return ''; + ) : array { + return []; } protected function processLimit( @@ -91,14 +88,11 @@ protected function processOffset( return [$this->offset]; } - /** - * {@inheritDoc} - */ protected function processStatementEnd( PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null - ) { - return ''; + ) : array { + return []; } } From 2c385f70939c41d0c56bac2dd0e250defbba1b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:09:12 +0100 Subject: [PATCH 19/45] Updated return type in DocBlock --- src/Sql/Platform/SqlServer/SelectDecorator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index 844528423f..85622dacfb 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -43,7 +43,7 @@ protected function localizeVariables() : void * @param $sqls * @param $parameters * - * @return null + * @return void */ protected function processLimitOffset( PlatformInterface $platform, From c2ab9c34634d1bc9668a0b6885e6c8eba62ef93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:10:55 +0100 Subject: [PATCH 20/45] Fixed case mismatch --- src/Sql/AbstractSql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 0690900182..638e0e43f7 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -453,7 +453,7 @@ protected function resolveTable( } if ($table instanceof Select) { - $table = '(' . $this->processSubselect($table, $platform, $driver, $parameterContainer) . ')'; + $table = '(' . $this->processSubSelect($table, $platform, $driver, $parameterContainer) . ')'; } elseif ($table) { $table = $platform->quoteIdentifier($table); } From 0f8f3f4864f57ae7e730c47849aa18810754ba6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:11:59 +0100 Subject: [PATCH 21/45] Use self class referencing --- src/Sql/Join.php | 2 +- src/Sql/Predicate/Predicate.php | 2 +- src/Sql/Predicate/PredicateSet.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Sql/Join.php b/src/Sql/Join.php index 27640fce8a..e3a03fa008 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -96,7 +96,7 @@ public function join($name, $on, $columns = [Select::SQL_STAR], string $type = J 'name' => $name, 'on' => $on, 'columns' => $columns, - 'type' => $type ? $type : Join::JOIN_INNER + 'type' => $type ? $type : self::JOIN_INNER ]; return $this; diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index b11e07cd7d..7669de776e 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -30,7 +30,7 @@ class Predicate extends PredicateSet */ public function nest() : Predicate { - $predicateSet = new Predicate(); + $predicateSet = new self(); $predicateSet->setUnnest($this); $this->addPredicate($predicateSet, ($this->nextPredicateCombineOperator) ?: $this->defaultCombination); $this->nextPredicateCombineOperator = null; diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index aba5dfc343..cb1517fd9c 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -191,13 +191,13 @@ public function getExpressionData() : array /** @var $predicate PredicateInterface */ $predicate = $this->predicates[$i][1]; - if ($predicate instanceof PredicateSet) { + if ($predicate instanceof self) { $parts[] = '('; } $parts = array_merge($parts, $predicate->getExpressionData()); - if ($predicate instanceof PredicateSet) { + if ($predicate instanceof self) { $parts[] = ')'; } From f4feef2cdb09f88deb8c3021c2fa8df7313d13e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:12:56 +0100 Subject: [PATCH 22/45] Use single quotes --- src/Sql/Ddl/AlterTable.php | 20 ++++++++++---------- src/Sql/Ddl/CreateTable.php | 2 +- src/Sql/Insert.php | 2 +- src/Sql/Platform/IbmDb2/SelectDecorator.php | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index d4109c35c9..e45f1a62f2 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -46,28 +46,28 @@ class AlterTable extends AbstractSql implements SqlInterface protected $specifications = [ self::TABLE => "ALTER TABLE %1\$s\n", self::ADD_COLUMNS => [ - "%1\$s" => [ - [1 => "ADD COLUMN %1\$s,\n", 'combinedby' => ""] + '%1$s' => [ + [1 => "ADD COLUMN %1\$s,\n", 'combinedby' => ''] ] ], self::CHANGE_COLUMNS => [ - "%1\$s" => [ - [2 => "CHANGE COLUMN %1\$s %2\$s,\n", 'combinedby' => ""], + '%1$s' => [ + [2 => "CHANGE COLUMN %1\$s %2\$s,\n", 'combinedby' => ''], ] ], self::DROP_COLUMNS => [ - "%1\$s" => [ - [1 => "DROP COLUMN %1\$s,\n", 'combinedby' => ""], + '%1$s' => [ + [1 => "DROP COLUMN %1\$s,\n", 'combinedby' => ''], ] ], self::ADD_CONSTRAINTS => [ - "%1\$s" => [ - [1 => "ADD %1\$s,\n", 'combinedby' => ""], + '%1$s' => [ + [1 => "ADD %1\$s,\n", 'combinedby' => ''], ] ], self::DROP_CONSTRAINTS => [ - "%1\$s" => [ - [1 => "DROP CONSTRAINT %1\$s,\n", 'combinedby' => ""], + '%1$s' => [ + [1 => "DROP CONSTRAINT %1\$s,\n", 'combinedby' => ''], ] ] ]; diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index 0c87c77d89..313acb5adf 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -40,7 +40,7 @@ class CreateTable extends AbstractSql implements SqlInterface [1 => '%1$s', 'combinedby' => ",\n "] ] ], - 'combinedBy' => ",", + 'combinedBy' => ',', self::CONSTRAINTS => [ "\n %1\$s" => [ [1 => '%1$s', 'combinedby' => ",\n "] diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 9fac19ccbe..5d3ffc8100 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -208,7 +208,7 @@ protected function processSelect( return sprintf( $this->specifications[static::SPECIFICATION_SELECT], $this->resolveTable($this->table, $platform, $driver, $parameterContainer), - $columns ? "($columns)" : "", + $columns ? "($columns)" : '', $selectSql ); } diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index ec9687842d..51c885b820 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -119,11 +119,11 @@ protected function processLimitOffset( $offset = (int) $this->offset; if ($offset) { - $sqls[] = sprintf("LIMIT %s OFFSET %s", $limit, $offset); + $sqls[] = sprintf('LIMIT %s OFFSET %s', $limit, $offset); return; } - $sqls[] = sprintf("LIMIT %s", $limit); + $sqls[] = sprintf('LIMIT %s', $limit); return; } @@ -162,7 +162,7 @@ protected function processLimitOffset( $sqls[] = sprintf( // @codingStandardsIgnoreStart - ") AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN %s AND %s", + ') AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN %s AND %s', // @codingStandardsIgnoreEnd $offsetParamName, $limitParamName @@ -184,7 +184,7 @@ protected function processLimitOffset( $sqls[] = sprintf( // @codingStandardsIgnoreStart - ") AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN %d AND %d", + ') AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN %d AND %d', // @codingStandardsIgnoreEnd $offset, (int)$this->limit + (int)$this->offset From 6000d508265359c945e0f9bedd908ac6261b88a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:13:53 +0100 Subject: [PATCH 23/45] Remove unnecessary parentheses --- src/Sql/AbstractSql.php | 4 +-- src/Sql/Ddl/AlterTable.php | 2 +- src/Sql/Expression.php | 2 +- src/Sql/Platform/IbmDb2/IbmDb2.php | 2 +- src/Sql/Platform/Oracle/Oracle.php | 2 +- src/Sql/Platform/SqlServer/SqlServer.php | 2 +- src/Sql/Predicate/Predicate.php | 34 ++++++++++++------------ src/Sql/Select.php | 6 ++--- src/Sql/Sql.php | 10 +++---- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 638e0e43f7..0a522db109 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -46,7 +46,7 @@ abstract class AbstractSql implements SqlInterface */ public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { - $adapterPlatform = ($adapterPlatform) ?: new DefaultAdapterPlatform; + $adapterPlatform = $adapterPlatform ?: new DefaultAdapterPlatform; return $this->buildSqlString($adapterPlatform); } @@ -363,7 +363,7 @@ protected function processJoin( // on expression // note: for Expression objects, pass them to processExpression with a prefix specific to each join // (used for named parameters) - if (($join['on'] instanceof ExpressionInterface)) { + if ($join['on'] instanceof ExpressionInterface) { $joinSpecArgArray[$j][] = $this->processExpression( $join['on'], $platform, diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index e45f1a62f2..91f0712afd 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -80,7 +80,7 @@ class AlterTable extends AbstractSql implements SqlInterface */ public function __construct($table = '') { - ($table) ? $this->setTable($table) : null; + $table ? $this->setTable($table) : null; } /** diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 67be99074d..e5bfaaef0e 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -119,7 +119,7 @@ public function getTypes() : array public function getExpressionData() : array { - $parameters = (is_scalar($this->parameters)) ? [$this->parameters] : $this->parameters; + $parameters = is_scalar($this->parameters) ? [$this->parameters] : $this->parameters; $parametersCount = count($parameters); $expression = str_replace('%', '%%', $this->expression); diff --git a/src/Sql/Platform/IbmDb2/IbmDb2.php b/src/Sql/Platform/IbmDb2/IbmDb2.php index ec4d48f91f..ea893d184b 100644 --- a/src/Sql/Platform/IbmDb2/IbmDb2.php +++ b/src/Sql/Platform/IbmDb2/IbmDb2.php @@ -19,6 +19,6 @@ class IbmDb2 extends AbstractPlatform */ public function __construct(SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator(Select::class, ($selectDecorator) ?: new SelectDecorator()); + $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); } } diff --git a/src/Sql/Platform/Oracle/Oracle.php b/src/Sql/Platform/Oracle/Oracle.php index 828acf842c..ff08398262 100644 --- a/src/Sql/Platform/Oracle/Oracle.php +++ b/src/Sql/Platform/Oracle/Oracle.php @@ -16,6 +16,6 @@ class Oracle extends AbstractPlatform { public function __construct(SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator(Select::class, ($selectDecorator) ?: new SelectDecorator()); + $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); } } diff --git a/src/Sql/Platform/SqlServer/SqlServer.php b/src/Sql/Platform/SqlServer/SqlServer.php index cb94dd3894..3d5102e76b 100644 --- a/src/Sql/Platform/SqlServer/SqlServer.php +++ b/src/Sql/Platform/SqlServer/SqlServer.php @@ -15,7 +15,7 @@ class SqlServer extends AbstractPlatform { public function __construct(SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator(Select::class, ($selectDecorator) ?: new SelectDecorator()); + $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); $this->setTypeDecorator(CreateTable::class, new Ddl\CreateTableDecorator()); } } diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index 7669de776e..47d37371c7 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -32,7 +32,7 @@ public function nest() : Predicate { $predicateSet = new self(); $predicateSet->setUnnest($this); - $this->addPredicate($predicateSet, ($this->nextPredicateCombineOperator) ?: $this->defaultCombination); + $this->addPredicate($predicateSet, $this->nextPredicateCombineOperator ?: $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $predicateSet; } @@ -86,7 +86,7 @@ public function equalTo( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_EQUAL_TO, $right, $leftType, $rightType), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -113,7 +113,7 @@ public function notEqualTo( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_NOT_EQUAL_TO, $right, $leftType, $rightType), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -140,7 +140,7 @@ public function lessThan( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_LESS_THAN, $right, $leftType, $rightType), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -167,7 +167,7 @@ public function greaterThan( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_GREATER_THAN, $right, $leftType, $rightType), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -194,7 +194,7 @@ public function lessThanOrEqualTo( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_LESS_THAN_OR_EQUAL_TO, $right, $leftType, $rightType), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -221,7 +221,7 @@ public function greaterThanOrEqualTo( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $right, $leftType, $rightType), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -242,7 +242,7 @@ public function like($identifier, string $like) : self { $this->addPredicate( new Like($identifier, $like), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -263,7 +263,7 @@ public function notLike($identifier, string $notLike) : self { $this->addPredicate( new NotLike($identifier, $notLike), - ($this->nextPredicateCombineOperator) ? : $this->defaultCombination + $this->nextPredicateCombineOperator ? : $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -283,7 +283,7 @@ public function expression($expression, $parameters = null) : self { $this->addPredicate( new Expression($expression, $parameters), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -315,7 +315,7 @@ public function literal(string $literal) : self $this->addPredicate( $predicate, - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -336,7 +336,7 @@ public function isNull($identifier) : self { $this->addPredicate( new IsNull($identifier), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -357,7 +357,7 @@ public function isNotNull($identifier) : self { $this->addPredicate( new IsNotNull($identifier), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -379,7 +379,7 @@ public function in($identifier, $valueSet = null) : self { $this->addPredicate( new In($identifier, $valueSet), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -401,7 +401,7 @@ public function notIn($identifier, $valueSet = null) : self { $this->addPredicate( new NotIn($identifier, $valueSet), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -423,7 +423,7 @@ public function between($identifier, $minValue, $maxValue) : self { $this->addPredicate( new Between($identifier, $minValue, $maxValue), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -446,7 +446,7 @@ public function notBetween($identifier, $minValue, $maxValue) : self { $this->addPredicate( new NotBetween($identifier, $minValue, $maxValue), - ($this->nextPredicateCombineOperator) ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?: $this->defaultCombination ); $this->nextPredicateCombineOperator = null; diff --git a/src/Sql/Select.php b/src/Sql/Select.php index fa68fbbc4c..85ab2b5550 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -506,14 +506,14 @@ protected function processSelect( if (is_string($columnIndexOrAs)) { $columnAs = $platform->quoteIdentifier($columnIndexOrAs); } elseif (stripos($columnName, ' as ') === false) { - $columnAs = (is_string($column)) ? $platform->quoteIdentifier($column) : 'Expression' . $expr++; + $columnAs = is_string($column) ? $platform->quoteIdentifier($column) : 'Expression' . $expr++; } - $columns[] = (isset($columnAs)) ? [$columnName, $columnAs] : [$columnName]; + $columns[] = isset($columnAs) ? [$columnName, $columnAs] : [$columnName]; } // process join columns foreach ($this->joins->getJoins() as $join) { - $joinName = (is_array($join['name'])) ? key($join['name']) : $join['name']; + $joinName = is_array($join['name']) ? key($join['name']) : $join['name']; $joinName = parent::resolveTable($joinName, $platform, $driver, $parameterContainer); foreach ($join['columns'] as $jKey => $jColumn) { diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 4cc8a37556..5a4438ebf4 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -90,7 +90,7 @@ public function select($table = null) : Select $this->table )); } - return new Select(($table) ?: $this->table); + return new Select($table ?: $this->table); } /** @@ -105,7 +105,7 @@ public function insert($table = null) : Insert $this->table )); } - return new Insert(($table) ?: $this->table); + return new Insert($table ?: $this->table); } /** @@ -120,7 +120,7 @@ public function update($table = null) : Update $this->table )); } - return new Update(($table) ?: $this->table); + return new Update($table ?: $this->table); } /** @@ -135,7 +135,7 @@ public function delete($table = null) : Delete $this->table )); } - return new Delete(($table) ?: $this->table); + return new Delete($table ?: $this->table); } public function prepareStatementForSqlObject( @@ -161,7 +161,7 @@ public function prepareStatementForSqlObject( */ public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterface $platform = null) : string { - $platform = ($platform) ?: $this->adapter->getPlatform(); + $platform = $platform ?: $this->adapter->getPlatform(); return $this->sqlPlatform->setSubject($sqlObject)->getSqlString($platform); } From 5866062a215e465b4716008e3d2b5083aae0eee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:15:15 +0100 Subject: [PATCH 24/45] Remove unnecessary type casting, as the argument is of needed type --- src/Sql/Ddl/Column/AbstractLengthColumn.php | 2 +- src/Sql/Ddl/Constraint/ForeignKey.php | 6 +++--- src/Sql/Ddl/CreateTable.php | 2 +- src/Sql/Select.php | 2 +- src/Sql/TableIdentifier.php | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index d4d66e7203..3708073e2a 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -37,7 +37,7 @@ public function __construct( */ public function setLength(int $length) : self { - $this->length = (int) $length; + $this->length = $length; return $this; } diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index 6d4eb60b09..8171e1c1eb 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -71,7 +71,7 @@ public function __construct( */ public function setReferenceTable(string $referenceTable) : self { - $this->referenceTable = (string) $referenceTable; + $this->referenceTable = $referenceTable; return $this; } @@ -109,7 +109,7 @@ public function getReferenceColumn() : array */ public function setOnDeleteRule(string $onDeleteRule) : self { - $this->onDeleteRule = (string) $onDeleteRule; + $this->onDeleteRule = $onDeleteRule; return $this; } @@ -128,7 +128,7 @@ public function getOnDeleteRule() : string */ public function setOnUpdateRule(string $onUpdateRule) : self { - $this->onUpdateRule = (string) $onUpdateRule; + $this->onUpdateRule = $onUpdateRule; return $this; } diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index 313acb5adf..95af8eb69a 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -69,7 +69,7 @@ public function __construct($table = '', bool $isTemporary = false) */ public function setTemporary(bool $temporary) : self { - $this->isTemporary = (bool) $temporary; + $this->isTemporary = $temporary; return $this; } diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 85ab2b5550..f9cfd28a11 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -226,7 +226,7 @@ public function quantifier($quantifier) : self public function columns(array $columns, bool $prefixColumnsWithTable = true) : self { $this->columns = $columns; - $this->prefixColumnsWithTable = (bool) $prefixColumnsWithTable; + $this->prefixColumnsWithTable = $prefixColumnsWithTable; return $this; } diff --git a/src/Sql/TableIdentifier.php b/src/Sql/TableIdentifier.php index eb04c513a6..a5895d003a 100644 --- a/src/Sql/TableIdentifier.php +++ b/src/Sql/TableIdentifier.php @@ -30,7 +30,7 @@ public function __construct(string $table, ?string $schema = null) )); } - $this->table = (string) $table; + $this->table = $table; if ('' === $this->table) { throw new Exception\InvalidArgumentException('$table must be a valid table name, empty string given'); @@ -46,7 +46,7 @@ public function __construct(string $table, ?string $schema = null) )); } - $this->schema = (string) $schema; + $this->schema = $schema; if ('' === $this->schema) { throw new Exception\InvalidArgumentException( From 31c14f67b1561b5134f208d89511ae2ad1971092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:16:52 +0100 Subject: [PATCH 25/45] Place namespace definition on its own line --- src/Sql/Ddl/Index/AbstractIndex.php | 4 +++- src/Sql/Ddl/Index/Index.php | 4 +++- src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php | 4 +++- src/Sql/Platform/SqlServer/SelectDecorator.php | 4 +++- src/Sql/Platform/SqlServer/SqlServer.php | 4 +++- src/Sql/Predicate/Predicate.php | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Sql/Ddl/Index/AbstractIndex.php b/src/Sql/Ddl/Index/AbstractIndex.php index 209c1d1cfa..8f7cfa9489 100644 --- a/src/Sql/Ddl/Index/AbstractIndex.php +++ b/src/Sql/Ddl/Index/AbstractIndex.php @@ -5,7 +5,9 @@ * @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License */ -declare(strict_types=1);namespace Zend\Db\Sql\Ddl\Index; +declare(strict_types=1); + +namespace Zend\Db\Sql\Ddl\Index; use Zend\Db\Sql\Ddl\Constraint\AbstractConstraint; diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index ba49e3f66c..23305189c3 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -5,7 +5,9 @@ * @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License */ -declare(strict_types=1);namespace Zend\Db\Sql\Ddl\Index; +declare(strict_types=1); + +namespace Zend\Db\Sql\Ddl\Index; class Index extends AbstractIndex { diff --git a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index 7e16f3e30d..d3d967ecbe 100644 --- a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -5,7 +5,9 @@ * @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License */ -declare(strict_types=1);namespace Zend\Db\Sql\Platform\SqlServer\Ddl; +declare(strict_types=1); + +namespace Zend\Db\Sql\Platform\SqlServer\Ddl; use Zend\Db\Adapter\Platform\PlatformInterface; use Zend\Db\Sql\Ddl\CreateTable; diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index 85622dacfb..6531fac973 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -5,7 +5,9 @@ * @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License */ -declare(strict_types=1);namespace Zend\Db\Sql\Platform\SqlServer; +declare(strict_types=1); + +namespace Zend\Db\Sql\Platform\SqlServer; use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\ParameterContainer; diff --git a/src/Sql/Platform/SqlServer/SqlServer.php b/src/Sql/Platform/SqlServer/SqlServer.php index 3d5102e76b..2154a006d6 100644 --- a/src/Sql/Platform/SqlServer/SqlServer.php +++ b/src/Sql/Platform/SqlServer/SqlServer.php @@ -5,7 +5,9 @@ * @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License */ -declare(strict_types=1);namespace Zend\Db\Sql\Platform\SqlServer; +declare(strict_types=1); + +namespace Zend\Db\Sql\Platform\SqlServer; use Zend\Db\Sql\Platform\AbstractPlatform; use Zend\Db\Sql\Ddl\CreateTable; diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index 47d37371c7..be4b1c2aa6 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -5,7 +5,9 @@ * @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License */ -declare(strict_types=1);namespace Zend\Db\Sql\Predicate; +declare(strict_types=1); + +namespace Zend\Db\Sql\Predicate; use Zend\Db\Sql\Exception\RuntimeException; use Zend\Db\Sql\Select; From 5f115d15fa27e5379e75de5bea6fc218489fe276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:17:29 +0100 Subject: [PATCH 26/45] Use compact() --- src/Sql/Combine.php | 6 +----- src/Sql/Select.php | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 1f78945fe3..0a9a5d02db 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -87,11 +87,7 @@ public function combine($select, string $type = self::COMBINE_UNION, string $mod )); } - $this->combine[] = [ - 'select' => $select, - 'type' => $type, - 'modifier' => $modifier - ]; + $this->combine[] = compact('select', 'type', 'modifier'); return $this; } diff --git a/src/Sql/Select.php b/src/Sql/Select.php index f9cfd28a11..05bed1be3a 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -352,11 +352,7 @@ public function combine(Select $select, string $type = self::COMBINE_UNION, stri 'This Select object is already combined and cannot be combined with multiple Selects objects' ); } - $this->combine = [ - 'select' => $select, - 'type' => $type, - 'modifier' => $modifier - ]; + $this->combine = compact('select', 'type', 'modifier'); return $this; } From a60c5c26b2000d79d9ed5eaaa2bc9cf8eb282419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:19:19 +0100 Subject: [PATCH 27/45] Converted elseif to if-branch (clearer intention, lower complexity number) --- src/Sql/Select.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 05bed1be3a..0d04527bd4 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -545,11 +545,13 @@ protected function processSelect( if (! isset($table)) { return [$columns]; - } elseif (isset($quantifier)) { + } + + if (isset($quantifier)) { return [$quantifier, $columns, $table]; - } else { - return [$columns, $table]; } + + return [$columns, $table]; } protected function processJoins( From 402e21b58f9208ada9f6a5d23e860146de7c2c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:26:05 +0100 Subject: [PATCH 28/45] Define one parameter per line in multi-line function declarations --- src/Sql/Predicate/Predicate.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index be4b1c2aa6..8deb07f49f 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -82,7 +82,8 @@ public function unnest() : Predicate * @return self Provides a fluent interface */ public function equalTo( - $left, $right, + $left, + $right, string $leftType = self::TYPE_IDENTIFIER, ?string$rightType = self::TYPE_VALUE ) : self { From 552623f96a84c1be4384bac7d4da70e529f9627a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:27:34 +0100 Subject: [PATCH 29/45] Removed unused imports --- src/Sql/AbstractExpression.php | 4 +--- src/Sql/Platform/IbmDb2/SelectDecorator.php | 1 - src/Sql/Platform/Oracle/SelectDecorator.php | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index 7e5c4e509a..d1baaadbf3 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -16,12 +16,10 @@ use function implode; use function in_array; use function is_array; -use function is_integer; +use function is_int; use function is_object; use function is_scalar; use function key; -use Zend\Db\Sql\SqlInterface; -use Zend\Db\Sql\ExpressionInterface; abstract class AbstractExpression implements ExpressionInterface { diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 51c885b820..426c333991 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -14,7 +14,6 @@ use Zend\Db\Adapter\Platform\PlatformInterface; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; use Zend\Db\Sql\Select; -use function array_push; use function array_shift; use function array_unshift; use function current; diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index abc5d79ba7..3dc03dd2bc 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -14,7 +14,6 @@ use Zend\Db\Adapter\Platform\PlatformInterface; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; use Zend\Db\Sql\Select; -use function array_push; use function array_shift; use function array_unshift; use function strpos; From a5d93333b951db1ed9b28593377f2687fbae594b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:29:14 +0100 Subject: [PATCH 30/45] Fixed typo --- src/Sql/Insert.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 5d3ffc8100..a383d4bc7b 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -110,7 +110,7 @@ public function values($values, string $flag = self::VALUES_SET) : self } if ($flag === self::VALUES_SET) { - $this->columns = $this->isAssocativeArray($values) + $this->columns = $this->isAssociativeArray($values) ? $values : array_combine(array_keys($this->columns), array_values($values)); } else { @@ -129,7 +129,7 @@ public function values($values, string $flag = self::VALUES_SET) : self * @param array $array * @return bool */ - private function isAssocativeArray(array $array) : bool + private function isAssociativeArray(array $array) : bool { return array_keys($array) !== range(0, count($array) - 1); } From 471da0cf0e55bbe4d9488287c16f7e0724f31b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:30:45 +0100 Subject: [PATCH 31/45] There must be exactly one space after a type cast --- src/Sql/Platform/IbmDb2/SelectDecorator.php | 2 +- src/Sql/Platform/Oracle/SelectDecorator.php | 8 ++++---- src/Sql/Platform/SqlServer/SelectDecorator.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 426c333991..a8935a6664 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -186,7 +186,7 @@ protected function processLimitOffset( ') AS ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION WHERE ZEND_IBMDB2_SERVER_LIMIT_OFFSET_EMULATION.ZEND_DB_ROWNUM BETWEEN %d AND %d', // @codingStandardsIgnoreEnd $offset, - (int)$this->limit + (int)$this->offset + (int) $this->limit + (int) $this->offset ); } diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index 3dc03dd2bc..3bd9ff00b1 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -128,14 +128,14 @@ protected function processLimitOffset( $this->processInfo['subselectCount']++; } else { if ($this->limit === null) { - $sqls[] = ') b ) WHERE b_rownum > (' . (int)$this->offset . ')'; + $sqls[] = ') b ) WHERE b_rownum > (' . (int) $this->offset . ')'; } else { $sqls[] = ') b WHERE rownum <= (' - . (int)$this->offset + . (int) $this->offset . '+' - . (int)$this->limit + . (int) $this->limit . ')) WHERE b_rownum >= (' - . (int)$this->offset + . (int) $this->offset . ' + 1)'; } } diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index 6531fac973..6c912adb88 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -104,8 +104,8 @@ protected function processLimitOffset( } else { // @codingStandardsIgnoreStart $sqls[] = ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' - . (int)$this->offset . '+1 AND ' - . (int)$this->limit . '+' . (int)$this->offset; + . (int) $this->offset . '+1 AND ' + . (int) $this->limit . '+' . (int) $this->offset; // @codingStandardsIgnoreEnd } From 636167e9d7cfcbdf374b77267aea7fb242fbfe7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 22:41:45 +0100 Subject: [PATCH 32/45] Nullable and optional arguments, which are marked as = null, must have the ? symbol present --- src/Sql/Combine.php | 2 +- src/Sql/Ddl/Constraint/AbstractConstraint.php | 2 +- src/Sql/Delete.php | 2 +- src/Sql/Expression.php | 4 ++-- src/Sql/Insert.php | 2 +- src/Sql/Platform/AbstractPlatform.php | 2 +- src/Sql/Platform/IbmDb2/IbmDb2.php | 5 +---- .../Platform/Mysql/Ddl/CreateTableDecorator.php | 2 +- src/Sql/Platform/Oracle/Oracle.php | 2 +- src/Sql/Platform/Platform.php | 4 ++-- .../SqlServer/Ddl/CreateTableDecorator.php | 6 +----- src/Sql/Platform/SqlServer/SqlServer.php | 2 +- src/Sql/Predicate/Between.php | 2 +- src/Sql/Predicate/Expression.php | 8 +------- src/Sql/Predicate/In.php | 2 +- src/Sql/Predicate/IsNull.php | 2 +- src/Sql/Predicate/Like.php | 6 +----- src/Sql/Predicate/Operator.php | 4 ++-- src/Sql/Predicate/Predicate.php | 10 +++++----- src/Sql/Predicate/PredicateSet.php | 2 +- src/Sql/Select.php | 2 +- src/Sql/Sql.php | 17 ++++++++++------- src/Sql/Update.php | 4 ++-- 23 files changed, 40 insertions(+), 54 deletions(-) diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 0a9a5d02db..0e98877b9c 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -45,7 +45,7 @@ class Combine extends AbstractPreparableSql * @param string $type * @param string $modifier */ - public function __construct($select = null, string $type = self::COMBINE_UNION, string $modifier = '') + public function __construct(?$select = null, string $type = self::COMBINE_UNION, string $modifier = '') { if ($select) { $this->combine($select, $type, $modifier); diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index 6f873c4008..a9a3e77a0c 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -30,7 +30,7 @@ abstract class AbstractConstraint implements ConstraintInterface * @param null|string|array $columns * @param string $name */ - public function __construct($columns = null, string $name = '') + public function __construct(?$columns = null, string $name = '') { if ($columns) { $this->setColumns($columns); diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 59a4c18b2b..13ed0d0eae 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -50,7 +50,7 @@ class Delete extends AbstractPreparableSql * * @param null|string|TableIdentifier $table */ - public function __construct($table = null) + public function __construct(?$table = null) { if ($table) { $this->from($table); diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index e5bfaaef0e..4719a2dd91 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -27,10 +27,10 @@ class Expression extends AbstractExpression /** * @param string $expression - * @param string|array $parameters + * @param null|string|array $parameters * @param array $types @deprecated will be dropped in version 3.0.0 */ - public function __construct(string $expression = '', $parameters = null, array $types = []) + public function __construct(string $expression = '', ?$parameters = null, array $types = []) { if ($expression !== '') { $this->setExpression($expression); diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index a383d4bc7b..688a3f7fc2 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -45,7 +45,7 @@ class Insert extends AbstractPreparableSql * * @param null|string|TableIdentifier $table */ - public function __construct($table = null) + public function __construct(?$table = null) { if ($table) { $this->into($table); diff --git a/src/Sql/Platform/AbstractPlatform.php b/src/Sql/Platform/AbstractPlatform.php index ae09799a9e..4a0a0d435d 100644 --- a/src/Sql/Platform/AbstractPlatform.php +++ b/src/Sql/Platform/AbstractPlatform.php @@ -95,7 +95,7 @@ public function prepareStatement(AdapterInterface $adapter, StatementContainerIn * * @throws RuntimeException */ - public function getSqlString(PlatformInterface $adapterPlatform = null) : string + public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { if (! $this->subject instanceof SqlInterface) { throw new RuntimeException( diff --git a/src/Sql/Platform/IbmDb2/IbmDb2.php b/src/Sql/Platform/IbmDb2/IbmDb2.php index ea893d184b..f6472e21fd 100644 --- a/src/Sql/Platform/IbmDb2/IbmDb2.php +++ b/src/Sql/Platform/IbmDb2/IbmDb2.php @@ -14,10 +14,7 @@ class IbmDb2 extends AbstractPlatform { - /** - * @param SelectDecorator $selectDecorator - */ - public function __construct(SelectDecorator $selectDecorator = null) + public function __construct(?SelectDecorator $selectDecorator = null) { $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); } diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index 7c77487b04..cd6703eae1 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -83,7 +83,7 @@ protected function getSqlInsertOffsets(string $sql) : array /** * {@inheritDoc} */ - protected function processColumns(PlatformInterface $platform = null) + protected function processColumns(?PlatformInterface $platform = null) { if (! $this->columns) { return; diff --git a/src/Sql/Platform/Oracle/Oracle.php b/src/Sql/Platform/Oracle/Oracle.php index ff08398262..ff12279e62 100644 --- a/src/Sql/Platform/Oracle/Oracle.php +++ b/src/Sql/Platform/Oracle/Oracle.php @@ -14,7 +14,7 @@ class Oracle extends AbstractPlatform { - public function __construct(SelectDecorator $selectDecorator = null) + public function __construct(?SelectDecorator $selectDecorator = null) { $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); } diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index 0017287d5a..007e536068 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -63,7 +63,7 @@ public function setTypeDecorator( * * @return PlatformDecoratorInterface|PreparableSqlInterface|SqlInterface */ - public function getTypeDecorator($subject, $adapterOrPlatform = null) + public function getTypeDecorator($subject, ?$adapterOrPlatform = null) { $platformName = $this->resolvePlatformName($adapterOrPlatform); @@ -114,7 +114,7 @@ public function prepareStatement(AdapterInterface $adapter, StatementContainerIn * * @throws RuntimeException */ - public function getSqlString(PlatformInterface $adapterPlatform = null) : string + public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { if (! $this->subject instanceof SqlInterface) { throw new RuntimeException( diff --git a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index d3d967ecbe..a0f5dfae94 100644 --- a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -28,11 +28,7 @@ public function setSubject($subject) : self return $this; } - /** - * @param PlatformInterface $adapterPlatform - * @return array - */ - protected function processTable(PlatformInterface $adapterPlatform = null) : array + protected function processTable(?PlatformInterface $adapterPlatform = null) : array { $table = ($this->isTemporary ? '#' : '') . ltrim($this->table, '#'); return [ diff --git a/src/Sql/Platform/SqlServer/SqlServer.php b/src/Sql/Platform/SqlServer/SqlServer.php index 2154a006d6..5673ba4198 100644 --- a/src/Sql/Platform/SqlServer/SqlServer.php +++ b/src/Sql/Platform/SqlServer/SqlServer.php @@ -15,7 +15,7 @@ class SqlServer extends AbstractPlatform { - public function __construct(SelectDecorator $selectDecorator = null) + public function __construct(?SelectDecorator $selectDecorator = null) { $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); $this->setTypeDecorator(CreateTable::class, new Ddl\CreateTableDecorator()); diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index 588bbced48..db7c2d7d46 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -25,7 +25,7 @@ class Between extends AbstractExpression implements PredicateInterface * @param int|float|string $minValue * @param int|float|string $maxValue */ - public function __construct(string $identifier = null, $minValue = null, $maxValue = null) + public function __construct(?string $identifier = null, $minValue = null, $maxValue = null) { if ($identifier) { $this->setIdentifier($identifier); diff --git a/src/Sql/Predicate/Expression.php b/src/Sql/Predicate/Expression.php index 15d3dfe344..e44a05f5ed 100644 --- a/src/Sql/Predicate/Expression.php +++ b/src/Sql/Predicate/Expression.php @@ -15,13 +15,7 @@ class Expression extends BaseExpression implements PredicateInterface { - /** - * Constructor - * - * @param string $expression - * @param int|float|bool|string|array $valueParameter - */ - public function __construct($expression = null, $valueParameter = null) + public function __construct(?string $expression = null, ?$valueParameter = null) { if ($expression) { $this->setExpression($expression); diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index 8d979beea2..db02235ddb 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -28,7 +28,7 @@ class In extends AbstractExpression implements PredicateInterface * @param null|string|array $identifier * @param null|array|Select $valueSet */ - public function __construct($identifier = null, $valueSet = null) + public function __construct(?$identifier = null, ?$valueSet = null) { if ($identifier) { $this->setIdentifier($identifier); diff --git a/src/Sql/Predicate/IsNull.php b/src/Sql/Predicate/IsNull.php index 55304a3b93..665264dc74 100644 --- a/src/Sql/Predicate/IsNull.php +++ b/src/Sql/Predicate/IsNull.php @@ -24,7 +24,7 @@ class IsNull extends AbstractExpression implements PredicateInterface * * @param string $identifier */ - public function __construct(string $identifier = null) + public function __construct(?string $identifier = null) { if ($identifier) { $this->setIdentifier($identifier); diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index 5b1936d96b..7061c27cb7 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -22,11 +22,7 @@ class Like extends AbstractExpression implements PredicateInterface /** @var string */ protected $like = ''; - /** - * @param string $identifier - * @param string $like - */ - public function __construct($identifier = null, $like = null) + public function __construct(?string $identifier = null, ?string $like = null) { if ($identifier) { $this->setIdentifier($identifier); diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 584438827e..17be9d6862 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -67,9 +67,9 @@ class Operator extends AbstractExpression implements PredicateInterface * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} */ public function __construct( - $left = null, + ?$left = null, string $operator = self::OPERATOR_EQUAL_TO, - $right = null, + ?$right = null, string $leftType = self::TYPE_IDENTIFIER, string $rightType = self::TYPE_VALUE ) { diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index 8deb07f49f..cb2ffa03a1 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -282,7 +282,7 @@ public function notLike($identifier, string $notLike) : self * * @return self Provides a fluent interface */ - public function expression($expression, $parameters = null) : self + public function expression($expression, ?$parameters = null) : self { $this->addPredicate( new Expression($expression, $parameters), @@ -374,11 +374,11 @@ public function isNotNull($identifier) : self * Utilizes In predicate * * @param string|Expression $identifier - * @param array|Select $valueSet + * @param array|Select|null $valueSet * * @return self Provides a fluent interface */ - public function in($identifier, $valueSet = null) : self + public function in($identifier, ?$valueSet = null) : self { $this->addPredicate( new In($identifier, $valueSet), @@ -396,11 +396,11 @@ public function in($identifier, $valueSet = null) : self * Utilizes NotIn predicate * * @param string|Expression $identifier - * @param array|Select $valueSet + * @param array|Select|null $valueSet * * @return self Provides a fluent interface */ - public function notIn($identifier, $valueSet = null) : self + public function notIn($identifier, ?$valueSet = null) : self { $this->addPredicate( new NotIn($identifier, $valueSet), diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index cb1517fd9c..e425f9d8d8 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -29,7 +29,7 @@ class PredicateSet implements PredicateInterface, Countable * @param null|array $predicates * @param string $defaultCombination */ - public function __construct(array $predicates = null, string $defaultCombination = self::COMBINED_BY_AND) + public function __construct(?array $predicates = null, string $defaultCombination = self::COMBINED_BY_AND) { $this->defaultCombination = $defaultCombination; diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 0d04527bd4..9ead676c79 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -145,7 +145,7 @@ class Select extends AbstractPreparableSql * * @param null|string|array|TableIdentifier $table */ - public function __construct($table = null) + public function __construct(?$table = null) { if ($table) { $this->from($table); diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 5a4438ebf4..87dd3302ca 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -29,8 +29,11 @@ class Sql * @param null|string|array|TableIdentifier $table * @param null|Platform\AbstractPlatform $sqlPlatform @deprecated since version 3.0 */ - public function __construct(AdapterInterface $adapter, $table = null, Platform\AbstractPlatform $sqlPlatform = null) - { + public function __construct( + AdapterInterface $adapter, + ?$table = null, + ?Platform\AbstractPlatform $sqlPlatform = null + ) { $this->adapter = $adapter; if ($table) { $this->setTable($table); @@ -82,7 +85,7 @@ public function getSqlPlatform() : Platform\Platform * @param null|string|array|TableIdentifier $table * @return Select */ - public function select($table = null) : Select + public function select(?$table = null) : Select { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -97,7 +100,7 @@ public function select($table = null) : Select * @param null|string|TableIdentifier $table * @return Insert */ - public function insert($table = null) : Insert + public function insert(?$table = null) : Insert { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -112,7 +115,7 @@ public function insert($table = null) : Insert * @param null|string|TableIdentifier $table * @return Update */ - public function update($table = null) : Update + public function update(?$table = null) : Update { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -127,7 +130,7 @@ public function update($table = null) : Update * @param null|string|TableIdentifier $table * @return Delete */ - public function delete($table = null) : Delete + public function delete(?$table = null) : Delete { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -159,7 +162,7 @@ public function prepareStatementForSqlObject( * * @deprecated Deprecated in 2.4. Use buildSqlString() instead */ - public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterface $platform = null) : string + public function getSqlStringForSqlObject(SqlInterface $sqlObject, ?PlatformInterface $platform = null) : string { $platform = $platform ?: $this->adapter->getPlatform(); return $this->sqlPlatform->setSubject($sqlObject)->getSqlString($platform); diff --git a/src/Sql/Update.php b/src/Sql/Update.php index cb8fec383b..e66223b30f 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -63,7 +63,7 @@ class Update extends AbstractPreparableSql * * @param null|string|TableIdentifier $table */ - public function __construct($table = null) + public function __construct(?$table = null) { if ($table) { $this->table($table); @@ -147,7 +147,7 @@ public function join($name, string $on, string $type = Join::JOIN_INNER) : self return $this; } - public function getRawState(string $key = null) + public function getRawState(?string $key = null) { $rawState = [ 'emptyWhereProtection' => $this->emptyWhereProtection, From 73c4a5979f04c60774c2b9baa0eb6eefb5cd124d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 23:06:59 +0100 Subject: [PATCH 33/45] Removed comments which do not add valuable information --- src/Sql/AbstractExpression.php | 2 - src/Sql/AbstractSql.php | 14 +--- src/Sql/Combine.php | 6 +- src/Sql/Ddl/AlterTable.php | 20 ++--- src/Sql/Ddl/Column/AbstractLengthColumn.php | 18 ----- .../Ddl/Column/AbstractPrecisionColumn.php | 25 ------- .../Ddl/Column/AbstractTimestampColumn.php | 3 - src/Sql/Ddl/Column/Column.php | 40 +--------- src/Sql/Ddl/Column/ColumnInterface.php | 9 --- src/Sql/Ddl/Column/Integer.php | 4 +- src/Sql/Ddl/Constraint/AbstractConstraint.php | 17 +---- src/Sql/Ddl/Constraint/Check.php | 3 - src/Sql/Ddl/Constraint/ForeignKey.php | 39 ++-------- src/Sql/Ddl/CreateTable.php | 45 +---------- src/Sql/Delete.php | 6 +- src/Sql/Expression.php | 9 +-- src/Sql/ExpressionInterface.php | 1 - src/Sql/Insert.php | 10 +-- src/Sql/Join.php | 2 +- src/Sql/Platform/AbstractPlatform.php | 20 ----- src/Sql/Platform/IbmDb2/SelectDecorator.php | 24 +----- .../Mysql/Ddl/AlterTableDecorator.php | 25 +------ .../Mysql/Ddl/CreateTableDecorator.php | 22 +----- src/Sql/Platform/Oracle/SelectDecorator.php | 12 --- src/Sql/Platform/Platform.php | 19 ----- .../Platform/PlatformDecoratorInterface.php | 1 - .../SqlServer/Ddl/CreateTableDecorator.php | 2 +- .../Platform/SqlServer/SelectDecorator.php | 9 --- src/Sql/Platform/Sqlite/SelectDecorator.php | 8 +- src/Sql/Platform/Sqlite/Sqlite.php | 5 -- src/Sql/Predicate/Between.php | 43 ++--------- src/Sql/Predicate/In.php | 13 +--- src/Sql/Predicate/IsNull.php | 34 --------- src/Sql/Predicate/Like.php | 28 +------ src/Sql/Predicate/Operator.php | 46 ++---------- src/Sql/Predicate/Predicate.php | 75 +++++-------------- src/Sql/Predicate/PredicateSet.php | 49 +----------- src/Sql/Select.php | 42 +++-------- src/Sql/Sql.php | 6 +- src/Sql/SqlInterface.php | 7 -- src/Sql/TableIdentifier.php | 14 +--- src/Sql/Update.php | 15 +--- 42 files changed, 83 insertions(+), 709 deletions(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index d1baaadbf3..ee1e9ef6a5 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -36,7 +36,6 @@ abstract class AbstractExpression implements ExpressionInterface * * @param mixed $argument * @param string $defaultType - * * @return array * * @throws Exception\InvalidArgumentException @@ -81,7 +80,6 @@ protected function normalizeArgument($argument, string $defaultType = self::TYPE /** * @param mixed $argument * @param string $argumentType - * * @return mixed[] * * @throws Exception\InvalidArgumentException diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 0a522db109..3232ae3e44 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -28,11 +28,7 @@ abstract class AbstractSql implements SqlInterface { - /** - * Specifications for Sql String generation - * - * @var string[]|array[] - */ + /** @var string[]|array[] Specifications for Sql String generation */ protected $specifications = []; /** @var string[] */ @@ -41,9 +37,6 @@ abstract class AbstractSql implements SqlInterface /** @var array */ protected $instanceParameterIndex = []; - /** - * {@inheritDoc} - */ public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { $adapterPlatform = $adapterPlatform ?: new DefaultAdapterPlatform; @@ -89,7 +82,6 @@ protected function buildSqlString( * @todo move TableIdentifier concatenation here * @param string $table * @param string|null $alias - * * @return string */ protected function renderTable(string $table, ?string $alias = null) : string @@ -105,7 +97,6 @@ protected function renderTable(string $table, ?string $alias = null) : string * @param null|DriverInterface $driver * @param null|ParameterContainer $parameterContainer * @param null|string $namedParameterPrefix - * * @return string * * @throws Exception\RuntimeException @@ -216,7 +207,6 @@ protected function processExpression( /** * @param string|array $specifications * @param array $parameters - * * @return string * * @throws Exception\RuntimeException @@ -389,7 +379,6 @@ protected function processJoin( * @param null|DriverInterface $driver * @param null|ParameterContainer $parameterContainer * @param null|string $namedParameterPrefix - * * @return string */ protected function resolveColumnValue( @@ -437,7 +426,6 @@ protected function resolveColumnValue( * @param PlatformInterface $platform * @param DriverInterface $driver * @param ParameterContainer $parameterContainer - * * @return string */ protected function resolveTable( diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 0e98877b9c..b0bba29fa5 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -58,8 +58,7 @@ public function __construct(?$select = null, string $type = self::COMBINE_UNION, * @param Select|array $select * @param string $type * @param string $modifier - * - * @return self Provides a fluent interface + * @return self * * @throws Exception\InvalidArgumentException */ @@ -97,7 +96,6 @@ public function combine($select, string $type = self::COMBINE_UNION, string $mod * * @param Select|array $select * @param string $modifier - * * @return self */ public function union($select, string $modifier = '') : self @@ -110,7 +108,6 @@ public function union($select, string $modifier = '') : self * * @param Select|array $select * @param string $modifier - * * @return self */ public function except($select, string $modifier = '') : self @@ -123,7 +120,6 @@ public function except($select, string $modifier = '') : self * * @param Select|array $select * @param string $modifier - * * @return self */ public function intersect($select, string $modifier = '') : self diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index 91f0712afd..5ab9ec77e0 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -83,11 +83,6 @@ public function __construct($table = '') $table ? $this->setTable($table) : null; } - /** - * @param string $name - * - * @return self Provides a fluent interface - */ public function setTable(string $name) : self { $this->table = $name; @@ -97,8 +92,7 @@ public function setTable(string $name) : self /** * @param ColumnInterface $column - * - * @return self Provides a fluent interface + * @return self */ public function addColumn(ColumnInterface $column) : self { @@ -110,8 +104,7 @@ public function addColumn(ColumnInterface $column) : self /** * @param string $name * @param ColumnInterface $column - * - * @return self Provides a fluent interface + * @return self */ public function changeColumn(string $name, ColumnInterface $column) : self { @@ -122,8 +115,7 @@ public function changeColumn(string $name, ColumnInterface $column) : self /** * @param string $name - * - * @return self Provides a fluent interface + * @return self */ public function dropColumn(string $name) : self { @@ -134,8 +126,7 @@ public function dropColumn(string $name) : self /** * @param string $name - * - * @return self Provides a fluent interface + * @return self */ public function dropConstraint(string $name) : self { @@ -146,8 +137,7 @@ public function dropConstraint(string $name) : self /** * @param ConstraintInterface $constraint - * - * @return self Provides a fluent interface + * @return self */ public function addConstraint(ConstraintInterface $constraint) : self { diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index 3708073e2a..a613c2f7cb 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -14,11 +14,6 @@ abstract class AbstractLengthColumn extends Column /** @var int */ protected $length; - /** - * {@inheritDoc} - * - * @param int $length - */ public function __construct( string $name = '', ?int $length = null, @@ -31,10 +26,6 @@ public function __construct( parent::__construct($name, $nullable, $default, $options); } - /** - * @param int $length - * @return self Provides a fluent interface - */ public function setLength(int $length) : self { $this->length = $length; @@ -42,25 +33,16 @@ public function setLength(int $length) : self return $this; } - /** - * @return int - */ public function getLength() : int { return $this->length; } - /** - * @return string - */ protected function getLengthExpression() : string { return (string) $this->length; } - /** - * @return array - */ public function getExpressionData() : array { $data = parent::getExpressionData(); diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index 977de61043..5f6a1d459f 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -14,12 +14,6 @@ abstract class AbstractPrecisionColumn extends AbstractLengthColumn /** @var int|null */ protected $decimal; - /** - * {@inheritDoc} - * - * @param int $digits - * @param int|null $decimal - */ public function __construct( string $name = '', ?int $digits = null, @@ -33,29 +27,16 @@ public function __construct( parent::__construct($name, $digits, $nullable, $default, $options); } - /** - * @param int $digits - * - * @return self - */ public function setDigits(int $digits) : self { return $this->setLength($digits); } - /** - * @return int - */ public function getDigits() : int { return $this->getLength(); } - /** - * @param int|null $decimal - * - * @return self Provides a fluent interface - */ public function setDecimal(?int $decimal) : self { $this->decimal = null === $decimal ? null : (int) $decimal; @@ -63,17 +44,11 @@ public function setDecimal(?int $decimal) : self return $this; } - /** - * @return int|null - */ public function getDecimal() : ?int { return $this->decimal; } - /** - * {@inheritDoc} - */ protected function getLengthExpression() : string { if ($this->decimal !== null) { diff --git a/src/Sql/Ddl/Column/AbstractTimestampColumn.php b/src/Sql/Ddl/Column/AbstractTimestampColumn.php index 3cd68e3be2..d1625ba353 100644 --- a/src/Sql/Ddl/Column/AbstractTimestampColumn.php +++ b/src/Sql/Ddl/Column/AbstractTimestampColumn.php @@ -16,9 +16,6 @@ */ abstract class AbstractTimestampColumn extends Column { - /** - * @return array - */ public function getExpressionData() : array { $spec = $this->specification; diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 5536ddf0bc..6973a399bd 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -34,12 +34,6 @@ class Column implements ColumnInterface /** @var string */ protected $type = 'INTEGER'; - /** - * @param string $name - * @param bool $nullable - * @param mixed|null $default - * @param mixed[] $options - */ public function __construct(string $name = '', bool $nullable = false, ?$default = null, array $options = []) { $this->setName($name); @@ -60,10 +54,6 @@ public function getName() : string return $this->name; } - /** - * @param bool $nullable - * @return self Provides a fluent interface - */ public function setNullable(bool $nullable) : self { $this->isNullable = $nullable; @@ -71,9 +61,6 @@ public function setNullable(bool $nullable) : self return $this; } - /** - * @return bool - */ public function isNullable() : bool { return $this->isNullable; @@ -81,8 +68,7 @@ public function isNullable() : bool /** * @param null|string|int $default - * - * @return self Provides a fluent interface + * @return self */ public function setDefault(?$default) : self { @@ -99,11 +85,6 @@ public function getDefault() return $this->default; } - /** - * @param array $options - * - * @return self Provides a fluent interface - */ public function setOptions(array $options) : self { $this->options = $options; @@ -111,12 +92,6 @@ public function setOptions(array $options) : self return $this; } - /** - * @param string $name - * @param string $value - * - * @return self Provides a fluent interface - */ public function setOption(string $name, string $value) : self { $this->options[$name] = $value; @@ -124,19 +99,12 @@ public function setOption(string $name, string $value) : self return $this; } - /** - * @return array - */ + public function getOptions() : array { return $this->options; } - /** - * @param ConstraintInterface $constraint - * - * @return self Provides a fluent interface - */ public function addConstraint(ConstraintInterface $constraint) : self { $this->constraints[] = $constraint; @@ -144,9 +112,7 @@ public function addConstraint(ConstraintInterface $constraint) : self return $this; } - /** - * @return array - */ + public function getExpressionData() : array { $spec = $this->specification; diff --git a/src/Sql/Ddl/Column/ColumnInterface.php b/src/Sql/Ddl/Column/ColumnInterface.php index a084923080..b52d43cf52 100644 --- a/src/Sql/Ddl/Column/ColumnInterface.php +++ b/src/Sql/Ddl/Column/ColumnInterface.php @@ -18,14 +18,8 @@ */ interface ColumnInterface extends ExpressionInterface { - /** - * @return string - */ public function getName() : string; - /** - * @return bool - */ public function isNullable() : bool; /** @@ -33,8 +27,5 @@ public function isNullable() : bool; */ public function getDefault(); - /** - * @return array - */ public function getOptions() : array; } diff --git a/src/Sql/Ddl/Column/Integer.php b/src/Sql/Ddl/Column/Integer.php index 9ec2fc1048..f2dbffa050 100644 --- a/src/Sql/Ddl/Column/Integer.php +++ b/src/Sql/Ddl/Column/Integer.php @@ -11,9 +11,7 @@ class Integer extends Column { - /** - * @return array - */ + public function getExpressionData() : array { $data = parent::getExpressionData(); diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index a9a3e77a0c..c8e0af7a03 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -46,9 +46,6 @@ public function setName(string $name) : self return $this; } - /** - * @return string - */ public function getName() : string { return $this->name; @@ -56,8 +53,7 @@ public function getName() : string /** * @param null|string|array $columns - * - * @return self Provides a fluent interface + * @return self */ public function setColumns(?$columns) : self { @@ -66,28 +62,17 @@ public function setColumns(?$columns) : self return $this; } - /** - * @param string $column - * - * @return self Provides a fluent interface - */ public function addColumn(string $column) : self { $this->columns[] = $column; return $this; } - /** - * {@inheritDoc} - */ public function getColumns() : array { return $this->columns; } - /** - * {@inheritDoc} - */ public function getExpressionData() : array { $colCount = count($this->columns); diff --git a/src/Sql/Ddl/Constraint/Check.php b/src/Sql/Ddl/Constraint/Check.php index 1ab554dde6..6135b995e0 100644 --- a/src/Sql/Ddl/Constraint/Check.php +++ b/src/Sql/Ddl/Constraint/Check.php @@ -31,9 +31,6 @@ public function __construct($expression, string $name = '') $this->name = $name; } - /** - * {@inheritDoc} - */ public function getExpressionData() : array { $newSpecTypes = [self::TYPE_LITERAL]; diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index 8171e1c1eb..0ba9c8ae6a 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -35,12 +35,12 @@ class ForeignKey extends AbstractConstraint ]; /** - * @param null|string $name + * @param string $name * @param null|string|array $columns - * @param string $referenceTable + * @param string $referenceTable * @param null|string|array $referenceColumn - * @param null|string $onDeleteRule - * @param null|string $onUpdateRule + * @param null|string $onDeleteRule + * @param null|string $onUpdateRule */ public function __construct( string $name, @@ -64,11 +64,6 @@ public function __construct( } } - /** - * @param string $referenceTable - * - * @return self Provides a fluent interface - */ public function setReferenceTable(string $referenceTable) : self { $this->referenceTable = $referenceTable; @@ -76,9 +71,6 @@ public function setReferenceTable(string $referenceTable) : self return $this; } - /** - * @return string - */ public function getReferenceTable() : string { return $this->referenceTable; @@ -86,7 +78,7 @@ public function getReferenceTable() : string /** * @param null|string|array $referenceColumn - * @return self Provides a fluent interface + * @return self */ public function setReferenceColumn(?$referenceColumn) : self { @@ -95,18 +87,12 @@ public function setReferenceColumn(?$referenceColumn) : self return $this; } - /** - * @return array - */ + public function getReferenceColumn() : array { return $this->referenceColumn; } - /** - * @param string $onDeleteRule - * @return self Provides a fluent interface - */ public function setOnDeleteRule(string $onDeleteRule) : self { $this->onDeleteRule = $onDeleteRule; @@ -114,18 +100,11 @@ public function setOnDeleteRule(string $onDeleteRule) : self return $this; } - /** - * @return string - */ public function getOnDeleteRule() : string { return $this->onDeleteRule; } - /** - * @param string $onUpdateRule - * @return self Provides a fluent interface - */ public function setOnUpdateRule(string $onUpdateRule) : self { $this->onUpdateRule = $onUpdateRule; @@ -133,17 +112,11 @@ public function setOnUpdateRule(string $onUpdateRule) : self return $this; } - /** - * @return string - */ public function getOnUpdateRule() : string { return $this->onUpdateRule; } - /** - * @return array - */ public function getExpressionData() : array { $data = parent::getExpressionData(); diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index 95af8eb69a..243e279990 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -30,9 +30,6 @@ class CreateTable extends AbstractSql implements SqlInterface /** @var bool */ protected $isTemporary = false; - /** - * {@inheritDoc} - */ protected $specifications = [ self::TABLE => 'CREATE %1$sTABLE %2$s (', self::COLUMNS => [ @@ -62,11 +59,6 @@ public function __construct($table = '', bool $isTemporary = false) $this->setTemporary($isTemporary); } - /** - * @param bool $temporary - * - * @return self Provides a fluent interface - */ public function setTemporary(bool $temporary) : self { $this->isTemporary = $temporary; @@ -74,18 +66,11 @@ public function setTemporary(bool $temporary) : self return $this; } - /** - * @return bool - */ public function isTemporary() : bool { return $this->isTemporary; } - /** - * @param string $name - * @return self Provides a fluent interface - */ public function setTable(string $name) : self { $this->table = $name; @@ -93,10 +78,6 @@ public function setTable(string $name) : self return $this; } - /** - * @param ColumnInterface $column - * @return self Provides a fluent interface - */ public function addColumn(ColumnInterface $column) : self { $this->columns[] = $column; @@ -104,10 +85,6 @@ public function addColumn(ColumnInterface $column) : self return $this; } - /** - * @param ConstraintInterface $constraint - * @return self Provides a fluent interface - */ public function addConstraint(ConstraintInterface $constraint) : self { $this->constraints[] = $constraint; @@ -115,11 +92,6 @@ public function addConstraint(ConstraintInterface $constraint) : self return $this; } - /** - * @param string|null $key - * - * @return array - */ public function getRawState(?string $key = null) : array { $rawState = [ @@ -131,11 +103,6 @@ public function getRawState(?string $key = null) : array return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } - /** - * @param PlatformInterface $adapterPlatform - * - * @return string[] - */ protected function processTable(?PlatformInterface $adapterPlatform = null) : array { return [ @@ -146,7 +113,6 @@ protected function processTable(?PlatformInterface $adapterPlatform = null) : ar /** * @param PlatformInterface $adapterPlatform - * * @return string[][]|void */ protected function processColumns(?PlatformInterface $adapterPlatform = null) @@ -165,8 +131,7 @@ protected function processColumns(?PlatformInterface $adapterPlatform = null) } /** - * @param PlatformInterface $adapterPlatform - * + * @param PlatformInterface|null $adapterPlatform * @return array|string|void */ protected function processCombinedby(?PlatformInterface $adapterPlatform = null) @@ -177,8 +142,7 @@ protected function processCombinedby(?PlatformInterface $adapterPlatform = null) } /** - * @param PlatformInterface $adapterPlatform - * + * @param PlatformInterface|null $adapterPlatform * @return string[][]|void */ protected function processConstraints(?PlatformInterface $adapterPlatform = null) @@ -196,11 +160,6 @@ protected function processConstraints(?PlatformInterface $adapterPlatform = null return [$sqls]; } - /** - * @param PlatformInterface $adapterPlatform - * - * @return string[] - */ protected function processStatementEnd(?PlatformInterface $adapterPlatform = null) : array { return ["\n)"]; diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 13ed0d0eae..b7935a332b 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -62,8 +62,7 @@ public function __construct(?$table = null) * Create from statement * * @param string|TableIdentifier $table - * - * @return self Provides a fluent interface + * @return self */ public function from($table) : self { @@ -89,8 +88,7 @@ public function getRawState(?string $key = null) * * @param Where|\Closure|string|array $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet - * - * @return self Provides a fluent interface + * @return self */ public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self { diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 4719a2dd91..57901fb4f0 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -73,9 +73,7 @@ public function getExpression() : string /** * @param $parameters - * - * @return self Provides a fluent interface - * + * @return self * @throws Exception\InvalidArgumentException */ public function setParameters($parameters) : self @@ -96,10 +94,8 @@ public function getParameters() : array /** * @deprecated - * * @param array $types - * - * @return self Provides a fluent interface + * @return self */ public function setTypes(array $types) : self { @@ -109,7 +105,6 @@ public function setTypes(array $types) : self /** * @deprecated - * * @return array */ public function getTypes() : array diff --git a/src/Sql/ExpressionInterface.php b/src/Sql/ExpressionInterface.php index 1a1ed83685..cef7122908 100644 --- a/src/Sql/ExpressionInterface.php +++ b/src/Sql/ExpressionInterface.php @@ -18,7 +18,6 @@ interface ExpressionInterface /** * @abstract - * * @return array of array|string should return an array in the format: * * array ( diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 688a3f7fc2..e531ac7adf 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -56,7 +56,7 @@ public function __construct(?$table = null) * Create INTO clause * * @param string|TableIdentifier $table - * @return self Provides a fluent interface + * @return self */ public function into($table) : self { @@ -64,12 +64,6 @@ public function into($table) : self return $this; } - /** - * Specify columns - * - * @param array $columns - * @return self Provides a fluent interface - */ public function columns(array $columns) : self { $this->columns = array_flip($columns); @@ -81,7 +75,7 @@ public function columns(array $columns) : self * * @param array|Select $values * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function values($values, string $flag = self::VALUES_SET) : self diff --git a/src/Sql/Join.php b/src/Sql/Join.php index e3a03fa008..aa14c1d404 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -77,7 +77,7 @@ public function getJoins() : array * of column names, or (a) specification(s) such as SQL_STAR representing * the columns to join. * @param string $type The JOIN type to use; see the JOIN_* constants. - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException for invalid $name values. */ public function join($name, $on, $columns = [Select::SQL_STAR], string $type = Join::JOIN_INNER) : self diff --git a/src/Sql/Platform/AbstractPlatform.php b/src/Sql/Platform/AbstractPlatform.php index 4a0a0d435d..7efc815f40 100644 --- a/src/Sql/Platform/AbstractPlatform.php +++ b/src/Sql/Platform/AbstractPlatform.php @@ -24,9 +24,6 @@ class AbstractPlatform implements PlatformDecoratorInterface, PreparableSqlInter /** @var PlatformDecoratorInterface[] */ protected $decorators = []; - /** - * {@inheritDoc} - */ public function setSubject($subject) { $this->subject = $subject; @@ -34,12 +31,6 @@ public function setSubject($subject) return $this; } - /** - * @param string $type - * @param PlatformDecoratorInterface $decorator - * - * @return void - */ public function setTypeDecorator(string $type, PlatformDecoratorInterface $decorator) : void { $this->decorators[$type] = $decorator; @@ -47,7 +38,6 @@ public function setTypeDecorator(string $type, PlatformDecoratorInterface $decor /** * @param PreparableSqlInterface|SqlInterface $subject - * * @return PlatformDecoratorInterface|PreparableSqlInterface|SqlInterface */ public function getTypeDecorator($subject) @@ -71,11 +61,6 @@ public function getDecorators() return $this->decorators; } - /** - * {@inheritDoc} - * - * @throws RuntimeException - */ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) { if (! $this->subject instanceof PreparableSqlInterface) { @@ -90,11 +75,6 @@ public function prepareStatement(AdapterInterface $adapter, StatementContainerIn return $statementContainer; } - /** - * {@inheritDoc} - * - * @throws RuntimeException - */ public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { if (! $this->subject instanceof SqlInterface) { diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index a8935a6664..88179d64c5 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -32,18 +32,11 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** @var bool */ protected $supportsLimitOffset = false; - - /** - * @return bool - */ public function getIsSelectContainDistinct() : bool { return $this->isSelectContainDistinct; } - /** - * @param bool $isSelectContainDistinct - */ public function setIsSelectContainDistinct(bool $isSelectContainDistinct) : void { $this->isSelectContainDistinct = $isSelectContainDistinct; @@ -57,25 +50,17 @@ public function setSubject($select) $this->subject = $select; } - /** - * @return bool - */ + public function getSupportsLimitOffset() : bool { return $this->supportsLimitOffset; } - /** - * @param bool $supportsLimitOffset - */ public function setSupportsLimitOffset(bool $supportsLimitOffset) : void { $this->supportsLimitOffset = $supportsLimitOffset; } - /** - * {@inheritDoc} - */ protected function renderTable(string $table, ?string $alias = null) : string { return $table . ' ' . $alias; @@ -91,13 +76,6 @@ protected function localizeVariables() : void $this->specifications['LIMITOFFSET'] = null; } - /** - * @param PlatformInterface $platform - * @param DriverInterface $driver - * @param ParameterContainer $parameterContainer - * @param array $sqls - * @param array $parameters - */ protected function processLimitOffset( PlatformInterface $platform, ?DriverInterface $driver = null, diff --git a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php index db6a1d2c9a..0ec33f25b1 100644 --- a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -43,8 +43,7 @@ class AlterTableDecorator extends AlterTable implements PlatformDecoratorInterfa /** * @param AlterTable $subject - * - * @return self Provides a fluent interface + * @return self */ public function setSubject($subject) : self { @@ -55,7 +54,6 @@ public function setSubject($subject) : self /** * @param string $sql - * * @return array */ protected function getSqlInsertOffsets(string $sql) : array @@ -88,11 +86,6 @@ protected function getSqlInsertOffsets(string $sql) : array return $insertStart; } - /** - * @param PlatformInterface $adapterPlatform - * - * @return array - */ protected function processAddColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; @@ -158,11 +151,6 @@ protected function processAddColumns(?PlatformInterface $adapterPlatform = null) return [$sqls]; } - /** - * @param PlatformInterface $adapterPlatform - * - * @return array - */ protected function processChangeColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; @@ -230,22 +218,11 @@ protected function processChangeColumns(?PlatformInterface $adapterPlatform = nu return [$sqls]; } - /** - * @param string $name - * - * @return string - */ private function normalizeColumnOption(string $name) : string { return strtolower(str_replace(['-', '_', ' '], '', $name)); } - /** - * @param string $columnA - * @param string $columnB - * - * @return int - */ private function compareColumnOptions(string $columnA, string $columnB) : int { $columnA = $this->normalizeColumnOption($columnA); diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index cd6703eae1..14c83014db 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -35,8 +35,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter /** * @param CreateTable $subject - * - * @return self Provides a fluent interface + * @return self */ public function setSubject($subject) : self { @@ -45,11 +44,6 @@ public function setSubject($subject) : self return $this; } - /** - * @param string $sql - * - * @return array - */ protected function getSqlInsertOffsets(string $sql) : array { $sqlLength = strlen($sql); @@ -80,9 +74,6 @@ protected function getSqlInsertOffsets(string $sql) : array return $insertStart; } - /** - * {@inheritDoc} - */ protected function processColumns(?PlatformInterface $platform = null) { if (! $this->columns) { @@ -151,22 +142,11 @@ protected function processColumns(?PlatformInterface $platform = null) return [$sqls]; } - /** - * @param string $name - * - * @return string - */ private function normalizeColumnOption(string $name) : string { return strtolower(str_replace(['-', '_', ' '], '', $name)); } - /** - * @param string $columnA - * @param string $columnB - * - * @return int - */ private function compareColumnOptions(string $columnA, string $columnB) : int { $columnA = $this->normalizeColumnOption($columnA); diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index 3bd9ff00b1..c4a41a93af 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -31,9 +31,6 @@ public function setSubject($select) $this->subject = $select; } - /** - * @inheritDoc - */ protected function renderTable(string $table, ?string $alias = null) : string { return $table . ($alias ? ' ' . $alias : ''); @@ -48,15 +45,6 @@ protected function localizeVariables() : void $this->specifications['LIMITOFFSET'] = null; } - /** - * @param PlatformInterface $platform - * @param DriverInterface $driver - * @param ParameterContainer $parameterContainer - * @param array $sqls - * @param array $parameters - * - * @return void - */ protected function processLimitOffset( PlatformInterface $platform, ?DriverInterface $driver = null, diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index 007e536068..60416d9f64 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -43,11 +43,6 @@ public function __construct(AdapterInterface $adapter) $this->decorators['sqlite'] = $sqlitePlatform->getDecorators(); } - /** - * @param string $type - * @param PlatformDecoratorInterface $decorator - * @param AdapterInterface|PlatformInterface $adapterOrPlatform - */ public function setTypeDecorator( string $type, PlatformDecoratorInterface $decorator, @@ -60,7 +55,6 @@ public function setTypeDecorator( /** * @param PreparableSqlInterface|SqlInterface $subject * @param AdapterInterface|PlatformInterface|null $adapterOrPlatform - * * @return PlatformDecoratorInterface|PreparableSqlInterface|SqlInterface */ public function getTypeDecorator($subject, ?$adapterOrPlatform = null) @@ -90,11 +84,6 @@ public function getDecorators() return $this->decorators[$platformName]; } - /** - * {@inheritDoc} - * - * @throws RuntimeException - */ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer) { if (! $this->subject instanceof PreparableSqlInterface) { @@ -109,11 +98,6 @@ public function prepareStatement(AdapterInterface $adapter, StatementContainerIn return $statementContainer; } - /** - * {@inheritDoc} - * - * @throws RuntimeException - */ public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { if (! $this->subject instanceof SqlInterface) { @@ -135,9 +119,7 @@ protected function resolvePlatformName($adapterOrPlatform) } /** * @param null|PlatformInterface|AdapterInterface $adapterOrPlatform - * * @return PlatformInterface - * * @throws InvalidArgumentException */ protected function resolvePlatform($adapterOrPlatform) : PlatformInterface @@ -163,7 +145,6 @@ protected function resolvePlatform($adapterOrPlatform) : PlatformInterface /** * @return PlatformInterface - * * @throws RuntimeException */ protected function getDefaultPlatform() : PlatformInterface diff --git a/src/Sql/Platform/PlatformDecoratorInterface.php b/src/Sql/Platform/PlatformDecoratorInterface.php index 54a88cc829..4bf490a6f7 100644 --- a/src/Sql/Platform/PlatformDecoratorInterface.php +++ b/src/Sql/Platform/PlatformDecoratorInterface.php @@ -13,7 +13,6 @@ interface PlatformDecoratorInterface { /** * @param $subject - * * @return self */ public function setSubject($subject); diff --git a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index a0f5dfae94..cd67126f0f 100644 --- a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -20,7 +20,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter /** * @param CreateTable $subject - * @return self Provides a fluent interface + * @return self */ public function setSubject($subject) : self { diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index 6c912adb88..56fe2733b5 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -38,15 +38,6 @@ protected function localizeVariables() : void $this->specifications['LIMITOFFSET'] = null; } - /** - * @param PlatformInterface $platform - * @param DriverInterface $driver - * @param ParameterContainer $parameterContainer - * @param $sqls - * @param $parameters - * - * @return void - */ protected function processLimitOffset( PlatformInterface $platform, ?DriverInterface $driver = null, diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index 0a36f15c76..3a125c5278 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -21,11 +21,8 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface protected $subject; /** - * Set Subject - * * @param Select $select - * - * @return self Provides a fluent interface + * @return self */ public function setSubject($select) : self { @@ -34,9 +31,6 @@ public function setSubject($select) : self return $this; } - /** - * {@inheritDoc} - */ protected function localizeVariables() : void { parent::localizeVariables(); diff --git a/src/Sql/Platform/Sqlite/Sqlite.php b/src/Sql/Platform/Sqlite/Sqlite.php index a6518e39bf..bdda4d5fa6 100644 --- a/src/Sql/Platform/Sqlite/Sqlite.php +++ b/src/Sql/Platform/Sqlite/Sqlite.php @@ -14,11 +14,6 @@ class Sqlite extends AbstractPlatform { - /** - * Constructor - * - * Registers the type decorator. - */ public function __construct() { $this->setTypeDecorator(Select::class, new SelectDecorator()); diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index db7c2d7d46..a678f48698 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -21,9 +21,9 @@ class Between extends AbstractExpression implements PredicateInterface /** * Constructor * - * @param string $identifier - * @param int|float|string $minValue - * @param int|float|string $maxValue + * @param null|string $identifier + * @param null|int|float|string $minValue + * @param null|int|float|string $maxValue */ public function __construct(?string $identifier = null, $minValue = null, $maxValue = null) { @@ -40,13 +40,6 @@ public function __construct(?string $identifier = null, $minValue = null, $maxVa } } - /** - * Set identifier for comparison - * - * @param string $identifier - * - * @return self Provides a fluent interface - */ public function setIdentifier(string $identifier) : self { $this->identifier = $identifier; @@ -54,11 +47,6 @@ public function setIdentifier(string $identifier) : self return $this; } - /** - * Get identifier of comparison - * - * @return null|string - */ public function getIdentifier() : ?string { return $this->identifier; @@ -68,8 +56,7 @@ public function getIdentifier() : ?string * Set minimum boundary for comparison * * @param int|float|string $minValue - * - * @return self Provides a fluent interface + * @return self */ public function setMinValue($minValue) : self { @@ -80,7 +67,6 @@ public function setMinValue($minValue) : self /** * Get minimum boundary for comparison - * * @return null|int|float|string */ public function getMinValue() @@ -92,8 +78,7 @@ public function getMinValue() * Set maximum boundary for comparison * * @param int|float|string $maxValue - * - * @return self Provides a fluent interface + * @return self */ public function setMaxValue($maxValue) : self { @@ -104,7 +89,6 @@ public function setMaxValue($maxValue) : self /** * Get maximum boundary for comparison - * * @return null|int|float|string */ public function getMaxValue() @@ -112,13 +96,6 @@ public function getMaxValue() return $this->maxValue; } - /** - * Set specification string to use in forming SQL predicate - * - * @param string $specification - * - * @return self Provides a fluent interface - */ public function setSpecification(string $specification) : self { $this->specification = $specification; @@ -126,21 +103,11 @@ public function setSpecification(string $specification) : self return $this; } - /** - * Get specification string to use in forming SQL predicate - * - * @return string - */ public function getSpecification() : string { return $this->specification; } - /** - * Return "where" parts - * - * @return mixed[][] - */ public function getExpressionData() : array { [$values[], $types[]] = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index db02235ddb..64f877a5c7 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -43,8 +43,7 @@ public function __construct(?$identifier = null, ?$valueSet = null) * Set identifier for comparison * * @param string|array $identifier - * - * @return self Provides a fluent interface + * @return self */ public function setIdentifier($identifier) : self { @@ -55,7 +54,6 @@ public function setIdentifier($identifier) : self /** * Get identifier of comparison - * * @return null|string|array */ public function getIdentifier() @@ -67,8 +65,7 @@ public function getIdentifier() * Set set of values for IN comparison * * @param array|Select $valueSet - * - * @return self Provides a fluent interface + * @return self * * @throws Exception\InvalidArgumentException */ @@ -87,7 +84,6 @@ public function setValueSet($valueSet) : self /** * Gets set of values in IN comparison - * * @return array|Select */ public function getValueSet() @@ -95,11 +91,6 @@ public function getValueSet() return $this->valueSet; } - /** - * Return array of parts for where statement - * - * @return array - */ public function getExpressionData() : array { $identifier = $this->getIdentifier(); diff --git a/src/Sql/Predicate/IsNull.php b/src/Sql/Predicate/IsNull.php index 665264dc74..84b1ce95e7 100644 --- a/src/Sql/Predicate/IsNull.php +++ b/src/Sql/Predicate/IsNull.php @@ -19,11 +19,6 @@ class IsNull extends AbstractExpression implements PredicateInterface /** @var null|string */ protected $identifier; - /** - * Constructor - * - * @param string $identifier - */ public function __construct(?string $identifier = null) { if ($identifier) { @@ -31,13 +26,6 @@ public function __construct(?string $identifier = null) } } - /** - * Set identifier for comparison - * - * @param string $identifier - * - * @return self Provides a fluent interface - */ public function setIdentifier(string $identifier) : self { $this->identifier = $identifier; @@ -45,23 +33,11 @@ public function setIdentifier(string $identifier) : self return $this; } - /** - * Get identifier of comparison - * - * @return null|string - */ public function getIdentifier() : ?string { return $this->identifier; } - /** - * Set specification string to use in forming SQL predicate - * - * @param string $specification - * - * @return self Provides a fluent interface - */ public function setSpecification(string $specification) : self { $this->specification = $specification; @@ -69,21 +45,11 @@ public function setSpecification(string $specification) : self return $this; } - /** - * Get specification string to use in forming SQL predicate - * - * @return string - */ public function getSpecification() : string { return $this->specification; } - /** - * Get parts for where statement - * - * @return array - */ public function getExpressionData() : array { $identifier = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index 7061c27cb7..7a3f977dda 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -32,11 +32,6 @@ public function __construct(?string $identifier = null, ?string $like = null) } } - /** - * @param string $identifier - * - * @return self Provides a fluent interface - */ public function setIdentifier(string $identifier) : self { $this->identifier = $identifier; @@ -44,19 +39,11 @@ public function setIdentifier(string $identifier) : self return $this; } - /** - * @return string - */ public function getIdentifier() : string { return $this->identifier; } - /** - * @param string $like - * - * @return self Provides a fluent interface - */ public function setLike(string $like) : self { $this->like = $like; @@ -64,19 +51,11 @@ public function setLike(string $like) : self return $this; } - /** - * @return string - */ public function getLike() : string { return $this->like; } - /** - * @param string $specification - * - * @return self Provides a fluent interface - */ public function setSpecification(string $specification) : self { $this->specification = $specification; @@ -84,17 +63,12 @@ public function setSpecification(string $specification) : self return $this; } - /** - * @return string - */ public function getSpecification() : string { return $this->specification; } - /** - * @return array - */ + public function getExpressionData() : array { [$values[], $types[]] = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 17be9d6862..1b47f62855 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -34,9 +34,6 @@ class Operator extends AbstractExpression implements PredicateInterface public const OPERATOR_GREATER_THAN_OR_EQUAL_TO = '>='; public const OP_GTE = '>='; - /** - * {@inheritDoc} - */ protected $allowedTypes = [ self::TYPE_IDENTIFIER, self::TYPE_VALUE, @@ -98,8 +95,7 @@ public function __construct( * Set left side of operator * * @param int|float|bool|string $left - * - * @return self Provides a fluent interface + * @return self */ public function setLeft($left) : self { @@ -115,7 +111,6 @@ public function setLeft($left) : self /** * Get left side of operator - * * @return int|float|bool|string */ public function getLeft() @@ -127,9 +122,7 @@ public function getLeft() * Set parameter type for left side of operator * * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} - * - * @return self Provides a fluent interface - * + * @return self * @throws Exception\InvalidArgumentException */ public function setLeftType($type) : self @@ -148,34 +141,18 @@ public function setLeftType($type) : self return $this; } - /** - * Get parameter type on left side of operator - * - * @return string - */ public function getLeftType() : string { return $this->leftType; } - /** - * Set operator string - * - * @param string $operator - * @return self Provides a fluent interface - */ - public function setOperator($operator) : self + public function setOperator(string $operator) : self { $this->operator = $operator; return $this; } - /** - * Get operator string - * - * @return string - */ public function getOperator() : string { return $this->operator; @@ -185,8 +162,7 @@ public function getOperator() : string * Set right side of operator * * @param int|float|bool|string $right - * - * @return self Provides a fluent interface + * @return self */ public function setRight($right) : self { @@ -202,7 +178,6 @@ public function setRight($right) : self /** * Get right side of operator - * * @return int|float|bool|string */ public function getRight() @@ -214,8 +189,7 @@ public function getRight() * Set parameter type for right side of operator * * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} - * - * @return self Provides a fluent interface + * @return self * * @throws Exception\InvalidArgumentException */ @@ -235,21 +209,11 @@ public function setRightType(string $type) : self return $this; } - /** - * Get parameter type on right side of operator - * - * @return string - */ public function getRightType() : string { return $this->rightType; } - /** - * Get predicate parts for where statement - * - * @return array - */ public function getExpressionData() : array { list($values[], $types[]) = $this->normalizeArgument($this->left, $this->leftType); diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index cb2ffa03a1..ff6f4c5035 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -25,11 +25,6 @@ class Predicate extends PredicateSet protected $unnest; protected $nextPredicateCombineOperator; - /** - * Begin nesting predicates - * - * @return Predicate - */ public function nest() : Predicate { $predicateSet = new self(); @@ -39,25 +34,11 @@ public function nest() : Predicate return $predicateSet; } - /** - * Indicate what predicate will be unnested - * - * @param Predicate $predicate - * - * @return void - */ public function setUnnest(Predicate $predicate) : void { $this->unnest = $predicate; } - /** - * Indicate end of nested predicate - * - * @return Predicate - * - * @throws RuntimeException - */ public function unnest() : Predicate { if ($this->unnest === null) { @@ -78,8 +59,7 @@ public function unnest() : Predicate * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * - * @return self Provides a fluent interface + * @return self */ public function equalTo( $left, @@ -105,8 +85,7 @@ public function equalTo( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * - * @return self Provides a fluent interface + * @return self */ public function notEqualTo( $left, @@ -132,8 +111,7 @@ public function notEqualTo( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * - * @return self Provides a fluent interface + * @return self */ public function lessThan( $left, @@ -159,8 +137,7 @@ public function lessThan( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * - * @return self Provides a fluent interface + * @return self */ public function greaterThan( $left, @@ -186,8 +163,7 @@ public function greaterThan( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * - * @return self Provides a fluent interface + * @return self */ public function lessThanOrEqualTo( $left, @@ -213,8 +189,7 @@ public function lessThanOrEqualTo( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * - * @return self Provides a fluent interface + * @return self */ public function greaterThanOrEqualTo( $left, @@ -238,8 +213,7 @@ public function greaterThanOrEqualTo( * * @param string|Expression $identifier * @param string $like - * - * @return self Provides a fluent interface + * @return self */ public function like($identifier, string $like) : self { @@ -259,8 +233,7 @@ public function like($identifier, string $like) : self * * @param string|Expression $identifier * @param string $notLike - * - * @return self Provides a fluent interface + * @return self */ public function notLike($identifier, string $notLike) : self { @@ -279,8 +252,7 @@ public function notLike($identifier, string $notLike) : self * * @param $expression * @param $parameters - * - * @return self Provides a fluent interface + * @return self */ public function expression($expression, ?$parameters = null) : self { @@ -300,8 +272,7 @@ public function expression($expression, ?$parameters = null) : self * Literal predicate, for parameters, use expression() * * @param string $literal - * - * @return self Provides a fluent interface + * @return self */ public function literal(string $literal) : self { @@ -332,8 +303,7 @@ public function literal(string $literal) : self * Utilizes IsNull predicate * * @param string|Expression $identifier - * - * @return self Provides a fluent interface + * @return self */ public function isNull($identifier) : self { @@ -353,8 +323,7 @@ public function isNull($identifier) : self * Utilizes IsNotNull predicate * * @param string|Expression $identifier - * - * @return self Provides a fluent interface + * @return self */ public function isNotNull($identifier) : self { @@ -375,8 +344,7 @@ public function isNotNull($identifier) : self * * @param string|Expression $identifier * @param array|Select|null $valueSet - * - * @return self Provides a fluent interface + * @return self */ public function in($identifier, ?$valueSet = null) : self { @@ -397,8 +365,7 @@ public function in($identifier, ?$valueSet = null) : self * * @param string|Expression $identifier * @param array|Select|null $valueSet - * - * @return self Provides a fluent interface + * @return self */ public function notIn($identifier, ?$valueSet = null) : self { @@ -419,8 +386,7 @@ public function notIn($identifier, ?$valueSet = null) : self * @param string|Expression $identifier * @param int|float|string $minValue * @param int|float|string $maxValue - * - * @return self Provides a fluent interface + * @return self */ public function between($identifier, $minValue, $maxValue) : self { @@ -442,8 +408,7 @@ public function between($identifier, $minValue, $maxValue) : self * @param string|Expression $identifier * @param int|float|string $minValue * @param int|float|string $maxValue - * - * @return self Provides a fluent interface + * @return self */ public function notBetween($identifier, $minValue, $maxValue) : self { @@ -465,8 +430,7 @@ public function notBetween($identifier, $minValue, $maxValue) : self * used fluently within where chains as any other concrete predicate. * * @param PredicateInterface $predicate - * - * @return self Provides a fluent interface + * @return self */ public function predicate(PredicateInterface $predicate) : self { @@ -485,10 +449,9 @@ public function predicate(PredicateInterface $predicate) : self * Overloads "or", "and", "nest", and "unnest" * * @param string $name - * - * @return self Provides a fluent interface + * @return mixed */ - public function __get($name) + public function __get(string $name) { switch (strtolower($name)) { case 'or': diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index e425f9d8d8..b5970a38c4 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -20,15 +20,12 @@ class PredicateSet implements PredicateInterface, Countable public const COMBINED_BY_OR = 'OR'; public const OP_OR = 'OR'; + /** @var string */ protected $defaultCombination = self::COMBINED_BY_AND; + + /** @var PredicateInterface[] */ protected $predicates = []; - /** - * Constructor - * - * @param null|array $predicates - * @param string $defaultCombination - */ public function __construct(?array $predicates = null, string $defaultCombination = self::COMBINED_BY_AND) { $this->defaultCombination = $defaultCombination; @@ -40,14 +37,6 @@ public function __construct(?array $predicates = null, string $defaultCombinatio } } - /** - * Add predicate to set - * - * @param PredicateInterface $predicate - * @param string $combination - * - * @return self Provides a fluent interface - */ public function addPredicate(PredicateInterface $predicate, ?string $combination = null) : self { if ($combination === null || ! in_array($combination, [self::OP_AND, self::OP_OR])) { @@ -70,8 +59,7 @@ public function addPredicate(PredicateInterface $predicate, ?string $combination * * @param PredicateInterface|\Closure|string|array $predicates * @param string $combination - * - * @return self Provides a fluent interface + * @return self * * @throws Exception\InvalidArgumentException */ @@ -141,23 +129,11 @@ public function addPredicates($predicates, string $combination = self::OP_AND) : return $this; } - /** - * Return the predicates - * - * @return PredicateInterface[] - */ public function getPredicates() : array { return $this->predicates; } - /** - * Add predicate using OR operator - * - * @param PredicateInterface $predicate - * - * @return self Provides a fluent interface - */ public function orPredicate(PredicateInterface $predicate) : self { $this->predicates[] = [self::OP_OR, $predicate]; @@ -165,13 +141,6 @@ public function orPredicate(PredicateInterface $predicate) : self return $this; } - /** - * Add predicate using AND operator - * - * @param PredicateInterface $predicate - * - * @return self Provides a fluent interface - */ public function andPredicate(PredicateInterface $predicate) : self { $this->predicates[] = [self::OP_AND, $predicate]; @@ -179,11 +148,6 @@ public function andPredicate(PredicateInterface $predicate) : self return $this; } - /** - * Get predicate parts for where statement - * - * @return array - */ public function getExpressionData() : array { $parts = []; @@ -209,11 +173,6 @@ public function getExpressionData() : array return $parts; } - /** - * Get count of attached predicates - * - * @return int - */ public function count() : int { return count($this->predicates); diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 9ead676c79..026f89def2 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -161,7 +161,7 @@ public function __construct(?$table = null) * Create from clause * * @param string|array|TableIdentifier $table - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function from($table) : self @@ -190,7 +190,7 @@ public function from($table) : self /** * @param string|Expression $quantifier DISTINCT|ALL - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function quantifier($quantifier) : self @@ -221,7 +221,7 @@ public function quantifier($quantifier) : self * * @param array $columns * @param bool $prefixColumnsWithTable - * @return self Provides a fluent interface + * @return self */ public function columns(array $columns, bool $prefixColumnsWithTable = true) : self { @@ -237,7 +237,7 @@ public function columns(array $columns, bool $prefixColumnsWithTable = true) : s * @param string|Predicate\Expression $on * @param string|array $columns * @param string $type one of the JOIN_* constants - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function join($name, $on, $columns = self::SQL_STAR, string $type = self::JOIN_INNER) : self @@ -252,7 +252,7 @@ public function join($name, $on, $columns = self::SQL_STAR, string $type = self: * * @param Where|\Closure|string|array|Predicate\PredicateInterface $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self @@ -267,7 +267,7 @@ public function where($predicate, string $combination = Predicate\PredicateSet:: /** * @param mixed $group - * @return self Provides a fluent interface + * @return self */ public function group($group) : self { @@ -286,7 +286,7 @@ public function group($group) : self * * @param Where|\Closure|string|array $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet - * @return self Provides a fluent interface + * @return self */ public function having($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self { @@ -300,7 +300,7 @@ public function having($predicate, string $combination = Predicate\PredicateSet: /** * @param string|array $order - * @return self Provides a fluent interface + * @return self */ public function order($order) : self { @@ -323,22 +323,12 @@ public function order($order) : self return $this; } - /** - * @param int $limit - * @return self Provides a fluent interface - * @throws Exception\InvalidArgumentException - */ public function limit(int $limit) : self { $this->limit = $limit; return $this; } - /** - * @param int $offset - * @return self Provides a fluent interface - * @throws Exception\InvalidArgumentException - */ public function offset(int $offset) : self { $this->offset = $offset; @@ -404,7 +394,7 @@ public function reset(string $part) : self /** * @param string $index * @param array|string $specification - * @return self Provides a fluent interface + * @return self */ public function setSpecification(string $index, $specification) : self { @@ -433,11 +423,6 @@ public function getRawState(?string $key = null) return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } - /** - * Returns whether the table is read only or not. - * - * @return bool - */ public function isTableReadOnly() : bool { return $this->tableReadOnly; @@ -463,14 +448,6 @@ protected function processStatementEnd( } } - /** - * Process the select part - * - * @param PlatformInterface $platform - * @param DriverInterface $driver - * @param ParameterContainer $parameterContainer - * @return null|array - */ protected function processSelect( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -725,7 +702,6 @@ public function __clone() * @param PlatformInterface $platform * @param DriverInterface $driver * @param ParameterContainer $parameterContainer - * * @return array */ protected function resolveTable( diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 87dd3302ca..8e536403ba 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -41,9 +41,6 @@ public function __construct( $this->sqlPlatform = $sqlPlatform ?: new Platform\Platform($adapter); } - /** - * @return null|AdapterInterface - */ public function getAdapter() : ?AdapterInterface { return $this->adapter; @@ -56,7 +53,7 @@ public function hasTable() : bool /** * @param string|array|TableIdentifier $table - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function setTable($table) : self @@ -157,7 +154,6 @@ public function prepareStatementForSqlObject( * * @param SqlInterface $sqlObject * @param PlatformInterface|null $platform - * * @return string * * @deprecated Deprecated in 2.4. Use buildSqlString() instead diff --git a/src/Sql/SqlInterface.php b/src/Sql/SqlInterface.php index 6b88681d2a..5831f98fb8 100644 --- a/src/Sql/SqlInterface.php +++ b/src/Sql/SqlInterface.php @@ -13,12 +13,5 @@ interface SqlInterface { - /** - * Get SQL string for statement - * - * @param null|PlatformInterface $adapterPlatform - * - * @return string - */ public function getSqlString(?PlatformInterface $adapterPlatform = null) : string; } diff --git a/src/Sql/TableIdentifier.php b/src/Sql/TableIdentifier.php index a5895d003a..e90ecf89e9 100644 --- a/src/Sql/TableIdentifier.php +++ b/src/Sql/TableIdentifier.php @@ -17,10 +17,6 @@ class TableIdentifier /** @var null|string */ protected $schema; - /** - * @param string $table - * @param null|string $schema - */ public function __construct(string $table, ?string $schema = null) { if (! (is_string($table) || is_callable([$table, '__toString']))) { @@ -58,7 +54,6 @@ public function __construct(string $table, ?string $schema = null) /** * @param string $table - * * @deprecated please use the constructor and build a new {@see TableIdentifier} instead */ public function setTable(string $table) : void @@ -66,25 +61,18 @@ public function setTable(string $table) : void $this->table = $table; } - /** - * @return string - */ public function getTable() : string { return $this->table; } - /** - * @return bool - */ public function hasSchema() : bool { return ($this->schema !== null); } /** - * @param $schema - * + * @param null|string $schema * @deprecated please use the constructor and build a new {@see TableIdentifier} instead */ public function setSchema(?string $schema) : void diff --git a/src/Sql/Update.php b/src/Sql/Update.php index e66223b30f..0276c15a4f 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -78,7 +78,7 @@ public function __construct(?$table = null) * Specify table for statement * * @param string|TableIdentifier $table - * @return self Provides a fluent interface + * @return self */ public function table($table) : self { @@ -91,7 +91,7 @@ public function table($table) : self * * @param array $values Associative array of key values * @param string $flag One of the VALUES_* constants - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function set(array $values, string $flag = self::VALUES_SET) : self @@ -118,7 +118,7 @@ public function set(array $values, string $flag = self::VALUES_SET) : self * * @param Where|\Closure|string|array $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self @@ -137,7 +137,7 @@ public function where($predicate, string $combination = Predicate\PredicateSet:: * @param string|array $name * @param string $on * @param string $type one of the JOIN_* constants - * @return self Provides a fluent interface + * @return self * @throws Exception\InvalidArgumentException */ public function join($name, string $on, string $type = Join::JOIN_INNER) : self @@ -251,13 +251,6 @@ public function __get(string $name) } } - /** - * __clone - * - * Resets the where object each time the Update is cloned. - * - * @return void - */ public function __clone() { $this->where = clone $this->where; From 5bb0ad8d8a9d49d5b90c87194b6041cbd35b4e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 23:09:51 +0100 Subject: [PATCH 34/45] Revert short list syntax where incompatible --- src/Sql/Predicate/Like.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index 7a3f977dda..bf327957d7 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -71,8 +71,8 @@ public function getSpecification() : string public function getExpressionData() : array { - [$values[], $types[]] = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); - [$values[], $types[]] = $this->normalizeArgument($this->like, self::TYPE_VALUE); + list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); + list($values[], $types[]) = $this->normalizeArgument($this->like, self::TYPE_VALUE); return [ [ $this->specification, From aca883d390b98b54885e7845e991025a5ed8580e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20R=C3=BCckauer?= Date: Sat, 16 Mar 2019 23:11:10 +0100 Subject: [PATCH 35/45] Removed duplicate blank lines --- src/Sql/Ddl/Column/Column.php | 2 -- src/Sql/Ddl/Constraint/ForeignKey.php | 1 - src/Sql/Platform/IbmDb2/SelectDecorator.php | 1 - src/Sql/Predicate/Like.php | 1 - 4 files changed, 5 deletions(-) diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 6973a399bd..4367797c74 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -99,7 +99,6 @@ public function setOption(string $name, string $value) : self return $this; } - public function getOptions() : array { return $this->options; @@ -112,7 +111,6 @@ public function addConstraint(ConstraintInterface $constraint) : self return $this; } - public function getExpressionData() : array { $spec = $this->specification; diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index 0ba9c8ae6a..a7c7fd09d8 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -87,7 +87,6 @@ public function setReferenceColumn(?$referenceColumn) : self return $this; } - public function getReferenceColumn() : array { return $this->referenceColumn; diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 88179d64c5..317622b8dc 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -50,7 +50,6 @@ public function setSubject($select) $this->subject = $select; } - public function getSupportsLimitOffset() : bool { return $this->supportsLimitOffset; diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index bf327957d7..e88aeafa02 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -68,7 +68,6 @@ public function getSpecification() : string return $this->specification; } - public function getExpressionData() : array { list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); From f94abb719c2a5cd488070444e43bcb38a79a2a0a Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sat, 16 Mar 2019 20:26:36 -0700 Subject: [PATCH 36/45] Resolving merge conflict --- src/Sql/Select.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 026f89def2..1e3448ee7d 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -299,7 +299,7 @@ public function having($predicate, string $combination = Predicate\PredicateSet: } /** - * @param string|array $order + * @param string|array|Expression $order * @return self */ public function order($order) : self From 417ca86f162c3ea3a6d15f2d235b832b9550983b Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 09:02:18 -0700 Subject: [PATCH 37/45] removed IDE/OS specifics --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index c305605c0d..245087af8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.idea/ /clover.xml /coveralls-upload.json /docs/html/ From 16dbb402d137a2e4666655b904b3039bfa53fd46 Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 09:04:26 -0700 Subject: [PATCH 38/45] fixed typehint --- src/Sql/AbstractSql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 3232ae3e44..b67e7a7d13 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -31,7 +31,7 @@ abstract class AbstractSql implements SqlInterface /** @var string[]|array[] Specifications for Sql String generation */ protected $specifications = []; - /** @var string[] */ + /** @var mixed[] */ protected $processInfo = ['paramPrefix' => '', 'subselectCount' => 0]; /** @var array */ From da8b22bdd86704e4a229b12b18c3d435025876bc Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 09:05:53 -0700 Subject: [PATCH 39/45] added parenthesis --- src/Sql/AbstractSql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index b67e7a7d13..fd220f06fe 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -39,7 +39,7 @@ abstract class AbstractSql implements SqlInterface public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { - $adapterPlatform = $adapterPlatform ?: new DefaultAdapterPlatform; + $adapterPlatform = ($adapterPlatform) ?: new DefaultAdapterPlatform; return $this->buildSqlString($adapterPlatform); } From 311ad6ce7be1fdb76d81f8fceb36674888ba4ab0 Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 09:28:00 -0700 Subject: [PATCH 40/45] changed self to $this --- src/Sql/AbstractSql.php | 22 ++++++------ src/Sql/Combine.php | 2 +- src/Sql/Ddl/AlterTable.php | 12 +++---- src/Sql/Ddl/Column/Column.php | 2 +- src/Sql/Ddl/Constraint/AbstractConstraint.php | 2 +- src/Sql/Ddl/Constraint/ForeignKey.php | 2 +- src/Sql/Delete.php | 4 +-- src/Sql/Expression.php | 4 +-- src/Sql/Insert.php | 4 +-- src/Sql/Join.php | 2 +- .../Mysql/Ddl/AlterTableDecorator.php | 2 +- .../Mysql/Ddl/CreateTableDecorator.php | 2 +- .../SqlServer/Ddl/CreateTableDecorator.php | 2 +- src/Sql/Platform/Sqlite/SelectDecorator.php | 2 +- src/Sql/Predicate/Between.php | 4 +-- src/Sql/Predicate/In.php | 4 +-- src/Sql/Predicate/Operator.php | 8 ++--- src/Sql/Predicate/Predicate.php | 34 +++++++++---------- src/Sql/Predicate/PredicateSet.php | 2 +- src/Sql/Select.php | 19 ++++++----- src/Sql/Sql.php | 2 +- src/Sql/Update.php | 8 ++--- 22 files changed, 73 insertions(+), 72 deletions(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index fd220f06fe..0ca895cbfa 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -44,7 +44,7 @@ public function getSqlString(?PlatformInterface $adapterPlatform = null) : strin } protected function buildSqlString( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : ?string { @@ -80,7 +80,7 @@ protected function buildSqlString( * Render table with alias in from/join parts * * @todo move TableIdentifier concatenation here - * @param string $table + * @param string $table * @param string|null $alias * @return string */ @@ -92,11 +92,11 @@ protected function renderTable(string $table, ?string $alias = null) : string /** * @staticvar int $runtimeExpressionPrefix * - * @param ExpressionInterface $expression - * @param PlatformInterface $platform - * @param null|DriverInterface $driver + * @param ExpressionInterface $expression + * @param PlatformInterface $platform + * @param null|DriverInterface $driver * @param null|ParameterContainer $parameterContainer - * @param null|string $namedParameterPrefix + * @param null|string $namedParameterPrefix * @return string * * @throws Exception\RuntimeException @@ -156,7 +156,7 @@ protected function processExpression( // Process values and types (the middle and last position of the // expression data) $values = $part[1]; - $types = isset($part[2]) ? $part[2] : []; + $types = isset($part[2]) ?? []; foreach ($values as $vIndex => $value) { if (! isset($types[$vIndex])) { @@ -303,8 +303,8 @@ protected function processSubSelect( } protected function processJoin( - Join $joins, - PlatformInterface $platform, + Join $joins, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : ?array { @@ -430,7 +430,7 @@ protected function resolveColumnValue( */ protected function resolveTable( $table, - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { @@ -446,7 +446,7 @@ protected function resolveTable( $table = $platform->quoteIdentifier($table); } - if (is_string($schema) && $table) { + if ($schema && $table) { $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; } diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index b0bba29fa5..0bc27a2d91 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -58,7 +58,7 @@ public function __construct(?$select = null, string $type = self::COMBINE_UNION, * @param Select|array $select * @param string $type * @param string $modifier - * @return self + * @return $this * * @throws Exception\InvalidArgumentException */ diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index 5ab9ec77e0..d751b469d9 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -47,7 +47,7 @@ class AlterTable extends AbstractSql implements SqlInterface self::TABLE => "ALTER TABLE %1\$s\n", self::ADD_COLUMNS => [ '%1$s' => [ - [1 => "ADD COLUMN %1\$s,\n", 'combinedby' => ''] + [1 => "ADD COLUMN %1\$s,\n", 'combinedby' => ''], ] ], self::CHANGE_COLUMNS => [ @@ -92,7 +92,7 @@ public function setTable(string $name) : self /** * @param ColumnInterface $column - * @return self + * @return $this */ public function addColumn(ColumnInterface $column) : self { @@ -104,7 +104,7 @@ public function addColumn(ColumnInterface $column) : self /** * @param string $name * @param ColumnInterface $column - * @return self + * @return $this */ public function changeColumn(string $name, ColumnInterface $column) : self { @@ -115,7 +115,7 @@ public function changeColumn(string $name, ColumnInterface $column) : self /** * @param string $name - * @return self + * @return $this */ public function dropColumn(string $name) : self { @@ -126,7 +126,7 @@ public function dropColumn(string $name) : self /** * @param string $name - * @return self + * @return $this */ public function dropConstraint(string $name) : self { @@ -137,7 +137,7 @@ public function dropConstraint(string $name) : self /** * @param ConstraintInterface $constraint - * @return self + * @return $this */ public function addConstraint(ConstraintInterface $constraint) : self { diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 4367797c74..79814a9098 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -68,7 +68,7 @@ public function isNullable() : bool /** * @param null|string|int $default - * @return self + * @return $this */ public function setDefault(?$default) : self { diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index c8e0af7a03..d58e2cfc90 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -53,7 +53,7 @@ public function getName() : string /** * @param null|string|array $columns - * @return self + * @return $this */ public function setColumns(?$columns) : self { diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index a7c7fd09d8..c056c9d611 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -78,7 +78,7 @@ public function getReferenceTable() : string /** * @param null|string|array $referenceColumn - * @return self + * @return $this */ public function setReferenceColumn(?$referenceColumn) : self { diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index b7935a332b..99fea1c94b 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -62,7 +62,7 @@ public function __construct(?$table = null) * Create from statement * * @param string|TableIdentifier $table - * @return self + * @return $this */ public function from($table) : self { @@ -88,7 +88,7 @@ public function getRawState(?string $key = null) * * @param Where|\Closure|string|array $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet - * @return self + * @return $this */ public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self { diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 57901fb4f0..9753416c85 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -73,7 +73,7 @@ public function getExpression() : string /** * @param $parameters - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function setParameters($parameters) : self @@ -95,7 +95,7 @@ public function getParameters() : array /** * @deprecated * @param array $types - * @return self + * @return $this */ public function setTypes(array $types) : self { diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index e531ac7adf..4c2e70da31 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -56,7 +56,7 @@ public function __construct(?$table = null) * Create INTO clause * * @param string|TableIdentifier $table - * @return self + * @return $this */ public function into($table) : self { @@ -75,7 +75,7 @@ public function columns(array $columns) : self * * @param array|Select $values * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function values($values, string $flag = self::VALUES_SET) : self diff --git a/src/Sql/Join.php b/src/Sql/Join.php index aa14c1d404..1214b37974 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -77,7 +77,7 @@ public function getJoins() : array * of column names, or (a) specification(s) such as SQL_STAR representing * the columns to join. * @param string $type The JOIN type to use; see the JOIN_* constants. - * @return self + * @return $this * @throws Exception\InvalidArgumentException for invalid $name values. */ public function join($name, $on, $columns = [Select::SQL_STAR], string $type = Join::JOIN_INNER) : self diff --git a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php index 0ec33f25b1..690c0e527d 100644 --- a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -43,7 +43,7 @@ class AlterTableDecorator extends AlterTable implements PlatformDecoratorInterfa /** * @param AlterTable $subject - * @return self + * @return $this */ public function setSubject($subject) : self { diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index 14c83014db..256aa6ab72 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -35,7 +35,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter /** * @param CreateTable $subject - * @return self + * @return $this */ public function setSubject($subject) : self { diff --git a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index cd67126f0f..330ad4131c 100644 --- a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -20,7 +20,7 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter /** * @param CreateTable $subject - * @return self + * @return $this */ public function setSubject($subject) : self { diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index 3a125c5278..8b2a9e024b 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -22,7 +22,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface /** * @param Select $select - * @return self + * @return $this */ public function setSubject($select) : self { diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index a678f48698..61c763c755 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -56,7 +56,7 @@ public function getIdentifier() : ?string * Set minimum boundary for comparison * * @param int|float|string $minValue - * @return self + * @return $this */ public function setMinValue($minValue) : self { @@ -78,7 +78,7 @@ public function getMinValue() * Set maximum boundary for comparison * * @param int|float|string $maxValue - * @return self + * @return $this */ public function setMaxValue($maxValue) : self { diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index 64f877a5c7..daea281722 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -43,7 +43,7 @@ public function __construct(?$identifier = null, ?$valueSet = null) * Set identifier for comparison * * @param string|array $identifier - * @return self + * @return $this */ public function setIdentifier($identifier) : self { @@ -65,7 +65,7 @@ public function getIdentifier() * Set set of values for IN comparison * * @param array|Select $valueSet - * @return self + * @return $this * * @throws Exception\InvalidArgumentException */ diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 1b47f62855..2abf5714dc 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -95,7 +95,7 @@ public function __construct( * Set left side of operator * * @param int|float|bool|string $left - * @return self + * @return $this */ public function setLeft($left) : self { @@ -122,7 +122,7 @@ public function getLeft() * Set parameter type for left side of operator * * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function setLeftType($type) : self @@ -162,7 +162,7 @@ public function getOperator() : string * Set right side of operator * * @param int|float|bool|string $right - * @return self + * @return $this */ public function setRight($right) : self { @@ -189,7 +189,7 @@ public function getRight() * Set parameter type for right side of operator * * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes} - * @return self + * @return $this * * @throws Exception\InvalidArgumentException */ diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index ff6f4c5035..1d423af1de 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -59,7 +59,7 @@ public function unnest() : Predicate * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * @return self + * @return $this */ public function equalTo( $left, @@ -85,7 +85,7 @@ public function equalTo( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * @return self + * @return $this */ public function notEqualTo( $left, @@ -111,7 +111,7 @@ public function notEqualTo( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * @return self + * @return $this */ public function lessThan( $left, @@ -137,7 +137,7 @@ public function lessThan( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * @return self + * @return $this */ public function greaterThan( $left, @@ -163,7 +163,7 @@ public function greaterThan( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * @return self + * @return $this */ public function lessThanOrEqualTo( $left, @@ -189,7 +189,7 @@ public function lessThanOrEqualTo( * @param int|float|bool|string $right * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes} * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} - * @return self + * @return $this */ public function greaterThanOrEqualTo( $left, @@ -213,7 +213,7 @@ public function greaterThanOrEqualTo( * * @param string|Expression $identifier * @param string $like - * @return self + * @return $this */ public function like($identifier, string $like) : self { @@ -233,7 +233,7 @@ public function like($identifier, string $like) : self * * @param string|Expression $identifier * @param string $notLike - * @return self + * @return $this */ public function notLike($identifier, string $notLike) : self { @@ -252,7 +252,7 @@ public function notLike($identifier, string $notLike) : self * * @param $expression * @param $parameters - * @return self + * @return $this */ public function expression($expression, ?$parameters = null) : self { @@ -272,7 +272,7 @@ public function expression($expression, ?$parameters = null) : self * Literal predicate, for parameters, use expression() * * @param string $literal - * @return self + * @return $this */ public function literal(string $literal) : self { @@ -303,7 +303,7 @@ public function literal(string $literal) : self * Utilizes IsNull predicate * * @param string|Expression $identifier - * @return self + * @return $this */ public function isNull($identifier) : self { @@ -323,7 +323,7 @@ public function isNull($identifier) : self * Utilizes IsNotNull predicate * * @param string|Expression $identifier - * @return self + * @return $this */ public function isNotNull($identifier) : self { @@ -344,7 +344,7 @@ public function isNotNull($identifier) : self * * @param string|Expression $identifier * @param array|Select|null $valueSet - * @return self + * @return s$this */ public function in($identifier, ?$valueSet = null) : self { @@ -365,7 +365,7 @@ public function in($identifier, ?$valueSet = null) : self * * @param string|Expression $identifier * @param array|Select|null $valueSet - * @return self + * @return $this */ public function notIn($identifier, ?$valueSet = null) : self { @@ -386,7 +386,7 @@ public function notIn($identifier, ?$valueSet = null) : self * @param string|Expression $identifier * @param int|float|string $minValue * @param int|float|string $maxValue - * @return self + * @return $this */ public function between($identifier, $minValue, $maxValue) : self { @@ -408,7 +408,7 @@ public function between($identifier, $minValue, $maxValue) : self * @param string|Expression $identifier * @param int|float|string $minValue * @param int|float|string $maxValue - * @return self + * @return $this */ public function notBetween($identifier, $minValue, $maxValue) : self { @@ -430,7 +430,7 @@ public function notBetween($identifier, $minValue, $maxValue) : self * used fluently within where chains as any other concrete predicate. * * @param PredicateInterface $predicate - * @return self + * @return $this */ public function predicate(PredicateInterface $predicate) : self { diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index b5970a38c4..a6c84b8698 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -59,7 +59,7 @@ public function addPredicate(PredicateInterface $predicate, ?string $combination * * @param PredicateInterface|\Closure|string|array $predicates * @param string $combination - * @return self + * @return $this * * @throws Exception\InvalidArgumentException */ diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 84efc70fc2..890cb53839 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -161,7 +161,7 @@ public function __construct(?$table = null) * Create from clause * * @param string|array|TableIdentifier $table - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function from($table) : self @@ -190,7 +190,7 @@ public function from($table) : self /** * @param string|Expression $quantifier DISTINCT|ALL - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function quantifier($quantifier) : self @@ -202,6 +202,7 @@ public function quantifier($quantifier) : self ); } $this->quantifier = $quantifier; + return $this; } @@ -221,7 +222,7 @@ public function quantifier($quantifier) : self * * @param array $columns * @param bool $prefixColumnsWithTable - * @return self + * @return $this */ public function columns(array $columns, bool $prefixColumnsWithTable = true) : self { @@ -237,7 +238,7 @@ public function columns(array $columns, bool $prefixColumnsWithTable = true) : s * @param string|Predicate\Expression $on * @param string|array $columns * @param string $type one of the JOIN_* constants - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function join($name, $on, $columns = self::SQL_STAR, string $type = self::JOIN_INNER) : self @@ -252,7 +253,7 @@ public function join($name, $on, $columns = self::SQL_STAR, string $type = self: * * @param Where|\Closure|string|array|Predicate\PredicateInterface $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self @@ -267,7 +268,7 @@ public function where($predicate, string $combination = Predicate\PredicateSet:: /** * @param mixed $group - * @return self + * @return $this */ public function group($group) : self { @@ -286,7 +287,7 @@ public function group($group) : self * * @param Where|\Closure|string|array $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet - * @return self + * @return $this */ public function having($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self { @@ -300,7 +301,7 @@ public function having($predicate, string $combination = Predicate\PredicateSet: /** * @param string|array|Expression $order - * @return self Provides a fluent interface + * @return $this Provides a fluent interface */ public function order($order) : self { @@ -394,7 +395,7 @@ public function reset(string $part) : self /** * @param string $index * @param array|string $specification - * @return self + * @return $this */ public function setSpecification(string $index, $specification) : self { diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 8e536403ba..72b7ac13f2 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -53,7 +53,7 @@ public function hasTable() : bool /** * @param string|array|TableIdentifier $table - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function setTable($table) : self diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 0276c15a4f..2eba5063bb 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -78,7 +78,7 @@ public function __construct(?$table = null) * Specify table for statement * * @param string|TableIdentifier $table - * @return self + * @return $this */ public function table($table) : self { @@ -91,7 +91,7 @@ public function table($table) : self * * @param array $values Associative array of key values * @param string $flag One of the VALUES_* constants - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function set(array $values, string $flag = self::VALUES_SET) : self @@ -118,7 +118,7 @@ public function set(array $values, string $flag = self::VALUES_SET) : self * * @param Where|\Closure|string|array $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self @@ -137,7 +137,7 @@ public function where($predicate, string $combination = Predicate\PredicateSet:: * @param string|array $name * @param string $on * @param string $type one of the JOIN_* constants - * @return self + * @return $this * @throws Exception\InvalidArgumentException */ public function join($name, string $on, string $type = Join::JOIN_INNER) : self From 110f7778d3b184ca8a5b74489a35af50247c011f Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 10:26:05 -0700 Subject: [PATCH 41/45] fixed column constructor --- src/Sql/AbstractSql.php | 2 +- src/Sql/Combine.php | 2 +- src/Sql/Ddl/Column/AbstractLengthColumn.php | 4 ++-- src/Sql/Ddl/Column/AbstractPrecisionColumn.php | 4 ++-- src/Sql/Ddl/Column/Column.php | 8 ++++---- src/Sql/Ddl/Column/Float.php | 2 +- src/Sql/Ddl/Constraint/AbstractConstraint.php | 2 +- src/Sql/Ddl/Constraint/ForeignKey.php | 6 +++--- src/Sql/Ddl/CreateTable.php | 6 +++--- src/Sql/Delete.php | 2 +- src/Sql/Expression.php | 4 ++-- src/Sql/Insert.php | 2 +- src/Sql/Platform/Platform.php | 2 +- src/Sql/Predicate/Between.php | 6 +++--- src/Sql/Predicate/Expression.php | 2 +- src/Sql/Predicate/In.php | 2 +- src/Sql/Predicate/Operator.php | 4 ++-- src/Sql/Predicate/Predicate.php | 8 ++++---- src/Sql/Select.php | 2 +- src/Sql/Sql.php | 12 ++++++------ src/Sql/Update.php | 2 +- 21 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 0ca895cbfa..015d21c4bd 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -382,7 +382,7 @@ protected function processJoin( * @return string */ protected function resolveColumnValue( - ?$column, + $column, PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null, diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 0bc27a2d91..68c7e2e70f 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -45,7 +45,7 @@ class Combine extends AbstractPreparableSql * @param string $type * @param string $modifier */ - public function __construct(?$select = null, string $type = self::COMBINE_UNION, string $modifier = '') + public function __construct($select = null, string $type = self::COMBINE_UNION, string $modifier = '') { if ($select) { $this->combine($select, $type, $modifier); diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index a613c2f7cb..78ad243615 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -15,10 +15,10 @@ abstract class AbstractLengthColumn extends Column protected $length; public function __construct( - string $name = '', + ?string $name = null, ?int $length = null, bool $nullable = false, - ?$default = null, + $default = null, array $options = [] ) { $this->setLength($length); diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index 5f6a1d459f..65d6dfd15d 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -15,11 +15,11 @@ abstract class AbstractPrecisionColumn extends AbstractLengthColumn protected $decimal; public function __construct( - string $name = '', + ?string $name = null, ?int $digits = null, ?int $decimal = null, bool $nullable = false, - ?$default = null, + $default = null, array $options = [] ) { $this->setDecimal($decimal); diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 79814a9098..ded083bd41 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -19,7 +19,7 @@ class Column implements ColumnInterface /** @var bool */ protected $isNullable = false; - /** @var string */ + /** @var string|null */ protected $name = ''; /** @var array */ @@ -34,7 +34,7 @@ class Column implements ColumnInterface /** @var string */ protected $type = 'INTEGER'; - public function __construct(string $name = '', bool $nullable = false, ?$default = null, array $options = []) + public function __construct(?string $name = null, bool $nullable = false, $default = null, array $options = []) { $this->setName($name); $this->setNullable($nullable); @@ -42,7 +42,7 @@ public function __construct(string $name = '', bool $nullable = false, ?$default $this->setOptions($options); } - public function setName(string $name) : self + public function setName(?string $name) : self { $this->name = $name; @@ -70,7 +70,7 @@ public function isNullable() : bool * @param null|string|int $default * @return $this */ - public function setDefault(?$default) : self + public function setDefault($default) : self { $this->default = $default; diff --git a/src/Sql/Ddl/Column/Float.php b/src/Sql/Ddl/Column/Float.php index d31224905b..11ac40ad55 100644 --- a/src/Sql/Ddl/Column/Float.php +++ b/src/Sql/Ddl/Column/Float.php @@ -31,7 +31,7 @@ public function __construct( ?int $digits = null, ?int $decimal = null, bool $nullable = false, - ?$default = null, + $default = null, array $options = [] ) { trigger_error( diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index d58e2cfc90..343ab64333 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -55,7 +55,7 @@ public function getName() : string * @param null|string|array $columns * @return $this */ - public function setColumns(?$columns) : self + public function setColumns($columns) : self { $this->columns = (array) $columns; diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index c056c9d611..4edc1e53b8 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -44,9 +44,9 @@ class ForeignKey extends AbstractConstraint */ public function __construct( string $name, - ?$columns, + $columns, string $referenceTable, - ?$referenceColumn, + $referenceColumn, ?string $onDeleteRule = null, ?string $onUpdateRule = null ) { @@ -80,7 +80,7 @@ public function getReferenceTable() : string * @param null|string|array $referenceColumn * @return $this */ - public function setReferenceColumn(?$referenceColumn) : self + public function setReferenceColumn($referenceColumn) : self { $this->referenceColumn = (array) $referenceColumn; diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index 243e279990..36e5b87e7b 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -113,7 +113,7 @@ protected function processTable(?PlatformInterface $adapterPlatform = null) : ar /** * @param PlatformInterface $adapterPlatform - * @return string[][]|void + * @return string[][]|null */ protected function processColumns(?PlatformInterface $adapterPlatform = null) { @@ -132,7 +132,7 @@ protected function processColumns(?PlatformInterface $adapterPlatform = null) /** * @param PlatformInterface|null $adapterPlatform - * @return array|string|void + * @return array|string|null */ protected function processCombinedby(?PlatformInterface $adapterPlatform = null) { @@ -143,7 +143,7 @@ protected function processCombinedby(?PlatformInterface $adapterPlatform = null) /** * @param PlatformInterface|null $adapterPlatform - * @return string[][]|void + * @return string[][]|null */ protected function processConstraints(?PlatformInterface $adapterPlatform = null) { diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 99fea1c94b..62d78d9b15 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -50,7 +50,7 @@ class Delete extends AbstractPreparableSql * * @param null|string|TableIdentifier $table */ - public function __construct(?$table = null) + public function __construct($table = null) { if ($table) { $this->from($table); diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 9753416c85..453f913a41 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -30,7 +30,7 @@ class Expression extends AbstractExpression * @param null|string|array $parameters * @param array $types @deprecated will be dropped in version 3.0.0 */ - public function __construct(string $expression = '', ?$parameters = null, array $types = []) + public function __construct(string $expression = '', $parameters = null, array $types = []) { if ($expression !== '') { $this->setExpression($expression); @@ -136,7 +136,7 @@ public function getExpressionData() : array } foreach ($parameters as $parameter) { - [$values[], $types[]] = $this->normalizeArgument($parameter, self::TYPE_VALUE); + list($values[], $types[]) = $this->normalizeArgument($parameter, self::TYPE_VALUE); } return [[ diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 4c2e70da31..6a531b8e61 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -45,7 +45,7 @@ class Insert extends AbstractPreparableSql * * @param null|string|TableIdentifier $table */ - public function __construct(?$table = null) + public function __construct($table = null) { if ($table) { $this->into($table); diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index 60416d9f64..f2e8e8816e 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -57,7 +57,7 @@ public function setTypeDecorator( * @param AdapterInterface|PlatformInterface|null $adapterOrPlatform * @return PlatformDecoratorInterface|PreparableSqlInterface|SqlInterface */ - public function getTypeDecorator($subject, ?$adapterOrPlatform = null) + public function getTypeDecorator($subject, $adapterOrPlatform = null) { $platformName = $this->resolvePlatformName($adapterOrPlatform); diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index 61c763c755..0648953ad2 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -110,9 +110,9 @@ public function getSpecification() : string public function getExpressionData() : array { - [$values[], $types[]] = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); - [$values[], $types[]] = $this->normalizeArgument($this->minValue, self::TYPE_VALUE); - [$values[], $types[]] = $this->normalizeArgument($this->maxValue, self::TYPE_VALUE); + list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); + list($values[], $types[]) = $this->normalizeArgument($this->minValue, self::TYPE_VALUE); + list($values[], $types[]) = $this->normalizeArgument($this->maxValue, self::TYPE_VALUE); return [ [ $this->getSpecification(), diff --git a/src/Sql/Predicate/Expression.php b/src/Sql/Predicate/Expression.php index e44a05f5ed..6fd5fff6f3 100644 --- a/src/Sql/Predicate/Expression.php +++ b/src/Sql/Predicate/Expression.php @@ -15,7 +15,7 @@ class Expression extends BaseExpression implements PredicateInterface { - public function __construct(?string $expression = null, ?$valueParameter = null) + public function __construct(?string $expression = null, $valueParameter = null) { if ($expression) { $this->setExpression($expression); diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index daea281722..ac0d926b0c 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -28,7 +28,7 @@ class In extends AbstractExpression implements PredicateInterface * @param null|string|array $identifier * @param null|array|Select $valueSet */ - public function __construct(?$identifier = null, ?$valueSet = null) + public function __construct($identifier = null, $valueSet = null) { if ($identifier) { $this->setIdentifier($identifier); diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 2abf5714dc..223b94d476 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -64,9 +64,9 @@ class Operator extends AbstractExpression implements PredicateInterface * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes} */ public function __construct( - ?$left = null, + $left = null, string $operator = self::OPERATOR_EQUAL_TO, - ?$right = null, + $right = null, string $leftType = self::TYPE_IDENTIFIER, string $rightType = self::TYPE_VALUE ) { diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index 1d423af1de..012a228ee4 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -239,7 +239,7 @@ public function notLike($identifier, string $notLike) : self { $this->addPredicate( new NotLike($identifier, $notLike), - $this->nextPredicateCombineOperator ? : $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -254,7 +254,7 @@ public function notLike($identifier, string $notLike) : self * @param $parameters * @return $this */ - public function expression($expression, ?$parameters = null) : self + public function expression($expression, $parameters = null) : self { $this->addPredicate( new Expression($expression, $parameters), @@ -346,7 +346,7 @@ public function isNotNull($identifier) : self * @param array|Select|null $valueSet * @return s$this */ - public function in($identifier, ?$valueSet = null) : self + public function in($identifier, $valueSet = null) : self { $this->addPredicate( new In($identifier, $valueSet), @@ -367,7 +367,7 @@ public function in($identifier, ?$valueSet = null) : self * @param array|Select|null $valueSet * @return $this */ - public function notIn($identifier, ?$valueSet = null) : self + public function notIn($identifier, $valueSet = null) : self { $this->addPredicate( new NotIn($identifier, $valueSet), diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 890cb53839..67728806cc 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -145,7 +145,7 @@ class Select extends AbstractPreparableSql * * @param null|string|array|TableIdentifier $table */ - public function __construct(?$table = null) + public function __construct($table = null) { if ($table) { $this->from($table); diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 72b7ac13f2..591a2772a0 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -31,7 +31,7 @@ class Sql */ public function __construct( AdapterInterface $adapter, - ?$table = null, + $table = null, ?Platform\AbstractPlatform $sqlPlatform = null ) { $this->adapter = $adapter; @@ -82,7 +82,7 @@ public function getSqlPlatform() : Platform\Platform * @param null|string|array|TableIdentifier $table * @return Select */ - public function select(?$table = null) : Select + public function select($table = null) : Select { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -97,7 +97,7 @@ public function select(?$table = null) : Select * @param null|string|TableIdentifier $table * @return Insert */ - public function insert(?$table = null) : Insert + public function insert($table = null) : Insert { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -112,7 +112,7 @@ public function insert(?$table = null) : Insert * @param null|string|TableIdentifier $table * @return Update */ - public function update(?$table = null) : Update + public function update($table = null) : Update { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -127,7 +127,7 @@ public function update(?$table = null) : Update * @param null|string|TableIdentifier $table * @return Delete */ - public function delete(?$table = null) : Delete + public function delete($table = null) : Delete { if ($this->table !== null && $table !== null) { throw new Exception\InvalidArgumentException(sprintf( @@ -135,7 +135,7 @@ public function delete(?$table = null) : Delete $this->table )); } - return new Delete($table ?: $this->table); + return new Delete($table ?? $this->table); } public function prepareStatementForSqlObject( diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 2eba5063bb..c1913df768 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -63,7 +63,7 @@ class Update extends AbstractPreparableSql * * @param null|string|TableIdentifier $table */ - public function __construct(?$table = null) + public function __construct($table = null) { if ($table) { $this->table($table); From 65409dbd0102d4aa37e53933b7a74ebdc5429102 Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 13:17:03 -0700 Subject: [PATCH 42/45] alignment and use function statements --- src/Sql/AbstractExpression.php | 2 +- src/Sql/AbstractSql.php | 6 +- src/Sql/Combine.php | 18 +-- src/Sql/Ddl/AlterTable.php | 44 ++++--- src/Sql/Ddl/Column/AbstractLengthColumn.php | 6 +- .../Ddl/Column/AbstractPrecisionColumn.php | 8 +- .../Ddl/Column/AbstractTimestampColumn.php | 2 + src/Sql/Ddl/Column/Column.php | 1 + src/Sql/Ddl/Column/Float.php | 11 +- src/Sql/Ddl/Constraint/AbstractConstraint.php | 22 ++-- src/Sql/Ddl/Constraint/Check.php | 4 +- src/Sql/Ddl/Constraint/ForeignKey.php | 28 ++-- src/Sql/Ddl/CreateTable.php | 11 +- src/Sql/Ddl/DropTable.php | 2 +- src/Sql/Ddl/Index/Index.php | 13 +- src/Sql/Delete.php | 30 +++-- src/Sql/Expression.php | 19 ++- src/Sql/ExpressionInterface.php | 6 +- src/Sql/Insert.php | 35 +++-- src/Sql/Join.php | 9 +- src/Sql/Literal.php | 5 +- src/Sql/Platform/IbmDb2/IbmDb2.php | 2 +- src/Sql/Platform/IbmDb2/SelectDecorator.php | 12 +- .../Mysql/Ddl/AlterTableDecorator.php | 19 +-- .../Mysql/Ddl/CreateTableDecorator.php | 29 +++-- src/Sql/Platform/Mysql/Mysql.php | 6 +- src/Sql/Platform/Mysql/SelectDecorator.php | 5 +- src/Sql/Platform/Oracle/Oracle.php | 2 +- src/Sql/Platform/Oracle/SelectDecorator.php | 3 +- src/Sql/Platform/Platform.php | 20 ++- .../SqlServer/Ddl/CreateTableDecorator.php | 2 + .../Platform/SqlServer/SelectDecorator.php | 9 +- src/Sql/Platform/SqlServer/SqlServer.php | 7 +- src/Sql/Platform/Sqlite/SelectDecorator.php | 13 +- src/Sql/Predicate/Between.php | 4 +- src/Sql/Predicate/Expression.php | 1 + src/Sql/Predicate/In.php | 9 +- src/Sql/Predicate/Like.php | 2 + src/Sql/Predicate/Operator.php | 3 +- src/Sql/Predicate/Predicate.php | 63 +++++---- src/Sql/Predicate/PredicateSet.php | 10 +- src/Sql/Select.php | 122 +++++++++++------- src/Sql/Sql.php | 28 ++-- src/Sql/TableIdentifier.php | 7 + src/Sql/Update.php | 38 +++--- 45 files changed, 447 insertions(+), 251 deletions(-) diff --git a/src/Sql/AbstractExpression.php b/src/Sql/AbstractExpression.php index ee1e9ef6a5..73cb1c474d 100644 --- a/src/Sql/AbstractExpression.php +++ b/src/Sql/AbstractExpression.php @@ -34,7 +34,7 @@ abstract class AbstractExpression implements ExpressionInterface /** * Normalize Argument * - * @param mixed $argument + * @param mixed $argument * @param string $defaultType * @return array * diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 015d21c4bd..fa0921d1c9 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -17,6 +17,7 @@ use Zend\Db\Sql\Exception\RuntimeException; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; use function count; +use function get_object_vars; use function gettype; use function implode; use function is_array; @@ -24,6 +25,7 @@ use function preg_replace; use function rtrim; use function sprintf; +use function strtoupper; use function vsprintf; abstract class AbstractSql implements SqlInterface @@ -39,7 +41,7 @@ abstract class AbstractSql implements SqlInterface public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { - $adapterPlatform = ($adapterPlatform) ?: new DefaultAdapterPlatform; + $adapterPlatform = ($adapterPlatform) ?? new DefaultAdapterPlatform; return $this->buildSqlString($adapterPlatform); } @@ -206,7 +208,7 @@ protected function processExpression( /** * @param string|array $specifications - * @param array $parameters + * @param array $parameters * @return string * * @throws Exception\RuntimeException diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 68c7e2e70f..4cc6e5c0ce 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -14,22 +14,24 @@ use Zend\Db\Adapter\Platform\PlatformInterface; use function array_key_exists; use function array_merge; +use function compact; use function get_class; use function gettype; use function is_array; use function is_object; use function sprintf; use function strtoupper; +use function trim; /** * Combine SQL statement - allows combining multiple select statements into one */ class Combine extends AbstractPreparableSql { - public const COLUMNS = 'columns'; - public const COMBINE = 'combine'; - public const COMBINE_UNION = 'union'; - public const COMBINE_EXCEPT = 'except'; + public const COLUMNS = 'columns'; + public const COMBINE = 'combine'; + public const COMBINE_UNION = 'union'; + public const COMBINE_EXCEPT = 'except'; public const COMBINE_INTERSECT = 'intersect'; /** @var string[] */ @@ -56,8 +58,8 @@ public function __construct($select = null, string $type = self::COMBINE_UNION, * Create combine clause * * @param Select|array $select - * @param string $type - * @param string $modifier + * @param string $type + * @param string $modifier * @return $this * * @throws Exception\InvalidArgumentException @@ -119,7 +121,7 @@ public function except($select, string $modifier = '') : self * Create intersect clause * * @param Select|array $select - * @param string $modifier + * @param string $modifier * @return self */ public function intersect($select, string $modifier = '') : self @@ -128,7 +130,7 @@ public function intersect($select, string $modifier = '') : self } protected function buildSqlString( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : ?string { diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index d751b469d9..dc6ae8dbe4 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -14,6 +14,7 @@ use Zend\Db\Sql\Ddl\Column\ColumnInterface; use Zend\Db\Sql\Ddl\Constraint\ConstraintInterface; use Zend\Db\Sql\TableIdentifier; +use function array_key_exists; class AlterTable extends AbstractSql implements SqlInterface { @@ -24,6 +25,8 @@ class AlterTable extends AbstractSql implements SqlInterface public const DROP_CONSTRAINTS = 'dropConstraints'; public const TABLE = 'table'; + private const COMBINEDBY = 'combinedby'; + /** @var array */ protected $addColumns = []; @@ -47,29 +50,29 @@ class AlterTable extends AbstractSql implements SqlInterface self::TABLE => "ALTER TABLE %1\$s\n", self::ADD_COLUMNS => [ '%1$s' => [ - [1 => "ADD COLUMN %1\$s,\n", 'combinedby' => ''], - ] + [1 => "ADD COLUMN %1\$s,\n", self::COMBINEDBY => ''], + ], ], self::CHANGE_COLUMNS => [ '%1$s' => [ - [2 => "CHANGE COLUMN %1\$s %2\$s,\n", 'combinedby' => ''], - ] + [2 => "CHANGE COLUMN %1\$s %2\$s,\n", self::COMBINEDBY => ''], + ], ], self::DROP_COLUMNS => [ '%1$s' => [ - [1 => "DROP COLUMN %1\$s,\n", 'combinedby' => ''], - ] + [1 => "DROP COLUMN %1\$s,\n", self::COMBINEDBY => ''], + ], ], self::ADD_CONSTRAINTS => [ '%1$s' => [ - [1 => "ADD %1\$s,\n", 'combinedby' => ''], - ] + [1 => "ADD %1\$s,\n", self::COMBINEDBY => ''], + ], ], self::DROP_CONSTRAINTS => [ '%1$s' => [ - [1 => "DROP CONSTRAINT %1\$s,\n", 'combinedby' => ''], - ] - ] + [1 => "DROP CONSTRAINT %1\$s,\n", self::COMBINEDBY => ''], + ], + ], ]; /** @var string */ @@ -102,7 +105,7 @@ public function addColumn(ColumnInterface $column) : self } /** - * @param string $name + * @param string $name * @param ColumnInterface $column * @return $this */ @@ -153,11 +156,11 @@ public function addConstraint(ConstraintInterface $constraint) : self public function getRawState(?string $key = null) : array { $rawState = [ - self::TABLE => $this->table, - self::ADD_COLUMNS => $this->addColumns, - self::DROP_COLUMNS => $this->dropColumns, - self::CHANGE_COLUMNS => $this->changeColumns, - self::ADD_CONSTRAINTS => $this->addConstraints, + self::TABLE => $this->table, + self::ADD_COLUMNS => $this->addColumns, + self::DROP_COLUMNS => $this->dropColumns, + self::CHANGE_COLUMNS => $this->changeColumns, + self::ADD_CONSTRAINTS => $this->addConstraints, self::DROP_CONSTRAINTS => $this->dropConstraints, ]; @@ -172,6 +175,7 @@ protected function processTable(?PlatformInterface $adapterPlatform = null) : ar protected function processAddColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; + foreach ($this->addColumns as $column) { $sqls[] = $this->processExpression($column, $adapterPlatform); } @@ -182,10 +186,11 @@ protected function processAddColumns(?PlatformInterface $adapterPlatform = null) protected function processChangeColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; + foreach ($this->changeColumns as $name => $column) { $sqls[] = [ $adapterPlatform->quoteIdentifier($name), - $this->processExpression($column, $adapterPlatform) + $this->processExpression($column, $adapterPlatform), ]; } @@ -195,6 +200,7 @@ protected function processChangeColumns(?PlatformInterface $adapterPlatform = nu protected function processDropColumns(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; + foreach ($this->dropColumns as $column) { $sqls[] = $adapterPlatform->quoteIdentifier($column); } @@ -205,6 +211,7 @@ protected function processDropColumns(?PlatformInterface $adapterPlatform = null protected function processAddConstraints(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; + foreach ($this->addConstraints as $constraint) { $sqls[] = $this->processExpression($constraint, $adapterPlatform); } @@ -215,6 +222,7 @@ protected function processAddConstraints(?PlatformInterface $adapterPlatform = n protected function processDropConstraints(?PlatformInterface $adapterPlatform = null) : array { $sqls = []; + foreach ($this->dropConstraints as $constraint) { $sqls[] = $adapterPlatform->quoteIdentifier($constraint); } diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index 78ad243615..8499fedb02 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -16,10 +16,10 @@ abstract class AbstractLengthColumn extends Column public function __construct( ?string $name = null, - ?int $length = null, - bool $nullable = false, + ?int $length = null, + bool $nullable = false, $default = null, - array $options = [] + array $options = [] ) { $this->setLength($length); diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index 65d6dfd15d..0a709a2227 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -16,11 +16,11 @@ abstract class AbstractPrecisionColumn extends AbstractLengthColumn public function __construct( ?string $name = null, - ?int $digits = null, - ?int $decimal = null, - bool $nullable = false, + ?int $digits = null, + ?int $decimal = null, + bool $nullable = false, $default = null, - array $options = [] + array $options = [] ) { $this->setDecimal($decimal); diff --git a/src/Sql/Ddl/Column/AbstractTimestampColumn.php b/src/Sql/Ddl/Column/AbstractTimestampColumn.php index d1625ba353..d84e1f31b6 100644 --- a/src/Sql/Ddl/Column/AbstractTimestampColumn.php +++ b/src/Sql/Ddl/Column/AbstractTimestampColumn.php @@ -9,6 +9,8 @@ namespace Zend\Db\Sql\Ddl\Column; +use function array_merge; + /** * Class AbstractTimestampColumn * @package Zend\Db\Sql\Ddl\Column diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index ded083bd41..96d25eeb24 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -10,6 +10,7 @@ namespace Zend\Db\Sql\Ddl\Column; use Zend\Db\Sql\Ddl\Constraint\ConstraintInterface; +use function array_merge; class Column implements ColumnInterface { diff --git a/src/Sql/Ddl/Column/Float.php b/src/Sql/Ddl/Column/Float.php index 11ac40ad55..d58def5338 100644 --- a/src/Sql/Ddl/Column/Float.php +++ b/src/Sql/Ddl/Column/Float.php @@ -9,6 +9,9 @@ namespace Zend\Db\Sql\Ddl\Column; +use function trigger_error; +use function sprintf; + /** * Stub class for backwards compatibility. * @@ -28,11 +31,11 @@ class Float extends Floating */ public function __construct( string $name = '', - ?int $digits = null, - ?int $decimal = null, - bool $nullable = false, + ?int $digits = null, + ?int $decimal = null, + bool $nullable = false, $default = null, - array $options = [] + array $options = [] ) { trigger_error( sprintf( diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index 343ab64333..e756825b68 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -9,6 +9,11 @@ namespace Zend\Db\Sql\Ddl\Constraint; +use function array_fill; +use function array_merge; +use function implode; +use function sprintf; + abstract class AbstractConstraint implements ConstraintInterface { /** @var string */ @@ -28,7 +33,7 @@ abstract class AbstractConstraint implements ConstraintInterface /** * @param null|string|array $columns - * @param string $name + * @param string $name */ public function __construct(?$columns = null, string $name = '') { @@ -65,6 +70,7 @@ public function setColumns($columns) : self public function addColumn(string $column) : self { $this->columns[] = $column; + return $this; } @@ -75,24 +81,24 @@ public function getColumns() : array public function getExpressionData() : array { - $colCount = count($this->columns); + $colCount = count($this->columns); $newSpecTypes = []; - $values = []; - $newSpec = ''; + $values = []; + $newSpec = ''; if ($this->name) { - $newSpec .= $this->namedSpecification; - $values[] = $this->name; + $newSpec .= $this->namedSpecification; + $values[] = $this->name; $newSpecTypes[] = self::TYPE_IDENTIFIER; } $newSpec .= $this->specification; if ($colCount) { - $values = array_merge($values, $this->columns); + $values = array_merge($values, $this->columns); $newSpecParts = array_fill(0, $colCount, '%s'); $newSpecTypes = array_merge($newSpecTypes, array_fill(0, $colCount, self::TYPE_IDENTIFIER)); - $newSpec .= sprintf($this->columnSpecification, implode(', ', $newSpecParts)); + $newSpec .= sprintf($this->columnSpecification, implode(', ', $newSpecParts)); } return [[ diff --git a/src/Sql/Ddl/Constraint/Check.php b/src/Sql/Ddl/Constraint/Check.php index 6135b995e0..d8d0f2ca06 100644 --- a/src/Sql/Ddl/Constraint/Check.php +++ b/src/Sql/Ddl/Constraint/Check.php @@ -11,6 +11,8 @@ use Zend\Db\Sql\ExpressionInterface; +use function array_unshift; + class Check extends AbstractConstraint { /** @var string|ExpressionInterface */ @@ -23,7 +25,7 @@ class Check extends AbstractConstraint /** * @param string|ExpressionInterface $expression - * @param string $name + * @param string $name */ public function __construct($expression, string $name = '') { diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index 4edc1e53b8..203cbce3d5 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -9,6 +9,12 @@ namespace Zend\Db\Sql\Ddl\Constraint; +use function array_fill; +use function array_merge; +use function count; +use function implode; +use function sprintf; + class ForeignKey extends AbstractConstraint { /** @var string */ @@ -31,21 +37,21 @@ class ForeignKey extends AbstractConstraint /** @var string[] */ protected $referenceSpecification = [ 'REFERENCES %s ', - 'ON DELETE %s ON UPDATE %s' + 'ON DELETE %s ON UPDATE %s', ]; /** - * @param string $name + * @param string $name * @param null|string|array $columns - * @param string $referenceTable + * @param string $referenceTable * @param null|string|array $referenceColumn - * @param null|string $onDeleteRule - * @param null|string $onUpdateRule + * @param null|string $onDeleteRule + * @param null|string $onUpdateRule */ public function __construct( - string $name, + string $name, $columns, - string $referenceTable, + string $referenceTable, $referenceColumn, ?string $onDeleteRule = null, ?string $onUpdateRule = null @@ -126,7 +132,8 @@ public function getExpressionData() : array $data[0][0] .= $this->referenceSpecification[0]; if ($colCount) { - $values = array_merge($values, $this->referenceColumn); + $values = array_merge($values, $this->referenceColumn); + $newSpecParts = array_fill(0, $colCount, '%s'); $newSpecTypes = array_merge($newSpecTypes, array_fill(0, $colCount, self::TYPE_IDENTIFIER)); @@ -135,8 +142,9 @@ public function getExpressionData() : array $data[0][0] .= $this->referenceSpecification[1]; - $values[] = $this->onDeleteRule; - $values[] = $this->onUpdateRule; + $values[] = $this->onDeleteRule; + $values[] = $this->onUpdateRule; + $newSpecTypes[] = self::TYPE_LITERAL; $newSpecTypes[] = self::TYPE_LITERAL; diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index 36e5b87e7b..46e50d54e4 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -14,6 +14,7 @@ use Zend\Db\Sql\Ddl\Column\ColumnInterface; use Zend\Db\Sql\Ddl\Constraint\ConstraintInterface; use Zend\Db\Sql\TableIdentifier; +use function array_key_exists; class CreateTable extends AbstractSql implements SqlInterface { @@ -34,14 +35,14 @@ class CreateTable extends AbstractSql implements SqlInterface self::TABLE => 'CREATE %1$sTABLE %2$s (', self::COLUMNS => [ "\n %1\$s" => [ - [1 => '%1$s', 'combinedby' => ",\n "] - ] + [1 => '%1$s', 'combinedby' => ",\n "], + ], ], 'combinedBy' => ',', self::CONSTRAINTS => [ "\n %1\$s" => [ - [1 => '%1$s', 'combinedby' => ",\n "] - ] + [1 => '%1$s', 'combinedby' => ",\n "], + ], ], 'statementEnd' => '%1$s', ]; @@ -51,7 +52,7 @@ class CreateTable extends AbstractSql implements SqlInterface /** * @param string|TableIdentifier $table - * @param bool $isTemporary + * @param bool $isTemporary */ public function __construct($table = '', bool $isTemporary = false) { diff --git a/src/Sql/Ddl/DropTable.php b/src/Sql/Ddl/DropTable.php index 5d1de2a8bd..d7025f34fb 100644 --- a/src/Sql/Ddl/DropTable.php +++ b/src/Sql/Ddl/DropTable.php @@ -19,7 +19,7 @@ class DropTable extends AbstractSql implements SqlInterface /** @var array */ protected $specifications = [ - self::TABLE => 'DROP TABLE %1$s' + self::TABLE => 'DROP TABLE %1$s', ]; /** @var string */ diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index 23305189c3..88ffa48f52 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -9,6 +9,11 @@ namespace Zend\Db\Sql\Ddl\Index; +use function array_merge; +use function count; +use function implode; +use function str_replace; + class Index extends AbstractIndex { /** @var string */ @@ -19,14 +24,14 @@ class Index extends AbstractIndex /** * @param string|array|null $columns - * @param string $name - * @param array $lengths + * @param string $name + * @param array $lengths */ public function __construct($columns, string $name = '', array $lengths = []) { $this->setColumns($columns); - $this->setName($name); + $this->lengths = $lengths; } @@ -49,7 +54,7 @@ public function getExpressionData() : array { $colCount = count($this->columns); $values = []; - $values[] = $this->name ?: ''; + $values[] = $this->name ?? ''; $newSpecTypes = [self::TYPE_IDENTIFIER]; $newSpecParts = []; diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 62d78d9b15..93d5755188 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -9,9 +9,13 @@ namespace Zend\Db\Sql; +use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; -use Zend\Db\Adapter\Driver\DriverInterface; +use Zend\Db\Sql\Predicate\PredicateSet; +use function array_key_exists; +use function sprintf; +use function strtolower; /** * @property Where $where @@ -22,7 +26,7 @@ class Delete extends AbstractPreparableSql * @const */ public const SPECIFICATION_DELETE = 'delete'; - public const SPECIFICATION_WHERE = 'where'; + public const SPECIFICATION_WHERE = 'where'; /**@#-*/ /** @@ -30,7 +34,7 @@ class Delete extends AbstractPreparableSql */ protected $specifications = [ self::SPECIFICATION_DELETE => 'DELETE FROM %1$s', - self::SPECIFICATION_WHERE => 'WHERE %1$s' + self::SPECIFICATION_WHERE => 'WHERE %1$s', ]; /** @var string|TableIdentifier */ @@ -55,6 +59,7 @@ public function __construct($table = null) if ($table) { $this->from($table); } + $this->where = new Where(); } @@ -75,9 +80,9 @@ public function getRawState(?string $key = null) { $rawState = [ 'emptyWhereProtection' => $this->emptyWhereProtection, - 'table' => $this->table, - 'set' => $this->set, - 'where' => $this->where + 'table' => $this->table, + 'set' => $this->set, + 'where' => $this->where, ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; @@ -90,7 +95,7 @@ public function getRawState(?string $key = null) * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return $this */ - public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self + public function where($predicate, string $combination = PredicateSet::OP_AND) : self { if ($predicate instanceof Where) { $this->where = $predicate; @@ -101,8 +106,8 @@ public function where($predicate, string $combination = Predicate\PredicateSet:: } protected function processDelete( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : string { return sprintf( @@ -122,15 +127,14 @@ protected function processWhere( return sprintf( $this->specifications[static::SPECIFICATION_WHERE], - $this->processExpression($this->where, $platform, $driver, $parameterContainer, 'where') + $this->processExpression($this->where, $platform, $driver, $parameterContainer, self::SPECIFICATION_WHERE) ); } public function __get(string $name) : ?Where { - switch (strtolower($name)) { - case 'where': - return $this->where; + if (strtolower($name) === self::SPECIFICATION_WHERE) { + return $this->where; } } } diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 453f913a41..dc1f0d6330 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -9,6 +9,14 @@ namespace Zend\Db\Sql; +use function count; +use function is_array; +use function is_scalar; +use function is_string; +use function preg_match_all; +use function str_ireplace; +use function str_replace; + class Expression extends AbstractExpression { /** @@ -26,9 +34,9 @@ class Expression extends AbstractExpression protected $types = []; /** - * @param string $expression + * @param string $expression * @param null|string|array $parameters - * @param array $types @deprecated will be dropped in version 3.0.0 + * @param array $types @deprecated will be dropped in version 3.0.0 */ public function __construct(string $expression = '', $parameters = null, array $types = []) { @@ -100,6 +108,7 @@ public function getParameters() : array public function setTypes(array $types) : self { $this->types = $types; + return $this; } @@ -114,9 +123,9 @@ public function getTypes() : array public function getExpressionData() : array { - $parameters = is_scalar($this->parameters) ? [$this->parameters] : $this->parameters; + $parameters = is_scalar($this->parameters) ? [$this->parameters] : $this->parameters; $parametersCount = count($parameters); - $expression = str_replace('%', '%%', $this->expression); + $expression = str_replace('%', '%%', $this->expression); if ($parametersCount == 0) { return [ @@ -142,7 +151,7 @@ public function getExpressionData() : array return [[ $expression, $values, - $types + $types, ]]; } } diff --git a/src/Sql/ExpressionInterface.php b/src/Sql/ExpressionInterface.php index cef7122908..1d19164338 100644 --- a/src/Sql/ExpressionInterface.php +++ b/src/Sql/ExpressionInterface.php @@ -12,9 +12,9 @@ interface ExpressionInterface { public const TYPE_IDENTIFIER = 'identifier'; - public const TYPE_VALUE = 'value'; - public const TYPE_LITERAL = 'literal'; - public const TYPE_SELECT = 'select'; + public const TYPE_VALUE = 'value'; + public const TYPE_LITERAL = 'literal'; + public const TYPE_SELECT = 'select'; /** * @abstract diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 6a531b8e61..0e784bc071 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -13,6 +13,16 @@ use Zend\Db\Adapter\Driver\Pdo\Pdo; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; +use function array_combine; +use function array_flip; +use function array_key_exists; +use function array_keys; +use function array_values; +use function count; +use function implode; +use function is_array; +use function is_scalar; +use function range; class Insert extends AbstractPreparableSql { @@ -23,8 +33,8 @@ class Insert extends AbstractPreparableSql */ public const SPECIFICATION_INSERT = 'insert'; public const SPECIFICATION_SELECT = 'select'; - public const VALUES_MERGE = 'merge'; - public const VALUES_SET = 'set'; + public const VALUES_MERGE = 'merge'; + public const VALUES_SET = 'set'; /**#@-*/ /** @var array Specification array */ @@ -35,7 +45,7 @@ class Insert extends AbstractPreparableSql /** @var string|TableIdentifier */ protected $table; - protected $columns = []; + protected $columns = []; /** @var array|Select */ protected $select; @@ -61,12 +71,14 @@ public function __construct($table = null) public function into($table) : self { $this->table = $table; + return $this; } public function columns(array $columns) : self { $this->columns = array_flip($columns); + return $this; } @@ -74,7 +86,7 @@ public function columns(array $columns) : self * Specify values to insert * * @param array|Select $values - * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET + * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET * @return $this * @throws Exception\InvalidArgumentException */ @@ -86,7 +98,9 @@ public function values($values, string $flag = self::VALUES_SET) : self 'A Zend\Db\Sql\Select instance cannot be provided with the merge flag' ); } + $this->select = $values; + return $this; } @@ -112,6 +126,7 @@ public function values($values, string $flag = self::VALUES_SET) : self $this->columns[$column] = $value; } } + return $this; } @@ -136,16 +151,17 @@ public function select(Select $select) : self public function getRawState(?string $key = null) { $rawState = [ - 'table' => $this->table, + 'table' => $this->table, 'columns' => array_keys($this->columns), - 'values' => array_values($this->columns) + 'values' => array_values($this->columns), ]; + return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } protected function processInsert( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { if ($this->select) { @@ -167,6 +183,7 @@ protected function processInsert( if ($driver instanceof Pdo) { $column = 'c_' . $i++; } + $values[] = $driver->formatParameterName($column); $parameterContainer->offsetSet($column, $value); } else { @@ -178,6 +195,7 @@ protected function processInsert( ); } } + return sprintf( $this->specifications[static::SPECIFICATION_INSERT], $this->resolveTable($this->table, $platform, $driver, $parameterContainer), @@ -236,6 +254,7 @@ public function __get(string $name) 'The key ' . $name . ' was not found in this objects column list' ); } + return $this->columns[$name]; } } diff --git a/src/Sql/Join.php b/src/Sql/Join.php index 1214b37974..8f6ad332bb 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -11,6 +11,12 @@ use Countable; use Iterator; +use function array_shift; +use function count; +use function is_array; +use function is_string; +use function key; +use function sprintf; /** * Aggregate JOIN specifications. @@ -96,7 +102,7 @@ public function join($name, $on, $columns = [Select::SQL_STAR], string $type = J 'name' => $name, 'on' => $on, 'columns' => $columns, - 'type' => $type ? $type : self::JOIN_INNER + 'type' => $type ? $type : self::JOIN_INNER, ]; return $this; @@ -105,6 +111,7 @@ public function join($name, $on, $columns = [Select::SQL_STAR], string $type = J public function reset() : self { $this->joins = []; + return $this; } diff --git a/src/Sql/Literal.php b/src/Sql/Literal.php index 98e7ad5dfc..042c67ac8c 100644 --- a/src/Sql/Literal.php +++ b/src/Sql/Literal.php @@ -9,6 +9,8 @@ namespace Zend\Db\Sql; +use function str_replace; + class Literal implements ExpressionInterface { protected $literal; @@ -21,6 +23,7 @@ public function __construct(string $literal = '') public function setLiteral(string $literal) : self { $this->literal = $literal; + return $this; } @@ -34,7 +37,7 @@ public function getExpressionData() : array return [[ str_replace('%', '%%', $this->literal), [], - [] + [], ]]; } } diff --git a/src/Sql/Platform/IbmDb2/IbmDb2.php b/src/Sql/Platform/IbmDb2/IbmDb2.php index f6472e21fd..5e4b31c914 100644 --- a/src/Sql/Platform/IbmDb2/IbmDb2.php +++ b/src/Sql/Platform/IbmDb2/IbmDb2.php @@ -16,6 +16,6 @@ class IbmDb2 extends AbstractPlatform { public function __construct(?SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); + $this->setTypeDecorator(Select::class, $selectDecorator ?? new SelectDecorator()); } } diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index 317622b8dc..fe42b11532 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -68,6 +68,7 @@ protected function renderTable(string $table, ?string $alias = null) : string protected function localizeVariables() : void { parent::localizeVariables(); + // set specifications unset($this->specifications[self::LIMIT]); unset($this->specifications[self::OFFSET]); @@ -76,7 +77,7 @@ protected function localizeVariables() : void } protected function processLimitOffset( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null, array &$sqls, @@ -89,23 +90,27 @@ protected function processLimitOffset( if ($this->supportsLimitOffset) { // Note: db2_prepare/db2_execute fails with positional parameters, for LIMIT & OFFSET $limit = (int) $this->limit; + if (! $limit) { return; } $offset = (int) $this->offset; + if ($offset) { $sqls[] = sprintf('LIMIT %s OFFSET %s', $limit, $offset); return; } $sqls[] = sprintf('LIMIT %s', $limit); + return; } $selectParameters = $parameters[self::SELECT]; $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR; + foreach ($selectParameters[0] as $i => $columnParameters) { if ($columnParameters[0] == self::SQL_STAR || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) @@ -133,8 +138,8 @@ protected function processLimitOffset( if ($parameterContainer) { // create bottom part of query, with offset and limit using row_number - $limitParamName = $driver->formatParameterName('limit'); - $offsetParamName = $driver->formatParameterName('offset'); + $limitParamName = $driver->formatParameterName('limit'); + $offsetParamName = $driver->formatParameterName('offset'); $sqls[] = sprintf( // @codingStandardsIgnoreStart @@ -169,6 +174,7 @@ protected function processLimitOffset( if (isset($sqls[self::ORDER])) { $orderBy = $sqls[self::ORDER]; + unset($sqls[self::ORDER]); } else { $orderBy = ''; diff --git a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php index 690c0e527d..b392a679b6 100644 --- a/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/AlterTableDecorator.php @@ -107,11 +107,11 @@ protected function processAddColumns(?PlatformInterface $adapterPlatform = null) switch ($this->normalizeColumnOption($coName)) { case 'unsigned': $insert = ' UNSIGNED'; - $j = 0; + $j = 0; break; case 'zerofill': $insert = ' ZEROFILL'; - $j = 0; + $j = 0; break; case 'identity': case 'serial': @@ -121,33 +121,36 @@ protected function processAddColumns(?PlatformInterface $adapterPlatform = null) break; case 'comment': $insert = ' COMMENT ' . $adapterPlatform->quoteValue($coValue); - $j = 2; + $j = 2; break; case 'columnformat': case 'format': $insert = ' COLUMN_FORMAT ' . strtoupper($coValue); - $j = 2; + $j = 2; break; case 'storage': $insert = ' STORAGE ' . strtoupper($coValue); - $j = 2; + $j = 2; break; case 'after': $insert = ' AFTER ' . $adapterPlatform->quoteIdentifier($coValue); - $j = 2; + $j = 2; } if ($insert) { - $j = isset($j) ? $j : 0; - $sql = substr_replace($sql, $insert, $insertStart[$j], 0); + $j = isset($j) ? $j : 0; + $sql = substr_replace($sql, $insert, $insertStart[$j], 0); $insertStartCount = count($insertStart); + for (; $j < $insertStartCount; ++$j) { $insertStart[$j] += strlen($insert); } } } + $sqls[$i] = $sql; } + return [$sqls]; } diff --git a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php index 256aa6ab72..2acea2b82c 100644 --- a/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php @@ -12,8 +12,14 @@ use Zend\Db\Adapter\Platform\PlatformInterface; use Zend\Db\Sql\Ddl\CreateTable; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; +use function count; +use function range; +use function str_replace; use function strlen; use function strpos; +use function strtoupper; +use function substr_replace; +use function uksort; class CreateTableDecorator extends CreateTable implements PlatformDecoratorInterface { @@ -99,37 +105,38 @@ protected function processColumns(?PlatformInterface $platform = null) switch ($this->normalizeColumnOption($coName)) { case 'unsigned': $insert = ' UNSIGNED'; - $j = 0; + $j = 0; break; case 'zerofill': $insert = ' ZEROFILL'; - $j = 0; + $j = 0; break; case 'identity': case 'serial': case 'autoincrement': $insert = ' AUTO_INCREMENT'; - $j = 1; + $j = 1; break; case 'comment': $insert = ' COMMENT ' . $platform->quoteValue($coValue); - $j = 2; + $j = 2; break; case 'columnformat': case 'format': $insert = ' COLUMN_FORMAT ' . strtoupper($coValue); - $j = 2; + $j = 2; break; case 'storage': $insert = ' STORAGE ' . strtoupper($coValue); - $j = 2; + $j = 2; break; } if ($insert) { - $j = isset($j) ? $j : 0; - $sql = substr_replace($sql, $insert, $insertStart[$j], 0); + $j = isset($j) ? $j : 0; + $sql = substr_replace($sql, $insert, $insertStart[$j], 0); $insertStartCount = count($insertStart); + for (; $j < $insertStartCount; ++$j) { $insertStart[$j] += strlen($insert); } @@ -151,11 +158,13 @@ private function compareColumnOptions(string $columnA, string $columnB) : int { $columnA = $this->normalizeColumnOption($columnA); $columnA = isset($this->columnOptionSortOrder[$columnA]) - ? $this->columnOptionSortOrder[$columnA] : count($this->columnOptionSortOrder); + ? $this->columnOptionSortOrder[$columnA] + : count($this->columnOptionSortOrder); $columnB = $this->normalizeColumnOption($columnB); $columnB = isset($this->columnOptionSortOrder[$columnB]) - ? $this->columnOptionSortOrder[$columnB] : count($this->columnOptionSortOrder); + ? $this->columnOptionSortOrder[$columnB] + : count($this->columnOptionSortOrder); return $columnA - $columnB; } diff --git a/src/Sql/Platform/Mysql/Mysql.php b/src/Sql/Platform/Mysql/Mysql.php index 9ab227c5e5..321aa2229f 100644 --- a/src/Sql/Platform/Mysql/Mysql.php +++ b/src/Sql/Platform/Mysql/Mysql.php @@ -12,6 +12,8 @@ use Zend\Db\Sql\Platform\AbstractPlatform; use Zend\Db\Sql\Ddl\AlterTable; use Zend\Db\Sql\Ddl\CreateTable; +use Zend\Db\Sql\Platform\Mysql\Ddl\AlterTableDecorator; +use Zend\Db\Sql\Platform\Mysql\Ddl\CreateTableDecorator; use Zend\Db\Sql\Select; class Mysql extends AbstractPlatform @@ -19,7 +21,7 @@ class Mysql extends AbstractPlatform public function __construct() { $this->setTypeDecorator(Select::class, new SelectDecorator()); - $this->setTypeDecorator(CreateTable::class, new Ddl\CreateTableDecorator()); - $this->setTypeDecorator(AlterTable::class, new Ddl\AlterTableDecorator()); + $this->setTypeDecorator(CreateTable::class, new CreateTableDecorator()); + $this->setTypeDecorator(AlterTable::class, new AlterTableDecorator()); } } diff --git a/src/Sql/Platform/Mysql/SelectDecorator.php b/src/Sql/Platform/Mysql/SelectDecorator.php index e4567fe2ef..a703efa734 100644 --- a/src/Sql/Platform/Mysql/SelectDecorator.php +++ b/src/Sql/Platform/Mysql/SelectDecorator.php @@ -37,7 +37,7 @@ protected function localizeVariables() : void } protected function processLimit( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { @@ -60,7 +60,7 @@ protected function processLimit( } protected function processOffset( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { @@ -70,6 +70,7 @@ protected function processOffset( if ($parameterContainer) { $paramPrefix = $this->processInfo['paramPrefix']; $parameterContainer->offsetSet($paramPrefix . 'offset', $this->offset, ParameterContainer::TYPE_INTEGER); + return [$driver->formatParameterName($paramPrefix . 'offset')]; } diff --git a/src/Sql/Platform/Oracle/Oracle.php b/src/Sql/Platform/Oracle/Oracle.php index ff12279e62..6f0163e8b3 100644 --- a/src/Sql/Platform/Oracle/Oracle.php +++ b/src/Sql/Platform/Oracle/Oracle.php @@ -16,6 +16,6 @@ class Oracle extends AbstractPlatform { public function __construct(?SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); + $this->setTypeDecorator(Select::class, $selectDecorator ?? new SelectDecorator()); } } diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index c4a41a93af..2651da4161 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -46,7 +46,7 @@ protected function localizeVariables() : void } protected function processLimitOffset( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null, array &$sqls = [], @@ -113,6 +113,7 @@ protected function processLimitOffset( $parameterContainer::TYPE_INTEGER ); } + $this->processInfo['subselectCount']++; } else { if ($this->limit === null) { diff --git a/src/Sql/Platform/Platform.php b/src/Sql/Platform/Platform.php index f2e8e8816e..0d47d9abb4 100644 --- a/src/Sql/Platform/Platform.php +++ b/src/Sql/Platform/Platform.php @@ -13,10 +13,17 @@ use Zend\Db\Adapter\Platform\PlatformInterface; use Zend\Db\Adapter\StatementContainerInterface; use Zend\Db\Sql\Exception\InvalidArgumentException; +use Zend\Db\Sql\Exception\RuntimeException; +use Zend\Db\Sql\Platform\IbmDb2\IbmDb2; +use Zend\Db\Sql\Platform\Mysql\Mysql; +use Zend\Db\Sql\Platform\Oracle\Oracle; +use Zend\Db\Sql\Platform\Sqlite\Sqlite; +use Zend\Db\Sql\Platform\SqlServer\SqlServer; use Zend\Db\Sql\PreparableSqlInterface; use Zend\Db\Sql\SqlInterface; -use Zend\Db\Sql\Exception\RuntimeException; use function is_a; +use function str_replace; +use function strtolower; class Platform extends AbstractPlatform { @@ -30,11 +37,11 @@ public function __construct(AdapterInterface $adapter) { $this->defaultPlatform = $adapter->getPlatform(); - $mySqlPlatform = new Mysql\Mysql(); - $sqlServerPlatform = new SqlServer\SqlServer(); - $oraclePlatform = new Oracle\Oracle(); - $ibmDb2Platform = new IbmDb2\IbmDb2(); - $sqlitePlatform = new Sqlite\Sqlite(); + $mySqlPlatform = new Mysql(); + $sqlServerPlatform = new SqlServer(); + $oraclePlatform = new Oracle(); + $ibmDb2Platform = new IbmDb2(); + $sqlitePlatform = new Sqlite(); $this->decorators['mysql'] = $mySqlPlatform->getDecorators(); $this->decorators['sqlserver'] = $sqlServerPlatform->getDecorators(); @@ -115,6 +122,7 @@ public function getSqlString(?PlatformInterface $adapterPlatform = null) : strin protected function resolvePlatformName($adapterOrPlatform) { $platformName = $this->resolvePlatform($adapterOrPlatform)->getName(); + return str_replace([' ', '_'], '', strtolower($platformName)); } /** diff --git a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php index 330ad4131c..dc91af6ada 100644 --- a/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php +++ b/src/Sql/Platform/SqlServer/Ddl/CreateTableDecorator.php @@ -25,12 +25,14 @@ class CreateTableDecorator extends CreateTable implements PlatformDecoratorInter public function setSubject($subject) : self { $this->subject = $subject; + return $this; } protected function processTable(?PlatformInterface $adapterPlatform = null) : array { $table = ($this->isTemporary ? '#' : '') . ltrim($this->table, '#'); + return [ '', $adapterPlatform->quoteIdentifier($table), diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index 56fe2733b5..ba291f0344 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -14,6 +14,11 @@ use Zend\Db\Adapter\Platform\PlatformInterface; use Zend\Db\Sql\Platform\PlatformDecoratorInterface; use Zend\Db\Sql\Select; +use function array_shift; +use function array_unshift; +use function array_values; +use function current; +use function strpos; class SelectDecorator extends Select implements PlatformDecoratorInterface { @@ -39,8 +44,8 @@ protected function localizeVariables() : void } protected function processLimitOffset( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null, &$sqls, &$parameters diff --git a/src/Sql/Platform/SqlServer/SqlServer.php b/src/Sql/Platform/SqlServer/SqlServer.php index 5673ba4198..94539f201d 100644 --- a/src/Sql/Platform/SqlServer/SqlServer.php +++ b/src/Sql/Platform/SqlServer/SqlServer.php @@ -9,15 +9,16 @@ namespace Zend\Db\Sql\Platform\SqlServer; -use Zend\Db\Sql\Platform\AbstractPlatform; use Zend\Db\Sql\Ddl\CreateTable; +use Zend\Db\Sql\Platform\AbstractPlatform; +use Zend\Db\Sql\Platform\SqlServer\Ddl\CreateTableDecorator; use Zend\Db\Sql\Select; class SqlServer extends AbstractPlatform { public function __construct(?SelectDecorator $selectDecorator = null) { - $this->setTypeDecorator(Select::class, $selectDecorator ?: new SelectDecorator()); - $this->setTypeDecorator(CreateTable::class, new Ddl\CreateTableDecorator()); + $this->setTypeDecorator(Select::class, $selectDecorator ?? new SelectDecorator()); + $this->setTypeDecorator(CreateTable::class, new CreateTableDecorator()); } } diff --git a/src/Sql/Platform/Sqlite/SelectDecorator.php b/src/Sql/Platform/Sqlite/SelectDecorator.php index 8b2a9e024b..9a1a5c88c6 100644 --- a/src/Sql/Platform/Sqlite/SelectDecorator.php +++ b/src/Sql/Platform/Sqlite/SelectDecorator.php @@ -38,27 +38,30 @@ protected function localizeVariables() : void } protected function processStatementStart( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : array { return []; } protected function processLimit( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { if ($this->limit === null && $this->offset !== null) { return ['']; } + if ($this->limit === null) { return; } + if ($parameterContainer) { $paramPrefix = $this->processInfo['paramPrefix']; $parameterContainer->offsetSet($paramPrefix . 'limit', $this->limit, ParameterContainer::TYPE_INTEGER); + return [$driver->formatParameterName('limit')]; } @@ -66,7 +69,7 @@ protected function processLimit( } protected function processOffset( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { @@ -83,7 +86,7 @@ protected function processOffset( } protected function processStatementEnd( - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : array { diff --git a/src/Sql/Predicate/Between.php b/src/Sql/Predicate/Between.php index 0648953ad2..efc0cb4f2c 100644 --- a/src/Sql/Predicate/Between.php +++ b/src/Sql/Predicate/Between.php @@ -21,7 +21,7 @@ class Between extends AbstractExpression implements PredicateInterface /** * Constructor * - * @param null|string $identifier + * @param null|string $identifier * @param null|int|float|string $minValue * @param null|int|float|string $maxValue */ @@ -67,6 +67,7 @@ public function setMinValue($minValue) : self /** * Get minimum boundary for comparison + * * @return null|int|float|string */ public function getMinValue() @@ -89,6 +90,7 @@ public function setMaxValue($maxValue) : self /** * Get maximum boundary for comparison + * * @return null|int|float|string */ public function getMaxValue() diff --git a/src/Sql/Predicate/Expression.php b/src/Sql/Predicate/Expression.php index 6fd5fff6f3..5694c4aebe 100644 --- a/src/Sql/Predicate/Expression.php +++ b/src/Sql/Predicate/Expression.php @@ -12,6 +12,7 @@ use Zend\Db\Sql\Expression as BaseExpression; use function array_slice; use function func_get_args; +use function is_array; class Expression extends BaseExpression implements PredicateInterface { diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index ac0d926b0c..a312d7cb2a 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -9,9 +9,15 @@ namespace Zend\Db\Sql\Predicate; +use Zend\Db\Sql\AbstractExpression; use Zend\Db\Sql\Exception; use Zend\Db\Sql\Select; -use Zend\Db\Sql\AbstractExpression; +use function array_fill; +use function count; +use function gettype; +use function implode; +use function is_array; +use function vsprintf; class In extends AbstractExpression implements PredicateInterface { @@ -54,6 +60,7 @@ public function setIdentifier($identifier) : self /** * Get identifier of comparison + * * @return null|string|array */ public function getIdentifier() diff --git a/src/Sql/Predicate/Like.php b/src/Sql/Predicate/Like.php index e88aeafa02..72905996e3 100644 --- a/src/Sql/Predicate/Like.php +++ b/src/Sql/Predicate/Like.php @@ -27,6 +27,7 @@ public function __construct(?string $identifier = null, ?string $like = null) if ($identifier) { $this->setIdentifier($identifier); } + if ($like) { $this->setLike($like); } @@ -72,6 +73,7 @@ public function getExpressionData() : array { list($values[], $types[]) = $this->normalizeArgument($this->identifier, self::TYPE_IDENTIFIER); list($values[], $types[]) = $this->normalizeArgument($this->like, self::TYPE_VALUE); + return [ [ $this->specification, diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 223b94d476..91e106f28a 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -13,6 +13,7 @@ use Zend\Db\Sql\Exception; use function in_array; use function is_array; +use function sprintf; class Operator extends AbstractExpression implements PredicateInterface { @@ -222,7 +223,7 @@ public function getExpressionData() : array return [[ '%s ' . $this->operator . ' %s', $values, - $types + $types, ]]; } } diff --git a/src/Sql/Predicate/Predicate.php b/src/Sql/Predicate/Predicate.php index 012a228ee4..ab61695d63 100644 --- a/src/Sql/Predicate/Predicate.php +++ b/src/Sql/Predicate/Predicate.php @@ -11,6 +11,9 @@ use Zend\Db\Sql\Exception\RuntimeException; use Zend\Db\Sql\Select; +use function func_get_arg; +use function func_num_args; +use function strtolower; /** * @property Predicate $and @@ -29,8 +32,10 @@ public function nest() : Predicate { $predicateSet = new self(); $predicateSet->setUnnest($this); - $this->addPredicate($predicateSet, $this->nextPredicateCombineOperator ?: $this->defaultCombination); + + $this->addPredicate($predicateSet, $this->nextPredicateCombineOperator ?? $this->defaultCombination); $this->nextPredicateCombineOperator = null; + return $predicateSet; } @@ -44,6 +49,7 @@ public function unnest() : Predicate if ($this->unnest === null) { throw new RuntimeException('Not nested'); } + $unnest = $this->unnest; $this->unnest = null; @@ -64,13 +70,14 @@ public function unnest() : Predicate public function equalTo( $left, $right, - string $leftType = self::TYPE_IDENTIFIER, - ?string$rightType = self::TYPE_VALUE + string $leftType = self::TYPE_IDENTIFIER, + ?string $rightType = self::TYPE_VALUE ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_EQUAL_TO, $right, $leftType, $rightType), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -95,8 +102,9 @@ public function notEqualTo( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_NOT_EQUAL_TO, $right, $leftType, $rightType), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -121,8 +129,9 @@ public function lessThan( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_LESS_THAN, $right, $leftType, $rightType), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -147,8 +156,9 @@ public function greaterThan( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_GREATER_THAN, $right, $leftType, $rightType), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -173,8 +183,9 @@ public function lessThanOrEqualTo( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_LESS_THAN_OR_EQUAL_TO, $right, $leftType, $rightType), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -199,8 +210,9 @@ public function greaterThanOrEqualTo( ) : self { $this->addPredicate( new Operator($left, Operator::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $right, $leftType, $rightType), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; @@ -212,14 +224,14 @@ public function greaterThanOrEqualTo( * Utilizes Like predicate * * @param string|Expression $identifier - * @param string $like + * @param string $like * @return $this */ public function like($identifier, string $like) : self { $this->addPredicate( new Like($identifier, $like), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -232,7 +244,7 @@ public function like($identifier, string $like) : self * Utilizes In predicate * * @param string|Expression $identifier - * @param string $notLike + * @param string $notLike * @return $this */ public function notLike($identifier, string $notLike) : self @@ -258,7 +270,7 @@ public function expression($expression, $parameters = null) : self { $this->addPredicate( new Expression($expression, $parameters), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -289,7 +301,7 @@ public function literal(string $literal) : self $this->addPredicate( $predicate, - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -309,7 +321,7 @@ public function isNull($identifier) : self { $this->addPredicate( new IsNull($identifier), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -329,7 +341,7 @@ public function isNotNull($identifier) : self { $this->addPredicate( new IsNotNull($identifier), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -350,7 +362,7 @@ public function in($identifier, $valueSet = null) : self { $this->addPredicate( new In($identifier, $valueSet), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -371,7 +383,7 @@ public function notIn($identifier, $valueSet = null) : self { $this->addPredicate( new NotIn($identifier, $valueSet), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -384,15 +396,15 @@ public function notIn($identifier, $valueSet = null) : self * Utilizes Between predicate * * @param string|Expression $identifier - * @param int|float|string $minValue - * @param int|float|string $maxValue + * @param int|float|string $minValue + * @param int|float|string $maxValue * @return $this */ public function between($identifier, $minValue, $maxValue) : self { $this->addPredicate( new Between($identifier, $minValue, $maxValue), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -406,15 +418,15 @@ public function between($identifier, $minValue, $maxValue) : self * Utilizes NotBetween predicate * * @param string|Expression $identifier - * @param int|float|string $minValue - * @param int|float|string $maxValue + * @param int|float|string $minValue + * @param int|float|string $maxValue * @return $this */ public function notBetween($identifier, $minValue, $maxValue) : self { $this->addPredicate( new NotBetween($identifier, $minValue, $maxValue), - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); $this->nextPredicateCombineOperator = null; @@ -436,8 +448,9 @@ public function predicate(PredicateInterface $predicate) : self { $this->addPredicate( $predicate, - $this->nextPredicateCombineOperator ?: $this->defaultCombination + $this->nextPredicateCombineOperator ?? $this->defaultCombination ); + $this->nextPredicateCombineOperator = null; return $this; diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index a6c84b8698..d581c60749 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -11,12 +11,17 @@ use Countable; use Zend\Db\Sql\Exception; +use function array_merge; +use function count; +use function in_array; +use function is_string; +use function sprintf; +use function strpos; class PredicateSet implements PredicateInterface, Countable { public const COMBINED_BY_AND = 'AND'; public const OP_AND = 'AND'; - public const COMBINED_BY_OR = 'OR'; public const OP_OR = 'OR'; @@ -58,7 +63,7 @@ public function addPredicate(PredicateInterface $predicate, ?string $combination * Add predicates to set * * @param PredicateInterface|\Closure|string|array $predicates - * @param string $combination + * @param string $combination * @return $this * * @throws Exception\InvalidArgumentException @@ -151,6 +156,7 @@ public function andPredicate(PredicateInterface $predicate) : self public function getExpressionData() : array { $parts = []; + for ($i = 0, $count = count($this->predicates); $i < $count; $i++) { /** @var $predicate PredicateInterface */ $predicate = $this->predicates[$i][1]; diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 67728806cc..ac12d7be7e 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -12,6 +12,23 @@ use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\ParameterContainer; use Zend\Db\Adapter\Platform\PlatformInterface; +use Zend\Db\Sql\Predicate\PredicateInterface; +use Zend\Db\Sql\Predicate\PredicateSet; +use function compact; +use function count; +use function current; +use function is_array; +use function is_scalar; +use function is_string; +use function key; +use function method_exists; +use function preg_split; +use function strcasecmp; +use function stripos; +use function strpos; +use function strtolower; +use function strtoupper; +use function trim; /** * @property Where $where @@ -49,6 +66,8 @@ class Select extends AbstractPreparableSql public const COMBINE_UNION = 'union'; public const COMBINE_EXCEPT = 'except'; public const COMBINE_INTERSECT = 'intersect'; + + private const MODIFIER = 'modifier'; /**#@-*/ /** @@ -81,19 +100,19 @@ class Select extends AbstractPreparableSql self::JOINS => [ '%1$s' => [ [3 => '%1$s JOIN %2$s ON %3$s', 'combinedby' => ' '] - ] + ], ], self::WHERE => 'WHERE %1$s', self::GROUP => [ 'GROUP BY %1$s' => [ [1 => '%1$s', 'combinedby' => ', '] - ] + ], ], self::HAVING => 'HAVING %1$s', self::ORDER => [ 'ORDER BY %1$s' => [ [1 => '%1$s', 2 => '%1$s %2$s', 'combinedby' => ', '] - ] + ], ], self::LIMIT => 'LIMIT %1$s', self::OFFSET => 'OFFSET %1$s', @@ -152,8 +171,8 @@ public function __construct($table = null) $this->tableReadOnly = true; } - $this->where = new Where; - $this->joins = new Join; + $this->where = new Where; + $this->joins = new Join; $this->having = new Having; } @@ -235,9 +254,9 @@ public function columns(array $columns, bool $prefixColumnsWithTable = true) : s * Create join clause * * @param string|array|TableIdentifier $name - * @param string|Predicate\Expression $on - * @param string|array $columns - * @param string $type one of the JOIN_* constants + * @param string|Predicate\Expression $on + * @param string|array $columns + * @param string $type one of the JOIN_* constants * @return $this * @throws Exception\InvalidArgumentException */ @@ -251,12 +270,12 @@ public function join($name, $on, $columns = self::SQL_STAR, string $type = self: /** * Create where clause * - * @param Where|\Closure|string|array|Predicate\PredicateInterface $predicate + * @param Where|\Closure|string|array|PredicateInterface $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return $this * @throws Exception\InvalidArgumentException */ - public function where($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self + public function where($predicate, string $combination = PredicateSet::OP_AND) : self { if ($predicate instanceof Where) { $this->where = $predicate; @@ -289,7 +308,7 @@ public function group($group) : self * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return $this */ - public function having($predicate, string $combination = Predicate\PredicateSet::OP_AND) : self + public function having($predicate, string $combination = PredicateSet::OP_AND) : self { if ($predicate instanceof Having) { $this->having = $predicate; @@ -343,7 +362,7 @@ public function combine(Select $select, string $type = self::COMBINE_UNION, stri 'This Select object is already combined and cannot be combined with multiple Selects objects' ); } - $this->combine = compact('select', 'type', 'modifier'); + $this->combine = compact(self::SELECT, 'type', self::MODIFIER); return $this; } @@ -393,7 +412,7 @@ public function reset(string $part) : self } /** - * @param string $index + * @param string $index * @param array|string $specification * @return $this */ @@ -419,7 +438,7 @@ public function getRawState(?string $key = null) self::HAVING => $this->having, self::LIMIT => $this->limit, self::OFFSET => $this->offset, - self::COMBINE => $this->combine + self::COMBINE => $this->combine, ]; return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState; } @@ -430,8 +449,8 @@ public function isTableReadOnly() : bool } protected function processStatementStart( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : ?array { if ($this->combine !== []) { @@ -440,8 +459,8 @@ protected function processStatementStart( } protected function processStatementEnd( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : ?array { if ($this->combine !== []) { @@ -450,13 +469,14 @@ protected function processStatementEnd( } protected function processSelect( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : ?array { $expr = 1; [$table, $fromTable] = $this->resolveTable($this->table, $platform, $driver, $parameterContainer); + // process table columns $columns = []; foreach ($this->columns as $columnIndexOrAs => $column) { @@ -476,6 +496,7 @@ protected function processSelect( $parameterContainer, (is_string($columnIndexOrAs) ? $columnIndexOrAs : 'column') ); + // process As portion if (is_string($columnIndexOrAs)) { $columnAs = $platform->quoteIdentifier($columnIndexOrAs); @@ -533,36 +554,39 @@ protected function processSelect( } protected function processJoins( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { return $this->processJoin($this->joins, $platform, $driver, $parameterContainer); } protected function processWhere( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { if ($this->where->count() == 0) { return; } + return [ - $this->processExpression($this->where, $platform, $driver, $parameterContainer, 'where') + $this->processExpression($this->where, $platform, $driver, $parameterContainer, self::WHERE) ]; } protected function processGroup( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { if ($this->group === null) { return; } + // process table columns $groups = []; + foreach ($this->group as $column) { $groups[] = $this->resolveColumnValue( [ @@ -579,21 +603,21 @@ protected function processGroup( } protected function processHaving( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { if ($this->having->count() == 0) { return; } return [ - $this->processExpression($this->having, $platform, $driver, $parameterContainer, 'having') + $this->processExpression($this->having, $platform, $driver, $parameterContainer, self::HAVING) ]; } protected function processOrder( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) : ?array { if (empty($this->order)) { @@ -634,10 +658,10 @@ protected function processLimit( } if ($parameterContainer) { $paramPrefix = $this->processInfo['paramPrefix']; - $parameterContainer->offsetSet($paramPrefix . 'limit', $this->limit, ParameterContainer::TYPE_INTEGER); - return [$driver->formatParameterName($paramPrefix . 'limit')]; + $parameterContainer->offsetSet($paramPrefix . self::LIMIT, $this->limit, ParameterContainer::TYPE_INTEGER); + return [$driver->formatParameterName($paramPrefix . self::LIMIT)]; } - return [$platform->quoteValue($this->limit)]; + return [$platform->quoteValue((string) $this->limit ?? '')]; } protected function processOffset( @@ -650,11 +674,11 @@ protected function processOffset( } if ($parameterContainer) { $paramPrefix = $this->processInfo['paramPrefix']; - $parameterContainer->offsetSet($paramPrefix . 'offset', $this->offset, ParameterContainer::TYPE_INTEGER); - return [$driver->formatParameterName($paramPrefix . 'offset')]; + $parameterContainer->offsetSet($paramPrefix . self::OFFSET, $this->offset, ParameterContainer::TYPE_INTEGER); + return [$driver->formatParameterName($paramPrefix . self::OFFSET)]; } - return [$platform->quoteValue($this->offset)]; + return [$platform->quoteValue((string) $this->offset ?? '')]; } protected function processCombine( @@ -667,24 +691,24 @@ protected function processCombine( } $type = $this->combine['type']; - if ($this->combine['modifier']) { - $type .= ' ' . $this->combine['modifier']; + if ($this->combine[self::MODIFIER]) { + $type .= ' ' . $this->combine[self::MODIFIER]; } return [ strtoupper($type), - $this->processSubSelect($this->combine['select'], $platform, $driver, $parameterContainer), + $this->processSubSelect($this->combine[self::SELECT], $platform, $driver, $parameterContainer), ]; } public function __get(string $name) { switch (strtolower($name)) { - case 'where': + case self::WHERE: return $this->where; - case 'having': + case self::HAVING: return $this->having; - case 'joins': + case self::JOINS: return $this->joins; default: throw new Exception\InvalidArgumentException('Not a valid magic property for this object'); @@ -700,14 +724,14 @@ public function __clone() /** * @param string|TableIdentifier|Select $table - * @param PlatformInterface $platform - * @param DriverInterface $driver - * @param ParameterContainer $parameterContainer + * @param PlatformInterface $platform + * @param DriverInterface $driver + * @param ParameterContainer $parameterContainer * @return array */ protected function resolveTable( $table, - PlatformInterface $platform, + PlatformInterface $platform, ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { @@ -735,7 +759,7 @@ protected function resolveTable( return [ $table, - $fromTable + $fromTable, ]; } } diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index 591a2772a0..f8fb8a2803 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -12,6 +12,10 @@ use Zend\Db\Adapter\AdapterInterface; use Zend\Db\Adapter\Driver\StatementInterface; use Zend\Db\Adapter\Platform\PlatformInterface; +use Zend\Db\Sql\Platform\AbstractPlatform; +use function is_array; +use function is_string; + class Sql { @@ -27,18 +31,18 @@ class Sql /** * @param AdapterInterface $adapter * @param null|string|array|TableIdentifier $table - * @param null|Platform\AbstractPlatform $sqlPlatform @deprecated since version 3.0 + * @param null|AbstractPlatform $sqlPlatform @deprecated since version 3.0 */ public function __construct( - AdapterInterface $adapter, + AdapterInterface $adapter, $table = null, - ?Platform\AbstractPlatform $sqlPlatform = null + ?AbstractPlatform $sqlPlatform = null ) { $this->adapter = $adapter; if ($table) { $this->setTable($table); } - $this->sqlPlatform = $sqlPlatform ?: new Platform\Platform($adapter); + $this->sqlPlatform = $sqlPlatform ?? new Platform\Platform($adapter); } public function getAdapter() : ?AdapterInterface @@ -90,7 +94,7 @@ public function select($table = null) : Select $this->table )); } - return new Select($table ?: $this->table); + return new Select($table ?? $this->table); } /** @@ -105,7 +109,7 @@ public function insert($table = null) : Insert $this->table )); } - return new Insert($table ?: $this->table); + return new Insert($table ?? $this->table); } /** @@ -120,7 +124,7 @@ public function update($table = null) : Update $this->table )); } - return new Update($table ?: $this->table); + return new Update($table ?? $this->table); } /** @@ -140,11 +144,11 @@ public function delete($table = null) : Delete public function prepareStatementForSqlObject( PreparableSqlInterface $sqlObject, - ?StatementInterface $statement = null, - ?AdapterInterface $adapter = null + ?StatementInterface $statement = null, + ?AdapterInterface $adapter = null ) : StatementInterface { - $adapter = $adapter ?: $this->adapter; - $statement = $statement ?: $adapter->getDriver()->createStatement(); + $adapter = $adapter ?? $this->adapter; + $statement = $statement ?? $adapter->getDriver()->createStatement(); return $this->sqlPlatform->setSubject($sqlObject)->prepareStatement($adapter, $statement); } @@ -160,7 +164,7 @@ public function prepareStatementForSqlObject( */ public function getSqlStringForSqlObject(SqlInterface $sqlObject, ?PlatformInterface $platform = null) : string { - $platform = $platform ?: $this->adapter->getPlatform(); + $platform = $platform ?? $this->adapter->getPlatform(); return $this->sqlPlatform->setSubject($sqlObject)->getSqlString($platform); } diff --git a/src/Sql/TableIdentifier.php b/src/Sql/TableIdentifier.php index e90ecf89e9..141f6af441 100644 --- a/src/Sql/TableIdentifier.php +++ b/src/Sql/TableIdentifier.php @@ -9,6 +9,13 @@ namespace Zend\Db\Sql; +use function get_class; +use function gettype; +use function is_callable; +use function is_object; +use function is_string; +use function sprintf; + class TableIdentifier { /** @var string */ diff --git a/src/Sql/Update.php b/src/Sql/Update.php index c1913df768..f4b6d1b0d8 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -9,11 +9,16 @@ namespace Zend\Db\Sql; -use Zend\Db\Adapter\ParameterContainer; -use Zend\Db\Adapter\Platform\PlatformInterface; use Zend\Db\Adapter\Driver\DriverInterface; use Zend\Db\Adapter\Driver\Pdo\Pdo; +use Zend\Db\Adapter\ParameterContainer; +use Zend\Db\Adapter\Platform\PlatformInterface; use Zend\Stdlib\PriorityList; +use function implode; +use function is_numeric; +use function is_string; +use function sprintf; +use function strtolower; /** * @property Where $where @@ -36,7 +41,7 @@ class Update extends AbstractPreparableSql self::SPECIFICATION_UPDATE => 'UPDATE %1$s', self::SPECIFICATION_JOIN => [ '%1$s' => [ - [3 => '%1$s JOIN %2$s ON %3$s', 'combinedby' => ' '] + [3 => '%1$s JOIN %2$s ON %3$s', 'combinedby' => ' '], ] ], self::SPECIFICATION_SET => 'SET %1$s', @@ -70,6 +75,7 @@ public function __construct($table = null) } $this->where = new Where(); $this->joins = new Join(); + $this->set = new PriorityList(); $this->set->isLIFO(false); } @@ -89,7 +95,7 @@ public function table($table) : self /** * Set key/value pairs to update * - * @param array $values Associative array of key values + * @param array $values Associative array of key values * @param string $flag One of the VALUES_* constants * @return $this * @throws Exception\InvalidArgumentException @@ -117,7 +123,7 @@ public function set(array $values, string $flag = self::VALUES_SET) : self * Create where clause * * @param Where|\Closure|string|array $predicate - * @param string $combination One of the OP_* constants from Predicate\PredicateSet + * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @return $this * @throws Exception\InvalidArgumentException */ @@ -135,8 +141,8 @@ public function where($predicate, string $combination = Predicate\PredicateSet:: * Create join clause * * @param string|array $name - * @param string $on - * @param string $type one of the JOIN_* constants + * @param string $on + * @param string $type one of the JOIN_* constants * @return $this * @throws Exception\InvalidArgumentException */ @@ -160,8 +166,8 @@ public function getRawState(?string $key = null) } protected function processUpdate( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { return sprintf( @@ -171,8 +177,8 @@ protected function processUpdate( } protected function processSet( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { $setSql = []; @@ -215,8 +221,8 @@ protected function processSet( } protected function processWhere( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { if ($this->where->count() == 0) { @@ -229,8 +235,8 @@ protected function processWhere( } protected function processJoins( - PlatformInterface $platform, - ?DriverInterface $driver = null, + PlatformInterface $platform, + ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { return $this->processJoin($this->joins, $platform, $driver, $parameterContainer); @@ -254,6 +260,6 @@ public function __get(string $name) public function __clone() { $this->where = clone $this->where; - $this->set = clone $this->set; + $this->set = clone $this->set; } } From ac29abee3b8cc6432f3ad666fef8365b566efaf5 Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 13:26:51 -0700 Subject: [PATCH 43/45] comparator --- src/Sql/AbstractSql.php | 10 +++++----- src/Sql/Combine.php | 2 +- src/Sql/Expression.php | 4 ++-- src/Sql/Platform/IbmDb2/SelectDecorator.php | 4 ++-- src/Sql/Platform/Oracle/SelectDecorator.php | 4 ++-- src/Sql/Platform/SqlServer/SelectDecorator.php | 4 ++-- src/Sql/Predicate/PredicateSet.php | 2 +- src/Sql/Select.php | 6 +++--- src/Sql/Update.php | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index fa0921d1c9..ff4bb95409 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -117,7 +117,7 @@ protected function processExpression( // static counter for the number of times this method was invoked across the PHP runtime static $runtimeExpressionPrefix = 0; - if ($parameterContainer && (! is_string($namedParameterPrefix) || $namedParameterPrefix == '')) { + if ($parameterContainer && (! is_string($namedParameterPrefix) || $namedParameterPrefix === '')) { $namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix); } else { $namedParameterPrefix = preg_replace('/\s/', '__', $namedParameterPrefix); @@ -179,9 +179,9 @@ protected function processExpression( $parameterContainer, $namedParameterPrefix . $vIndex . 'subpart' ); - } elseif ($type == ExpressionInterface::TYPE_IDENTIFIER) { + } elseif ($type === ExpressionInterface::TYPE_IDENTIFIER) { $values[$vIndex] = $platform->quoteIdentifierInFragment($value); - } elseif ($type == ExpressionInterface::TYPE_VALUE) { + } elseif ($type === ExpressionInterface::TYPE_VALUE) { // if prepareType is set, it means that this particular value must be // passed back to the statement in a way it can be used as a placeholder value if ($parameterContainer) { @@ -193,7 +193,7 @@ protected function processExpression( // if not a preparable statement, simply quote the value and move on $values[$vIndex] = $platform->quoteValue($value); - } elseif ($type == ExpressionInterface::TYPE_LITERAL) { + } elseif ($type === ExpressionInterface::TYPE_LITERAL) { $values[$vIndex] = $value; } } @@ -222,7 +222,7 @@ protected function createSqlFromSpecificationAndParameters($specifications, arra $parametersCount = count($parameters); foreach ($specifications as $specificationString => $paramSpecs) { - if ($parametersCount == count($paramSpecs)) { + if ($parametersCount === count($paramSpecs)) { break; } diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index 4cc6e5c0ce..307d9184f6 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -141,7 +141,7 @@ protected function buildSqlString( $sql = ''; foreach ($this->combine as $i => $combine) { - $type = $i == 0 + $type = $i === 0 ? '' : strtoupper($combine['type'] . ($combine['modifier'] ? ' ' . $combine['modifier'] : '')); $select = $this->processSubSelect($combine['select'], $platform, $driver, $parameterContainer); diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index dc1f0d6330..24932b730b 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -65,7 +65,7 @@ public function __construct(string $expression = '', $parameters = null, array $ public function setExpression(string $expression) : self { - if (! is_string($expression) || $expression == '') { + if (! is_string($expression) || $expression === '') { throw new Exception\InvalidArgumentException('Supplied expression must be a string.'); } @@ -127,7 +127,7 @@ public function getExpressionData() : array $parametersCount = count($parameters); $expression = str_replace('%', '%%', $this->expression); - if ($parametersCount == 0) { + if ($parametersCount === 0) { return [ str_ireplace(self::PLACEHOLDER, '', $expression) ]; diff --git a/src/Sql/Platform/IbmDb2/SelectDecorator.php b/src/Sql/Platform/IbmDb2/SelectDecorator.php index fe42b11532..7a57be6f52 100644 --- a/src/Sql/Platform/IbmDb2/SelectDecorator.php +++ b/src/Sql/Platform/IbmDb2/SelectDecorator.php @@ -112,8 +112,8 @@ protected function processLimitOffset( $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR; foreach ($selectParameters[0] as $i => $columnParameters) { - if ($columnParameters[0] == self::SQL_STAR - || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) + if ($columnParameters[0] === self::SQL_STAR + || (isset($columnParameters[1]) && $columnParameters[1] === self::SQL_STAR) || strpos($columnParameters[0], $starSuffix) ) { $selectParameters[0] = [[self::SQL_STAR]]; diff --git a/src/Sql/Platform/Oracle/SelectDecorator.php b/src/Sql/Platform/Oracle/SelectDecorator.php index 2651da4161..ae774778a8 100644 --- a/src/Sql/Platform/Oracle/SelectDecorator.php +++ b/src/Sql/Platform/Oracle/SelectDecorator.php @@ -60,8 +60,8 @@ protected function processLimitOffset( $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR; foreach ($selectParameters[0] as $i => $columnParameters) { - if ($columnParameters[0] == self::SQL_STAR - || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) + if ($columnParameters[0] === self::SQL_STAR + || (isset($columnParameters[1]) && $columnParameters[1] === self::SQL_STAR) || strpos($columnParameters[0], $starSuffix) ) { $selectParameters[0] = [[self::SQL_STAR]]; diff --git a/src/Sql/Platform/SqlServer/SelectDecorator.php b/src/Sql/Platform/SqlServer/SelectDecorator.php index ba291f0344..afd2adac74 100644 --- a/src/Sql/Platform/SqlServer/SelectDecorator.php +++ b/src/Sql/Platform/SqlServer/SelectDecorator.php @@ -66,8 +66,8 @@ protected function processLimitOffset( $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR; foreach ($selectParameters[0] as $i => $columnParameters) { - if ($columnParameters[0] == self::SQL_STAR - || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) + if ($columnParameters[0] === self::SQL_STAR + || (isset($columnParameters[1]) && $columnParameters[1] === self::SQL_STAR) || strpos($columnParameters[0], $starSuffix) ) { $selectParameters[0] = [[self::SQL_STAR]]; diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index d581c60749..a8c7e452f3 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -48,7 +48,7 @@ public function addPredicate(PredicateInterface $predicate, ?string $combination $combination = $this->defaultCombination; } - if ($combination == self::OP_OR) { + if ($combination === self::OP_OR) { $this->orPredicate($predicate); return $this; diff --git a/src/Sql/Select.php b/src/Sql/Select.php index ac12d7be7e..8df7f4b59f 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -566,7 +566,7 @@ protected function processWhere( ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { - if ($this->where->count() == 0) { + if ($this->where->count() === 0) { return; } @@ -607,7 +607,7 @@ protected function processHaving( ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { - if ($this->having->count() == 0) { + if ($this->having->count() === 0) { return; } return [ @@ -686,7 +686,7 @@ protected function processCombine( ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { - if ($this->combine == []) { + if ($this->combine === []) { return; } diff --git a/src/Sql/Update.php b/src/Sql/Update.php index f4b6d1b0d8..ca4b2b92dc 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -225,7 +225,7 @@ protected function processWhere( ?DriverInterface $driver = null, ?ParameterContainer $parameterContainer = null ) { - if ($this->where->count() == 0) { + if ($this->where->count() === 0) { return; } return sprintf( From f7487542fe022ab7794d1dc044f1b698c4e859f8 Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 13:41:43 -0700 Subject: [PATCH 44/45] parenthesis fixed --- src/Sql/AbstractSql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index ff4bb95409..8318b72236 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -41,7 +41,7 @@ abstract class AbstractSql implements SqlInterface public function getSqlString(?PlatformInterface $adapterPlatform = null) : string { - $adapterPlatform = ($adapterPlatform) ?? new DefaultAdapterPlatform; + $adapterPlatform = $adapterPlatform ?? new DefaultAdapterPlatform(); return $this->buildSqlString($adapterPlatform); } From ba08bf44d6834578ede303b2d97330f226177ca1 Mon Sep 17 00:00:00 2001 From: Guido Faecke Date: Sun, 17 Mar 2019 22:46:16 -0700 Subject: [PATCH 45/45] return fix --- src/Sql/Ddl/Column/Boolean.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Sql/Ddl/Column/Boolean.php b/src/Sql/Ddl/Column/Boolean.php index 1464f06349..6087bdca02 100644 --- a/src/Sql/Ddl/Column/Boolean.php +++ b/src/Sql/Ddl/Column/Boolean.php @@ -13,9 +13,4 @@ class Boolean extends Column { /** @var string */ protected $type = 'BOOLEAN'; - - public function setNullable(bool $nullable) : self - { - return parent::setNullable(false); - } }