diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3ded6f9..945d7f3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,8 +41,8 @@ jobs: - name: Install Composer dependencies run: composer update ${{ matrix.composer-flag }} --no-interaction --no-progress -# - name: Run Code Style Check for PHP ${{ matrix.php-version }} -# run: composer run-script style-check + - name: Run Code Style Check for PHP ${{ matrix.php-version }} + run: composer run-script style-check - name: Run tests for PHP ${{ matrix.php-version }} run: composer run-script test diff --git a/.gitignore b/.gitignore index 64c25ee..012d502 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ phpunit.xml Vagrantfile .php_cs.dist /.php-cs-fixer.cache +/.phpunit.result.cache diff --git a/PHPUnit/Framework/BinaryTypeTestCase.php b/PHPUnit/Framework/BinaryTypeTestCase.php index 54eb0d1..59ab157 100644 --- a/PHPUnit/Framework/BinaryTypeTestCase.php +++ b/PHPUnit/Framework/BinaryTypeTestCase.php @@ -1,5 +1,7 @@ getBinaryType(); @@ -21,7 +23,7 @@ public function testSetLength() $this->assertSame(3, $binaryType->getLength()); } - public function testCast() + public function testCast(): void { $binaryType = $this->getBinaryType(); diff --git a/PHPUnit/Framework/CharTypeTestCase.php b/PHPUnit/Framework/CharTypeTestCase.php index 748d27b..9fe35d0 100644 --- a/PHPUnit/Framework/CharTypeTestCase.php +++ b/PHPUnit/Framework/CharTypeTestCase.php @@ -1,5 +1,7 @@ getCharType(); @@ -31,7 +33,7 @@ public function testInitialProperties() $this->assertTrue($charType->doesAllowDefault()); } - public function testSetNewLength() + public function testSetNewLength(): void { $charType = $this->getCharType(); $charType->setLength(12); @@ -39,7 +41,7 @@ public function testSetNewLength() $this->assertSame(12, $charType->getLength()); } - public function testSetCollation() + public function testSetCollation(): void { $collation = 'utf8mb4_general_ci'; $charType = $this->getCharType(); @@ -49,7 +51,7 @@ public function testSetCollation() $this->assertSame($collation, $charType->getCollation()); } - public function testCast() + public function testCast(): void { $charType = $this->getCharType(); @@ -68,12 +70,12 @@ public function DDLProvider() return [ [ strtoupper($charType->getType()) . "($length)", - $charType + $charType, ], [ strtoupper($charType->getType()) . "($length) COLLATE '$collation'", - $charTypeCollate - ] + $charTypeCollate, + ], ]; } } diff --git a/PHPUnit/Framework/ConstraintTestCase.php b/PHPUnit/Framework/ConstraintTestCase.php index 08c628b..4641148 100644 --- a/PHPUnit/Framework/ConstraintTestCase.php +++ b/PHPUnit/Framework/ConstraintTestCase.php @@ -1,5 +1,7 @@ getConstraint(); @@ -33,7 +35,7 @@ public function testInitialProperties() $this->assertNull($constraint->getDatabaseName(), 'Assertion on ' . get_class($constraint)); } - public function testSetTableName() + public function testSetTableName(): void { $tableName = 'schnoop_tbl'; $constraint = $this->getConstraint(); @@ -43,7 +45,7 @@ public function testSetTableName() $this->assertSame($tableName, $constraint->getTableName(), 'Assertion on ' . get_class($constraint)); } - public function testSetDatabaseName() + public function testSetDatabaseName(): void { $databaseName = 'schnoop_db'; $constraint = $this->getConstraint(); diff --git a/PHPUnit/Framework/DataTypeTestCase.php b/PHPUnit/Framework/DataTypeTestCase.php index 7ce5f57..17d110f 100644 --- a/PHPUnit/Framework/DataTypeTestCase.php +++ b/PHPUnit/Framework/DataTypeTestCase.php @@ -1,5 +1,7 @@ assertSame($expectedDDL, (string)$intType); + $this->assertSame($expectedDDL, (string) $intType); } } diff --git a/PHPUnit/Framework/IndexTestCase.php b/PHPUnit/Framework/IndexTestCase.php index c407c87..d631d89 100644 --- a/PHPUnit/Framework/IndexTestCase.php +++ b/PHPUnit/Framework/IndexTestCase.php @@ -1,5 +1,7 @@ getIndex(); } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); @@ -34,7 +36,7 @@ public function testInitialProperties() $this->assertNull($index->getComment(), 'Assertion on ' . get_class($index)); } - public function testSetIndexedColumns() + public function testSetIndexedColumns(): void { $indexedColumnA = $this->createMock(IndexedColumn::class); $indexedColumnA->method('getColumnName')->willReturn('col_a'); @@ -43,7 +45,7 @@ public function testSetIndexedColumns() $indexedColumns = [ $indexedColumnA, - $indexedColumnB + $indexedColumnB, ]; $index = $this->getConstraint(); @@ -53,7 +55,7 @@ public function testSetIndexedColumns() $this->assertSame($indexedColumns, $index->getIndexedColumns()); } - public function testSetIndexedColumnsReplacesPreviouslySetColumns() + public function testSetIndexedColumnsReplacesPreviouslySetColumns(): void { $indexedColumnA = $this->createMock(IndexedColumn::class); $indexedColumnA->method('getColumnName')->willReturn('col_a'); @@ -64,12 +66,12 @@ public function testSetIndexedColumnsReplacesPreviouslySetColumns() $indexedColumnsFirstSet = [ $indexedColumnA, - $indexedColumnB + $indexedColumnB, ]; $indexedColumnsSecondSet = [ $indexedColumnB, - $indexedColumnC + $indexedColumnC, ]; $index = $this->getConstraint(); @@ -79,7 +81,7 @@ public function testSetIndexedColumnsReplacesPreviouslySetColumns() $this->assertSame($indexedColumnsSecondSet, $index->getIndexedColumns()); } - public function testAddIndexedColumns() + public function testAddIndexedColumns(): void { $indexedColumnA = $this->createMock(IndexedColumn::class); $indexedColumnA->method('getColumnName')->willReturn('col_a'); @@ -88,7 +90,7 @@ public function testAddIndexedColumns() $indexedColumns = [ $indexedColumnA, - $indexedColumnB + $indexedColumnB, ]; $index = $this->getConstraint(); @@ -99,7 +101,7 @@ public function testAddIndexedColumns() $this->assertSame($indexedColumns, $index->getIndexedColumns()); } - public function testGetIndexedColumnNames() + public function testGetIndexedColumnNames(): void { $indexedColumnA = $this->createMock(IndexedColumn::class); $indexedColumnA->method('getColumnName')->willReturn('col_a'); @@ -108,7 +110,7 @@ public function testGetIndexedColumnNames() $indexedColumns = [ $indexedColumnA, - $indexedColumnB + $indexedColumnB, ]; $index = $this->getConstraint(); @@ -117,7 +119,7 @@ public function testGetIndexedColumnNames() $this->assertSame(['col_a', 'col_b'], $index->getIndexedColumnNames()); } - public function testSetComment() + public function testSetComment(): void { $comment = 'Schnoop comment'; $index = $this->getIndex(); @@ -127,7 +129,7 @@ public function testSetComment() $this->assertSame($comment, $index->getComment(), 'Assertion on ' . get_class($index)); } - protected function indexDDLAsserts($ddlPrefix) + protected function indexDDLAsserts($ddlPrefix): void { $index = $this->getIndex(); @@ -138,7 +140,7 @@ protected function indexDDLAsserts($ddlPrefix) $indexedColumns = [ $indexedColumnA, - $indexedColumnB + $indexedColumnB, ]; $index->setIndexedColumns($indexedColumns); @@ -150,7 +152,6 @@ protected function indexDDLAsserts($ddlPrefix) {$ddlPrefix} (`col_a`,`col_b`) COMMENT '$comment' SQL; - - $this->assertSame($expectedDDL, (string)$index); + $this->assertSame($expectedDDL, (string) $index); } } diff --git a/PHPUnit/Framework/IntTypeTestCase.php b/PHPUnit/Framework/IntTypeTestCase.php index 7062c58..516322b 100644 --- a/PHPUnit/Framework/IntTypeTestCase.php +++ b/PHPUnit/Framework/IntTypeTestCase.php @@ -1,5 +1,7 @@ getIntType(); @@ -22,7 +24,7 @@ public function testInitialProperties() $this->assertFalse($intType->isZeroFill()); } - public function testSetDisplayWidth() + public function testSetDisplayWidth(): void { $displayWidth = 2; $intType = $this->getIntType(); @@ -32,7 +34,7 @@ public function testSetDisplayWidth() $this->assertSame($displayWidth, $intType->getDisplayWidth()); } - public function testZeroFill() + public function testZeroFill(): void { $intType = $this->getIntType(); $intType->setZeroFill(true); @@ -40,7 +42,7 @@ public function testZeroFill() $this->assertTrue($intType->isZeroFill()); } - public function testCast() + public function testCast(): void { $intType = $this->getIntType(); diff --git a/PHPUnit/Framework/NumericPointTypeTestCase.php b/PHPUnit/Framework/NumericPointTypeTestCase.php index 135ee10..5bd4d38 100644 --- a/PHPUnit/Framework/NumericPointTypeTestCase.php +++ b/PHPUnit/Framework/NumericPointTypeTestCase.php @@ -1,5 +1,7 @@ getNumericPointType(); @@ -31,7 +33,7 @@ public function testInitialProperties() $this->assertFalse($numericPointType->isZeroFill()); } - public function testSetSigned() + public function testSetSigned(): void { $numericPointType = $this->getNumericPointType(); $numericPointType->setSigned(false); @@ -39,7 +41,7 @@ public function testSetSigned() $this->assertFalse($numericPointType->isSigned()); } - public function testSetPrecision() + public function testSetPrecision(): void { $numericPointType = $this->getNumericPointType(); @@ -53,7 +55,7 @@ public function testSetPrecision() $this->assertSame(0, $numericPointType->getScale()); } - public function testSetPrecisionScale() + public function testSetPrecisionScale(): void { $numericPointType = $this->getNumericPointType(); @@ -69,7 +71,7 @@ public function testSetPrecisionScale() $this->assertSame($scale, $numericPointType->getScale()); } - public function testSetZeroFill() + public function testSetZeroFill(): void { $numericPointType = $this->getNumericPointType(); $numericPointType->setZeroFill(true); @@ -77,7 +79,7 @@ public function testSetZeroFill() $this->assertTrue($numericPointType->isZeroFill()); } - public function testMinRangeSigned() + public function testMinRangeSigned(): void { $numericPointType = $this->getNumericPointType(); $numericPointType->setPrecisionScale(6, 2); @@ -85,7 +87,7 @@ public function testMinRangeSigned() $this->assertSame('-9999.99', $numericPointType->getMinRange()); } - public function testMinRangeUnsigned() + public function testMinRangeUnsigned(): void { $numericPointType = $this->getNumericPointType(); $numericPointType->setPrecisionScale(6, 2); @@ -94,7 +96,7 @@ public function testMinRangeUnsigned() $this->assertSame(0, $numericPointType->getMinRange()); } - public function testMaxRange() + public function testMaxRange(): void { $numericPointType = $this->getNumericPointType(); $numericPointType->setPrecisionScale(6, 2); @@ -122,24 +124,24 @@ public function DDLProvider() return [ [ strtoupper($numericPointType->getType()), - $numericPointType + $numericPointType, ], [ strtoupper($numericPointTypeUnsigned->getType()) . ' UNSIGNED', - $numericPointTypeUnsigned + $numericPointTypeUnsigned, ], [ strtoupper($numericPointTypePrecision->getType()) . '(6)', - $numericPointTypePrecision + $numericPointTypePrecision, ], [ strtoupper($numericPointTypePrecisionScale->getType()) . '(6,2)', - $numericPointTypePrecisionScale + $numericPointTypePrecisionScale, ], [ strtoupper($numericPointTypeUnsignedPrecisionScale->getType()) . '(6,2) UNSIGNED', - $numericPointTypeUnsignedPrecisionScale - ] + $numericPointTypeUnsignedPrecisionScale, + ], ]; } } diff --git a/PHPUnit/Framework/OptionsTypeTestCase.php b/PHPUnit/Framework/OptionsTypeTestCase.php index bbc01ec..4b4d7fd 100644 --- a/PHPUnit/Framework/OptionsTypeTestCase.php +++ b/PHPUnit/Framework/OptionsTypeTestCase.php @@ -1,5 +1,7 @@ getOptionsType(); @@ -48,9 +50,8 @@ public function testSetOptions() /** * @depends testSetOptions - * @param array $testData */ - public function testAddOption(array $testData) + public function testAddOption(array $testData): void { /** @var OptionsTypeInterface $optionsType */ list($optionsType, $presetOptions) = $testData; @@ -68,7 +69,7 @@ public function testAddOption(array $testData) } } - public function testSetCollation() + public function testSetCollation(): void { $collation = 'utf8mb4_general_ci'; $optionsType = $this->getOptionsType(); @@ -78,7 +79,7 @@ public function testSetCollation() $this->assertSame($collation, $optionsType->getCollation()); } - public function testCast() + public function testCast(): void { $optionsType = $this->getOptionsType(); @@ -87,7 +88,7 @@ public function testCast() public function DDLProvider() { - $simpleOptions = array('abc', '123'); + $simpleOptions = ['abc', '123']; $optionsType = $this->createOptionsType(); $optionsType->setOptions($simpleOptions); @@ -95,8 +96,8 @@ public function DDLProvider() return [ [ strtoupper($optionsType->getType()) . "('abc','123')", - $optionsType - ] + $optionsType, + ], ]; } } diff --git a/PHPUnit/Framework/RoutineParameterTestCase.php b/PHPUnit/Framework/RoutineParameterTestCase.php index 9e5035f..839715a 100644 --- a/PHPUnit/Framework/RoutineParameterTestCase.php +++ b/PHPUnit/Framework/RoutineParameterTestCase.php @@ -1,5 +1,7 @@ assertSame($this->getExpectedParameterName(), $this->getRoutineParameter()->getName()); $this->assertSame($this->getExpectedParameterDataType(), $this->getRoutineParameter()->getDataType()); } - public function testSetName() + public function testSetName(): void { $newName = 'neo_name'; $this->getRoutineParameter()->setName($newName); @@ -34,7 +36,7 @@ public function testSetName() $this->assertSame($newName, $this->getRoutineParameter()->getName()); } - public function testSetDataType() + public function testSetDataType(): void { $newMockDataType = $this->createMock(DataTypeInterface::class); $this->getRoutineParameter()->setDataType($newMockDataType); diff --git a/PHPUnit/Framework/RoutineTestCase.php b/PHPUnit/Framework/RoutineTestCase.php index ae4af61..72e46e3 100644 --- a/PHPUnit/Framework/RoutineTestCase.php +++ b/PHPUnit/Framework/RoutineTestCase.php @@ -1,10 +1,11 @@ getRoutine(); @@ -45,7 +46,7 @@ public function testInitialProperties() $this->assertSame(DroppableInterface::DDL_DROP_POLICY_DO_NOT_DROP, $routine->getDropPolicy()); } - public function testSetDatabaseName() + public function testSetDatabaseName(): void { $databaseName = 'schnoop_db'; $this->getRoutine()->setDatabaseName($databaseName); @@ -54,7 +55,7 @@ public function testSetDatabaseName() $this->assertSame($databaseName, $this->getRoutine()->getDatabaseName()); } - public function testSetDefiner() + public function testSetDefiner(): void { $definer = 'me@example'; $routine = $this->getRoutine(); @@ -63,7 +64,7 @@ public function testSetDefiner() $this->assertSame($definer, $routine->getDefiner()); } - public function testSetComment() + public function testSetComment(): void { $comment = 'Routine comment.'; $routine = $this->getRoutine(); @@ -73,7 +74,7 @@ public function testSetComment() $this->assertSame($comment, $routine->getComment()); } - public function testSetDeterministic() + public function testSetDeterministic(): void { $routine = $this->getRoutine(); $routine->setDeterministic(true); @@ -81,7 +82,7 @@ public function testSetDeterministic() $this->assertTrue($routine->isDeterministic()); } - public function testSetContains() + public function testSetContains(): void { $routine = $this->getRoutine(); $routine->setDataAccess(RoutineInterface::DATA_ACCESS_MODIFIES_SQL_DATA); @@ -89,7 +90,7 @@ public function testSetContains() $this->assertSame(RoutineInterface::DATA_ACCESS_MODIFIES_SQL_DATA, $routine->getDataAccess()); } - public function testSetSqlSecurity() + public function testSetSqlSecurity(): void { $routine = $this->getRoutine(); $routine->setSqlSecurity(RoutineInterface::SECURITY_INVOKER); @@ -97,9 +98,9 @@ public function testSetSqlSecurity() $this->assertSame(RoutineInterface::SECURITY_INVOKER, $routine->getSqlSecurity()); } - public function testSetBody() + public function testSetBody(): void { - $body = "Hello world."; + $body = 'Hello world.'; $routine = $this->getRoutine(); $routine->setBody($body); @@ -120,9 +121,8 @@ public function testSetSQLMode() /** * @depends testSetSQLMode - * @param RoutineInterface $routineWithSqlMode */ - public function testUnsetSqlMode(RoutineInterface $routineWithSqlMode) + public function testUnsetSqlMode(RoutineInterface $routineWithSqlMode): void { $routineWithSqlMode->unsetSqlMode(); @@ -130,7 +130,7 @@ public function testUnsetSqlMode(RoutineInterface $routineWithSqlMode) $this->assertNull($routineWithSqlMode->getSqlMode()); } - public function testSetUseFullyQualifiedName() + public function testSetUseFullyQualifiedName(): void { $routine = $this->getRoutine(); $routine->setUseFullyQualifiedName(true); @@ -138,7 +138,7 @@ public function testSetUseFullyQualifiedName() $this->assertTrue($routine->useFullyQualifiedName()); } - public function testSetDDLDelimiter() + public function testSetDDLDelimiter(): void { $routine = $this->getRoutine(); $routine->setDelimiter('@@'); @@ -146,7 +146,7 @@ public function testSetDDLDelimiter() $this->assertSame('@@', $routine->getDelimiter()); } - public function testSetDDLDropPolicy() + public function testSetDDLDropPolicy(): void { $routine = $this->getRoutine(); $routine->setDropPolicy(RoutineInterface::DDL_DROP_POLICY_DROP_IF_EXISTS); diff --git a/PHPUnit/Framework/SchnoopSchemaTestCase.php b/PHPUnit/Framework/SchnoopSchemaTestCase.php index f915fb7..7d0f14b 100644 --- a/PHPUnit/Framework/SchnoopSchemaTestCase.php +++ b/PHPUnit/Framework/SchnoopSchemaTestCase.php @@ -1,5 +1,7 @@ getTextType(); @@ -26,7 +28,7 @@ public function testInitialProperties() $this->assertFalse($textType->doesAllowDefault()); } - public function testSetCollation() + public function testSetCollation(): void { $collation = 'utf8mb4_general_ci'; $textType = $this->getTextType(); @@ -36,7 +38,7 @@ public function testSetCollation() $this->assertSame($collation, $textType->getCollation()); } - public function testCast() + public function testCast(): void { $textType = $this->getTextType(); @@ -45,6 +47,7 @@ public function testCast() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -57,12 +60,12 @@ public function DDLProvider() return [ [ strtoupper($textType->getType()), - $textType + $textType, ], [ strtoupper($textTypeCollate->getType()) . " COLLATE '$collation'", - $textTypeCollate - ] + $textTypeCollate, + ], ]; } } diff --git a/PHPUnit/Framework/TimeTypeTestCase.php b/PHPUnit/Framework/TimeTypeTestCase.php index 22694f0..b6ad86b 100644 --- a/PHPUnit/Framework/TimeTypeTestCase.php +++ b/PHPUnit/Framework/TimeTypeTestCase.php @@ -1,5 +1,7 @@ getTimeType(); @@ -25,7 +27,7 @@ public function testInitialProperties() $this->assertTrue($timeType->doesAllowDefault()); } - public function testSetPrecision() + public function testSetPrecision(): void { $precision = 2; $timeType = $this->getTimeType(); @@ -35,7 +37,7 @@ public function testSetPrecision() $this->assertSame($precision, $timeType->getPrecision()); } - public function testCast() + public function testCast(): void { $timeType = $this->getTimeType(); @@ -53,12 +55,12 @@ public function DDLProvider() return [ [ strtoupper($timeType->getType()), - $timeType + $timeType, ], [ strtoupper($timeType->getType()) . "($precision)", - $timeTypePrecision - ] + $timeTypePrecision, + ], ]; } } diff --git a/PHPUnit/bootstrap.php b/PHPUnit/bootstrap.php index c55fb89..a075e1e 100644 --- a/PHPUnit/bootstrap.php +++ b/PHPUnit/bootstrap.php @@ -1,3 +1,5 @@ - + ./tests/SchnoopSchema/ - - + + ./src/ - - + + - \ No newline at end of file + diff --git a/src/MySQL/Column/Column.php b/src/MySQL/Column/Column.php index 0c3fca8..baaa49d 100644 --- a/src/MySQL/Column/Column.php +++ b/src/MySQL/Column/Column.php @@ -1,58 +1,68 @@ tableName = $tableName; } @@ -120,7 +131,7 @@ public function getDatabaseName() /** * {@inheritdoc} */ - public function setDatabaseName($databaseName) + public function setDatabaseName($databaseName): void { $this->databaseName = $databaseName; } @@ -152,7 +163,7 @@ public function isNullable() /** * {@inheritdoc} */ - public function setNullable($nullable) + public function setNullable($nullable): void { $this->nullable = $nullable; } @@ -166,7 +177,7 @@ public function hasDefault() return false; } - return $this->default !== null || $this->isNullable(); + return null !== $this->default || $this->isNullable(); } /** @@ -179,25 +190,21 @@ public function getDefault() /** * {@inheritdoc} - * @throws LogicException Exception when setting a default value when the - * data type does not support it. + * + * @throws LogicException exception when setting a default value when the + * data type does not support it */ - public function setDefault($default) + public function setDefault($default): void { - if ($default !== null && !$this->getDataType()->doesAllowDefault()) { - throw new LogicException( - sprintf( - 'Unable to set default value for the column. The data-type "%s" does not support a default.', - $this->getDataType()->getType() - ) - ); + if (null !== $default && !$this->getDataType()->doesAllowDefault()) { + throw new LogicException(sprintf('Unable to set default value for the column. The data-type "%s" does not support a default.', $this->getDataType()->getType())); } if (is_array($default)) { foreach ($default as $k => $v) { $default[$k] = $this->getDataType()->cast($v); } - } elseif ($default !== null) { + } elseif (null !== $default) { if (!($this->getDataType() instanceof TimeTypeInterface)) { $default = $this->getDataType()->cast($default); } @@ -209,7 +216,7 @@ public function setDefault($default) /** * {@inheritdoc} */ - public function unsetDefault() + public function unsetDefault(): void { $this->default = null; } @@ -224,19 +231,14 @@ public function isOnUpdateCurrentTimestamp() /** * {@inheritdoc} - * @throws LogicException Exception when setting this property when the - * data type does not support it. + * + * @throws LogicException exception when setting this property when the + * data type does not support it */ - public function setOnUpdateCurrentTimestamp($onUpdateCurrentTimestamp) + public function setOnUpdateCurrentTimestamp($onUpdateCurrentTimestamp): void { if (!empty($onUpdateCurrentTimestamp) && !($this->dataType instanceof TimeTypeInterface)) { - throw new LogicException( - sprintf( - 'Data type "%s" for column "%s" does not support setting current time on update.', - $this->dataType->getType(), - $this->name - ) - ); + throw new LogicException(sprintf('Data type "%s" for column "%s" does not support setting current time on update.', $this->dataType->getType(), $this->name)); } $this->onUpdateCurrentTimestamp = $onUpdateCurrentTimestamp; @@ -255,21 +257,21 @@ public function getComment() */ public function hasComment() { - return (bool)strlen($this->comment); + return null !== $this->comment && '' !== $this->comment; } /** * {@inheritdoc} */ - public function setComment($comment) + public function setComment($comment): void { - $this->comment = strlen($comment) ? (string)$comment : null; + $this->comment = null !== $comment && '' !== $comment ? $comment : null; } /** * {@inheritdoc} */ - public function unsetComment() + public function unsetComment(): void { $this->comment = ''; } @@ -284,18 +286,14 @@ public function isAutoIncrement() /** * {@inheritdoc} - * @throws LogicException Exception when setting this property when the - * data type does not support it. + * + * @throws LogicException exception when setting this property when the + * data type does not support it */ - public function setAutoIncrement($autoIncrement) + public function setAutoIncrement($autoIncrement): void { if ($autoIncrement && !($this->dataType instanceof NumericTypeInterface)) { - throw new LogicException( - sprintf( - 'Unable to set auto-increment property on the column. Data-type "%s" does not support an auto-incrementing value.', - $this->getDataType()->getType() - ) - ); + throw new LogicException(sprintf('Unable to set auto-increment property on the column. Data-type "%s" does not support an auto-incrementing value.', $this->getDataType()->getType())); } $this->autoIncrement = $autoIncrement; @@ -317,12 +315,12 @@ public function getDDL() array_filter( [ '`' . $this->getName() . '`', - (string)$this->getDataType(), + (string) $this->getDataType(), $this->nullable ? 'NULL' : 'NOT NULL', $this->hasDefault() ? 'DEFAULT ' . $default : null, $this->isOnUpdateCurrentTimestamp() ? $this->createOnUpdateCurrentTimestampDDL() : null, $this->isAutoIncrement() ? 'AUTO_INCREMENT' : null, - $this->hasComment() ? sprintf("COMMENT '%s'", addslashes($this->getComment())) : null + $this->hasComment() ? sprintf("COMMENT '%s'", addslashes($this->getComment())) : null, ] ) ); @@ -338,8 +336,10 @@ public function __toString() /** * Creates the portion of DDL for the column default value. + * * @param mixed $default - * @return string DDL portion for the column default. + * + * @return string DDL portion for the column default */ protected function createDefaultDDL($default) { @@ -351,12 +351,12 @@ protected function createDefaultDDL($default) } $default = '(' . implode(',', $default) . ')'; } elseif ($dataType instanceof TimeTypeInterface - && $this->getDefault() == self::DEFAULT_CURRENT_TIMESTAMP + && self::DEFAULT_CURRENT_TIMESTAMP == $this->getDefault() ) { $precision = $dataType->hasPrecision() ? '(' . $dataType->getPrecision() . ')' : null; $default = self::DEFAULT_CURRENT_TIMESTAMP . $precision; } else { - $default = $this->getDefault() === null ? 'NULL' : $this->getDataType()->quote($default); + $default = null === $this->getDefault() ? 'NULL' : $this->getDataType()->quote($default); } return $default; @@ -365,8 +365,9 @@ protected function createDefaultDDL($default) /** * Creates the portion of DDL for setting column value to the current * time on update. - * @return null|string DDL portion for setting column value to the current - * time. NULL if the column is not set to have the value set on update. + * + * @return string|null DDL portion for setting column value to the current + * time. NULL if the column is not set to have the value set on update. */ protected function createOnUpdateCurrentTimestampDDL() { diff --git a/src/MySQL/Column/ColumnInterface.php b/src/MySQL/Column/ColumnInterface.php index 633b0b6..6106d1e 100644 --- a/src/MySQL/Column/ColumnInterface.php +++ b/src/MySQL/Column/ColumnInterface.php @@ -1,5 +1,7 @@ tableName = $tableName; } @@ -98,7 +105,7 @@ public function hasDatabaseName() /** * {@inheritdoc} */ - public function setDatabaseName($databaseName) + public function setDatabaseName($databaseName): void { $this->databaseName = $databaseName; } diff --git a/src/MySQL/Constraint/AbstractIndex.php b/src/MySQL/Constraint/AbstractIndex.php index 8d83de0..b8e740a 100644 --- a/src/MySQL/Constraint/AbstractIndex.php +++ b/src/MySQL/Constraint/AbstractIndex.php @@ -1,29 +1,35 @@ indexedColumns = []; @@ -66,7 +72,7 @@ public function hasIndexedColumns() /** * {@inheritdoc} */ - public function addIndexedColumn(IndexedColumnInterface $indexedColumn) + public function addIndexedColumn(IndexedColumnInterface $indexedColumn): void { $this->indexedColumns[$indexedColumn->getColumnName()] = $indexedColumn; } @@ -100,21 +106,23 @@ public function getComment() */ public function hasComment() { - return (bool)strlen($this->comment); + return null !== $this->comment && '' !== $this->comment; } /** * {@inheritdoc} */ - public function setComment($comment) + public function setComment($comment): void { $this->comment = $comment; } /** * Makes the DDL statement for the index. + * * @param string $type Index type * @param string|null $name Index name + * * @return string Index DDL */ protected function makeIndexDDL($type, $name = null) @@ -124,9 +132,9 @@ protected function makeIndexDDL($type, $name = null) array_filter( [ strtoupper($type), - $name !== null ? '`' . $name . '`' : null, + null !== $name ? '`' . $name . '`' : null, $this->makeIndexedColumnsDDL(), - $this->hasComment() ? "COMMENT '" . addslashes($this->getComment()) . "'" : null + $this->hasComment() ? "COMMENT '" . addslashes($this->getComment()) . "'" : null, ] ) ); @@ -134,7 +142,8 @@ protected function makeIndexDDL($type, $name = null) /** * Makes the column portion of the index DDL statement. - * @return string Column portion of index DDL statement. + * + * @return string column portion of index DDL statement */ protected function makeIndexedColumnsDDL() { @@ -151,9 +160,10 @@ protected function makeIndexedColumnsDDL() /** * Set the index type. + * * @param $indexType Index type. One of self::INDEX_TYPE_* constants. */ - protected function setIndexType($indexType) + protected function setIndexType($indexType): void { $this->indexType = $indexType; } diff --git a/src/MySQL/Constraint/ConstraintColumnInterface.php b/src/MySQL/Constraint/ConstraintColumnInterface.php index 82377a5..85d439c 100644 --- a/src/MySQL/Constraint/ConstraintColumnInterface.php +++ b/src/MySQL/Constraint/ConstraintColumnInterface.php @@ -1,18 +1,22 @@ onDeleteAction = $onDeleteAction; } @@ -66,7 +73,7 @@ public function getOnUpdateAction() /** * {@inheritdoc} */ - public function setOnUpdateAction($onUpdateAction) + public function setOnUpdateAction($onUpdateAction): void { $this->onUpdateAction = $onUpdateAction; } @@ -90,7 +97,7 @@ public function hasReferenceTableName() /** * {@inheritdoc} */ - public function setReferenceTableName($referenceTableName) + public function setReferenceTableName($referenceTableName): void { $this->referenceTableName = $referenceTableName; } @@ -168,7 +175,7 @@ public function hasForeignKeyColumn($columnName) /** * {@inheritdoc} */ - public function setForeignKeyColumns(array $foreignKeyColumns) + public function setForeignKeyColumns(array $foreignKeyColumns): void { $this->foreignKeyColumns = []; @@ -180,7 +187,7 @@ public function setForeignKeyColumns(array $foreignKeyColumns) /** * {@inheritdoc} */ - public function addForeignKeyColumn(ForeignKeyColumnInterface $foreignKeyColumn) + public function addForeignKeyColumn(ForeignKeyColumnInterface $foreignKeyColumn): void { $this->foreignKeyColumns[$foreignKeyColumn->getColumnName()] = $foreignKeyColumn; } @@ -222,7 +229,7 @@ public function getDDL() 'REFERENCES', $this->makeReferenceColumnDDL(), 'ON DELETE ' . $this->getOnDeleteAction(), - 'ON UPDATE ' . $this->getOnUpdateAction() + 'ON UPDATE ' . $this->getOnUpdateAction(), ] ) ); diff --git a/src/MySQL/Constraint/ForeignKeyColumn.php b/src/MySQL/Constraint/ForeignKeyColumn.php index 6a1be96..141db1f 100644 --- a/src/MySQL/Constraint/ForeignKeyColumn.php +++ b/src/MySQL/Constraint/ForeignKeyColumn.php @@ -1,25 +1,30 @@ collation = $collation; } diff --git a/src/MySQL/Constraint/IndexedColumnInterface.php b/src/MySQL/Constraint/IndexedColumnInterface.php index 8bb2fb4..2f7f4d0 100644 --- a/src/MySQL/Constraint/IndexedColumnInterface.php +++ b/src/MySQL/Constraint/IndexedColumnInterface.php @@ -1,5 +1,7 @@ getName()) == 0) { + if (0 == strcasecmp('primary', $this->getName())) { return $this->makeIndexDDL('PRIMARY KEY', null); } diff --git a/src/MySQL/CreateStatementInterface.php b/src/MySQL/CreateStatementInterface.php index 4520893..43e71d9 100644 --- a/src/MySQL/CreateStatementInterface.php +++ b/src/MySQL/CreateStatementInterface.php @@ -1,11 +1,14 @@ length = (int)$length; + $this->length = (int) $length; } /** @@ -56,7 +58,7 @@ public function doesAllowDefault() */ public function cast($value) { - return (string)$value; + return (string) $value; } public function getDDL() diff --git a/src/MySQL/DataType/AbstractBlobType.php b/src/MySQL/DataType/AbstractBlobType.php index ddea6ef..1bbb769 100644 --- a/src/MySQL/DataType/AbstractBlobType.php +++ b/src/MySQL/DataType/AbstractBlobType.php @@ -1,5 +1,7 @@ getType()) . ($this->hasLength() ? '(' . $this->getLength() . ')' : null), - $this->hasCollation() ? "COLLATE '" . addslashes($this->getCollation()) . "'" : null + $this->hasCollation() ? "COLLATE '" . addslashes($this->getCollation()) . "'" : null, ] ) ); diff --git a/src/MySQL/DataType/AbstractIntType.php b/src/MySQL/DataType/AbstractIntType.php index 35f0145..060ef44 100644 --- a/src/MySQL/DataType/AbstractIntType.php +++ b/src/MySQL/DataType/AbstractIntType.php @@ -1,5 +1,7 @@ getType()) . ($this->displayWidth > 0 ? '(' . $this->displayWidth .')' : null), - !$this->isSigned() ? 'UNSIGNED' : null + strtoupper($this->getType()) . ($this->displayWidth > 0 ? '(' . $this->displayWidth . ')' : null), + !$this->isSigned() ? 'UNSIGNED' : null, ] ) ); diff --git a/src/MySQL/DataType/AbstractNumericPointType.php b/src/MySQL/DataType/AbstractNumericPointType.php index e3a0f18..69d0131 100644 --- a/src/MySQL/DataType/AbstractNumericPointType.php +++ b/src/MySQL/DataType/AbstractNumericPointType.php @@ -1,5 +1,7 @@ isSigned() ? 'UNSIGNED' : null + !$this->isSigned() ? 'UNSIGNED' : null, ] ) ); diff --git a/src/MySQL/DataType/AbstractOptionsType.php b/src/MySQL/DataType/AbstractOptionsType.php index 0d1af51..ba27e82 100644 --- a/src/MySQL/DataType/AbstractOptionsType.php +++ b/src/MySQL/DataType/AbstractOptionsType.php @@ -1,5 +1,7 @@ options); + return in_array($option, $this->options, true); } /** * {@inheritdoc} */ - public function setOptions(array $options) + public function setOptions(array $options): void { $this->options = array_values($options); } @@ -50,7 +52,7 @@ public function setOptions(array $options) /** * {@inheritdoc} */ - public function addOption($option) + public function addOption($option): void { $this->options[] = $option; } @@ -68,7 +70,7 @@ public function doesAllowDefault() */ public function cast($value) { - return (string)$value; + return (string) $value; } /** @@ -80,8 +82,8 @@ public function getDDL() ' ', array_filter( [ - strtoupper($this->getType()) . "(" . $this->makeOptionsDDL($this->getOptions()) . ")", - $this->hasCollation() ? 'COLLATE ' . $this->getCollation() : null + strtoupper($this->getType()) . '(' . $this->makeOptionsDDL($this->getOptions()) . ')', + $this->hasCollation() ? 'COLLATE ' . $this->getCollation() : null, ] ) ); @@ -96,16 +98,16 @@ public function __toString() } /** - * Make just the portion of the DDL that describes the options - * @param array $options - * @return string Portion of DDL for options. + * Make just the portion of the DDL that describes the options. + * + * @return string portion of DDL for options */ protected function makeOptionsDDL(array $options) { $escapedOptions = []; foreach ($options as $option) { - $escapedOptions[] = $this->quote((string)$option); + $escapedOptions[] = $this->quote((string) $option); } return implode(',', $escapedOptions); diff --git a/src/MySQL/DataType/AbstractTextType.php b/src/MySQL/DataType/AbstractTextType.php index e28738e..e05e948 100644 --- a/src/MySQL/DataType/AbstractTextType.php +++ b/src/MySQL/DataType/AbstractTextType.php @@ -1,5 +1,7 @@ getType()), - $this->hasCollation() ? "COLLATE '" . addslashes($this->getCollation()) . "'" : null + $this->hasCollation() ? "COLLATE '" . addslashes($this->getCollation()) . "'" : null, ] ) ); diff --git a/src/MySQL/DataType/AbstractTimeType.php b/src/MySQL/DataType/AbstractTimeType.php index dfe78b5..aa98479 100644 --- a/src/MySQL/DataType/AbstractTimeType.php +++ b/src/MySQL/DataType/AbstractTimeType.php @@ -1,5 +1,7 @@ precision = $precision; } diff --git a/src/MySQL/DataType/BigIntType.php b/src/MySQL/DataType/BigIntType.php index 61a6314..4d6b7f7 100644 --- a/src/MySQL/DataType/BigIntType.php +++ b/src/MySQL/DataType/BigIntType.php @@ -1,13 +1,15 @@ length)-1; + return pow(2, $this->length) - 1; } /** @@ -64,7 +67,7 @@ public function getMaxRange() */ public function cast($value) { - return (int)$value; + return (int) $value; } /** diff --git a/src/MySQL/DataType/BitTypeInterface.php b/src/MySQL/DataType/BitTypeInterface.php index ec02f64..24ca53e 100644 --- a/src/MySQL/DataType/BitTypeInterface.php +++ b/src/MySQL/DataType/BitTypeInterface.php @@ -1,5 +1,7 @@ collation = $collation; } diff --git a/src/MySQL/DataType/Option/DisplayWidthInterface.php b/src/MySQL/DataType/Option/DisplayWidthInterface.php index 8f16db5..fd8ca83 100644 --- a/src/MySQL/DataType/Option/DisplayWidthInterface.php +++ b/src/MySQL/DataType/Option/DisplayWidthInterface.php @@ -1,9 +1,11 @@ displayWidth = (int)$displayWidth; + $this->displayWidth = (int) $displayWidth; } } diff --git a/src/MySQL/DataType/Option/LengthInterface.php b/src/MySQL/DataType/Option/LengthInterface.php index 0171fe1..4cedb81 100644 --- a/src/MySQL/DataType/Option/LengthInterface.php +++ b/src/MySQL/DataType/Option/LengthInterface.php @@ -1,24 +1,29 @@ length = (int)$length; + $this->length = (int) $length; } } diff --git a/src/MySQL/DataType/Option/NumericRangeInterface.php b/src/MySQL/DataType/Option/NumericRangeInterface.php index 86d4d55..856c680 100644 --- a/src/MySQL/DataType/Option/NumericRangeInterface.php +++ b/src/MySQL/DataType/Option/NumericRangeInterface.php @@ -1,18 +1,22 @@ precision !== null; + return null !== $this->precision; } /** @@ -55,9 +57,9 @@ public function hasScale() /** * @see PrecisionScaleInterface::setPrecisionScale() */ - public function setPrecisionScale($precision, $scale = 0) + public function setPrecisionScale($precision, $scale = 0): void { - $this->precision = $precision !== null ? (int)$precision : null; - $this->scale = $scale === null ? 0 : $scale; + $this->precision = null !== $precision ? (int) $precision : null; + $this->scale = null === $scale ? 0 : $scale; } } diff --git a/src/MySQL/DataType/Option/QuoteTrait.php b/src/MySQL/DataType/Option/QuoteTrait.php index 9e6023a..3ba058f 100644 --- a/src/MySQL/DataType/Option/QuoteTrait.php +++ b/src/MySQL/DataType/Option/QuoteTrait.php @@ -1,5 +1,7 @@ signed = (bool)$signed; + $this->signed = (bool) $signed; } } diff --git a/src/MySQL/DataType/Option/ZeroFillInterface.php b/src/MySQL/DataType/Option/ZeroFillInterface.php index 3017f09..dd60bc9 100644 --- a/src/MySQL/DataType/Option/ZeroFillInterface.php +++ b/src/MySQL/DataType/Option/ZeroFillInterface.php @@ -1,18 +1,22 @@ zeroFill = $zeroFill; } diff --git a/src/MySQL/DataType/OptionsTypeInterface.php b/src/MySQL/DataType/OptionsTypeInterface.php index 2f5925e..51490a5 100644 --- a/src/MySQL/DataType/OptionsTypeInterface.php +++ b/src/MySQL/DataType/OptionsTypeInterface.php @@ -1,5 +1,7 @@ defaultCollation = $defaultCollation; } @@ -80,7 +87,7 @@ public function getDelimiter() /** * {@inheritdoc} */ - public function setDelimiter($delimiter) + public function setDelimiter($delimiter): void { $this->ddlDelimiter = $delimiter; } @@ -96,7 +103,7 @@ public function getDropPolicy() /** * {@inheritdoc} */ - public function setDropPolicy($ddlDropPolicyPolicy) + public function setDropPolicy($ddlDropPolicyPolicy): void { $this->ddlDropPolicy = $ddlDropPolicyPolicy; } @@ -132,7 +139,7 @@ public function getCreateStatement() array_filter( [ $dropDDL, - $createDDL + $createDDL, ] ) ); diff --git a/src/MySQL/Database/DatabaseInterface.php b/src/MySQL/Database/DatabaseInterface.php index 187d0cc..7c67794 100644 --- a/src/MySQL/Database/DatabaseInterface.php +++ b/src/MySQL/Database/DatabaseInterface.php @@ -1,42 +1,50 @@ databaseName = $databaseName; } @@ -132,7 +145,7 @@ public function getDefiner() /** * {@inheritdoc} */ - public function setDefiner($definer) + public function setDefiner($definer): void { $this->definer = $definer; } @@ -156,7 +169,7 @@ public function getComment() /** * {@inheritdoc} */ - public function setComment($comment) + public function setComment($comment): void { $this->comment = $comment; } @@ -180,7 +193,7 @@ public function isDeterministic() /** * {@inheritdoc} */ - public function setDeterministic($deterministic) + public function setDeterministic($deterministic): void { $this->deterministic = $deterministic; } @@ -196,7 +209,7 @@ public function getDataAccess() /** * {@inheritdoc} */ - public function setDataAccess($dataAccess) + public function setDataAccess($dataAccess): void { $this->dataAccess = $dataAccess; } @@ -212,7 +225,7 @@ public function getSqlSecurity() /** * {@inheritdoc} */ - public function setSqlSecurity($sqlSecurity) + public function setSqlSecurity($sqlSecurity): void { $this->sqlSecurity = $sqlSecurity; } @@ -228,7 +241,7 @@ public function getBody() /** * {@inheritdoc} */ - public function setBody($body) + public function setBody($body): void { $this->body = $body; } @@ -252,12 +265,12 @@ public function hasSqlMode() /** * {@inheritdoc} */ - public function setSqlMode(SqlMode $sqlMode) + public function setSqlMode(SqlMode $sqlMode): void { $this->sqlMode = $sqlMode; } - public function unsetSqlMode() + public function unsetSqlMode(): void { $this->sqlMode = null; } @@ -273,7 +286,7 @@ public function getDelimiter() /** * {@inheritdoc} */ - public function setDelimiter($delimiter) + public function setDelimiter($delimiter): void { $this->delimiter = $delimiter; } @@ -289,7 +302,7 @@ public function getDropPolicy() /** * {@inheritdoc} */ - public function setDropPolicy($ddlDropPolicy) + public function setDropPolicy($ddlDropPolicy): void { $this->dropPolicy = $ddlDropPolicy; } @@ -305,22 +318,21 @@ public function useFullyQualifiedName() /** * {@inheritdoc} */ - public function setUseFullyQualifiedName($useFullyQualifiedName) + public function setUseFullyQualifiedName($useFullyQualifiedName): void { $this->useFullyQualifiedName = $useFullyQualifiedName; } /** * Resolve the routine name to an enclosed name. + * * @return string Routine name */ protected function makeRoutineName() { if ($this->useFullyQualifiedName()) { if (!$this->hasDatabaseName()) { - throw new FQNException( - 'Unable to create DDL with fully-qualified-name because the database name has not been set.' - ); + throw new FQNException('Unable to create DDL with fully-qualified-name because the database name has not been set.'); } $routineName = "`{$this->getDatabaseName()}`.`{$this->getName()}`"; @@ -333,18 +345,19 @@ protected function makeRoutineName() /** * Make the portion of the routine DDL statement that describes deterministic, sql security and comment. - * @return string Characteristics DDL. + * + * @return string characteristics DDL */ protected function makeCharacteristicsDDL() { return implode( - " ", + ' ', array_filter( [ $this->deterministic ? 'DETERMINISTIC' : 'NOT DETERMINISTIC', $this->dataAccess, !empty($this->sqlSecurity) ? 'SQL SECURITY ' . $this->sqlSecurity : null, - !empty($this->comment) ? "\nCOMMENT '" . addslashes($this->comment) . "'" : null + !empty($this->comment) ? "\nCOMMENT '" . addslashes($this->comment) . "'" : null, ] ) ); diff --git a/src/MySQL/Routine/AbstractRoutineParameter.php b/src/MySQL/Routine/AbstractRoutineParameter.php index 682249e..8172c58 100644 --- a/src/MySQL/Routine/AbstractRoutineParameter.php +++ b/src/MySQL/Routine/AbstractRoutineParameter.php @@ -1,5 +1,7 @@ name = $name; } @@ -56,7 +61,7 @@ public function getDataType() /** * {@inheritdoc} */ - public function setDataType(DataTypeInterface $dataType) + public function setDataType(DataTypeInterface $dataType): void { $this->dataType = $dataType; } diff --git a/src/MySQL/Routine/FunctionParameter.php b/src/MySQL/Routine/FunctionParameter.php index 7b82891..1db5cbc 100644 --- a/src/MySQL/Routine/FunctionParameter.php +++ b/src/MySQL/Routine/FunctionParameter.php @@ -1,5 +1,7 @@ getName(), - (string)$this->getDataType() + (string) $this->getDataType() ); } diff --git a/src/MySQL/Routine/FunctionParameterInterface.php b/src/MySQL/Routine/FunctionParameterInterface.php index 1f1cc14..db5d29d 100644 --- a/src/MySQL/Routine/FunctionParameterInterface.php +++ b/src/MySQL/Routine/FunctionParameterInterface.php @@ -1,5 +1,7 @@ direction = $direction; } @@ -50,7 +54,7 @@ public function getDDL() '%s `%s` %s', $this->direction, $this->getName(), - (string)$this->getDataType() + (string) $this->getDataType() ); } diff --git a/src/MySQL/Routine/ProcedureParameterInterface.php b/src/MySQL/Routine/ProcedureParameterInterface.php index 1dd1c57..58b4881 100644 --- a/src/MySQL/Routine/ProcedureParameterInterface.php +++ b/src/MySQL/Routine/ProcedureParameterInterface.php @@ -1,16 +1,19 @@ parameters = $parameters; } @@ -58,7 +62,7 @@ public function setParameters(array $parameters) /** * {@inheritdoc} */ - public function addParameter(FunctionParameterInterface $parameter) + public function addParameter(FunctionParameterInterface $parameter): void { $this->parameters[] = $parameter; } @@ -74,7 +78,7 @@ public function getReturnType() /** * {@inheritdoc} */ - public function setReturnType(DataTypeInterface $returns) + public function setReturnType(DataTypeInterface $returns): void { $this->returns = $returns; } @@ -128,7 +132,7 @@ public function getCreateStatement() $this->makeCharacteristicsDDL(), 'BEGIN', $this->body, - 'END' . $this->delimiter + 'END' . $this->delimiter, ] ) ); @@ -140,7 +144,7 @@ public function getCreateStatement() $setSqlMode, $dropDDL, $createDDL, - $revertSqlMode + $revertSqlMode, ] ) ); @@ -155,10 +159,12 @@ public function __toString() /** * Make the portion of DDL for describing the parameters. - * @param string $separator String to apply between parameters. - * @return string Parameters DDL. + * + * @param string $separator string to apply between parameters + * + * @return string parameters DDL */ - protected function makeParametersDDL($separator = " ") + protected function makeParametersDDL($separator = ' ') { $params = []; diff --git a/src/MySQL/Routine/RoutineFunctionInterface.php b/src/MySQL/Routine/RoutineFunctionInterface.php index 6a6922a..f93c0f0 100644 --- a/src/MySQL/Routine/RoutineFunctionInterface.php +++ b/src/MySQL/Routine/RoutineFunctionInterface.php @@ -1,4 +1,7 @@ parameters = $parameters; } @@ -39,7 +40,7 @@ public function setParameters(array $parameters) /** * {@inheritdoc} */ - public function addParameter(ProcedureParameterInterface $parameter) + public function addParameter(ProcedureParameterInterface $parameter): void { $this->parameters[] = $parameter; } @@ -93,7 +94,7 @@ public function getCreateStatement() $this->makeCharacteristicsDDL(), 'BEGIN', $this->body, - 'END' . $this->delimiter + 'END' . $this->delimiter, ] ) ); @@ -105,7 +106,7 @@ public function getCreateStatement() $setSqlMode, $dropDDL, $createDDL, - $revertSqlMode + $revertSqlMode, ] ) ); @@ -123,10 +124,12 @@ public function __toString() /** * Make the portion of DDL for describing the parameters. - * @param string $separator String to apply between parameters. - * @return string Parameters DDL. + * + * @param string $separator string to apply between parameters + * + * @return string parameters DDL */ - protected function makeParametersDDL($separator = " ") + protected function makeParametersDDL($separator = ' ') { $params = []; diff --git a/src/MySQL/Routine/RoutineProcedureInterface.php b/src/MySQL/Routine/RoutineProcedureInterface.php index 3c37b40..89b67d2 100644 --- a/src/MySQL/Routine/RoutineProcedureInterface.php +++ b/src/MySQL/Routine/RoutineProcedureInterface.php @@ -1,29 +1,34 @@ mode = $mode; } /** * Get the delimiter to use between statements. + * * @return string */ public function getDelimiter() @@ -49,15 +55,17 @@ public function getDelimiter() /** * Set the delimiter to use between statements. + * * @param $delimiter */ - public function setDelimiter($delimiter) + public function setDelimiter($delimiter): void { $this->delimiter = $delimiter; } /** * Get the DDL statements for setting the SQL mode whilst preserving the original SQL mode. + * * @return string */ public function getSetStatements() @@ -70,6 +78,7 @@ public function getSetStatements() /** * Get the DDL statements for restoring the previously changed SQL mode. + * * @return string */ public function getRestoreStatements() diff --git a/src/MySQL/Table/Table.php b/src/MySQL/Table/Table.php index 53917b4..d8c975d 100644 --- a/src/MySQL/Table/Table.php +++ b/src/MySQL/Table/Table.php @@ -1,5 +1,7 @@ name = $name; } @@ -125,7 +140,7 @@ public function hasDatabaseName() /** * {@inheritdoc} */ - public function setDatabaseName($databaseName) + public function setDatabaseName($databaseName): void { $this->databaseName = $databaseName; } @@ -165,7 +180,7 @@ public function getColumn($columnName) /** * {@inheritdoc} */ - public function setColumns(array $columns) + public function setColumns(array $columns): void { $this->columns = []; @@ -177,7 +192,7 @@ public function setColumns(array $columns) /** * {@inheritdoc} */ - public function addColumn(ColumnInterface $column) + public function addColumn(ColumnInterface $column): void { $column->setTableName($this->name); $this->columns[$column->getName()] = $column; @@ -218,7 +233,7 @@ public function getIndex($indexName) /** * {@inheritdoc} */ - public function setIndexes(array $indexes) + public function setIndexes(array $indexes): void { $this->indexes = []; @@ -230,11 +245,11 @@ public function setIndexes(array $indexes) /** * {@inheritdoc} */ - public function addIndex(ConstraintInterface $index) + public function addIndex(ConstraintInterface $index): void { $name = $index->getName(); - if (strtoupper($name) == 'PRIMARY') { + if ('PRIMARY' == strtoupper($name)) { $name = strtoupper($name); } @@ -293,7 +308,7 @@ public function hasForeignKey($foreignKeyName) /** * {@inheritdoc} */ - public function setForeignKeys(array $foreignKeys) + public function setForeignKeys(array $foreignKeys): void { $this->foreignKeys = []; @@ -305,7 +320,7 @@ public function setForeignKeys(array $foreignKeys) /** * {@inheritdoc} */ - public function addForeignKey(ForeignKeyInterface $foreignKey) + public function addForeignKey(ForeignKeyInterface $foreignKey): void { $this->foreignKeys[$foreignKey->getName()] = $foreignKey; $foreignKey->setTableName($this->getName()); @@ -330,7 +345,7 @@ public function hasEngine() /** * {@inheritdoc} */ - public function setEngine($engine) + public function setEngine($engine): void { $this->engine = strtoupper($engine); } @@ -354,7 +369,7 @@ public function hasDefaultCollation() /** * {@inheritdoc} */ - public function setDefaultCollation($defaultCollation) + public function setDefaultCollation($defaultCollation): void { $this->defaultCollation = $defaultCollation; } @@ -378,7 +393,7 @@ public function hasRowFormat() /** * {@inheritdoc} */ - public function setRowFormat($rowFormat) + public function setRowFormat($rowFormat): void { $this->rowFormat = strtoupper($rowFormat); } @@ -396,13 +411,13 @@ public function getComment() */ public function hasComment() { - return (bool)strlen($this->comment); + return null !== $this->comment && '' !== $this->comment; } /** * {@inheritdoc} */ - public function setComment($comment) + public function setComment($comment): void { $this->comment = $comment; } @@ -418,7 +433,7 @@ public function getDelimiter() /** * {@inheritdoc} */ - public function setDelimiter($delimiter) + public function setDelimiter($delimiter): void { $this->ddlDelimiter = $delimiter; } @@ -434,7 +449,7 @@ public function getDropPolicy() /** * {@inheritdoc} */ - public function setDropPolicy($ddlDropPolicy) + public function setDropPolicy($ddlDropPolicy): void { $this->ddlDropPolicy = $ddlDropPolicy; } @@ -450,7 +465,7 @@ public function useFullyQualifiedName() /** * {@inheritdoc} */ - public function setUseFullyQualifiedName($useFullyQualifiedName) + public function setUseFullyQualifiedName($useFullyQualifiedName): void { $this->ddlUseFullyQualifiedName = $useFullyQualifiedName; } @@ -464,9 +479,7 @@ public function getCreateStatement() if ($this->ddlUseFullyQualifiedName) { if (!$this->hasDatabaseName()) { - throw new FQNException( - 'Unable to create DDL with fully-qualified-name because the database name has not been set.' - ); + throw new FQNException('Unable to create DDL with fully-qualified-name because the database name has not been set.'); } $tableName = "`{$this->getDatabaseName()}`.`{$this->getName()}`"; @@ -491,17 +504,17 @@ public function getCreateStatement() $columnDefinitions = []; foreach ($this->getColumns() as $column) { - $columnDefinitions[] = ' '.(string)$column; + $columnDefinitions[] = ' ' . (string) $column; } $indexDefinitions = []; foreach ($this->getIndexes() as $index) { - $indexDefinitions[] = ' '.(string)$index; + $indexDefinitions[] = ' ' . (string) $index; } $foreignKeyDefinitions = []; foreach ($this->getForeignKeys() as $foreignKey) { - $foreignKeyDefinitions[] = ' ' . (string)$foreignKey; + $foreignKeyDefinitions[] = ' ' . (string) $foreignKey; } $tableOptions = array_filter( @@ -509,7 +522,7 @@ public function getCreateStatement() $this->hasEngine() ? 'ENGINE = ' . strtoupper($this->getEngine()) : null, $this->hasDefaultCollation() ? "DEFAULT COLLATE = '" . $this->getDefaultCollation() . "'" : null, $this->hasRowFormat() ? 'ROW_FORMAT = ' . strtoupper($this->getRowFormat()) : null, - $this->hasComment() ? "COMMENT = '" . addslashes($this->getComment()) . "'" : null + $this->hasComment() ? "COMMENT = '" . addslashes($this->getComment()) . "'" : null, ] ); @@ -537,7 +550,7 @@ public function getCreateStatement() array_filter( [ $dropDDL, - $createDDL + $createDDL, ] ) ); diff --git a/src/MySQL/Table/TableInterface.php b/src/MySQL/Table/TableInterface.php index 48cd34e..6223b7e 100644 --- a/src/MySQL/Table/TableInterface.php +++ b/src/MySQL/Table/TableInterface.php @@ -1,5 +1,7 @@ name = $name; } @@ -127,7 +143,7 @@ public function getTableName() /** * {@inheritdoc} */ - public function setTableName($tableName) + public function setTableName($tableName): void { $this->tableName = $tableName; } @@ -151,7 +167,7 @@ public function hasDatabaseName() /** * {@inheritdoc} */ - public function setDatabaseName($databaseName) + public function setDatabaseName($databaseName): void { $this->databaseName = $databaseName; } @@ -175,7 +191,7 @@ public function hasDefiner() /** * {@inheritdoc} */ - public function setDefiner($definer) + public function setDefiner($definer): void { $this->definer = $definer; } @@ -191,7 +207,7 @@ public function getEvent() /** * {@inheritdoc} */ - public function setEvent($event) + public function setEvent($event): void { $this->event = $event; } @@ -207,7 +223,7 @@ public function getTiming() /** * {@inheritdoc} */ - public function setTiming($timing) + public function setTiming($timing): void { $this->timing = $timing; } @@ -225,13 +241,13 @@ public function getBody() */ public function hasBody() { - return (bool)strlen($this->body); + return null !== $this->body && '' !== $this->body; } /** * {@inheritdoc} */ - public function setBody($body) + public function setBody($body): void { $this->body = $body; } @@ -263,7 +279,7 @@ public function hasPosition() /** * {@inheritdoc} */ - public function setPosition($positionContext, $relativeTo) + public function setPosition($positionContext, $relativeTo): void { $this->positionContext = $positionContext; $this->positionRelativeTo = $relativeTo; @@ -288,12 +304,12 @@ public function hasSqlMode() /** * {@inheritdoc} */ - public function setSqlMode(SqlMode $sqlMode) + public function setSqlMode(SqlMode $sqlMode): void { $this->sqlMode = $sqlMode; } - public function unsetSqlMode() + public function unsetSqlMode(): void { $this->sqlMode = null; } @@ -309,7 +325,7 @@ public function getDelimiter() /** * {@inheritdoc} */ - public function setDelimiter($delimiter) + public function setDelimiter($delimiter): void { $this->delimiter = $delimiter; } @@ -325,7 +341,7 @@ public function getDropPolicy() /** * {@inheritdoc} */ - public function setDropPolicy($ddlDropPolicy) + public function setDropPolicy($ddlDropPolicy): void { $this->dropPolicy = $ddlDropPolicy; } @@ -341,7 +357,7 @@ public function useFullyQualifiedName() /** * {@inheritdoc} */ - public function setUseFullyQualifiedName($useFullyQualifiedName) + public function setUseFullyQualifiedName($useFullyQualifiedName): void { $this->useFullyQualifiedName = $useFullyQualifiedName; } @@ -355,9 +371,7 @@ public function getCreateStatement() if ($this->useFullyQualifiedName) { if (!$this->hasDatabaseName()) { - throw new FQNException( - 'Unable to create DDL with fully-qualified-name because the database name has not been set.' - ); + throw new FQNException('Unable to create DDL with fully-qualified-name because the database name has not been set.'); } $tableName = "`{$this->getDatabaseName()}`.`{$this->getTableName()}`"; @@ -409,7 +423,7 @@ public function getCreateStatement() $triggerOrder, 'BEGIN', $this->getBody(), - 'END' . $this->delimiter + 'END' . $this->delimiter, ] ) ); @@ -421,7 +435,7 @@ public function getCreateStatement() $setSqlMode, $dropDDL, $createDDL, - $revertSqlMode + $revertSqlMode, ] ) ); diff --git a/src/MySQL/Trigger/TriggerInterface.php b/src/MySQL/Trigger/TriggerInterface.php index 27129fa..8ab5569 100644 --- a/src/MySQL/Trigger/TriggerInterface.php +++ b/src/MySQL/Trigger/TriggerInterface.php @@ -1,171 +1,186 @@ column = new Column($this->name, $this->dataType); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame($this->name, $this->column->getName()); $this->assertSame($this->dataType, $this->column->getDataType()); @@ -60,7 +62,7 @@ public function testInitialProperties() $this->assertNull($this->column->isAutoIncrement()); } - public function testInitialPropertiesWithNumericDataType() + public function testInitialPropertiesWithNumericDataType(): void { $dataType = $this->createMock(NumericTypeInterface::class); $dataType->method('doesAllowDefault')->willReturn(true); @@ -69,7 +71,7 @@ public function testInitialPropertiesWithNumericDataType() $this->assertFalse($column->isAutoIncrement()); } - public function testSetTableName() + public function testSetTableName(): void { $tableName = 'schnoop_tbl'; $this->column->setTableName($tableName); @@ -78,7 +80,7 @@ public function testSetTableName() $this->assertSame($tableName, $this->column->getTableName()); } - public function testSetDatabaseName() + public function testSetDatabaseName(): void { $databaseName = 'schnoop_db'; $this->column->setDatabaseName($databaseName); @@ -87,7 +89,7 @@ public function testSetDatabaseName() $this->assertSame($databaseName, $this->column->getDatabaseName()); } - public function testSetNullable() + public function testSetNullable(): void { $this->column->setNullable(true); $this->assertTrue($this->column->hasDefault()); @@ -112,11 +114,11 @@ public function testSetDefault() return $this->column; } - public function testSetDefaultArray() + public function testSetDefaultArray(): void { $defaultArray = [ 'foo', - 'bar' + 'bar', ]; $this->dataType->method('cast') @@ -129,9 +131,8 @@ public function testSetDefaultArray() /** * @depends testSetDefault - * @param Column $columnWithDefault */ - public function testUnsetDefault(Column $columnWithDefault) + public function testUnsetDefault(Column $columnWithDefault): void { $columnWithDefault->unsetDefault(); @@ -139,7 +140,7 @@ public function testUnsetDefault(Column $columnWithDefault) $this->assertNull($columnWithDefault->getDefault()); } - public function testNotHasDefaultWhenNotAllowDefaultAndAllowNull() + public function testNotHasDefaultWhenNotAllowDefaultAndAllowNull(): void { $dataType = $this->createMock(DataTypeInterface::class); $dataType->method('doesAllowDefault')->willReturn(false); @@ -150,9 +151,9 @@ public function testNotHasDefaultWhenNotAllowDefaultAndAllowNull() $this->assertNull($this->column->getDefault()); } - public function testExceptionWhenSetDefaultWhenNotAllowed() + public function testExceptionWhenSetDefaultWhenNotAllowed(): void { - $this->expectExceptionMessage("Unable to set default value for the column. The data-type \"FOO\" does not support a default."); + $this->expectExceptionMessage('Unable to set default value for the column. The data-type "FOO" does not support a default.'); $this->expectException(LogicException::class); /** @var DataTypeInterface|PHPUnit_Framework_MockObject_MockObject $mockDataType */ @@ -164,7 +165,6 @@ public function testExceptionWhenSetDefaultWhenNotAllowed() $mockDataType->method('getType') ->willReturn('FOO'); - $column = new Column( 'foo', $mockDataType @@ -173,7 +173,7 @@ public function testExceptionWhenSetDefaultWhenNotAllowed() $column->setDefault('foo'); } - public function testExceptionWhenSetOnUpdateCurrentTimestapForUnsupportedDataType() + public function testExceptionWhenSetOnUpdateCurrentTimestapForUnsupportedDataType(): void { $this->expectExceptionMessage( 'Data type "FOOTYPE" for column "schnoop_col" does not support setting current time on update.' @@ -197,7 +197,7 @@ public function testExceptionWhenSetOnUpdateCurrentTimestapForUnsupportedDataTyp * Testing that no warning is triggered when setting default to null when a default is not allowed. * This is allowed to reduce the conditions in a column mapper. */ - public function testSetDefaultNullOkWhenDefaultNotAllowed() + public function testSetDefaultNullOkWhenDefaultNotAllowed(): void { /** @var DataTypeInterface|PHPUnit_Framework_MockObject_MockObject $mockDataType */ $mockDataType = $this->createMock(DataTypeInterface::class); @@ -216,7 +216,7 @@ public function testSetDefaultNullOkWhenDefaultNotAllowed() $this->assertNull($this->column->getDefault()); } - public function testSetOnUpdateCurrentTimestamp() + public function testSetOnUpdateCurrentTimestamp(): void { $mockTimeStamp = $this->createMock(TimestampType::class); $mockTimeStamp->method('doesAllowDefault') @@ -227,7 +227,7 @@ public function testSetOnUpdateCurrentTimestamp() $this->assertTrue($column->isOnUpdateCurrentTimestamp()); } - public function testSetAutoIncrement() + public function testSetAutoIncrement(): void { $dataType = $this->createMock(NumericTypeInterface::class); $dataType->method('doesAllowDefault')->willReturn(true); @@ -237,7 +237,7 @@ public function testSetAutoIncrement() $this->assertTrue($column->isAutoIncrement()); } - public function testExceptionSetAutoIncrementOnUnsupportedType() + public function testExceptionSetAutoIncrementOnUnsupportedType(): void { $this->expectExceptionMessage( 'Unable to set auto-increment property on the column. Data-type "FOO" does not support an auto-incrementing value.' @@ -254,7 +254,7 @@ public function testExceptionSetAutoIncrementOnUnsupportedType() * Specifically testing that no problem is reported when setting ZeroFill * to false even when the type does not support it. */ - public function testNoWarningUnsetAutoIncrementOnUnsupportedType() + public function testNoWarningUnsetAutoIncrementOnUnsupportedType(): void { $this->column->setAutoIncrement(false); $this->assertFalse($this->column->isAutoIncrement()); @@ -272,9 +272,8 @@ public function testSetComment() /** * @depends testSetComment - * @param Column $columnWithComment */ - public function testUnsetComment(Column $columnWithComment) + public function testUnsetComment(Column $columnWithComment): void { $columnWithComment->unsetComment(); @@ -284,15 +283,16 @@ public function testUnsetComment(Column $columnWithComment) /** * @dataProvider DDLProvider + * * @param $column * @param $expectedDDL */ - public function testDDL(Column $column, $expectedDDL) + public function testDDL(Column $column, $expectedDDL): void { $this->assertSame($expectedDDL, $column->getDDL()); } - public function testToStringAliasesGetDDL() + public function testToStringAliasesGetDDL(): void { $ddl = '__dll__'; @@ -300,7 +300,7 @@ public function testToStringAliasesGetDDL() ->setConstructorArgs( [ $this->name, - $this->dataType + $this->dataType, ] )->setMethods( ['getDDL'] @@ -310,11 +310,12 @@ public function testToStringAliasesGetDDL() ->method('getDDL') ->willReturn($ddl); - $this->assertSame($ddl, (string)$mockColumn); + $this->assertSame($ddl, (string) $mockColumn); } /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -330,7 +331,7 @@ public function DDLProvider() $defaultArray = [ 'foo', - 'bar' + 'bar', ]; $mockSetDataType = $this->createMock(SetType::class); @@ -339,16 +340,16 @@ public function DDLProvider() $mockSetDataType->method('cast') ->will($this->onConsecutiveCalls($defaultArray[0], $defaultArray[1])); $mockSetDataType->method('quote') - ->will($this->onConsecutiveCalls("'" . $defaultArray[0] . "'", "'". $defaultArray[1] . "'")); + ->will($this->onConsecutiveCalls("'" . $defaultArray[0] . "'", "'" . $defaultArray[1] . "'")); - $mockTimeType = $this->createMock(TimeTypeInterface::class); + $mockTimeType = $this->createMock(TimeTypeInterface::class); $mockTimeType->method('doesAllowDefault')->willReturn(true); $mockTimeType->method('__toString')->willReturn('_DATATYPE_DDL_'); $mockTimeType->method('cast') ->willReturn($default); $mockTimeType->method('quote')->willReturn($default); - $mockTimeTypeWithPrecision = $this->createMock(TimeTypeInterface::class); + $mockTimeTypeWithPrecision = $this->createMock(TimeTypeInterface::class); $mockTimeTypeWithPrecision->method('doesAllowDefault')->willReturn(true); $mockTimeTypeWithPrecision->method('hasPrecision')->willReturn(true); $mockTimeTypeWithPrecision->method('getPrecision')->willReturn($timePrecision); @@ -441,19 +442,20 @@ public function DDLProvider() <<< SQL `{$this->name}` _DATATYPE_DDL_ NOT NULL DEFAULT CURRENT_TIMESTAMP({$timePrecision}) ON UPDATE CURRENT_TIMESTAMP({$timePrecision}) SQL - ] + ], ]; } /** * @param string $name - * @param DataTypeInterface $dataType * @param bool $nullable * @param mixed $default * @param $onUpdateCurrentTimestamp * @param bool|null $autoIncrement * @param string $comment + * * @return Column + * * @internal param bool|null $zeroFill */ protected function createColumn( @@ -470,7 +472,7 @@ protected function createColumn( $column->setDefault($default); $column->setOnUpdateCurrentTimestamp($onUpdateCurrentTimestamp); - if ($autoIncrement !== null) { + if (null !== $autoIncrement) { $column->setAutoIncrement($autoIncrement); } diff --git a/tests/SchnoopSchema/MySQL/Constraint/AbstractConstraintTest.php b/tests/SchnoopSchema/MySQL/Constraint/AbstractConstraintTest.php index e05118f..7bcfb00 100644 --- a/tests/SchnoopSchema/MySQL/Constraint/AbstractConstraintTest.php +++ b/tests/SchnoopSchema/MySQL/Constraint/AbstractConstraintTest.php @@ -1,5 +1,7 @@ foreignKeyColumn = new ForeignKeyColumn($this->columnName, $this->referenceColumnName); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame($this->columnName, $this->foreignKeyColumn->getColumnName()); $this->assertSame($this->referenceColumnName, $this->foreignKeyColumn->getReferenceColumnName()); diff --git a/tests/SchnoopSchema/MySQL/Constraint/ForeignKeyTest.php b/tests/SchnoopSchema/MySQL/Constraint/ForeignKeyTest.php index c9ab08b..84782dd 100644 --- a/tests/SchnoopSchema/MySQL/Constraint/ForeignKeyTest.php +++ b/tests/SchnoopSchema/MySQL/Constraint/ForeignKeyTest.php @@ -1,5 +1,7 @@ assertFalse($this->foreignKey->hasReferenceColumnName('bogus')); } - public function testSetOnDeleteAction() + public function testSetOnDeleteAction(): void { $this->foreignKey->setOnDeleteAction(ForeignKey::REFERENCE_ACTION_CASCADE); $this->assertSame(ForeignKey::REFERENCE_ACTION_CASCADE, $this->foreignKey->getOnDeleteAction()); } - public function testSetOnUpdateAction() + public function testSetOnUpdateAction(): void { $this->foreignKey->setOnUpdateAction(ForeignKey::REFERENCE_ACTION_CASCADE); $this->assertSame(ForeignKey::REFERENCE_ACTION_CASCADE, $this->foreignKey->getOnUpdateAction()); } - public function testSetReferenceTableName() + public function testSetReferenceTableName(): void { $referenceTableName = 'ref_tbl'; $this->foreignKey->setReferenceTableName($referenceTableName); @@ -81,10 +83,10 @@ public function testSetReferenceTableName() $this->assertSame($referenceTableName, $this->foreignKey->getReferenceTableName()); } - public function testSetForeignKeyColumns() + public function testSetForeignKeyColumns(): void { - $columnNames = ['col_a','col_b']; - $refColumnNames = ['ref_col_a','ref_col_b']; + $columnNames = ['col_a', 'col_b']; + $refColumnNames = ['ref_col_a', 'ref_col_b']; $fkColumnA = $this->createMock(ForeignKeyColumn::class); $fkColumnA->method('getColumnName')->willReturn($columnNames[0]); @@ -95,7 +97,7 @@ public function testSetForeignKeyColumns() $foreignKeyColumns = [ $fkColumnA, - $fkColumnB + $fkColumnB, ]; $this->foreignKey->setForeignKeyColumns($foreignKeyColumns); @@ -113,7 +115,7 @@ public function testSetForeignKeyColumns() } } - public function testHasReferenceColumnNameWithRefTable() + public function testHasReferenceColumnNameWithRefTable(): void { $refTableName = 'ref_tbl'; $refColumnName = 'ref_col'; @@ -127,7 +129,7 @@ public function testHasReferenceColumnNameWithRefTable() $this->assertFalse($this->foreignKey->hasReferenceColumnName($refColumnName, 'bogus')); } - public function testDDL() + public function testDDL(): void { $expectedDDL = <<constraintName}` FOREIGN KEY (`col_a`,`col_b`) REFERENCES `ref_tbl` (`ref_col_a`,`ref_col_b`) ON DELETE RESTRICT ON UPDATE RESTRICT @@ -141,12 +143,12 @@ public function testDDL() $foreignKeyColumns = [ $fkColumnA, - $fkColumnB + $fkColumnB, ]; $this->foreignKey->setForeignKeyColumns($foreignKeyColumns); $this->foreignKey->setReferenceTableName('ref_tbl'); - $this->assertSame($expectedDDL, (string)$this->foreignKey); + $this->assertSame($expectedDDL, (string) $this->foreignKey); } } diff --git a/tests/SchnoopSchema/MySQL/Constraint/FullTextIndexTest.php b/tests/SchnoopSchema/MySQL/Constraint/FullTextIndexTest.php index 92b2801..7555d61 100644 --- a/tests/SchnoopSchema/MySQL/Constraint/FullTextIndexTest.php +++ b/tests/SchnoopSchema/MySQL/Constraint/FullTextIndexTest.php @@ -1,10 +1,12 @@ indexDDLAsserts("FULLTEXT INDEX `{$this->constraintName}`"); } diff --git a/tests/SchnoopSchema/MySQL/Constraint/IndexTest.php b/tests/SchnoopSchema/MySQL/Constraint/IndexTest.php index 2ca233c..cab54f5 100644 --- a/tests/SchnoopSchema/MySQL/Constraint/IndexTest.php +++ b/tests/SchnoopSchema/MySQL/Constraint/IndexTest.php @@ -1,10 +1,12 @@ index = new Index($this->constraintName); } - public function testDDL() + public function testDDL(): void { $this->indexDDLAsserts("INDEX `{$this->constraintName}`"); } diff --git a/tests/SchnoopSchema/MySQL/Constraint/IndexedColumnTest.php b/tests/SchnoopSchema/MySQL/Constraint/IndexedColumnTest.php index 81663fb..747f769 100644 --- a/tests/SchnoopSchema/MySQL/Constraint/IndexedColumnTest.php +++ b/tests/SchnoopSchema/MySQL/Constraint/IndexedColumnTest.php @@ -1,5 +1,7 @@ indexedColumn = new IndexedColumn($this->columnName); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame($this->columnName, $this->indexedColumn->getColumnName()); @@ -32,7 +34,7 @@ public function testInitialProperties() $this->assertNull($this->indexedColumn->getLength()); } - public function testSetCollation() + public function testSetCollation(): void { $collation = IndexedColumn::COLLATION_ASC; $this->indexedColumn->setCollation($collation); @@ -40,7 +42,7 @@ public function testSetCollation() $this->assertTrue($this->indexedColumn->hasCollation()); } - public function testSetLength() + public function testSetLength(): void { $length = 123; $this->indexedColumn->setLength($length); diff --git a/tests/SchnoopSchema/MySQL/Constraint/PrimaryKeyTest.php b/tests/SchnoopSchema/MySQL/Constraint/PrimaryKeyTest.php index 9655dad..e2cbf77 100644 --- a/tests/SchnoopSchema/MySQL/Constraint/PrimaryKeyTest.php +++ b/tests/SchnoopSchema/MySQL/Constraint/PrimaryKeyTest.php @@ -1,5 +1,7 @@ spatialIndex = new SpatialIndex($this->constraintName); } - public function testDDL() + public function testDDL(): void { $this->indexDDLAsserts("SPATIAL INDEX `{$this->constraintName}`"); } diff --git a/tests/SchnoopSchema/MySQL/Constraint/UniqueIndexTest.php b/tests/SchnoopSchema/MySQL/Constraint/UniqueIndexTest.php index e7ed11f..fbb85ae 100644 --- a/tests/SchnoopSchema/MySQL/Constraint/UniqueIndexTest.php +++ b/tests/SchnoopSchema/MySQL/Constraint/UniqueIndexTest.php @@ -1,10 +1,12 @@ uniqueIndex = new UniqueIndex($this->constraintName); } - public function testDDL() + public function testDDL(): void { $this->indexDDLAsserts("UNIQUE INDEX `{$this->constraintName}`"); } - public function testPublicKeyDDL() + public function testPublicKeyDDL(): void { $this->uniqueIndex = new UniqueIndex('primary'); - $this->indexDDLAsserts("PRIMARY KEY"); + $this->indexDDLAsserts('PRIMARY KEY'); } protected function getConstraintName() diff --git a/tests/SchnoopSchema/MySQL/DataType/AbstractBinaryTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/AbstractBinaryTypeTest.php index b2bd504..35a4d16 100644 --- a/tests/SchnoopSchema/MySQL/DataType/AbstractBinaryTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/AbstractBinaryTypeTest.php @@ -1,16 +1,18 @@ abstractBinaryType; } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertFalse($this->abstractBinaryType->hasLength()); $this->assertNull($this->abstractBinaryType->getLength()); $this->assertTrue($this->abstractBinaryType->doesAllowDefault()); } - public function testCast() + public function testCast(): void { $this->assertSame('123', $this->abstractBinaryType->cast(123)); } /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -64,17 +67,18 @@ public function DDLProvider() return [ [ 'FOO', - $abstractBinaryType + $abstractBinaryType, ], [ 'FOO(3)', - $abstractBinaryTypeExtra - ] + $abstractBinaryTypeExtra, + ], ]; } /** * @param $type + * * @return AbstractBinaryType|\PHPUnit_Framework_MockObject_MockObject */ protected function createMockAbstractBinaryType($type) diff --git a/tests/SchnoopSchema/MySQL/DataType/AbstractBlobTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/AbstractBlobTypeTest.php index f7beddc..7c5156c 100644 --- a/tests/SchnoopSchema/MySQL/DataType/AbstractBlobTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/AbstractBlobTypeTest.php @@ -1,9 +1,11 @@ abstractBlobType = $this->createMockAbstractBlobType($this->type); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertFalse($this->abstractBlobType->doesAllowDefault()); } - public function testCast() + public function testCast(): void { $this->assertSame('123', $this->abstractBlobType->cast(123)); } /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -42,13 +45,14 @@ public function DDLProvider() return [ [ 'FOO', - $this->createMockAbstractBlobType('foo') - ] + $this->createMockAbstractBlobType('foo'), + ], ]; } /** * @param $type + * * @return AbstractBlobType|\PHPUnit_Framework_MockObject_MockObject */ protected function createMockAbstractBlobType($type) diff --git a/tests/SchnoopSchema/MySQL/DataType/AbstractCharTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/AbstractCharTypeTest.php index 40e7a50..e761f5f 100644 --- a/tests/SchnoopSchema/MySQL/DataType/AbstractCharTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/AbstractCharTypeTest.php @@ -1,5 +1,7 @@ length; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame($this->type, $this->abstractCharType->getType()); @@ -47,6 +49,7 @@ public function testInitialProperties() /** * @param $type + * * @return AbstractCharType|MockObject */ protected function createMockAbstractCharType($type) diff --git a/tests/SchnoopSchema/MySQL/DataType/AbstractIntTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/AbstractIntTypeTest.php index e2ba5ba..1b1c039 100644 --- a/tests/SchnoopSchema/MySQL/DataType/AbstractIntTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/AbstractIntTypeTest.php @@ -1,9 +1,11 @@ abstractIntType; } - public function testSetUnsigned() + public function testSetUnsigned(): void { $this->abstractIntType->setSigned(false); @@ -36,6 +38,7 @@ public function testSetUnsigned() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -49,17 +52,18 @@ public function DDLProvider() return [ [ 'FOO', - $abstractIntType + $abstractIntType, ], [ 'FOO(3) UNSIGNED', - $abstractIntTypeExtra - ] + $abstractIntTypeExtra, + ], ]; } /** * @param string $type + * * @return AbstractIntType|MockObject */ protected function createMockAbstractIntType($type) diff --git a/tests/SchnoopSchema/MySQL/DataType/AbstractNumericPointTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/AbstractNumericPointTypeTest.php index 528f960..4f73d30 100644 --- a/tests/SchnoopSchema/MySQL/DataType/AbstractNumericPointTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/AbstractNumericPointTypeTest.php @@ -1,9 +1,11 @@ createMockAbstractNumericPointType('foo'); } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame($this->type, $this->abstractNumericPointType->getType()); @@ -40,6 +42,7 @@ public function testInitialProperties() /** * @param $type + * * @return AbstractNumericPointType|MockObject */ protected function createMockAbstractNumericPointType($type) diff --git a/tests/SchnoopSchema/MySQL/DataType/AbstractOptionsTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/AbstractOptionsTypeTest.php index ce38028..af9822b 100644 --- a/tests/SchnoopSchema/MySQL/DataType/AbstractOptionsTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/AbstractOptionsTypeTest.php @@ -1,5 +1,7 @@ createAbstractOptionsType($this->type); } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame($this->type, $this->abstractOptionsType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/AbstractTextTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/AbstractTextTypeTest.php index d29e7c0..576ed32 100644 --- a/tests/SchnoopSchema/MySQL/DataType/AbstractTextTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/AbstractTextTypeTest.php @@ -1,5 +1,7 @@ createMockAbstractTextType($this->type); } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame($this->type, $this->abstractTextType->getType()); @@ -41,6 +43,7 @@ public function testInitialProperties() /** * @param string $type + * * @return AbstractTextType|MockObject */ protected function createMockAbstractTextType($type) diff --git a/tests/SchnoopSchema/MySQL/DataType/AbstractTimeTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/AbstractTimeTypeTest.php index 17b0bad..1c09860 100644 --- a/tests/SchnoopSchema/MySQL/DataType/AbstractTimeTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/AbstractTimeTypeTest.php @@ -1,5 +1,7 @@ assertSame(DataTypeInterface::TYPE_BIGINT, $this->bigIntType->getType()); @@ -38,7 +40,7 @@ public function testInitialProperties() $this->assertSame(BigIntType::MAX_SIGNED, $this->bigIntType->getMaxRange()); } - public function testSetUnsigned() + public function testSetUnsigned(): void { $this->bigIntType->setSigned(false); @@ -49,6 +51,7 @@ public function testSetUnsigned() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -62,12 +65,12 @@ public function DDLProvider() return [ [ 'BIGINT', - $bigIntTypeDefault + $bigIntTypeDefault, ], [ 'BIGINT(3) UNSIGNED', - $BigIntTypeExtra - ] + $BigIntTypeExtra, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/BinaryTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/BinaryTypeTest.php index b0403d9..4b03e06 100644 --- a/tests/SchnoopSchema/MySQL/DataType/BinaryTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/BinaryTypeTest.php @@ -1,10 +1,12 @@ binaryType; } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame(DataTypeInterface::TYPE_BINARY, $this->binaryType->getType()); $this->assertFalse($this->binaryType->hasLength()); @@ -35,6 +37,7 @@ public function testInitialProperties() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -47,12 +50,12 @@ public function DDLProvider() return [ [ 'BINARY', - $binaryType + $binaryType, ], [ 'BINARY(3)', - $binaryTypeExtra - ] + $binaryTypeExtra, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/BitTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/BitTypeTest.php index 7253007..b3777f2 100644 --- a/tests/SchnoopSchema/MySQL/DataType/BitTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/BitTypeTest.php @@ -1,16 +1,18 @@ bitType = new BitType(); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame(DataTypeInterface::TYPE_BIT, $this->bitType->getType()); $this->assertTrue($this->bitType->hasLength()); @@ -34,10 +36,10 @@ public function testInitialProperties() $this->assertSame(0, $this->bitType->getMinRange()); $this->assertSame(1, $this->bitType->getMaxRange()); $this->assertTrue($this->bitType->doesAllowDefault()); - $this->assertSame("BIT(1)", (string)$this->bitType); + $this->assertSame('BIT(1)', (string) $this->bitType); } - public function testSetLength() + public function testSetLength(): void { $length = 4; $this->bitType->setLength($length); @@ -47,7 +49,7 @@ public function testSetLength() $this->assertSame(15, $this->bitType->getMaxRange()); } - public function testCast() + public function testCast(): void { $this->assertSame(123, $this->bitType->cast('123')); } diff --git a/tests/SchnoopSchema/MySQL/DataType/BlobTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/BlobTypeTest.php index 16f77f9..4b11ef0 100644 --- a/tests/SchnoopSchema/MySQL/DataType/BlobTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/BlobTypeTest.php @@ -1,10 +1,12 @@ blobType = new BlobType(); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame(DataTypeInterface::TYPE_BLOB, $this->blobType->getType()); $this->assertFalse($this->blobType->doesAllowDefault()); } - public function testCast() + public function testCast(): void { $this->assertSame('123', $this->blobType->cast(123)); } @@ -38,8 +40,8 @@ public function DDLProvider() return [ [ 'BLOB', - $blobType - ] + $blobType, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/CharTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/CharTypeTest.php index 23059e2..25d2c27 100644 --- a/tests/SchnoopSchema/MySQL/DataType/CharTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/CharTypeTest.php @@ -1,10 +1,12 @@ length; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame(DataTypeInterface::TYPE_CHAR, $this->charType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/DateTimeTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/DateTimeTypeTest.php index 1144947..ae782f6 100644 --- a/tests/SchnoopSchema/MySQL/DataType/DateTimeTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/DateTimeTypeTest.php @@ -1,5 +1,7 @@ assertSame(DataTypeInterface::TYPE_DATETIME, $this->dateTimeType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/DateTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/DateTypeTest.php index 0fd0ab7..2ffb15d 100644 --- a/tests/SchnoopSchema/MySQL/DataType/DateTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/DateTypeTest.php @@ -1,5 +1,7 @@ assertSame(DataTypeInterface::TYPE_DATE, $dateType->getType()); $this->assertTrue($dateType->doesAllowDefault()); $this->assertSame($dateStr, $dateType->cast($dateStr)); - $this->assertSame('DATE', (string)$dateType); + $this->assertSame('DATE', (string) $dateType); } } diff --git a/tests/SchnoopSchema/MySQL/DataType/DecimalTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/DecimalTypeTest.php index 0cd11c3..6e05823 100644 --- a/tests/SchnoopSchema/MySQL/DataType/DecimalTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/DecimalTypeTest.php @@ -1,9 +1,11 @@ assertSame(DataTypeInterface::TYPE_ENUM, $this->enumType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/FloatTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/FloatTypeTest.php index 0ce1f35..c05b227 100644 --- a/tests/SchnoopSchema/MySQL/DataType/FloatTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/FloatTypeTest.php @@ -1,10 +1,12 @@ assertSame(DataTypeInterface::TYPE_FLOAT, $this->floatType->getType()); } - public function testCast() + public function testCast(): void { $floatType = new FloatType(); diff --git a/tests/SchnoopSchema/MySQL/DataType/IntTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/IntTypeTest.php index d101544..4add927 100644 --- a/tests/SchnoopSchema/MySQL/DataType/IntTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/IntTypeTest.php @@ -1,10 +1,12 @@ intType; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame(DataTypeInterface::TYPE_INT, $this->intType->getType()); @@ -33,7 +35,7 @@ public function testInitialProperties() $this->assertSame(IntType::MAX_SIGNED, $this->intType->getMaxRange()); } - public function testSetUnsigned() + public function testSetUnsigned(): void { $this->intType->setSigned(false); @@ -44,6 +46,7 @@ public function testSetUnsigned() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -57,12 +60,12 @@ public function DDLProvider() return [ [ 'INT', - $intTypeDefault + $intTypeDefault, ], [ 'INT(3) UNSIGNED', - $intTypeExtra - ] + $intTypeExtra, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/JsonTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/JsonTypeTest.php index 4c8edd7..2ab1f50 100644 --- a/tests/SchnoopSchema/MySQL/DataType/JsonTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/JsonTypeTest.php @@ -31,7 +31,7 @@ public function testCast(): void public function DDLProvider() { return [ - ['JSON', new JsonType()] + ['JSON', new JsonType()], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/LongBlobTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/LongBlobTypeTest.php index 60635d3..84681e3 100644 --- a/tests/SchnoopSchema/MySQL/DataType/LongBlobTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/LongBlobTypeTest.php @@ -1,10 +1,12 @@ longBlobType = new LongBlobType(); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame(DataTypeInterface::TYPE_LONGBLOB, $this->longBlobType->getType()); $this->assertFalse($this->longBlobType->doesAllowDefault()); } - public function testCast() + public function testCast(): void { $this->assertSame('123', $this->longBlobType->cast(123)); } @@ -38,8 +40,8 @@ public function DDLProvider() return [ [ 'LONGBLOB', - $longBlobType - ] + $longBlobType, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/LongTextTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/LongTextTypeTest.php index 43aa77a..089e262 100644 --- a/tests/SchnoopSchema/MySQL/DataType/LongTextTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/LongTextTypeTest.php @@ -1,10 +1,12 @@ assertSame(DataTypeInterface::TYPE_LONGTEXT, $this->longTextType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/MediumBlobTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/MediumBlobTypeTest.php index 9728415..1e78a66 100644 --- a/tests/SchnoopSchema/MySQL/DataType/MediumBlobTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/MediumBlobTypeTest.php @@ -1,10 +1,12 @@ mediumBlobType = new MediumBlobType(); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame(DataTypeInterface::TYPE_MEDIUMBLOB, $this->mediumBlobType->getType()); $this->assertFalse($this->mediumBlobType->doesAllowDefault()); } - public function testCast() + public function testCast(): void { $this->assertSame('123', $this->mediumBlobType->cast(123)); } /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -42,8 +45,8 @@ public function DDLProvider() return [ [ 'MEDIUMBLOB', - $mediumBlobType - ] + $mediumBlobType, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/MediumIntTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/MediumIntTypeTest.php index e5eba5b..f2dcefb 100644 --- a/tests/SchnoopSchema/MySQL/DataType/MediumIntTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/MediumIntTypeTest.php @@ -1,10 +1,12 @@ mediumIntType; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame(DataTypeInterface::TYPE_MEDIUMINT, $this->mediumIntType->getType()); @@ -33,7 +35,7 @@ public function testInitialProperties() $this->assertSame(MediumIntType::MAX_SIGNED, $this->mediumIntType->getMaxRange()); } - public function testSetUnsigned() + public function testSetUnsigned(): void { $this->mediumIntType->setSigned(false); @@ -44,6 +46,7 @@ public function testSetUnsigned() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -57,12 +60,12 @@ public function DDLProvider() return [ [ 'MEDIUMINT', - $intTypeDefault + $intTypeDefault, ], [ 'MEDIUMINT(3) UNSIGNED', - $intTypeExtra - ] + $intTypeExtra, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/MediumTextTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/MediumTextTypeTest.php index 57c80cc..adbd7a5 100644 --- a/tests/SchnoopSchema/MySQL/DataType/MediumTextTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/MediumTextTypeTest.php @@ -1,10 +1,12 @@ assertSame(DataTypeInterface::TYPE_MEDIUMTEXT, $this->mediumTextType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/Option/QuoteTraitTest.php b/tests/SchnoopSchema/MySQL/DataType/Option/QuoteTraitTest.php index 496fadc..d415f84 100644 --- a/tests/SchnoopSchema/MySQL/DataType/Option/QuoteTraitTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/Option/QuoteTraitTest.php @@ -1,5 +1,7 @@ quoteTrait = $this->getMockForTrait(QuoteTrait::class); } - public function testQuoteNumeric() + public function testQuoteNumeric(): void { $this->assertSame('123', $this->quoteTrait->quote(123)); } - public function testQuoteString() + public function testQuoteString(): void { $this->assertSame("'Ja\'mie'", $this->quoteTrait->quote("Ja'mie")); } diff --git a/tests/SchnoopSchema/MySQL/DataType/SetTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/SetTypeTest.php index e7d360c..aaa275d 100644 --- a/tests/SchnoopSchema/MySQL/DataType/SetTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/SetTypeTest.php @@ -1,10 +1,12 @@ assertSame(DataTypeInterface::TYPE_SET, $this->setType->getType()); } - public function testCast() + public function testCast(): void { $value = [123]; $expectedValue = ['123']; diff --git a/tests/SchnoopSchema/MySQL/DataType/SmallIntTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/SmallIntTypeTest.php index 60a9733..ffeca19 100644 --- a/tests/SchnoopSchema/MySQL/DataType/SmallIntTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/SmallIntTypeTest.php @@ -1,10 +1,12 @@ smallIntType; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame(DataTypeInterface::TYPE_SMALLINT, $this->smallIntType->getType()); @@ -33,7 +35,7 @@ public function testInitialProperties() $this->assertSame(SmallIntType::MAX_SIGNED, $this->smallIntType->getMaxRange()); } - public function testSetUnsigned() + public function testSetUnsigned(): void { $this->smallIntType->setSigned(false); @@ -44,6 +46,7 @@ public function testSetUnsigned() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -57,12 +60,12 @@ public function DDLProvider() return [ [ 'SMALLINT', - $tinyIntTypeDefault + $tinyIntTypeDefault, ], [ 'SMALLINT(3) UNSIGNED', - $tinyIntTypeExtra - ] + $tinyIntTypeExtra, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/TextTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/TextTypeTest.php index a331c1b..37711fc 100644 --- a/tests/SchnoopSchema/MySQL/DataType/TextTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/TextTypeTest.php @@ -1,5 +1,7 @@ assertSame(DataTypeInterface::TYPE_TEXT, $this->textType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/TimeTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/TimeTypeTest.php index bc0b932..35afcab 100644 --- a/tests/SchnoopSchema/MySQL/DataType/TimeTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/TimeTypeTest.php @@ -1,5 +1,7 @@ assertSame(DataTypeInterface::TYPE_TIME, $this->timeType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/TimestampTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/TimestampTypeTest.php index b57ab01..8bc8324 100644 --- a/tests/SchnoopSchema/MySQL/DataType/TimestampTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/TimestampTypeTest.php @@ -1,5 +1,7 @@ assertSame(DataTypeInterface::TYPE_TIMESTAMP, $this->timestampType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/TinyBlobTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/TinyBlobTypeTest.php index ee0a8e5..f7e2b42 100644 --- a/tests/SchnoopSchema/MySQL/DataType/TinyBlobTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/TinyBlobTypeTest.php @@ -1,16 +1,18 @@ tinyBlobType = new TinyBlobType(); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame(DataTypeInterface::TYPE_TINYBLOB, $this->tinyBlobType->getType()); $this->assertFalse($this->tinyBlobType->doesAllowDefault()); } - public function testCast() + public function testCast(): void { $this->assertSame('123', $this->tinyBlobType->cast(123)); } /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -48,8 +51,8 @@ public function DDLProvider() return [ [ 'TINYBLOB', - $tinyBlobType - ] + $tinyBlobType, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/TinyIntTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/TinyIntTypeTest.php index 6e71968..55ba769 100644 --- a/tests/SchnoopSchema/MySQL/DataType/TinyIntTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/TinyIntTypeTest.php @@ -1,10 +1,12 @@ tinyIntType; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame(DataTypeInterface::TYPE_TINYINT, $this->tinyIntType->getType()); @@ -33,7 +35,7 @@ public function testInitialProperties() $this->assertSame(TinyIntType::MAX_SIGNED, $this->tinyIntType->getMaxRange()); } - public function testSetUnsigned() + public function testSetUnsigned(): void { $this->tinyIntType->setSigned(false); @@ -44,6 +46,7 @@ public function testSetUnsigned() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -57,12 +60,12 @@ public function DDLProvider() return [ [ 'TINYINT', - $tinyIntTypeDefault + $tinyIntTypeDefault, ], [ 'TINYINT(3) UNSIGNED', - $tinyIntTypeExtra - ] + $tinyIntTypeExtra, + ], ]; } } diff --git a/tests/SchnoopSchema/MySQL/DataType/TinyTextTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/TinyTextTypeTest.php index e130575..9d89182 100644 --- a/tests/SchnoopSchema/MySQL/DataType/TinyTextTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/TinyTextTypeTest.php @@ -1,9 +1,11 @@ assertSame(DataTypeInterface::TYPE_TINYTEXT, $this->tinyTextType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/VarBinaryTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/VarBinaryTypeTest.php index d1c0e83..c0a4ac8 100644 --- a/tests/SchnoopSchema/MySQL/DataType/VarBinaryTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/VarBinaryTypeTest.php @@ -1,10 +1,12 @@ varBinaryType; } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame(DataTypeInterface::TYPE_VARBINARY, $this->varBinaryType->getType()); $this->assertTrue($this->varBinaryType->hasLength()); @@ -37,6 +39,7 @@ public function testInitialProperties() /** * @see testDDL + * * @return array */ public function DDLProvider() @@ -46,7 +49,7 @@ public function DDLProvider() return [ [ 'VARBINARY(5)', - $binaryType + $binaryType, ], ]; } diff --git a/tests/SchnoopSchema/MySQL/DataType/VarCharTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/VarCharTypeTest.php index 8ca35da..8437e2e 100644 --- a/tests/SchnoopSchema/MySQL/DataType/VarCharTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/VarCharTypeTest.php @@ -1,5 +1,7 @@ length; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame(DataTypeInterface::TYPE_VARCHAR, $this->varCharType->getType()); diff --git a/tests/SchnoopSchema/MySQL/DataType/YearTypeTest.php b/tests/SchnoopSchema/MySQL/DataType/YearTypeTest.php index 330209c..a70e639 100644 --- a/tests/SchnoopSchema/MySQL/DataType/YearTypeTest.php +++ b/tests/SchnoopSchema/MySQL/DataType/YearTypeTest.php @@ -1,5 +1,7 @@ assertSame(DataTypeInterface::TYPE_YEAR, $yearType->getType()); $this->assertTrue($yearType->doesAllowDefault()); - $this->assertSame((int)$yearStr, $yearType->cast($yearStr)); - $this->assertSame('YEAR', (string)$yearType); + $this->assertSame((int) $yearStr, $yearType->cast($yearStr)); + $this->assertSame('YEAR', (string) $yearType); } } diff --git a/tests/SchnoopSchema/MySQL/Database/DatabaseTest.php b/tests/SchnoopSchema/MySQL/Database/DatabaseTest.php index 1328eea..8a5fb32 100644 --- a/tests/SchnoopSchema/MySQL/Database/DatabaseTest.php +++ b/tests/SchnoopSchema/MySQL/Database/DatabaseTest.php @@ -1,11 +1,13 @@ database = new Database($this->name); } - public function testName() + public function testName(): void { $this->assertSame($this->name, $this->database->getName()); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertFalse($this->database->hasDefaultCollation()); $this->assertNull($this->database->getDefaultCollation()); @@ -43,13 +45,13 @@ public function testInitialProperties() $this->assertSame(DroppableInterface::DDL_DROP_POLICY_DO_NOT_DROP, $this->database->getDropPolicy()); } - public function testDefaultCollationUndefined() + public function testDefaultCollationUndefined(): void { $this->assertFalse($this->database->hasDefaultCollation()); $this->assertNull($this->database->getDefaultCollation()); } - public function testSetDefaultCollation() + public function testSetDefaultCollation(): void { $collation = 'utf8_general_ci'; $this->database->setDefaultCollation($collation); @@ -58,14 +60,14 @@ public function testSetDefaultCollation() $this->assertSame($collation, $this->database->getDefaultCollation()); } - public function testSetDDLDropPolicy() + public function testSetDDLDropPolicy(): void { $this->database->setDropPolicy(Database::DDL_DROP_POLICY_DROP_IF_EXISTS); $this->assertSame(Database::DDL_DROP_POLICY_DROP_IF_EXISTS, $this->database->getDropPolicy()); } - public function testSetDDLDelimiter() + public function testSetDDLDelimiter(): void { $this->database->setDelimiter('@@'); @@ -74,15 +76,16 @@ public function testSetDDLDelimiter() /** * @dataProvider DDLProvider + * * @param Database $database * @param $expectedDDL */ - public function testDDL($database, $expectedDDL) + public function testDDL($database, $expectedDDL): void { $this->assertSame($expectedDDL, $database->getCreateStatement()); } - public function testToStringAliasesGetDDL() + public function testToStringAliasesGetDDL(): void { $ddl = '__ddl__'; @@ -97,11 +100,12 @@ public function testToStringAliasesGetDDL() ->method('getCreateStatement') ->willReturn($ddl); - $this->assertSame($ddl, (string)$mockDatabase); + $this->assertSame($ddl, (string) $mockDatabase); } /** * @see testDDL + * * @return array */ public function DDLProvider() diff --git a/tests/SchnoopSchema/MySQL/Routine/AbstractRoutineParameterTest.php b/tests/SchnoopSchema/MySQL/Routine/AbstractRoutineParameterTest.php index df5d11d..a6c733e 100644 --- a/tests/SchnoopSchema/MySQL/Routine/AbstractRoutineParameterTest.php +++ b/tests/SchnoopSchema/MySQL/Routine/AbstractRoutineParameterTest.php @@ -1,5 +1,7 @@ name; } - + protected function getExpectedParameterDataType() { return $this->mockDataType; diff --git a/tests/SchnoopSchema/MySQL/Routine/AbstractRoutineTest.php b/tests/SchnoopSchema/MySQL/Routine/AbstractRoutineTest.php index 4b0d7ff..cbf7448 100644 --- a/tests/SchnoopSchema/MySQL/Routine/AbstractRoutineTest.php +++ b/tests/SchnoopSchema/MySQL/Routine/AbstractRoutineTest.php @@ -1,5 +1,7 @@ mockDataType; } - public function testDDL() + public function testDDL(): void { - $this->assertSame("`param_name` DT_DDL", (string)$this->functionParameter); + $this->assertSame('`param_name` DT_DDL', (string) $this->functionParameter); } } diff --git a/tests/SchnoopSchema/MySQL/Routine/ProcedureParameterTest.php b/tests/SchnoopSchema/MySQL/Routine/ProcedureParameterTest.php index 2b3969c..cc5fa7d 100644 --- a/tests/SchnoopSchema/MySQL/Routine/ProcedureParameterTest.php +++ b/tests/SchnoopSchema/MySQL/Routine/ProcedureParameterTest.php @@ -1,5 +1,7 @@ mockDataType; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); $this->assertSame(ProcedureParameterInterface::DIRECTION_IN, $this->procedureParameter->getDirection()); } - public function testSetDirection() + public function testSetDirection(): void { $this->procedureParameter->setDirection(ProcedureParameterInterface::DIRECTION_INOUT); $this->assertSame(ProcedureParameterInterface::DIRECTION_INOUT, $this->procedureParameter->getDirection()); } - public function testDDL() + public function testDDL(): void { - $this->assertSame("IN `param_name` DT_DDL", (string)$this->procedureParameter); + $this->assertSame('IN `param_name` DT_DDL', (string) $this->procedureParameter); } } diff --git a/tests/SchnoopSchema/MySQL/Routine/RoutineFunctionTest.php b/tests/SchnoopSchema/MySQL/Routine/RoutineFunctionTest.php index dc5e6d2..8e23ae8 100644 --- a/tests/SchnoopSchema/MySQL/Routine/RoutineFunctionTest.php +++ b/tests/SchnoopSchema/MySQL/Routine/RoutineFunctionTest.php @@ -1,12 +1,13 @@ name; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); @@ -70,7 +71,7 @@ public function testInitialProperties() $this->assertSame($this->returns, $this->function->getReturnType()); } - public function testSetReturns() + public function testSetReturns(): void { $mockReturns = $this->createMock(DataTypeInterface::class); @@ -79,12 +80,12 @@ public function testSetReturns() $this->assertSame($mockReturns, $this->function->getReturnType()); } - public function testSetParameters() + public function testSetParameters(): void { /** @var FunctionParameterInterface[]|PHPUnit_Framework_MockObject_MockObject[] $parameters */ $parameters = [ $this->createMock(FunctionParameterInterface::class), - $this->createMock(FunctionParameterInterface::class) + $this->createMock(FunctionParameterInterface::class), ]; $parameters[0]->method('getName') @@ -98,12 +99,12 @@ public function testSetParameters() $this->assertSame($parameters, $this->function->getParameters()); } - public function testAddParameter() + public function testAddParameter(): void { /** @var FunctionParameterInterface[]|PHPUnit_Framework_MockObject_MockObject[] $parameters */ $parameters = [ $this->createMock(FunctionParameterInterface::class), - $this->createMock(FunctionParameterInterface::class) + $this->createMock(FunctionParameterInterface::class), ]; $parameters[0]->method('getName') @@ -119,11 +120,11 @@ public function testAddParameter() /** * @dataProvider getDDLTestData - * @param RoutineFunction $function + * * @param bool $doMockSqlMode * @param $expectedDDL */ - public function testGetDDL(RoutineFunction $function, $doMockSqlMode, $expectedDDL) + public function testGetDDL(RoutineFunction $function, $doMockSqlMode, $expectedDDL): void { if ($doMockSqlMode) { $mockSqlMode = $this->createMock(SqlMode::class); @@ -135,7 +136,7 @@ public function testGetDDL(RoutineFunction $function, $doMockSqlMode, $expectedD $this->assertSame($expectedDDL, $function->getCreateStatement()); } - public function testToStringAliasesGetDDL() + public function testToStringAliasesGetDDL(): void { $ddl = '__ddl__'; $mockFunction = $this->getMockBuilder(RoutineFunction::class) @@ -148,11 +149,12 @@ public function testToStringAliasesGetDDL() ->method('getCreateStatement') ->willReturn($ddl); - $this->assertSame($ddl, (string)$mockFunction); + $this->assertSame($ddl, (string) $mockFunction); } /** * @see testGetDDL + * * @return array */ public function getDDLTestData() @@ -166,7 +168,7 @@ public function getDDLTestData() $mockParameters = [ $this->createMock(ProcedureParameterInterface::class), - $this->createMock(ProcedureParameterInterface::class) + $this->createMock(ProcedureParameterInterface::class), ]; $mockParameters[0]->method('getDDL')->willReturn('__param_1__'); @@ -243,11 +245,11 @@ public function getDDLTestData() END@@ __sql_mode_restore__ SQL - ] + ], ]; } - public function testExceptionOnUseFQNWhenDatabaseNameNotSet() + public function testExceptionOnUseFQNWhenDatabaseNameNotSet(): void { $this->expectExceptionMessage( 'Unable to create DDL with fully-qualified-name because the database name has not been set.' @@ -262,12 +264,12 @@ public function testExceptionOnUseFQNWhenDatabaseNameNotSet() /** * @param $name * @param $databaseName - * @param DataTypeInterface $returnType * @param $body * @param ProcedureParameterInterface[] $parameters * @param $useFQN * @param $ddlDelimiter * @param $ddlDropPolicy + * * @return RoutineFunction */ protected function createFunction( diff --git a/tests/SchnoopSchema/MySQL/Routine/RoutineProcedureTest.php b/tests/SchnoopSchema/MySQL/Routine/RoutineProcedureTest.php index e010ee4..c73d686 100644 --- a/tests/SchnoopSchema/MySQL/Routine/RoutineProcedureTest.php +++ b/tests/SchnoopSchema/MySQL/Routine/RoutineProcedureTest.php @@ -1,14 +1,15 @@ name; } - public function testInitialProperties() + public function testInitialProperties(): void { parent::testInitialProperties(); @@ -58,12 +59,12 @@ public function testInitialProperties() $this->assertSame([], $this->procedure->getParameters()); } - public function testSetParameters() + public function testSetParameters(): void { /** @var ProcedureParameterInterface[]|PHPUnit_Framework_MockObject_MockObject[] $parameters */ $parameters = [ $this->createMock(ProcedureParameterInterface::class), - $this->createMock(ProcedureParameterInterface::class) + $this->createMock(ProcedureParameterInterface::class), ]; $parameters[0]->method('getName') @@ -77,12 +78,12 @@ public function testSetParameters() $this->assertSame($parameters, $this->procedure->getParameters()); } - public function testAddParameter() + public function testAddParameter(): void { /** @var ProcedureParameterInterface[]|PHPUnit_Framework_MockObject_MockObject[] $parameters */ $parameters = [ $this->createMock(ProcedureParameterInterface::class), - $this->createMock(ProcedureParameterInterface::class) + $this->createMock(ProcedureParameterInterface::class), ]; $parameters[0]->method('getName') @@ -98,11 +99,11 @@ public function testAddParameter() /** * @dataProvider getDDLTestData - * @param RoutineProcedure $procedure + * * @param $doMockSqlMode * @param $expectedDDL */ - public function testDDL(RoutineProcedure $procedure, $doMockSqlMode, $expectedDDL) + public function testDDL(RoutineProcedure $procedure, $doMockSqlMode, $expectedDDL): void { if ($doMockSqlMode) { $mockSqlMode = $this->createMock(SqlMode::class); @@ -114,7 +115,7 @@ public function testDDL(RoutineProcedure $procedure, $doMockSqlMode, $expectedDD $this->assertSame($expectedDDL, $procedure->getCreateStatement()); } - public function testToStringAliasesGetDDL() + public function testToStringAliasesGetDDL(): void { $ddl = '__ddl__'; $mockProcedure = $this->getMockBuilder(RoutineProcedure::class) @@ -127,7 +128,7 @@ public function testToStringAliasesGetDDL() ->method('getCreateStatement') ->willReturn($ddl); - $this->assertSame($ddl, (string)$mockProcedure); + $this->assertSame($ddl, (string) $mockProcedure); } public function getDDLTestData() @@ -137,7 +138,7 @@ public function getDDLTestData() /** @var ProcedureParameterInterface[]|PHPUnit_Framework_MockObject_MockObject[] $mockParameters */ $mockParameters = [ $this->createMock(ProcedureParameterInterface::class), - $this->createMock(ProcedureParameterInterface::class) + $this->createMock(ProcedureParameterInterface::class), ]; $mockParameters[0]->method('getDDL')->willReturn('__param_1__'); @@ -205,11 +206,11 @@ public function getDDLTestData() END@@ __sql_mode_restore__ SQL - ] + ], ]; } - public function testExceptionOnUseFQNWhenDatabaseNameNotSet() + public function testExceptionOnUseFQNWhenDatabaseNameNotSet(): void { $this->expectExceptionMessage( 'Unable to create DDL with fully-qualified-name because the database name has not been set.' diff --git a/tests/SchnoopSchema/MySQL/SetVar/SqlModeTest.php b/tests/SchnoopSchema/MySQL/SetVar/SqlModeTest.php index 1a3a953..afdd5ce 100644 --- a/tests/SchnoopSchema/MySQL/SetVar/SqlModeTest.php +++ b/tests/SchnoopSchema/MySQL/SetVar/SqlModeTest.php @@ -1,9 +1,10 @@ sqlMode = new SqlMode($this->mode); } - public function testInitialProperties() + public function testInitialProperties(): void { $this->assertSame($this->mode, $this->sqlMode->getMode()); $this->assertSame(HasDelimiterInterface::DEFAULT_DELIMITER, $this->sqlMode->getDelimiter()); } - public function testSetMode() + public function testSetMode(): void { $newMode = 'BAR'; $this->sqlMode->setMode($newMode); @@ -36,7 +37,7 @@ public function testSetMode() $this->assertSame($newMode, $this->sqlMode->getMode()); } - public function testSetDelimiter() + public function testSetDelimiter(): void { $delimiter = '@@'; $this->sqlMode->setDelimiter($delimiter); @@ -44,7 +45,7 @@ public function testSetDelimiter() $this->assertSame($delimiter, $this->sqlMode->getDelimiter()); } - public function testGetSetStatements() + public function testGetSetStatements(): void { $expectedStatements = <<assertSame($expectedStatements, $this->sqlMode->getSetStatements()); } - public function testGetRestoreStatements() + public function testGetRestoreStatements(): void { $expectedStatements = <<assertSame($this->name, $this->table->getName()); @@ -60,7 +62,7 @@ public function testInitialProperties() $this->assertSame(DroppableInterface::DDL_DROP_POLICY_DO_NOT_DROP, $this->table->getDropPolicy()); } - public function testSetNewName() + public function testSetNewName(): void { $newName = 'new_table_name'; $this->table->setName($newName); @@ -68,7 +70,7 @@ public function testSetNewName() $this->assertSame($newName, $this->table->getName()); } - public function testSetDatabaseName() + public function testSetDatabaseName(): void { $databaseName = 'schnoop_db'; $this->table->setDatabaseName($databaseName); @@ -77,7 +79,7 @@ public function testSetDatabaseName() $this->assertSame($databaseName, $this->table->getDatabaseName()); } - public function testSetEngine() + public function testSetEngine(): void { $this->table->setEngine(Table::ENGINE_INNODB); @@ -85,14 +87,14 @@ public function testSetEngine() $this->assertSame(Table::ENGINE_INNODB, $this->table->getEngine()); } - public function testSetEngineForcesCase() + public function testSetEngineForcesCase(): void { $this->table->setEngine('InnoDB'); $this->assertSame(Table::ENGINE_INNODB, $this->table->getEngine()); } - public function testSetDefaultCollation() + public function testSetDefaultCollation(): void { $defaultCollation = 'utf8mb4_general_ci'; @@ -102,7 +104,7 @@ public function testSetDefaultCollation() $this->assertSame($defaultCollation, $this->table->getDefaultCollation()); } - public function testSetRowFormat() + public function testSetRowFormat(): void { $this->table->setRowFormat(Table::ROW_FORMAT_COMPACT); @@ -110,14 +112,14 @@ public function testSetRowFormat() $this->assertSame(Table::ROW_FORMAT_COMPACT, $this->table->getRowFormat()); } - public function testSetRowFormatForcesCase() + public function testSetRowFormatForcesCase(): void { $this->table->setRowFormat('ComPacT'); $this->assertSame(Table::ROW_FORMAT_COMPACT, $this->table->getRowFormat()); } - public function testSetComment() + public function testSetComment(): void { $comment = 'Schnoop comment'; $this->table->setComment($comment); @@ -126,7 +128,7 @@ public function testSetComment() $this->assertSame($comment, $this->table->getComment()); } - public function testUndefinedColumn() + public function testUndefinedColumn(): void { $columnName = 'schnoop_col'; @@ -134,7 +136,7 @@ public function testUndefinedColumn() $this->assertNull($this->table->getColumn($columnName)); } - public function testAddColumn() + public function testAddColumn(): void { $columnName = 'schnoop_col'; $columnDDL = '_COL_DDL_'; @@ -155,21 +157,21 @@ public function testAddColumn() /** * @depends testAddColumn */ - public function testSetColumns() + public function testSetColumns(): void { $columnNames = [ 'schnoop_col1', - 'schnoop_col2' + 'schnoop_col2', ]; $columnDDLs = [ '_COL_DDL_1_', - '_COL_DDL_2_' + '_COL_DDL_2_', ]; $mockColumns = [ $this->createMockColumn($columnNames[0], $columnDDLs[0]), - $this->createMockColumn($columnNames[1], $columnDDLs[1]) + $this->createMockColumn($columnNames[1], $columnDDLs[1]), ]; $this->table->setColumns($mockColumns); @@ -178,7 +180,7 @@ public function testSetColumns() $this->assertSame($columnNames, $this->table->getColumnList()); } - public function testUndefinedConstraint() + public function testUndefinedConstraint(): void { $constraintName = 'schnoop_idx'; @@ -186,7 +188,7 @@ public function testUndefinedConstraint() $this->assertNull($this->table->getIndex($constraintName)); } - public function testAddIndex() + public function testAddIndex(): void { $indexName = 'schnoop_idx'; $indexDDL = '_IDX_DDL_'; @@ -207,21 +209,21 @@ public function testAddIndex() /** * @depends testAddIndex */ - public function testSetIndexes() + public function testSetIndexes(): void { $indexNames = [ 'schnoop_idx1', - 'schnoop_idx2' + 'schnoop_idx2', ]; $indexDDLs = [ '_IDX_DDL_1_', - '_IDX_DDL_2_' + '_IDX_DDL_2_', ]; $mockIndexes = [ $this->createMockIndex($indexNames[0], $indexDDLs[0]), - $this->createMockIndex($indexNames[1], $indexDDLs[1]) + $this->createMockIndex($indexNames[1], $indexDDLs[1]), ]; $this->table->setIndexes($mockIndexes); @@ -230,7 +232,7 @@ public function testSetIndexes() $this->assertSame($indexNames, $this->table->getIndexList()); } - public function testAddPrimaryKey() + public function testAddPrimaryKey(): void { $mockPrimaryKey = $this->createMock(UniqueIndex::class); $mockPrimaryKey->method('getName')->willReturn('primary'); @@ -240,7 +242,7 @@ public function testAddPrimaryKey() $this->assertSame($mockPrimaryKey, $this->table->getPrimaryKey()); } - public function testAddForeignKey() + public function testAddForeignKey(): void { $foreignKeyName = 'schnoop_fk'; $foreignKeyDDL = '_FK_DDL_'; @@ -261,21 +263,21 @@ public function testAddForeignKey() /** * @depends testAddForeignKey */ - public function testSetForeignKey() + public function testSetForeignKey(): void { $foreignKeyNames = [ 'schnoop_fk1', - 'schnoop_fk2' + 'schnoop_fk2', ]; $foreignKeyDDLs = [ '_FK_DDL_1_', - '_FK_DDL_2_' + '_FK_DDL_2_', ]; $mockForeignKeys = [ $this->createMockForeignKey($foreignKeyNames[0], $foreignKeyDDLs[0]), - $this->createMockForeignKey($foreignKeyNames[1], $foreignKeyDDLs[1]) + $this->createMockForeignKey($foreignKeyNames[1], $foreignKeyDDLs[1]), ]; $this->table->setForeignKeys($mockForeignKeys); @@ -284,14 +286,14 @@ public function testSetForeignKey() $this->assertSame($foreignKeyNames, $this->table->getForeignKeyList()); } - public function testSetUseFullyQualifiedName() + public function testSetUseFullyQualifiedName(): void { $this->table->setUseFullyQualifiedName(true); $this->assertTrue($this->table->useFullyQualifiedName()); } - public function testSetDelimiter() + public function testSetDelimiter(): void { $newDelimiter = '$$'; $this->table->setDelimiter($newDelimiter); @@ -299,7 +301,7 @@ public function testSetDelimiter() $this->assertSame($newDelimiter, $this->table->getDelimiter()); } - public function testSetDropPolicy() + public function testSetDropPolicy(): void { $this->table->setDropPolicy(DroppableInterface::DDL_DROP_POLICY_DROP_IF_EXISTS); @@ -308,15 +310,15 @@ public function testSetDropPolicy() /** * @dataProvider getDDLTestData - * @param Table $table + * * @param string $expectedDDL */ - public function testDDL(Table $table, $expectedDDL) + public function testDDL(Table $table, $expectedDDL): void { $this->assertSame($expectedDDL, $table->getCreateStatement()); } - public function testToStringAliasesGetDDL() + public function testToStringAliasesGetDDL(): void { $ddl = '__ddl__'; $mockTable = $this->getMockBuilder(Table::class) @@ -329,10 +331,10 @@ public function testToStringAliasesGetDDL() ->method('getCreateStatement') ->willReturn($ddl); - $this->assertSame($ddl, (string)$mockTable); + $this->assertSame($ddl, (string) $mockTable); } - public function testExceptionOnUseFQNWhenDatabaseNameNotSet() + public function testExceptionOnUseFQNWhenDatabaseNameNotSet(): void { $this->expectExceptionMessage( 'Unable to create DDL with fully-qualified-name because the database name has not been set.' @@ -346,6 +348,7 @@ public function testExceptionOnUseFQNWhenDatabaseNameNotSet() /** * @see testDDL + * * @return array */ public function getDDLTestData() @@ -354,17 +357,17 @@ public function getDDLTestData() $mockColumns = [ $this->createMockColumn('schnoop_col1', '_COL_DDL_1_'), - $this->createMockColumn('schnoop_col2', '_COL_DDL_2_') + $this->createMockColumn('schnoop_col2', '_COL_DDL_2_'), ]; $mockIndexes = [ $this->createMockIndex('schnoop_idx1', '_IDX_DDL_1_'), - $this->createMockIndex('schnoop_idx2', '_IDX_DDL_2_') + $this->createMockIndex('schnoop_idx2', '_IDX_DDL_2_'), ]; $mockForeignKeys = [ $this->createMockForeignKey('schnoop_fk1', '_FK_DDL_1_'), - $this->createMockForeignKey('schnoop_fk2', '_FK_DDL_2_') + $this->createMockForeignKey('schnoop_fk2', '_FK_DDL_2_'), ]; return [ @@ -471,6 +474,7 @@ public function getDDLTestData() * @param bool $useFQN * @param string $delimiter * @param string $dropPolicy + * * @return Table */ protected function createTable( diff --git a/tests/SchnoopSchema/MySQL/Trigger/TriggerTest.php b/tests/SchnoopSchema/MySQL/Trigger/TriggerTest.php index 0331d95..a578dfc 100644 --- a/tests/SchnoopSchema/MySQL/Trigger/TriggerTest.php +++ b/tests/SchnoopSchema/MySQL/Trigger/TriggerTest.php @@ -1,5 +1,7 @@ assertSame($this->name, $this->trigger->getName()); $this->assertSame($this->timing, $this->trigger->getTiming()); @@ -46,7 +48,7 @@ public function testInitialProperties() $this->assertFalse($this->trigger->hasDatabaseName()); $this->assertNull($this->trigger->getDatabaseName()); - + $this->assertFalse($this->trigger->hasDefiner()); $this->assertNull($this->trigger->getDefiner()); @@ -65,7 +67,7 @@ public function testInitialProperties() $this->assertSame(DroppableInterface::DDL_DROP_POLICY_DO_NOT_DROP, $this->trigger->getDropPolicy()); } - public function testConstants() + public function testConstants(): void { $this->assertSame('CURRENT_USER', TriggerInterface::DEFINER_CURRENT_USER); $this->assertSame('BEFORE', TriggerInterface::TIMING_BEFORE); @@ -76,26 +78,26 @@ public function testConstants() $this->assertSame('FOLLOWS', TriggerInterface::POSITION_FOLLOWS); $this->assertSame('PRECEDES', TriggerInterface::POSITION_PRECEDES); } - - public function testSetDatabaseName() + + public function testSetDatabaseName(): void { $databaseName = 'schnoop_db'; $this->trigger->setDatabaseName($databaseName); - + $this->assertTrue($this->trigger->hasDatabaseName()); $this->assertSame($databaseName, $this->trigger->getDatabaseName()); } - public function testSetDefiner() + public function testSetDefiner(): void { $definer = 'root@localhost'; $this->trigger->setDefiner($definer); - + $this->assertTrue($this->trigger->hasDefiner()); $this->assertSame($definer, $this->trigger->getDefiner()); } - public function testSetPosition() + public function testSetPosition(): void { $relation = 'FOLLOWS'; $relativeTo = 'schnoop_other_trigger'; @@ -106,7 +108,7 @@ public function testSetPosition() $this->assertSame($relativeTo, $this->trigger->getPositionRelativeTo()); } - public function testSetStatement() + public function testSetStatement(): void { $statement = 'SELECT 1;'; $this->trigger->setBody($statement); @@ -128,9 +130,8 @@ public function testSetSqlMode() /** * @depends testSetSqlMode - * @param Trigger $triggerWithSetSqlMode */ - public function testUnsetSqlMode(Trigger $triggerWithSetSqlMode) + public function testUnsetSqlMode(Trigger $triggerWithSetSqlMode): void { $triggerWithSetSqlMode->unsetSqlMode(); @@ -138,14 +139,14 @@ public function testUnsetSqlMode(Trigger $triggerWithSetSqlMode) $this->assertNull($triggerWithSetSqlMode->getSqlMode()); } - public function testSetUseFullyQualifiedName() + public function testSetUseFullyQualifiedName(): void { $this->trigger->setUseFullyQualifiedName(true); $this->assertTrue($this->trigger->useFullyQualifiedName()); } - public function testSetDelimiter() + public function testSetDelimiter(): void { $newDelimiter = '$$'; $this->trigger->setDelimiter($newDelimiter); @@ -153,7 +154,7 @@ public function testSetDelimiter() $this->assertSame($newDelimiter, $this->trigger->getDelimiter()); } - public function testSetDropPolicy() + public function testSetDropPolicy(): void { $this->trigger->setDropPolicy(DroppableInterface::DDL_DROP_POLICY_DROP_IF_EXISTS); @@ -162,11 +163,11 @@ public function testSetDropPolicy() /** * @dataProvider getDDLTestData - * @param Trigger $trigger + * * @param $doMockSqlMode * @param $expectedDDL */ - public function testDDL(Trigger $trigger, $doMockSqlMode, $expectedDDL) + public function testDDL(Trigger $trigger, $doMockSqlMode, $expectedDDL): void { if ($doMockSqlMode) { $mockSqlMode = $this->createMock(SqlMode::class); @@ -178,7 +179,7 @@ public function testDDL(Trigger $trigger, $doMockSqlMode, $expectedDDL) $this->assertSame($expectedDDL, $trigger->getCreateStatement()); } - public function testToStringAliasesGetDDL() + public function testToStringAliasesGetDDL(): void { $ddl = '__ddl__'; $mockTrigger = $this->getMockBuilder(Trigger::class) @@ -191,10 +192,10 @@ public function testToStringAliasesGetDDL() ->method('getCreateStatement') ->willReturn($ddl); - $this->assertSame($ddl, (string)$mockTrigger); + $this->assertSame($ddl, (string) $mockTrigger); } - public function testExceptionOnUseFQNWhenDatabaseNameNotSet() + public function testExceptionOnUseFQNWhenDatabaseNameNotSet(): void { $this->expectExceptionMessage( 'Unable to create DDL with fully-qualified-name because the database name has not been set.' @@ -208,11 +209,13 @@ public function testExceptionOnUseFQNWhenDatabaseNameNotSet() /** * @see testDDL + * * @return array */ public function getDDLTestData() { $databaseName = 'schnoop_db'; + return [ [ $this->createTrigger( @@ -306,6 +309,7 @@ public function getDDLTestData() * @param bool $useFQN * @param string $delimiter * @param string $dropPolicy + * * @return Trigger */ public function createTrigger(