diff --git a/composer.json b/composer.json index 0590853cf..bb915b46d 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "bantu/ini-get-wrapper": "v1.0.1", "deepdiver/zipstreamer": "1.1.1", "deepdiver1975/TarStreamer": "v0.1.0", - "doctrine/dbal": "2.6.3", + "doctrine/dbal": "2.7.2", "guzzlehttp/guzzle": "6.3.3", "icewind/searchdav": "1.0.1", "icewind/Streams": "0.6.1", diff --git a/composer.lock b/composer.lock index 360c49ccb..4c2478b1a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f73785b6f4c9458ffad21e0503de6f96", + "content-hash": "bb74e64cd54642f056266311911f5214", "packages": [ { "name": "aws/aws-sdk-php", @@ -516,16 +516,16 @@ }, { "name": "doctrine/dbal", - "version": "v2.6.3", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13" + "reference": "c0e5736016a51b427a8cba8bc470fbea78165819" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/e3eed9b1facbb0ced3a0995244843a189e7d1b13", - "reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/c0e5736016a51b427a8cba8bc470fbea78165819", + "reference": "c0e5736016a51b427a8cba8bc470fbea78165819", "shasum": "" }, "require": { @@ -534,9 +534,11 @@ "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^5.4.6", + "doctrine/coding-standard": "^4.0", + "phpunit/phpunit": "^7.0", "phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5", - "symfony/console": "2.*||^3.0" + "symfony/console": "^2.0.5||^3.0", + "symfony/phpunit-bridge": "^3.4.5|^4.0.5" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -547,7 +549,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6.x-dev" + "dev-master": "2.7.x-dev" } }, "autoload": { @@ -585,7 +587,7 @@ "persistence", "queryobject" ], - "time": "2017-11-19T13:38:54+00:00" + "time": "2018-07-13T04:49:01+00:00" }, { "name": "doctrine/event-manager", diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index eefd4119a..f1a68dde1 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -584,6 +584,7 @@ 'Doctrine\\DBAL\\Cache\\CacheException' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php', 'Doctrine\\DBAL\\Cache\\QueryCacheProfile' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php', 'Doctrine\\DBAL\\Cache\\ResultCacheStatement' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php', + 'Doctrine\\DBAL\\ColumnCase' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/ColumnCase.php', 'Doctrine\\DBAL\\Configuration' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Configuration.php', 'Doctrine\\DBAL\\Connection' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Connection.php', 'Doctrine\\DBAL\\ConnectionException' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/ConnectionException.php', @@ -640,6 +641,7 @@ 'Doctrine\\DBAL\\Driver\\SQLSrv\\SQLSrvStatement' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php', 'Doctrine\\DBAL\\Driver\\ServerInfoAwareConnection' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php', 'Doctrine\\DBAL\\Driver\\Statement' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php', + 'Doctrine\\DBAL\\Driver\\StatementIterator' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Driver/StatementIterator.php', 'Doctrine\\DBAL\\Event\\ConnectionEventArgs' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php', 'Doctrine\\DBAL\\Event\\Listeners\\MysqlSessionInit' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php', 'Doctrine\\DBAL\\Event\\Listeners\\OracleSessionInit' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php', @@ -675,6 +677,7 @@ 'Doctrine\\DBAL\\Exception\\TableExistsException' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Exception/TableExistsException.php', 'Doctrine\\DBAL\\Exception\\TableNotFoundException' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Exception/TableNotFoundException.php', 'Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Exception/UniqueConstraintViolationException.php', + 'Doctrine\\DBAL\\FetchMode' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/FetchMode.php', 'Doctrine\\DBAL\\Id\\TableGenerator' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGenerator.php', 'Doctrine\\DBAL\\Id\\TableGeneratorSchemaVisitor' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php', 'Doctrine\\DBAL\\LockMode' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/LockMode.php', @@ -682,16 +685,20 @@ 'Doctrine\\DBAL\\Logging\\EchoSQLLogger' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php', 'Doctrine\\DBAL\\Logging\\LoggerChain' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php', 'Doctrine\\DBAL\\Logging\\SQLLogger' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Logging/SQLLogger.php', + 'Doctrine\\DBAL\\ParameterType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/ParameterType.php', 'Doctrine\\DBAL\\Platforms\\AbstractPlatform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php', 'Doctrine\\DBAL\\Platforms\\DB2Platform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php', + 'Doctrine\\DBAL\\Platforms\\DateIntervalUnit' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DateIntervalUnit.php', 'Doctrine\\DBAL\\Platforms\\DrizzlePlatform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\DB2Keywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\DrizzleKeywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\KeywordList' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php', + 'Doctrine\\DBAL\\Platforms\\Keywords\\MariaDb102Keywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\MsSQLKeywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\MySQL57Keywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\MySQLKeywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\OracleKeywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php', + 'Doctrine\\DBAL\\Platforms\\Keywords\\PostgreSQL100Keywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\PostgreSQL91Keywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL91Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\PostgreSQL92Keywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL92Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\PostgreSQL94Keywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php', @@ -706,9 +713,11 @@ 'Doctrine\\DBAL\\Platforms\\Keywords\\SQLServer2012Keywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\SQLServerKeywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\SQLiteKeywords' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php', + 'Doctrine\\DBAL\\Platforms\\MariaDb1027Platform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php', 'Doctrine\\DBAL\\Platforms\\MySQL57Platform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php', 'Doctrine\\DBAL\\Platforms\\MySqlPlatform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php', 'Doctrine\\DBAL\\Platforms\\OraclePlatform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php', + 'Doctrine\\DBAL\\Platforms\\PostgreSQL100Platform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php', 'Doctrine\\DBAL\\Platforms\\PostgreSQL91Platform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php', 'Doctrine\\DBAL\\Platforms\\PostgreSQL92Platform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php', 'Doctrine\\DBAL\\Platforms\\PostgreSQL94Platform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php', @@ -723,6 +732,7 @@ 'Doctrine\\DBAL\\Platforms\\SQLServer2012Platform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php', 'Doctrine\\DBAL\\Platforms\\SQLServerPlatform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php', 'Doctrine\\DBAL\\Platforms\\SqlitePlatform' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php', + 'Doctrine\\DBAL\\Platforms\\TrimMode' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/TrimMode.php', 'Doctrine\\DBAL\\Portability\\Connection' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Portability/Connection.php', 'Doctrine\\DBAL\\Portability\\Statement' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php', 'Doctrine\\DBAL\\Query\\Expression\\CompositeExpression' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php', @@ -782,6 +792,7 @@ 'Doctrine\\DBAL\\Tools\\Console\\Command\\RunSqlCommand' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php', 'Doctrine\\DBAL\\Tools\\Console\\ConsoleRunner' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php', 'Doctrine\\DBAL\\Tools\\Console\\Helper\\ConnectionHelper' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php', + 'Doctrine\\DBAL\\TransactionIsolationLevel' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/TransactionIsolationLevel.php', 'Doctrine\\DBAL\\Types\\ArrayType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php', 'Doctrine\\DBAL\\Types\\BigIntType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/BigIntType.php', 'Doctrine\\DBAL\\Types\\BinaryType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/BinaryType.php', @@ -802,6 +813,8 @@ 'Doctrine\\DBAL\\Types\\JsonArrayType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php', 'Doctrine\\DBAL\\Types\\JsonType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonType.php', 'Doctrine\\DBAL\\Types\\ObjectType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php', + 'Doctrine\\DBAL\\Types\\PhpDateTimeMappingType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpDateTimeMappingType.php', + 'Doctrine\\DBAL\\Types\\PhpIntegerMappingType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpIntegerMappingType.php', 'Doctrine\\DBAL\\Types\\SimpleArrayType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php', 'Doctrine\\DBAL\\Types\\SmallIntType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php', 'Doctrine\\DBAL\\Types\\StringType' => $vendorDir . '/doctrine/dbal/lib/Doctrine/DBAL/Types/StringType.php', diff --git a/composer/autoload_static.php b/composer/autoload_static.php index 86df20333..9167ed2bd 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -970,6 +970,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Cache\\CacheException' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php', 'Doctrine\\DBAL\\Cache\\QueryCacheProfile' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php', 'Doctrine\\DBAL\\Cache\\ResultCacheStatement' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php', + 'Doctrine\\DBAL\\ColumnCase' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/ColumnCase.php', 'Doctrine\\DBAL\\Configuration' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Configuration.php', 'Doctrine\\DBAL\\Connection' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Connection.php', 'Doctrine\\DBAL\\ConnectionException' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/ConnectionException.php', @@ -1026,6 +1027,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Driver\\SQLSrv\\SQLSrvStatement' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php', 'Doctrine\\DBAL\\Driver\\ServerInfoAwareConnection' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php', 'Doctrine\\DBAL\\Driver\\Statement' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php', + 'Doctrine\\DBAL\\Driver\\StatementIterator' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Driver/StatementIterator.php', 'Doctrine\\DBAL\\Event\\ConnectionEventArgs' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php', 'Doctrine\\DBAL\\Event\\Listeners\\MysqlSessionInit' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php', 'Doctrine\\DBAL\\Event\\Listeners\\OracleSessionInit' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php', @@ -1061,6 +1063,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Exception\\TableExistsException' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Exception/TableExistsException.php', 'Doctrine\\DBAL\\Exception\\TableNotFoundException' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Exception/TableNotFoundException.php', 'Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Exception/UniqueConstraintViolationException.php', + 'Doctrine\\DBAL\\FetchMode' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/FetchMode.php', 'Doctrine\\DBAL\\Id\\TableGenerator' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGenerator.php', 'Doctrine\\DBAL\\Id\\TableGeneratorSchemaVisitor' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php', 'Doctrine\\DBAL\\LockMode' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/LockMode.php', @@ -1068,16 +1071,20 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Logging\\EchoSQLLogger' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php', 'Doctrine\\DBAL\\Logging\\LoggerChain' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php', 'Doctrine\\DBAL\\Logging\\SQLLogger' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Logging/SQLLogger.php', + 'Doctrine\\DBAL\\ParameterType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/ParameterType.php', 'Doctrine\\DBAL\\Platforms\\AbstractPlatform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php', 'Doctrine\\DBAL\\Platforms\\DB2Platform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php', + 'Doctrine\\DBAL\\Platforms\\DateIntervalUnit' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DateIntervalUnit.php', 'Doctrine\\DBAL\\Platforms\\DrizzlePlatform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\DB2Keywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\DrizzleKeywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\KeywordList' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php', + 'Doctrine\\DBAL\\Platforms\\Keywords\\MariaDb102Keywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\MsSQLKeywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\MySQL57Keywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\MySQLKeywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\OracleKeywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php', + 'Doctrine\\DBAL\\Platforms\\Keywords\\PostgreSQL100Keywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\PostgreSQL91Keywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL91Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\PostgreSQL92Keywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL92Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\PostgreSQL94Keywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL94Keywords.php', @@ -1092,9 +1099,11 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Platforms\\Keywords\\SQLServer2012Keywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\SQLServerKeywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php', 'Doctrine\\DBAL\\Platforms\\Keywords\\SQLiteKeywords' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php', + 'Doctrine\\DBAL\\Platforms\\MariaDb1027Platform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php', 'Doctrine\\DBAL\\Platforms\\MySQL57Platform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php', 'Doctrine\\DBAL\\Platforms\\MySqlPlatform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php', 'Doctrine\\DBAL\\Platforms\\OraclePlatform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php', + 'Doctrine\\DBAL\\Platforms\\PostgreSQL100Platform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php', 'Doctrine\\DBAL\\Platforms\\PostgreSQL91Platform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php', 'Doctrine\\DBAL\\Platforms\\PostgreSQL92Platform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php', 'Doctrine\\DBAL\\Platforms\\PostgreSQL94Platform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL94Platform.php', @@ -1109,6 +1118,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Platforms\\SQLServer2012Platform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php', 'Doctrine\\DBAL\\Platforms\\SQLServerPlatform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php', 'Doctrine\\DBAL\\Platforms\\SqlitePlatform' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php', + 'Doctrine\\DBAL\\Platforms\\TrimMode' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Platforms/TrimMode.php', 'Doctrine\\DBAL\\Portability\\Connection' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Portability/Connection.php', 'Doctrine\\DBAL\\Portability\\Statement' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php', 'Doctrine\\DBAL\\Query\\Expression\\CompositeExpression' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php', @@ -1168,6 +1178,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Tools\\Console\\Command\\RunSqlCommand' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php', 'Doctrine\\DBAL\\Tools\\Console\\ConsoleRunner' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php', 'Doctrine\\DBAL\\Tools\\Console\\Helper\\ConnectionHelper' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php', + 'Doctrine\\DBAL\\TransactionIsolationLevel' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/TransactionIsolationLevel.php', 'Doctrine\\DBAL\\Types\\ArrayType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php', 'Doctrine\\DBAL\\Types\\BigIntType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/BigIntType.php', 'Doctrine\\DBAL\\Types\\BinaryType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/BinaryType.php', @@ -1188,6 +1199,8 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\DBAL\\Types\\JsonArrayType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php', 'Doctrine\\DBAL\\Types\\JsonType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonType.php', 'Doctrine\\DBAL\\Types\\ObjectType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php', + 'Doctrine\\DBAL\\Types\\PhpDateTimeMappingType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpDateTimeMappingType.php', + 'Doctrine\\DBAL\\Types\\PhpIntegerMappingType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpIntegerMappingType.php', 'Doctrine\\DBAL\\Types\\SimpleArrayType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php', 'Doctrine\\DBAL\\Types\\SmallIntType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php', 'Doctrine\\DBAL\\Types\\StringType' => __DIR__ . '/..' . '/doctrine/dbal/lib/Doctrine/DBAL/Types/StringType.php', diff --git a/composer/installed.json b/composer/installed.json index acd462a4c..70cb2239c 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -525,17 +525,17 @@ }, { "name": "doctrine/dbal", - "version": "v2.6.3", - "version_normalized": "2.6.3.0", + "version": "v2.7.2", + "version_normalized": "2.7.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13" + "reference": "c0e5736016a51b427a8cba8bc470fbea78165819" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/e3eed9b1facbb0ced3a0995244843a189e7d1b13", - "reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/c0e5736016a51b427a8cba8bc470fbea78165819", + "reference": "c0e5736016a51b427a8cba8bc470fbea78165819", "shasum": "" }, "require": { @@ -544,21 +544,23 @@ "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^5.4.6", + "doctrine/coding-standard": "^4.0", + "phpunit/phpunit": "^7.0", "phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5", - "symfony/console": "2.*||^3.0" + "symfony/console": "^2.0.5||^3.0", + "symfony/phpunit-bridge": "^3.4.5|^4.0.5" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." }, - "time": "2017-11-19T13:38:54+00:00", + "time": "2018-07-13T04:49:01+00:00", "bin": [ "bin/doctrine-dbal" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6.x-dev" + "dev-master": "2.7.x-dev" } }, "installation-source": "source", diff --git a/doctrine/dbal/.appveyor.yml b/doctrine/dbal/.appveyor.yml new file mode 100644 index 000000000..ee2043667 --- /dev/null +++ b/doctrine/dbal/.appveyor.yml @@ -0,0 +1,107 @@ +build: false +platform: + - x64 +#matrix: +# fast_finish: true # kills the build at the first failure +clone_folder: C:\projects\dbal +clone_depth: 1 + +cache: + - C:\ProgramData\chocolatey\bin -> .appveyor.yml + - C:\ProgramData\chocolatey\lib -> .appveyor.yml + - C:\tools\php -> .appveyor.yml + - composer.phar + - '%LOCALAPPDATA%\Composer\files' + #- vendor + +## Build matrix for lowest and highest possible targets +environment: + matrix: + - db: mssql + driver: sqlsrv + db_version: sql2008r2sp2 + php: 7.2 + - db: mssql + driver: sqlsrv + db_version: sql2012sp1 + php: 7.2 + - db: mssql + driver: sqlsrv + db_version: sql2017 + php: 7.2 + - db: mssql + driver: pdo_sqlsrv + db_version: sql2017 + php: 7.2 + +init: + - SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH% + - SET COMPOSER_NO_INTERACTION=1 + - SET ANSICON=121x90 (121x90) + +## Install PHP and composer, and run the appropriate composer command +install: + - ps: | + # Check if installation is cached + if (!(Test-Path c:\tools\php)) { + appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','') + # install sqlite + appveyor-retry cinst -y sqlite + Get-ChildItem -Path c:\tools\php + cd c:\tools\php + + # Set PHP environment items that are always needed + copy php.ini-production php.ini + Add-Content php.ini "`n date.timezone=UTC" + Add-Content php.ini "`n extension_dir=ext" + Add-Content php.ini "`n extension=php_openssl.dll" + Add-Content php.ini "`n extension=php_mbstring.dll" + Add-Content php.ini "`n extension=php_fileinfo.dll" + Add-Content php.ini "`n extension=php_pdo_sqlite.dll" + Add-Content php.ini "`n extension=php_sqlite3.dll" + + # Get and install the MSSQL DLL's + $DLLVersion = "5.2.0rc1" + cd c:\tools\php\ext + $source = "https://windows.php.net/downloads/pecl/releases/sqlsrv/$($DLLVersion)/php_sqlsrv-$($DLLVersion)-$($env:php)-nts-vc15-x64.zip" + $destination = "c:\tools\php\ext\php_sqlsrv-$($DLLVersion)-$($env:php)-nts-vc15-x64.zip" + Invoke-WebRequest $source -OutFile $destination + 7z x -y php_sqlsrv-$($DLLVersion)-$($env:php)-nts-vc15-x64.zip > $null + $source = "https://windows.php.net/downloads/pecl/releases/pdo_sqlsrv/$($DLLVersion)/php_pdo_sqlsrv-$($DLLVersion)-$($env:php)-nts-vc15-x64.zip" + $destination = "c:\tools\php\ext\php_pdo_sqlsrv-$($DLLVersion)-$($env:php)-nts-vc15-x64.zip" + Invoke-WebRequest $source -OutFile $destination + 7z x -y php_pdo_sqlsrv-$($DLLVersion)-$($env:php)-nts-vc15-x64.zip > $null + Remove-Item c:\tools\php\* -include .zip + cd c:\tools\php + Add-Content php.ini "`nextension=php_sqlsrv.dll" + Add-Content php.ini "`nextension=php_pdo_sqlsrv.dll" + Add-Content php.ini "`n" + + cd c:\projects\dbal + + if (!(Test-Path c:\projects\dbal\composer.phar)) { + appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar + } + } + # install composer dependencies + - rm composer.lock + - appveyor-retry php composer.phar self-update + - appveyor-retry php composer.phar install --no-progress --profile + +before_test: +# Selectively start the services + - ps: >- + if ($env:db -eq "mssql") { + $instanceName = $env:db_version.ToUpper() + net start "MSSQL`$$instanceName" + } + +test_script: + - cd C:\projects\dbal + - ps: >- + if ($env:db_version) { + vendor\bin\phpunit -c tests\appveyor\%db%.%db_version%.%driver%.appveyor.xml + } + else { + vendor\bin\phpunit -c tests\appveyor\%db%.%driver%.appveyor.xml + } diff --git a/doctrine/dbal/.scrutinizer.yml b/doctrine/dbal/.scrutinizer.yml index 7d81696c1..56a0bf721 100644 --- a/doctrine/dbal/.scrutinizer.yml +++ b/doctrine/dbal/.scrutinizer.yml @@ -1,10 +1,22 @@ build: - environment: - php: - version: 7.1 + nodes: + analysis: + environment: + php: + version: 7.1 + cache: + disabled: false + directories: + - ~/.composer/cache + + project_setup: + override: true + tests: + override: + - php-scrutinizer-run before_commands: - - "composer install --no-dev --prefer-source" + - "composer install --no-dev --prefer-source -a" tools: external_code_coverage: @@ -16,8 +28,6 @@ filter: build_failure_conditions: - 'elements.rating(<= C).new.exists' # No new classes/methods with a rating of C or worse allowed - - 'issues.label("coding-style").new.exists' # No new coding style issues allowed - 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity - 'project.metric_change("scrutinizer.test_coverage", < 0)' # Code Coverage decreased from previous inspection - - 'patches.label("Doc Comments").new.exists' # No new doc comments patches allowed - 'patches.label("Unused Use Statements").new.exists' # No new unused imports patches allowed diff --git a/doctrine/dbal/LICENSE b/doctrine/dbal/LICENSE index 4a91f0bf2..e8fdec4af 100644 --- a/doctrine/dbal/LICENSE +++ b/doctrine/dbal/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2006-2012 Doctrine Project +Copyright (c) 2006-2018 Doctrine Project Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/doctrine/dbal/README.md b/doctrine/dbal/README.md index de477e7bc..8236c1f8f 100644 --- a/doctrine/dbal/README.md +++ b/doctrine/dbal/README.md @@ -1,14 +1,15 @@ # Doctrine DBAL -| [Master][Master] | [2.5][2.5] | -|:----------------:|:----------:| -| [![Build status][Master image]][Master] | [![Build status][2.5 image]][2.5] | -| [![Code Coverage](https://scrutinizer-ci.com/g/doctrine/dbal/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/doctrine/dbal/?branch=master) | [![Code Coverage](https://scrutinizer-ci.com/g/doctrine/dbal/badges/coverage.png?b=2.5)](https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.5) | - +| [Master][Master] | [2.7][2.7] | [2.6][2.6] | +|:----------------:|:----------:|:----------:| +| [![Build status][Master image]][Master] | [![Build status][2.7 image]][2.7] | [![Build status][2.6 image]][2.6] | +| [![Build Status][ContinuousPHP image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.7 image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.6 image]][ContinuousPHP] | +| [![Code Coverage][Coverage image]][Scrutinizer Master] | [![Code Coverage][Coverage 2.7 image]][Scrutinizer 2.7] | [![Code Coverage][Coverage 2.6 image]][Scrutinizer 2.6] | +| [![Code Quality][Quality image]][Scrutinizer Master] | [![Code Quality][Quality 2.7 image]][Scrutinizer 2.7] | [![Code Quality][Quality 2.6 image]][Scrutinizer 2.6] | +| [![AppVeyor][AppVeyor master image]][AppVeyor master] | [![AppVeyor][AppVeyor 2.7 image]][AppVeyor 2.7] | | Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction. - ## More resources: * [Website](http://www.doctrine-project.org/projects/dbal.html) @@ -17,6 +18,25 @@ Powerful database abstraction layer with many features for database schema intro [Master image]: https://img.shields.io/travis/doctrine/dbal/master.svg?style=flat-square + [Coverage image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/master.svg?style=flat-square + [Quality image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/master.svg?style=flat-square + [ContinuousPHP image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/master.svg?style=flat-square [Master]: https://travis-ci.org/doctrine/dbal - [2.5 image]: https://img.shields.io/travis/doctrine/dbal/2.5.svg?style=flat-square - [2.5]: https://github.com/doctrine/dbal/tree/2.5 + [Scrutinizer Master]: https://scrutinizer-ci.com/g/doctrine/dbal/ + [AppVeyor master]: https://ci.appveyor.com/project/doctrine/dbal/branch/master + [AppVeyor master image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/master?svg=true + [ContinuousPHP]: https://continuousphp.com/git-hub/doctrine/dbal + [2.7 image]: https://img.shields.io/travis/doctrine/dbal/2.7.svg?style=flat-square + [Coverage 2.7 image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.7.svg?style=flat-square + [Quality 2.7 image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/2.7.svg?style=flat-square + [ContinuousPHP 2.7 image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.7.svg?style=flat-square + [2.7]: https://github.com/doctrine/dbal/tree/2.7 + [Scrutinizer 2.7]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.7 + [AppVeyor 2.7]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.7 + [AppVeyor 2.7 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.7?svg=true + [2.6 image]: https://img.shields.io/travis/doctrine/dbal/2.6.svg?style=flat-square + [Coverage 2.6 image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.6.svg?style=flat-square + [Quality 2.6 image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/2.6.svg?style=flat-square + [ContinuousPHP 2.6 image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.6.svg?style=flat-square + [2.6]: https://github.com/doctrine/dbal/tree/2.6 + [Scrutinizer 2.6]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.6 diff --git a/doctrine/dbal/UPGRADE.md b/doctrine/dbal/UPGRADE.md index 2847c7864..cc238ee34 100644 --- a/doctrine/dbal/UPGRADE.md +++ b/doctrine/dbal/UPGRADE.md @@ -1,3 +1,26 @@ +# Upgrade to 2.7 + +## Doctrine\DBAL\Platforms\AbstractPlatform::DATE_INTERVAL_UNIT_* constants deprecated + +``Doctrine\DBAL\Platforms\AbstractPlatform::DATE_INTERVAL_UNIT_*`` constants were moved into ``Doctrine\DBAL\Platforms\DateIntervalUnit`` class without the ``DATE_INTERVAL_UNIT_`` prefix. + +## Doctrine\DBAL\Platforms\AbstractPlatform::TRIM_* constants deprecated + +``Doctrine\DBAL\Platforms\AbstractPlatform::TRIM_*`` constants were moved into ``Doctrine\DBAL\Platforms\TrimMode`` class without the ``TRIM_`` prefix. + +## Doctrine\DBAL\Connection::TRANSACTION_* constants deprecated + +``Doctrine\DBAL\Connection::TRANSACTION_*`` were moved into ``Doctrine\DBAL\TransactionIsolationLevel`` class without the ``TRANSACTION_`` prefix. + +## DEPRECATION: direct usage of the PDO APIs in the DBAL API + +1. When calling `Doctrine\DBAL\Driver\Statement` methods, instead of `PDO::PARAM_*` constants, `Doctrine\DBAL\ParameterType` constants should be used. +2. When calling `Doctrine\DBAL\Driver\ResultStatement` methods, instead of `PDO::FETCH_*` constants, `Doctrine\DBAL\FetchMode` constants should be used. +3. When configuring `Doctrine\DBAL\Portability\Connection`, instead of `PDO::CASE_*` constants, `Doctrine\DBAL\ColumnCase` constants should be used. +4. Usage of `PDO::PARAM_INPUT_OUTPUT` in `Doctrine\DBAL\Driver\Statement::bindValue()` is deprecated. +5. Usage of `PDO::FETCH_FUNC` in `Doctrine\DBAL\Driver\ResultStatement::fetch()` is deprecated. +6. Calls to `\PDOStatement` methods on a `\Doctrine\DBAL\Driver\PDOStatement` instance (e.g. `fetchObject()`) are deprecated. + # Upgrade to 2.6 ## MINOR BC BREAK: `fetch()` and `fetchAll()` method signatures in `Doctrine\DBAL\Driver\ResultStatement` diff --git a/doctrine/dbal/composer.json b/doctrine/dbal/composer.json index 67b307183..943dcf031 100644 --- a/doctrine/dbal/composer.json +++ b/doctrine/dbal/composer.json @@ -17,14 +17,19 @@ "doctrine/common": "^2.7.1" }, "require-dev": { - "phpunit/phpunit": "^5.4.6", + "doctrine/coding-standard": "^4.0", + "phpunit/phpunit": "^7.0", "phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5", - "symfony/console": "2.*||^3.0" + "symfony/console": "^2.0.5||^3.0", + "symfony/phpunit-bridge": "^3.4.5|^4.0.5" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." }, "bin": ["bin/doctrine-dbal"], + "config": { + "sort-packages": true + }, "autoload": { "psr-0": { "Doctrine\\DBAL\\": "lib/" } }, @@ -33,10 +38,10 @@ }, "extra": { "branch-alias": { - "dev-master": "2.6.x-dev" + "dev-master": "2.7.x-dev" } }, "archive": { - "exclude": ["!vendor", "tests", "*phpunit.xml", ".travis.yml", "build.xml", "build.properties", "composer.phar"] + "exclude": ["!vendor", "tests", "*phpunit.xml", ".appveyor.yml", ".travis.yml", "build.xml", "build.properties", "composer.phar"] } } diff --git a/doctrine/dbal/composer.lock b/doctrine/dbal/composer.lock new file mode 100644 index 000000000..20e03e47d --- /dev/null +++ b/doctrine/dbal/composer.lock @@ -0,0 +1,2393 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "a408facf78f3db3aa10aca1da0473202", + "packages": [ + { + "name": "doctrine/annotations", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-12-06T07:11:42+00:00" + }, + { + "name": "doctrine/cache", + "version": "v1.7.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^5.7", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2017-08-25T07:02:50+00:00" + }, + { + "name": "doctrine/collections", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "~0.1@dev", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ], + "time": "2017-07-22T10:37:32+00:00" + }, + { + "name": "doctrine/common", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", + "reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": "~7.1" + }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ], + "time": "2017-08-31T08:43:38+00:00" + }, + { + "name": "doctrine/inflector", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "5527a48b7313d15261292c149e55e26eae771b0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", + "reference": "5527a48b7313d15261292c149e55e26eae771b0a", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2018-01-09T20:05:19+00:00" + }, + { + "name": "doctrine/lexer", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09T13:34:57+00:00" + } + ], + "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.4.4", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/2e41850d5f7797cbb1af7b030d245b3b24e63a08", + "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "^5.3|^7", + "squizlabs/php_codesniffer": "*" + }, + "require-dev": { + "composer/composer": "*", + "wimg/php-compatibility": "^8.0" + }, + "suggest": { + "dealerdirect/qa-tools": "All the PHP QA tools you'll need" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "f.nijhof@dealerdirect.nl", + "homepage": "http://workingatdealerdirect.eu", + "role": "Developer" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://workingatdealerdirect.eu", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "time": "2017-12-06T16:27:17+00:00" + }, + { + "name": "doctrine/coding-standard", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/coding-standard.git", + "reference": "0469c18a1a4724c278f2879c0dd7b1fa860b52de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/0469c18a1a4724c278f2879c0dd7b1fa860b52de", + "reference": "0469c18a1a4724c278f2879c0dd7b1fa860b52de", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.2", + "php": "^7.1", + "slevomat/coding-standard": "^4.5.0", + "squizlabs/php_codesniffer": "^3.2.3" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Sniffs\\": "lib/Doctrine/Sniffs" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Steve Müller", + "email": "st.mueller@dzh-online.de" + } + ], + "description": "Doctrine Coding Standard", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "code", + "coding", + "cs", + "doctrine", + "sniffer", + "standard", + "style" + ], + "time": "2018-03-03T23:49:15+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2017-07-22T11:58:36+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-10-19T19:58:43+00:00" + }, + { + "name": "phar-io/manifest", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", + "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^1.0.1", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2017-03-05T18:14:27+00:00" + }, + { + "name": "phar-io/version", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", + "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2017-03-05T17:38:23+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2017-09-11T18:02:19+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "4.3.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "shasum": "" + }, + "require": { + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2017-11-30T07:14:17+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14T14:27:02+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.7.5", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2018-02-19T10:16:54+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "f8ca4b604baf23dab89d87773c28cc07405189ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f8ca4b604baf23dab89d87773c28cc07405189ba", + "reference": "f8ca4b604baf23dab89d87773c28cc07405189ba", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.1", + "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "suggest": { + "ext-xdebug": "^2.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2018-02-02T07:01:41+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2017-11-27T13:52:08+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2018-02-01T13:07:23+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2018-02-01T13:16:43+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "7.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "536f4d853c12d8189963435088e8ff7c0daeab2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/536f4d853c12d8189963435088e8ff7c0daeab2e", + "reference": "536f4d853c12d8189963435088e8ff7c0daeab2e", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "^1.6.1", + "phar-io/manifest": "^1.0.1", + "phar-io/version": "^1.0", + "php": "^7.1", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^6.0.1", + "phpunit/php-file-iterator": "^1.4.3", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.0", + "phpunit/phpunit-mock-objects": "^6.0", + "sebastian/comparator": "^2.1", + "sebastian/diff": "^3.0", + "sebastian/environment": "^3.1", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^1.0", + "sebastian/version": "^2.0.1" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-xdebug": "*", + "phpunit/php-invoker": "^2.0" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2018-03-26T07:36:48+00:00" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/e3249dedc2d99259ccae6affbc2684eac37c2e53", + "reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.5", + "php": "^7.1", + "phpunit/php-text-template": "^1.2.1", + "sebastian/exporter": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2018-02-15T05:27:38+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" + }, + { + "name": "sebastian/comparator", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/diff": "^2.0 || ^3.0", + "sebastian/exporter": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2018-02-01T13:46:46+00:00" + }, + { + "name": "sebastian/diff", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/e09160918c66281713f1c324c1f4c4c3037ba1e8", + "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0", + "symfony/process": "^2 || ^3.3 || ^4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "time": "2018-02-01T13:45:15+00:00" + }, + { + "name": "sebastian/environment", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2017-07-01T08:51:00+00:00" + }, + { + "name": "sebastian/exporter", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2017-04-03T13:19:02+00:00" + }, + { + "name": "sebastian/global-state", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2017-04-27T15:39:26+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-08-03T12:35:26+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29T09:07:27+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2017-03-03T06:23:57+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28T20:34:47+00:00" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "slevomat/coding-standard", + "version": "4.5.2", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "1e609159241fa90d5a429f185b2ea9b881340a7c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/1e609159241fa90d5a429f185b2ea9b881340a7c", + "reference": "1e609159241fa90d5a429f185b2ea9b881340a7c", + "shasum": "" + }, + "require": { + "php": "^7.1", + "squizlabs/php_codesniffer": "^3.2.3" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "1.0.0", + "phing/phing": "2.16", + "phpstan/phpstan": "0.9.2", + "phpstan/phpstan-phpunit": "0.9.4", + "phpstan/phpstan-strict-rules": "0.9", + "phpunit/php-code-coverage": "6.0.1", + "phpunit/phpunit": "7.0.2" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "time": "2018-03-08T08:14:33+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.2.3", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "4842476c434e375f9d3182ff7b89059583aa8b27" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27", + "reference": "4842476c434e375f9d3182ff7b89059583aa8b27", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2018-02-20T21:35:23+00:00" + }, + { + "name": "symfony/console", + "version": "v3.4.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "067339e9b8ec30d5f19f5950208893ff026b94f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/067339e9b8ec30d5f19f5950208893ff026b94f7", + "reference": "067339e9b8ec30d5f19f5950208893ff026b94f7", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2018-02-26T15:46:28+00:00" + }, + { + "name": "symfony/debug", + "version": "v4.0.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "1721e4e7effb23480966690cdcdc7d2a4152d489" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/1721e4e7effb23480966690cdcdc7d2a4152d489", + "reference": "1721e4e7effb23480966690cdcdc7d2a4152d489", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": "<3.4" + }, + "require-dev": { + "symfony/http-kernel": "~3.4|~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2018-02-28T21:50:02+00:00" + }, + { + "name": "symfony/phpunit-bridge", + "version": "v4.0.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/phpunit-bridge.git", + "reference": "14ffbbe2a72d0f6339b24eb830dd38cf63ba6630" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/14ffbbe2a72d0f6339b24eb830dd38cf63ba6630", + "reference": "14ffbbe2a72d0f6339b24eb830dd38cf63ba6630", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "conflict": { + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" + }, + "suggest": { + "ext-zip": "Zip support is required when using bin/simple-phpunit", + "symfony/debug": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" + }, + "bin": [ + "bin/simple-phpunit" + ], + "type": "symfony-bridge", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + }, + "thanks": { + "name": "phpunit/phpunit", + "url": "https://github.com/sebastianbergmann/phpunit" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Bridge\\PhpUnit\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony PHPUnit Bridge", + "homepage": "https://symfony.com", + "time": "2018-02-19T16:50:22+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-01-30T19:27:44+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2017-04-07T12:08:54+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2018-01-29T19:49:41+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^7.1", + "ext-pdo": "*" + }, + "platform-dev": [] +} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/doctrine/dbal/lib/Doctrine/DBAL/Cache/ArrayStatement.php index 7417e9af3..6e09e124d 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -20,7 +20,11 @@ namespace Doctrine\DBAL\Cache; use Doctrine\DBAL\Driver\ResultStatement; -use PDO; +use Doctrine\DBAL\FetchMode; +use function array_merge; +use function array_values; +use function count; +use function reset; class ArrayStatement implements \IteratorAggregate, ResultStatement { @@ -30,19 +34,19 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement private $data; /** - * @var integer + * @var int */ private $columnCount = 0; /** - * @var integer + * @var int */ private $num = 0; /** - * @var integer + * @var int */ - private $defaultFetchMode = PDO::FETCH_BOTH; + private $defaultFetchMode = FetchMode::MIXED; /** * @param array $data @@ -100,23 +104,30 @@ public function getIterator() */ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { - if (isset($this->data[$this->num])) { - $row = $this->data[$this->num++]; - $fetchMode = $fetchMode ?: $this->defaultFetchMode; - if ($fetchMode === PDO::FETCH_ASSOC) { - return $row; - } elseif ($fetchMode === PDO::FETCH_NUM) { - return array_values($row); - } elseif ($fetchMode === PDO::FETCH_BOTH) { - return array_merge($row, array_values($row)); - } elseif ($fetchMode === PDO::FETCH_COLUMN) { - return reset($row); - } else { - throw new \InvalidArgumentException("Invalid fetch-style given for fetching result."); - } + if (! isset($this->data[$this->num])) { + return false; + } + + $row = $this->data[$this->num++]; + $fetchMode = $fetchMode ?: $this->defaultFetchMode; + + if ($fetchMode === FetchMode::ASSOCIATIVE) { + return $row; + } + + if ($fetchMode === FetchMode::NUMERIC) { + return array_values($row); } - return false; + if ($fetchMode === FetchMode::MIXED) { + return array_merge($row, array_values($row)); + } + + if ($fetchMode === FetchMode::COLUMN) { + return reset($row); + } + + throw new \InvalidArgumentException('Invalid fetch-style given for fetching result.'); } /** @@ -124,7 +135,7 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { - $rows = array(); + $rows = []; while ($row = $this->fetch($fetchMode)) { $rows[] = $row; } @@ -137,12 +148,9 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n */ public function fetchColumn($columnIndex = 0) { - $row = $this->fetch(PDO::FETCH_NUM); - if (!isset($row[$columnIndex])) { - // TODO: verify this is correct behavior - return false; - } + $row = $this->fetch(FetchMode::NUMERIC); - return $row[$columnIndex]; + // TODO: verify that return false is the correct behavior + return $row[$columnIndex] ?? false; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php b/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php index 6b3b5394b..1b69058cd 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php @@ -28,7 +28,7 @@ class CacheException extends \Doctrine\DBAL\DBALException /** * @return \Doctrine\DBAL\Cache\CacheException */ - static public function noCacheKey() + public static function noCacheKey() { return new self("No cache key was set."); } @@ -36,7 +36,7 @@ static public function noCacheKey() /** * @return \Doctrine\DBAL\Cache\CacheException */ - static public function noResultDriverConfigured() + public static function noResultDriverConfigured() { return new self("Trying to cache a query but no result driver is configured."); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php b/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php index 19f7a6096..a722681ce 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php @@ -20,23 +20,24 @@ namespace Doctrine\DBAL\Cache; use Doctrine\Common\Cache\Cache; +use function hash; +use function serialize; +use function sha1; /** * Query Cache Profile handles the data relevant for query caching. * * It is a value object, setter methods return NEW instances. - * - * @author Benjamin Eberlei */ class QueryCacheProfile { /** - * @var \Doctrine\Common\Cache\Cache|null + * @var Cache|null */ private $resultCacheDriver; /** - * @var integer + * @var int */ private $lifetime = 0; @@ -46,19 +47,18 @@ class QueryCacheProfile private $cacheKey; /** - * @param integer $lifetime - * @param string|null $cacheKey - * @param \Doctrine\Common\Cache\Cache|null $resultCache + * @param int $lifetime + * @param string|null $cacheKey */ - public function __construct($lifetime = 0, $cacheKey = null, Cache $resultCache = null) + public function __construct($lifetime = 0, $cacheKey = null, ?Cache $resultCache = null) { - $this->lifetime = $lifetime; - $this->cacheKey = $cacheKey; + $this->lifetime = $lifetime; + $this->cacheKey = $cacheKey; $this->resultCacheDriver = $resultCache; } /** - * @return \Doctrine\Common\Cache\Cache|null + * @return Cache|null */ public function getResultCacheDriver() { @@ -66,7 +66,7 @@ public function getResultCacheDriver() } /** - * @return integer + * @return int */ public function getLifetime() { @@ -76,7 +76,7 @@ public function getLifetime() /** * @return string * - * @throws \Doctrine\DBAL\Cache\CacheException + * @throws CacheException */ public function getCacheKey() { @@ -102,7 +102,7 @@ public function generateCacheKeys($query, $params, $types, array $connectionPara $realCacheKey = 'query=' . $query . '¶ms=' . serialize($params) . '&types=' . serialize($types) . - '&connectionParams=' . serialize($connectionParams); + '&connectionParams=' . hash('sha256', serialize($connectionParams)); // should the key be automatically generated using the inputs or is the cache key set? if ($this->cacheKey === null) { @@ -111,11 +111,10 @@ public function generateCacheKeys($query, $params, $types, array $connectionPara $cacheKey = $this->cacheKey; } - return array($cacheKey, $realCacheKey); + return [$cacheKey, $realCacheKey]; } /** - * @param \Doctrine\Common\Cache\Cache $cache * * @return \Doctrine\DBAL\Cache\QueryCacheProfile */ @@ -135,7 +134,7 @@ public function setCacheKey($cacheKey) } /** - * @param integer $lifetime + * @param int $lifetime * * @return \Doctrine\DBAL\Cache\QueryCacheProfile */ diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index 7a5921d05..4b200a5d4 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -22,7 +22,10 @@ use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\Common\Cache\Cache; -use PDO; +use Doctrine\DBAL\FetchMode; +use function array_merge; +use function array_values; +use function reset; /** * Cache statement for SQL results. @@ -56,7 +59,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement private $realKey; /** - * @var integer + * @var int */ private $lifetime; @@ -68,7 +71,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement /** * Did we reach the end of the statement? * - * @var boolean + * @var bool */ private $emptied = false; @@ -78,16 +81,16 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement private $data; /** - * @var integer + * @var int */ - private $defaultFetchMode = PDO::FETCH_BOTH; + private $defaultFetchMode = FetchMode::MIXED; /** * @param \Doctrine\DBAL\Driver\Statement $stmt * @param \Doctrine\Common\Cache\Cache $resultCache * @param string $cacheKey * @param string $realKey - * @param integer $lifetime + * @param int $lifetime */ public function __construct(Statement $stmt, Cache $resultCache, $cacheKey, $realKey, $lifetime) { @@ -107,7 +110,7 @@ public function closeCursor() if ($this->emptied && $this->data !== null) { $data = $this->resultCache->fetch($this->cacheKey); if ( ! $data) { - $data = array(); + $data = []; } $data[$this->realKey] = $this->data; @@ -150,27 +153,35 @@ public function getIterator() public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { if ($this->data === null) { - $this->data = array(); + $this->data = []; } - $row = $this->statement->fetch(PDO::FETCH_ASSOC); + $row = $this->statement->fetch(FetchMode::ASSOCIATIVE); + if ($row) { $this->data[] = $row; $fetchMode = $fetchMode ?: $this->defaultFetchMode; - if ($fetchMode == PDO::FETCH_ASSOC) { + if ($fetchMode === FetchMode::ASSOCIATIVE) { return $row; - } elseif ($fetchMode == PDO::FETCH_NUM) { + } + + if ($fetchMode === FetchMode::NUMERIC) { return array_values($row); - } elseif ($fetchMode == PDO::FETCH_BOTH) { + } + + if ($fetchMode === FetchMode::MIXED) { return array_merge($row, array_values($row)); - } elseif ($fetchMode == PDO::FETCH_COLUMN) { + } + + if ($fetchMode === FetchMode::COLUMN) { return reset($row); - } else { - throw new \InvalidArgumentException("Invalid fetch-style given for caching result."); } + + throw new \InvalidArgumentException('Invalid fetch-style given for caching result.'); } + $this->emptied = true; return false; @@ -181,7 +192,7 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { - $rows = array(); + $rows = []; while ($row = $this->fetch($fetchMode)) { $rows[] = $row; } @@ -194,13 +205,10 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n */ public function fetchColumn($columnIndex = 0) { - $row = $this->fetch(PDO::FETCH_NUM); - if (!isset($row[$columnIndex])) { - // TODO: verify this is correct behavior - return false; - } + $row = $this->fetch(FetchMode::NUMERIC); - return $row[$columnIndex]; + // TODO: verify that return false is the correct behavior + return $row[$columnIndex] ?? false; } /** @@ -212,7 +220,7 @@ public function fetchColumn($columnIndex = 0) * this behaviour is not guaranteed for all databases and should not be * relied on for portable applications. * - * @return integer The number of rows. + * @return int The number of rows. */ public function rowCount() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/ColumnCase.php b/doctrine/dbal/lib/Doctrine/DBAL/ColumnCase.php new file mode 100644 index 000000000..420d868f5 --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/ColumnCase.php @@ -0,0 +1,30 @@ +_attributes['sqlLogger']) ? - $this->_attributes['sqlLogger'] : null; + return $this->_attributes['sqlLogger'] ?? null; } /** @@ -72,8 +71,7 @@ public function getSQLLogger() */ public function getResultCacheImpl() { - return isset($this->_attributes['resultCacheImpl']) ? - $this->_attributes['resultCacheImpl'] : null; + return $this->_attributes['resultCacheImpl'] ?? null; } /** @@ -111,11 +109,7 @@ public function setFilterSchemaAssetsExpression($filterExpression) */ public function getFilterSchemaAssetsExpression() { - if (isset($this->_attributes['filterSchemaAssetsExpression'])) { - return $this->_attributes['filterSchemaAssetsExpression']; - } - - return null; + return $this->_attributes['filterSchemaAssetsExpression'] ?? null; } /** @@ -125,7 +119,7 @@ public function getFilterSchemaAssetsExpression() * transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either * the method commit or the method rollback. By default, new connections are in auto-commit mode. * - * @param boolean $autoCommit True to enable auto-commit mode; false to disable it. + * @param bool $autoCommit True to enable auto-commit mode; false to disable it. * * @see getAutoCommit */ @@ -137,16 +131,12 @@ public function setAutoCommit($autoCommit) /** * Returns the default auto-commit mode for connections. * - * @return boolean True if auto-commit mode is enabled by default for connections, false otherwise. + * @return bool True if auto-commit mode is enabled by default for connections, false otherwise. * * @see setAutoCommit */ public function getAutoCommit() { - if (isset($this->_attributes['autoCommit'])) { - return $this->_attributes['autoCommit']; - } - - return true; + return $this->_attributes['autoCommit'] ?? true; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Connection.php b/doctrine/dbal/lib/Doctrine/DBAL/Connection.php index 082e413fd..3c876eb9e 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Connection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Connection.php @@ -21,7 +21,6 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Exception\InvalidArgumentException; -use PDO; use Closure; use Exception; use Doctrine\DBAL\Types\Type; @@ -33,6 +32,13 @@ use Doctrine\DBAL\Cache\CacheException; use Doctrine\DBAL\Driver\PingableConnection; use Throwable; +use function array_key_exists; +use function array_merge; +use function func_get_args; +use function implode; +use function is_int; +use function is_string; +use function key; /** * A wrapper around a Doctrine\DBAL\Driver\Connection that adds features like @@ -52,42 +58,50 @@ class Connection implements DriverConnection { /** * Constant for transaction isolation level READ UNCOMMITTED. + * + * @deprecated Use TransactionIsolationLevel::READ_UNCOMMITTED. */ - const TRANSACTION_READ_UNCOMMITTED = 1; + public const TRANSACTION_READ_UNCOMMITTED = TransactionIsolationLevel::READ_UNCOMMITTED; /** * Constant for transaction isolation level READ COMMITTED. + * + * @deprecated Use TransactionIsolationLevel::READ_COMMITTED. */ - const TRANSACTION_READ_COMMITTED = 2; + public const TRANSACTION_READ_COMMITTED = TransactionIsolationLevel::READ_COMMITTED; /** * Constant for transaction isolation level REPEATABLE READ. + * + * @deprecated Use TransactionIsolationLevel::REPEATABLE_READ. */ - const TRANSACTION_REPEATABLE_READ = 3; + public const TRANSACTION_REPEATABLE_READ = TransactionIsolationLevel::REPEATABLE_READ; /** * Constant for transaction isolation level SERIALIZABLE. + * + * @deprecated Use TransactionIsolationLevel::SERIALIZABLE. */ - const TRANSACTION_SERIALIZABLE = 4; + public const TRANSACTION_SERIALIZABLE = TransactionIsolationLevel::SERIALIZABLE; /** * Represents an array of ints to be expanded by Doctrine SQL parsing. * - * @var integer + * @var int */ - const PARAM_INT_ARRAY = 101; + public const PARAM_INT_ARRAY = ParameterType::INTEGER + self::ARRAY_PARAM_OFFSET; /** * Represents an array of strings to be expanded by Doctrine SQL parsing. * - * @var integer + * @var int */ - const PARAM_STR_ARRAY = 102; + public const PARAM_STR_ARRAY = ParameterType::STRING + self::ARRAY_PARAM_OFFSET; /** * Offset by which PARAM_* constants are detected as arrays of the param type. * - * @var integer + * @var int */ const ARRAY_PARAM_OFFSET = 100; @@ -116,35 +130,35 @@ class Connection implements DriverConnection /** * Whether or not a connection has been established. * - * @var boolean + * @var bool */ private $_isConnected = false; /** * The current auto-commit mode of this connection. * - * @var boolean + * @var bool */ private $autoCommit = true; /** * The transaction nesting level. * - * @var integer + * @var int */ private $_transactionNestingLevel = 0; /** * The currently active transaction isolation level. * - * @var integer + * @var int */ private $_transactionIsolationLevel; /** * If nested transactions should use savepoints. * - * @var boolean + * @var bool */ private $_nestTransactionsWithSavepoints = false; @@ -153,7 +167,7 @@ class Connection implements DriverConnection * * @var array */ - private $_params = array(); + private $_params = []; /** * The DatabasePlatform object that provides information about the @@ -180,14 +194,14 @@ class Connection implements DriverConnection /** * Flag that indicates whether the current transaction is marked for rollback only. * - * @var boolean + * @var bool */ private $_isRollbackOnly = false; /** - * @var integer + * @var int */ - protected $defaultFetchMode = PDO::FETCH_ASSOC; + protected $defaultFetchMode = FetchMode::ASSOCIATIVE; /** * Initializes a new instance of the Connection class. @@ -264,7 +278,7 @@ public function getDatabase() */ public function getHost() { - return isset($this->_params['host']) ? $this->_params['host'] : null; + return $this->_params['host'] ?? null; } /** @@ -274,7 +288,7 @@ public function getHost() */ public function getPort() { - return isset($this->_params['port']) ? $this->_params['port'] : null; + return $this->_params['port'] ?? null; } /** @@ -284,7 +298,7 @@ public function getPort() */ public function getUsername() { - return isset($this->_params['user']) ? $this->_params['user'] : null; + return $this->_params['user'] ?? null; } /** @@ -294,7 +308,7 @@ public function getUsername() */ public function getPassword() { - return isset($this->_params['password']) ? $this->_params['password'] : null; + return $this->_params['password'] ?? null; } /** @@ -331,6 +345,8 @@ public function getEventManager() * Gets the DatabasePlatform for the connection. * * @return \Doctrine\DBAL\Platforms\AbstractPlatform + * + * @throws \Doctrine\DBAL\DBALException */ public function getDatabasePlatform() { @@ -354,8 +370,8 @@ public function getExpressionBuilder() /** * Establishes the connection with the database. * - * @return boolean TRUE if the connection was successfully established, FALSE if - * the connection is already open. + * @return bool TRUE if the connection was successfully established, FALSE if + * the connection is already open. */ public function connect() { @@ -363,11 +379,9 @@ public function connect() return false; } - $driverOptions = isset($this->_params['driverOptions']) ? - $this->_params['driverOptions'] : array(); - $user = isset($this->_params['user']) ? $this->_params['user'] : null; - $password = isset($this->_params['password']) ? - $this->_params['password'] : null; + $driverOptions = $this->_params['driverOptions'] ?? []; + $user = $this->_params['user'] ?? null; + $password = $this->_params['password'] ?? null; $this->_conn = $this->_driver->connect($this->_params, $user, $password, $driverOptions); $this->_isConnected = true; @@ -413,6 +427,8 @@ private function detectDatabasePlatform() * version without having to query it (performance reasons). * * @return string|null + * + * @throws Exception */ private function getDatabasePlatformVersion() { @@ -487,7 +503,7 @@ private function getServerVersion() /** * Returns the current auto-commit mode for this connection. * - * @return boolean True if auto-commit mode is currently enabled for this connection, false otherwise. + * @return bool True if auto-commit mode is currently enabled for this connection, false otherwise. * * @see setAutoCommit */ @@ -506,7 +522,7 @@ public function isAutoCommit() * NOTE: If this method is called during a transaction and the auto-commit mode is changed, the transaction is * committed. If this method is called and the auto-commit mode is not changed, the call is a no-op. * - * @param boolean $autoCommit True to enable auto-commit mode; false to disable it. + * @param bool $autoCommit True to enable auto-commit mode; false to disable it. * * @see isAutoCommit */ @@ -530,7 +546,7 @@ public function setAutoCommit($autoCommit) /** * Sets the fetch mode. * - * @param integer $fetchMode + * @param int $fetchMode * * @return void */ @@ -548,10 +564,12 @@ public function setFetchMode($fetchMode) * @param array $types The query parameter types. * * @return array|bool False is returned if no rows are found. + * + * @throws \Doctrine\DBAL\DBALException */ - public function fetchAssoc($statement, array $params = array(), array $types = array()) + public function fetchAssoc($statement, array $params = [], array $types = []) { - return $this->executeQuery($statement, $params, $types)->fetch(PDO::FETCH_ASSOC); + return $this->executeQuery($statement, $params, $types)->fetch(FetchMode::ASSOCIATIVE); } /** @@ -564,23 +582,25 @@ public function fetchAssoc($statement, array $params = array(), array $types = a * * @return array|bool False is returned if no rows are found. */ - public function fetchArray($statement, array $params = array(), array $types = array()) + public function fetchArray($statement, array $params = [], array $types = []) { - return $this->executeQuery($statement, $params, $types)->fetch(PDO::FETCH_NUM); + return $this->executeQuery($statement, $params, $types)->fetch(FetchMode::NUMERIC); } /** * Prepares and executes an SQL query and returns the value of a single column * of the first row of the result. * - * @param string $statement The SQL query to be executed. - * @param array $params The prepared statement params. - * @param integer $column The 0-indexed column number to retrieve. - * @param array $types The query parameter types. + * @param string $statement The SQL query to be executed. + * @param array $params The prepared statement params. + * @param int $column The 0-indexed column number to retrieve. + * @param array $types The query parameter types. * * @return mixed|bool False is returned if no rows are found. + * + * @throws \Doctrine\DBAL\DBALException */ - public function fetchColumn($statement, array $params = array(), $column = 0, array $types = array()) + public function fetchColumn($statement, array $params = [], $column = 0, array $types = []) { return $this->executeQuery($statement, $params, $types)->fetchColumn($column); } @@ -588,7 +608,7 @@ public function fetchColumn($statement, array $params = array(), $column = 0, ar /** * Whether an actual connection to the database is established. * - * @return boolean + * @return bool */ public function isConnected() { @@ -598,7 +618,7 @@ public function isConnected() /** * Checks whether a transaction is currently active. * - * @return boolean TRUE if a transaction is currently active, FALSE otherwise. + * @return bool TRUE if a transaction is currently active, FALSE otherwise. */ public function isTransactionActive() { @@ -640,15 +660,16 @@ private function gatherConditions(array $identifiers) * * Table expression and columns are not escaped and are not safe for user-input. * - * @param string $tableExpression The expression of the table on which to delete. - * @param array $identifier The deletion criteria. An associative array containing column-value pairs. - * @param array $types The types of identifiers. + * @param string $tableExpression The expression of the table on which to delete. + * @param array $identifier The deletion criteria. An associative array containing column-value pairs. + * @param array $types The types of identifiers. * - * @return integer The number of affected rows. + * @return int The number of affected rows. * + * @throws \Doctrine\DBAL\DBALException * @throws InvalidArgumentException */ - public function delete($tableExpression, array $identifier, array $types = array()) + public function delete($tableExpression, array $identifier, array $types = []) { if (empty($identifier)) { throw InvalidArgumentException::fromEmptyCriteria(); @@ -678,9 +699,9 @@ public function close() /** * Sets the transaction isolation level. * - * @param integer $level The level to set. + * @param int $level The level to set. * - * @return integer + * @return int */ public function setTransactionIsolation($level) { @@ -692,7 +713,7 @@ public function setTransactionIsolation($level) /** * Gets the currently active transaction isolation level. * - * @return integer The current transaction isolation level. + * @return int The current transaction isolation level. */ public function getTransactionIsolation() { @@ -708,18 +729,20 @@ public function getTransactionIsolation() * * Table expression and columns are not escaped and are not safe for user-input. * - * @param string $tableExpression The expression of the table to update quoted or unquoted. - * @param array $data An associative array containing column-value pairs. - * @param array $identifier The update criteria. An associative array containing column-value pairs. - * @param array $types Types of the merged $data and $identifier arrays in that order. + * @param string $tableExpression The expression of the table to update quoted or unquoted. + * @param array $data An associative array containing column-value pairs. + * @param array $identifier The update criteria. An associative array containing column-value pairs. + * @param array $types Types of the merged $data and $identifier arrays in that order. + * + * @return int The number of affected rows. * - * @return integer The number of affected rows. + * @throws \Doctrine\DBAL\DBALException */ - public function update($tableExpression, array $data, array $identifier, array $types = array()) + public function update($tableExpression, array $data, array $identifier, array $types = []) { - $setColumns = array(); - $setValues = array(); - $set = array(); + $setColumns = []; + $setValues = []; + $set = []; foreach ($data as $columnName => $value) { $setColumns[] = $columnName; @@ -747,20 +770,22 @@ public function update($tableExpression, array $data, array $identifier, array $ * Table expression and columns are not escaped and are not safe for user-input. * * @param string $tableExpression The expression of the table to insert data into, quoted or unquoted. - * @param array $data An associative array containing column-value pairs. - * @param array $types Types of the inserted data. + * @param array $data An associative array containing column-value pairs. + * @param array $types Types of the inserted data. * - * @return integer The number of affected rows. + * @return int The number of affected rows. + * + * @throws \Doctrine\DBAL\DBALException */ - public function insert($tableExpression, array $data, array $types = array()) + public function insert($tableExpression, array $data, array $types = []) { if (empty($data)) { return $this->executeUpdate('INSERT INTO ' . $tableExpression . ' ()' . ' VALUES ()'); } - $columns = array(); - $values = array(); - $set = array(); + $columns = []; + $values = []; + $set = []; foreach ($data as $columnName => $value) { $columns[] = $columnName; @@ -786,12 +811,10 @@ public function insert($tableExpression, array $data, array $types = array()) */ private function extractTypeValues(array $columnList, array $types) { - $typeValues = array(); + $typeValues = []; foreach ($columnList as $columnIndex => $columnName) { - $typeValues[] = isset($types[$columnName]) - ? $types[$columnName] - : \PDO::PARAM_STR; + $typeValues[] = $types[$columnName] ?? ParameterType::STRING; } return $typeValues; @@ -819,7 +842,7 @@ public function quoteIdentifier($str) /** * Quotes a given input parameter. * - * @param mixed $input The parameter to be quoted. + * @param mixed $input The parameter to be quoted. * @param int|null $type The type of the parameter. * * @return string The quoted parameter. @@ -842,7 +865,7 @@ public function quote($input, $type = null) * * @return array */ - public function fetchAll($sql, array $params = array(), $types = array()) + public function fetchAll($sql, array $params = [], $types = []) { return $this->executeQuery($sql, $params, $types)->fetchAll(); } @@ -884,7 +907,7 @@ public function prepare($statement) * * @throws \Doctrine\DBAL\DBALException */ - public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null) + public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null) { if ($qcp !== null) { return $this->executeCacheQuery($query, $params, $types, $qcp); @@ -951,7 +974,7 @@ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qc if (isset($data[$realKey])) { $stmt = new ArrayStatement($data[$realKey]); } elseif (array_key_exists($realKey, $data)) { - $stmt = new ArrayStatement(array()); + $stmt = new ArrayStatement([]); } } @@ -978,7 +1001,7 @@ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qc */ public function project($query, array $params, Closure $function) { - $result = array(); + $result = []; $stmt = $this->executeQuery($query, $params); while ($row = $stmt->fetch()) { @@ -1033,11 +1056,11 @@ public function query() * @param array $params The query parameters. * @param array $types The parameter types. * - * @return integer The number of affected rows. + * @return int The number of affected rows. * * @throws \Doctrine\DBAL\DBALException */ - public function executeUpdate($query, array $params = array(), array $types = array()) + public function executeUpdate($query, array $params = [], array $types = []) { $this->connect(); @@ -1077,7 +1100,7 @@ public function executeUpdate($query, array $params = array(), array $types = ar * * @param string $statement * - * @return integer The number of affected rows. + * @return int The number of affected rows. * * @throws \Doctrine\DBAL\DBALException */ @@ -1106,7 +1129,7 @@ public function exec($statement) /** * Returns the current transaction nesting level. * - * @return integer The nesting level. A value of 0 means there's no active transaction. + * @return int The nesting level. A value of 0 means there's no active transaction. */ public function getTransactionNestingLevel() { @@ -1116,7 +1139,7 @@ public function getTransactionNestingLevel() /** * Fetches the SQLSTATE associated with the last database operation. * - * @return integer The last error code. + * @return int The last error code. */ public function errorCode() { @@ -1168,7 +1191,8 @@ public function lastInsertId($seqName = null) * * @return mixed The value returned by $func * - * @throws \Exception + * @throws Exception + * @throws Throwable */ public function transactional(Closure $func) { @@ -1189,7 +1213,7 @@ public function transactional(Closure $func) /** * Sets if nested transactions should use savepoints. * - * @param boolean $nestTransactionsWithSavepoints + * @param bool $nestTransactionsWithSavepoints * * @return void * @@ -1211,7 +1235,7 @@ public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoint /** * Gets if nested transactions should use savepoints. * - * @return boolean + * @return bool */ public function getNestTransactionsWithSavepoints() { @@ -1471,7 +1495,7 @@ public function setRollbackOnly() /** * Checks whether the current transaction is marked for rollback only. * - * @return boolean + * @return bool * * @throws \Doctrine\DBAL\ConnectionException If no transaction is active. */ @@ -1574,10 +1598,10 @@ private function getBindingInfo($value, $type) $value = $type->convertToDatabaseValue($value, $this->getDatabasePlatform()); $bindingType = $type->getBindingType(); } else { - $bindingType = $type; // PDO::PARAM_* constants + $bindingType = $type; } - return array($value, $bindingType); + return [$value, $bindingType]; } /** @@ -1593,7 +1617,7 @@ private function getBindingInfo($value, $type) */ public function resolveParams(array $params, array $types) { - $resolvedParams = array(); + $resolvedParams = []; // Check whether parameters are positional or named. Mixing is not allowed, just like in PDO. if (is_int(key($params))) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/doctrine/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 4a91de675..e769cc429 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -25,6 +25,9 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; +use function array_rand; +use function count; +use function func_get_args; /** * Master-Slave Connection @@ -93,7 +96,7 @@ class MasterSlaveConnection extends Connection * You can keep the slave connection and then switch back to it * during the request if you know what you are doing. * - * @var boolean + * @var bool */ protected $keepSlave = false; @@ -121,7 +124,7 @@ public function __construct(array $params, Driver $driver, Configuration $config $params['slaves'][$slaveKey]['driver'] = $params['driver']; } - $this->keepSlave = isset($params['keepSlave']) ? (bool) $params['keepSlave'] : false; + $this->keepSlave = (bool) ($params['keepSlave'] ?? false); parent::__construct($params, $driver, $config, $eventManager); } @@ -129,7 +132,7 @@ public function __construct(array $params, Driver $driver, Configuration $config /** * Checks if the connection is currently towards the master or not. * - * @return boolean + * @return bool */ public function isConnectedToMaster() { @@ -202,12 +205,12 @@ protected function connectTo($connectionName) { $params = $this->getParams(); - $driverOptions = isset($params['driverOptions']) ? $params['driverOptions'] : []; + $driverOptions = $params['driverOptions'] ?? []; $connectionParams = $this->chooseConnectionConfiguration($connectionName, $params); - $user = isset($connectionParams['user']) ? $connectionParams['user'] : null; - $password = isset($connectionParams['password']) ? $connectionParams['password'] : null; + $user = $connectionParams['user'] ?? null; + $password = $connectionParams['password'] ?? null; return $this->_driver->connect($connectionParams, $user, $password, $driverOptions); } @@ -224,7 +227,13 @@ protected function chooseConnectionConfiguration($connectionName, $params) return $params['master']; } - return $params['slaves'][array_rand($params['slaves'])]; + $config = $params['slaves'][array_rand($params['slaves'])]; + + if ( ! isset($config['charset']) && isset($params['master']['charset'])) { + $config['charset'] = $params['master']['charset']; + } + + return $config; } /** @@ -282,13 +291,12 @@ public function delete($tableName, array $identifier, array $types = []) */ public function close() { - unset($this->connections['master']); - unset($this->connections['slave']); + unset($this->connections['master'], $this->connections['slave']); parent::close(); $this->_conn = null; - $this->connections = array('master' => null, 'slave' => null); + $this->connections = ['master' => null, 'slave' => null]; } /** @@ -364,7 +372,7 @@ public function query() if ($logger) { $logger->startQuery($args[0]); } - + $statement = $this->_conn->query(...$args); if ($logger) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php b/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php index a3643677f..67265d954 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php @@ -23,6 +23,14 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\ExceptionConverterDriver; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function array_map; +use function bin2hex; +use function implode; +use function is_resource; +use function is_string; +use function json_encode; +use function sprintf; +use function str_split; class DBALException extends \Exception { @@ -132,14 +140,14 @@ public static function unknownDriver($unknownDriverName, array $knownDrivers) } /** - * @param \Doctrine\DBAL\Driver $driver - * @param \Exception $driverEx - * @param string $sql - * @param array $params + * @param \Doctrine\DBAL\Driver $driver + * @param \Exception $driverEx + * @param string $sql + * @param array $params * * @return \Doctrine\DBAL\DBALException */ - public static function driverExceptionDuringQuery(Driver $driver, \Exception $driverEx, $sql, array $params = array()) + public static function driverExceptionDuringQuery(Driver $driver, \Exception $driverEx, $sql, array $params = []) { $msg = "An exception occurred while executing '".$sql."'"; if ($params) { @@ -151,8 +159,8 @@ public static function driverExceptionDuringQuery(Driver $driver, \Exception $dr } /** - * @param \Doctrine\DBAL\Driver $driver - * @param \Exception $driverEx + * @param \Doctrine\DBAL\Driver $driver + * @param \Exception $driverEx * * @return \Doctrine\DBAL\DBALException */ @@ -162,8 +170,8 @@ public static function driverException(Driver $driver, \Exception $driverEx) } /** - * @param \Doctrine\DBAL\Driver $driver - * @param \Exception $driverEx + * @param \Doctrine\DBAL\Driver $driver + * @param \Exception $driverEx * * @return \Doctrine\DBAL\DBALException */ @@ -190,6 +198,10 @@ private static function wrapException(Driver $driver, \Exception $driverEx, $msg private static function formatParameters(array $params) { return '[' . implode(', ', array_map(function ($param) { + if (is_resource($param)) { + return (string) $param; + } + $json = @json_encode($param); if (! is_string($json) || $json == 'null' && is_string($param)) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver.php index 21d606466..300a27dec 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver.php @@ -37,7 +37,7 @@ interface Driver * * @return \Doctrine\DBAL\Driver\Connection The database connection. */ - public function connect(array $params, $username = null, $password = null, array $driverOptions = array()); + public function connect(array $params, $username = null, $password = null, array $driverOptions = []); /** * Gets the DatabasePlatform instance that provides all the metadata about diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractDriverException.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractDriverException.php index 84b95db10..83c38d71d 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractDriverException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractDriverException.php @@ -31,7 +31,7 @@ abstract class AbstractDriverException extends \Exception implements DriverExcep /** * The driver specific error code. * - * @var integer|string|null + * @var int|string|null */ private $errorCode; @@ -45,9 +45,9 @@ abstract class AbstractDriverException extends \Exception implements DriverExcep /** * Constructor. * - * @param string $message The driver error message. - * @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any. - * @param integer|string|null $errorCode The driver specific error code if any. + * @param string $message The driver error message. + * @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any. + * @param int|string|null $errorCode The driver specific error code if any. */ public function __construct($message, $sqlState = null, $errorCode = null) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index a06d2c0ab..ed881052c 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -22,10 +22,14 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MySQL57Platform; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; +use function preg_match; +use function stripos; +use function version_compare; /** * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for MySQL based drivers. @@ -123,35 +127,74 @@ public function convertException($message, DriverException $exception) /** * {@inheritdoc} + * + * @throws DBALException */ public function createDatabasePlatformForVersion($version) { - if ( ! preg_match('/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?/', $version, $versionParts)) { - throw DBALException::invalidPlatformVersionSpecified( - $version, - '..' - ); + $mariadb = false !== stripos($version, 'mariadb'); + if ($mariadb && version_compare($this->getMariaDbMysqlVersionNumber($version), '10.2.7', '>=')) { + return new MariaDb1027Platform(); } - if (false !== stripos($version, 'mariadb')) { - return $this->getDatabasePlatform(); + if ( ! $mariadb && version_compare($this->getOracleMysqlVersionNumber($version), '5.7.9', '>=')) { + return new MySQL57Platform(); } + return $this->getDatabasePlatform(); + } + + /** + * Get a normalized 'version number' from the server string + * returned by Oracle MySQL servers. + * + * @param string $versionString Version string returned by the driver, i.e. '5.7.10' + * @throws DBALException + */ + private function getOracleMysqlVersionNumber(string $versionString) : string + { + if ( ! preg_match( + '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?/', + $versionString, + $versionParts + )) { + throw DBALException::invalidPlatformVersionSpecified( + $versionString, + '..' + ); + } $majorVersion = $versionParts['major']; - $minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0; - $patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : null; + $minorVersion = $versionParts['minor'] ?? 0; + $patchVersion = $versionParts['patch'] ?? null; if ('5' === $majorVersion && '7' === $minorVersion && null === $patchVersion) { $patchVersion = '9'; } - $version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion; + return $majorVersion . '.' . $minorVersion . '.' . $patchVersion; + } - if (version_compare($version, '5.7.9', '>=')) { - return new MySQL57Platform(); + /** + * Detect MariaDB server version, including hack for some mariadb distributions + * that starts with the prefix '5.5.5-' + * + * @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial' + * @throws DBALException + */ + private function getMariaDbMysqlVersionNumber(string $versionString) : string + { + if ( ! preg_match( + '/^(?:5\.5\.5-)?(mariadb-)?(?P\d+)\.(?P\d+)\.(?P\d+)/i', + $versionString, + $versionParts + )) { + throw DBALException::invalidPlatformVersionSpecified( + $versionString, + '^(?:5\.5\.5-)?(mariadb-)?..' + ); } - return $this->getDatabasePlatform(); + return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch']; } /** @@ -161,15 +204,12 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); - if (isset($params['dbname'])) { - return $params['dbname']; - } - - return $conn->query('SELECT DATABASE()')->fetchColumn(); + return $params['dbname'] ?? $conn->query('SELECT DATABASE()')->fetchColumn(); } /** * {@inheritdoc} + * @return MySqlPlatform */ public function getDatabasePlatform() { @@ -178,6 +218,7 @@ public function getDatabasePlatform() /** * {@inheritdoc} + * @return MySqlSchemaManager */ public function getSchemaManager(\Doctrine\DBAL\Connection $conn) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php index bffcc4a15..26cfcd150 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php @@ -150,6 +150,6 @@ protected function getEasyConnectString(array $params) } - return isset($params['dbname']) ? $params['dbname'] : ''; + return $params['dbname'] ?? ''; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index 31f48ee77..ea7aa7167 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -22,12 +22,16 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\PostgreSQL100Platform; use Doctrine\DBAL\Platforms\PostgreSQL91Platform; use Doctrine\DBAL\Platforms\PostgreSQL92Platform; use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; +use function preg_match; +use function strpos; +use function version_compare; /** * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for PostgreSQL based drivers. @@ -108,11 +112,13 @@ public function createDatabasePlatformForVersion($version) } $majorVersion = $versionParts['major']; - $minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0; - $patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : 0; + $minorVersion = $versionParts['minor'] ?? 0; + $patchVersion = $versionParts['patch'] ?? 0; $version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion; switch(true) { + case version_compare($version, '10.0', '>='): + return new PostgreSQL100Platform(); case version_compare($version, '9.4', '>='): return new PostgreSQL94Platform(); case version_compare($version, '9.2', '>='): @@ -131,9 +137,7 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); - return (isset($params['dbname'])) - ? $params['dbname'] - : $conn->query('SELECT CURRENT_DATABASE()')->fetchColumn(); + return $params['dbname'] ?? $conn->query('SELECT CURRENT_DATABASE()')->fetchColumn(); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index d6c5944be..ca966511d 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -28,6 +28,8 @@ use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; +use function preg_match; +use function version_compare; /** * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SAP Sybase SQL Anywhere based drivers. @@ -100,9 +102,9 @@ public function createDatabasePlatformForVersion($version) } $majorVersion = $versionParts['major']; - $minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0; - $patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : 0; - $buildVersion = isset($versionParts['build']) ? $versionParts['build'] : 0; + $minorVersion = $versionParts['minor'] ?? 0; + $patchVersion = $versionParts['patch'] ?? 0; + $buildVersion = $versionParts['build'] ?? 0; $version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion; switch(true) { @@ -124,11 +126,7 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); - if (isset($params['dbname'])) { - return $params['dbname']; - } - - return $conn->query('SELECT DB_NAME()')->fetchColumn(); + return $params['dbname'] ?? $conn->query('SELECT DB_NAME()')->fetchColumn(); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index 53a4dd526..fb9c989bd 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -27,6 +27,8 @@ use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Schema\SQLServerSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; +use function preg_match; +use function version_compare; /** * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Microsoft SQL Server based drivers. @@ -54,9 +56,9 @@ public function createDatabasePlatformForVersion($version) } $majorVersion = $versionParts['major']; - $minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0; - $patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : 0; - $buildVersion = isset($versionParts['build']) ? $versionParts['build'] : 0; + $minorVersion = $versionParts['minor'] ?? 0; + $patchVersion = $versionParts['patch'] ?? 0; + $buildVersion = $versionParts['build'] ?? 0; $version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion; switch(true) { @@ -78,11 +80,7 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); - if (isset($params['dbname'])) { - return $params['dbname']; - } - - return $conn->query('SELECT DB_NAME()')->fetchColumn(); + return $params['dbname'] ?? $conn->query('SELECT DB_NAME()')->fetchColumn(); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index 92368ed6e..406cb92ef 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -23,6 +23,7 @@ use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\SqliteSchemaManager; +use function strpos; /** * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SQLite based drivers. @@ -96,7 +97,7 @@ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); - return isset($params['path']) ? $params['path'] : null; + return $params['path'] ?? null; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Connection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Connection.php index 24cd5485a..773407510 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Connection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Connection.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\ParameterType; + /** * Connection interface. * Driver connections must implement this interface. @@ -36,33 +38,33 @@ interface Connection * * @return \Doctrine\DBAL\Driver\Statement */ - function prepare($prepareString); + public function prepare($prepareString); /** * Executes an SQL statement, returning a result set as a Statement object. * * @return \Doctrine\DBAL\Driver\Statement */ - function query(); + public function query(); /** * Quotes a string for use in a query. * - * @param mixed $input - * @param integer $type + * @param mixed $input + * @param int $type * * @return mixed */ - function quote($input, $type=\PDO::PARAM_STR); + public function quote($input, $type = ParameterType::STRING); /** * Executes an SQL statement and return the number of affected rows. * * @param string $statement * - * @return integer + * @return int */ - function exec($statement); + public function exec($statement); /** * Returns the ID of the last inserted row or sequence value. @@ -71,40 +73,40 @@ function exec($statement); * * @return string */ - function lastInsertId($name = null); + public function lastInsertId($name = null); /** * Initiates a transaction. * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ - function beginTransaction(); + public function beginTransaction(); /** * Commits a transaction. * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ - function commit(); + public function commit(); /** * Rolls back the current transaction, as initiated by beginTransaction(). * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ - function rollBack(); + public function rollBack(); /** * Returns the error code associated with the last operation on the database handle. * * @return string|null The error code, or null if no operation has been run on the database handle. */ - function errorCode(); + public function errorCode(); /** * Returns extended error information associated with the last operation on the database handle. * * @return array */ - function errorInfo(); + public function errorInfo(); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/DriverException.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/DriverException.php index a96ccdce9..ce1d1e381 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/DriverException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/DriverException.php @@ -37,7 +37,7 @@ interface DriverException extends \Throwable * Returns null if no driver specific error code is available * for the error raised by the driver. * - * @return integer|string|null + * @return int|string|null */ public function getErrorCode(); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php index 92ca6601f..bfc61acf9 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Driver\DrizzlePDOMySql; +use Doctrine\DBAL\ParameterType; + /** * @author Kim Hemsø Rasmussen */ @@ -27,14 +29,10 @@ class Connection extends \Doctrine\DBAL\Driver\PDOConnection /** * {@inheritdoc} */ - public function quote($value, $type = \PDO::PARAM_STR) + public function quote($value, $type = ParameterType::STRING) { - if (\PDO::PARAM_BOOL === $type) { - if ($value) { - return 'true'; - } else { - return 'false'; - } + if ($type === ParameterType::BOOLEAN) { + return $value ? 'true' : 'false'; } return parent::quote($value, $type); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 263c6d446..72ef79686 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -21,6 +21,24 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; +use Doctrine\DBAL\ParameterType; +use const DB2_AUTOCOMMIT_OFF; +use const DB2_AUTOCOMMIT_ON; +use function db2_autocommit; +use function db2_commit; +use function db2_conn_error; +use function db2_conn_errormsg; +use function db2_connect; +use function db2_escape_string; +use function db2_exec; +use function db2_last_insert_id; +use function db2_num_rows; +use function db2_pconnect; +use function db2_prepare; +use function db2_rollback; +use function db2_server_info; +use function db2_stmt_errormsg; +use function func_get_args; class DB2Connection implements Connection, ServerInfoAwareConnection { @@ -98,14 +116,15 @@ public function query() /** * {@inheritdoc} */ - public function quote($input, $type=\PDO::PARAM_STR) + public function quote($input, $type = ParameterType::STRING) { $input = db2_escape_string($input); - if ($type == \PDO::PARAM_INT) { + + if ($type === ParameterType::INTEGER) { return $input; - } else { - return "'".$input."'"; } + + return "'".$input."'"; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index c2355cbc6..4aaa054ab 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -20,6 +20,33 @@ namespace Doctrine\DBAL\Driver\IBMDB2; use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Driver\StatementIterator; +use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ParameterType; +use const DB2_CHAR; +use const DB2_LONG; +use const DB2_PARAM_IN; +use function array_change_key_case; +use function call_user_func_array; +use function db2_bind_param; +use function db2_execute; +use function db2_fetch_array; +use function db2_fetch_assoc; +use function db2_fetch_both; +use function db2_fetch_object; +use function db2_free_result; +use function db2_num_fields; +use function db2_num_rows; +use function db2_stmt_error; +use function db2_stmt_errormsg; +use function func_get_args; +use function func_num_args; +use function gettype; +use function is_object; +use function is_string; +use function ksort; +use function sprintf; +use function strtolower; class DB2Statement implements \IteratorAggregate, Statement { @@ -34,19 +61,19 @@ class DB2Statement implements \IteratorAggregate, Statement private $_bindParam = []; /** - * @var string Name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS. + * @var string Name of the default class to instantiate when fetching class instances. */ private $defaultFetchClass = '\stdClass'; /** - * @var string Constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS. + * @var string Constructor arguments for the default class to instantiate when fetching class instances. */ private $defaultFetchClassCtorArgs = []; /** - * @var integer + * @var int */ - private $_defaultFetchMode = \PDO::FETCH_BOTH; + private $_defaultFetchMode = FetchMode::MIXED; /** * Indicates whether the statement is in the state when fetching results is possible @@ -61,8 +88,8 @@ class DB2Statement implements \IteratorAggregate, Statement * @var array */ static private $_typeMap = [ - \PDO::PARAM_INT => DB2_LONG, - \PDO::PARAM_STR => DB2_CHAR, + ParameterType::INTEGER => DB2_LONG, + ParameterType::STRING => DB2_CHAR, ]; /** @@ -76,7 +103,7 @@ public function __construct($stmt) /** * {@inheritdoc} */ - public function bindValue($param, $value, $type = null) + public function bindValue($param, $value, $type = ParameterType::STRING) { return $this->bindParam($param, $value, $type); } @@ -84,7 +111,7 @@ public function bindValue($param, $value, $type = null) /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = null, $length = null) + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null) { $this->_bindParam[$column] =& $variable; @@ -171,7 +198,7 @@ public function execute($params = null) } } - $retval = @db2_execute($this->_stmt, $params); + $retval = db2_execute($this->_stmt, $params); if ($retval === false) { throw new DB2Exception(db2_stmt_errormsg()); @@ -199,9 +226,7 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) */ public function getIterator() { - $data = $this->fetchAll(); - - return new \ArrayIterator($data); + return new StatementIterator($this); } /** @@ -217,18 +242,23 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE $fetchMode = $fetchMode ?: $this->_defaultFetchMode; switch ($fetchMode) { - case \PDO::FETCH_BOTH: + case FetchMode::COLUMN: + return $this->fetchColumn(); + + case FetchMode::MIXED: return db2_fetch_both($this->_stmt); - case \PDO::FETCH_ASSOC: + + case FetchMode::ASSOCIATIVE: return db2_fetch_assoc($this->_stmt); - case \PDO::FETCH_CLASS: + + case FetchMode::CUSTOM_OBJECT: $className = $this->defaultFetchClass; $ctorArgs = $this->defaultFetchClassCtorArgs; if (func_num_args() >= 2) { $args = func_get_args(); $className = $args[1]; - $ctorArgs = isset($args[2]) ? $args[2] : []; + $ctorArgs = $args[2] ?? []; } $result = db2_fetch_object($this->_stmt); @@ -238,10 +268,13 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE } return $result; - case \PDO::FETCH_NUM: + + case FetchMode::NUMERIC: return db2_fetch_array($this->_stmt); - case \PDO::FETCH_OBJ: + + case FetchMode::STANDARD_OBJECT: return db2_fetch_object($this->_stmt); + default: throw new DB2Exception('Given Fetch-Style ' . $fetchMode . ' is not supported.'); } @@ -255,12 +288,12 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n $rows = []; switch ($fetchMode) { - case \PDO::FETCH_CLASS: + case FetchMode::CUSTOM_OBJECT: while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) { $rows[] = $row; } break; - case \PDO::FETCH_COLUMN: + case FetchMode::COLUMN: while ($row = $this->fetchColumn()) { $rows[] = $row; } @@ -279,13 +312,13 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n */ public function fetchColumn($columnIndex = 0) { - $row = $this->fetch(\PDO::FETCH_NUM); + $row = $this->fetch(FetchMode::NUMERIC); if (false === $row) { return false; } - return isset($row[$columnIndex]) ? $row[$columnIndex] : null; + return $row[$columnIndex] ?? null; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 9d30b9686..98a5b2361 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -22,6 +22,20 @@ use Doctrine\DBAL\Driver\Connection as Connection; use Doctrine\DBAL\Driver\PingableConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; +use Doctrine\DBAL\ParameterType; +use function defined; +use function floor; +use function func_get_args; +use function in_array; +use function ini_get; +use function mysqli_errno; +use function mysqli_error; +use function mysqli_init; +use function mysqli_options; +use function restore_error_handler; +use function set_error_handler; +use function sprintf; +use function stripos; /** * @author Kim Hemsø Rasmussen @@ -49,17 +63,17 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar */ public function __construct(array $params, $username, $password, array $driverOptions = []) { - $port = isset($params['port']) ? $params['port'] : ini_get('mysqli.default_port'); + $port = $params['port'] ?? ini_get('mysqli.default_port'); // Fallback to default MySQL port if not given. if ( ! $port) { $port = 3306; } - $socket = isset($params['unix_socket']) ? $params['unix_socket'] : ini_get('mysqli.default_socket'); - $dbname = isset($params['dbname']) ? $params['dbname'] : null; + $socket = $params['unix_socket'] ?? ini_get('mysqli.default_socket'); + $dbname = $params['dbname'] ?? null; - $flags = isset($driverOptions[static::OPTION_FLAGS]) ? $driverOptions[static::OPTION_FLAGS] : null; + $flags = $driverOptions[static::OPTION_FLAGS] ?? null; $this->_conn = mysqli_init(); @@ -94,9 +108,18 @@ public function getWrappedResourceHandle() /** * {@inheritdoc} + * + * The server version detection includes a special case for MariaDB + * to support '5.5.5-' prefixed versions introduced in Maria 10+ + * @link https://jira.mariadb.org/browse/MDEV-4088 */ public function getServerVersion() { + $serverInfos = $this->_conn->get_server_info(); + if (false !== stripos($serverInfos, 'mariadb')) { + return $serverInfos; + } + $majorVersion = floor($this->_conn->server_version / 10000); $minorVersion = floor(($this->_conn->server_version - $majorVersion * 10000) / 100); $patchVersion = floor($this->_conn->server_version - $majorVersion * 10000 - $minorVersion * 100); @@ -136,7 +159,7 @@ public function query() /** * {@inheritdoc} */ - public function quote($input, $type=\PDO::PARAM_STR) + public function quote($input, $type = ParameterType::STRING) { return "'". $this->_conn->escape_string($input) ."'"; } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 57d7e3ee7..db78c7178 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -20,7 +20,14 @@ namespace Doctrine\DBAL\Driver\Mysqli; use Doctrine\DBAL\Driver\Statement; -use PDO; +use Doctrine\DBAL\Driver\StatementIterator; +use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ParameterType; +use function array_combine; +use function array_fill; +use function call_user_func_array; +use function count; +use function str_repeat; /** * @author Kim Hemsø Rasmussen @@ -31,11 +38,13 @@ class MysqliStatement implements \IteratorAggregate, Statement * @var array */ protected static $_paramTypeMap = [ - PDO::PARAM_STR => 's', - PDO::PARAM_BOOL => 'i', - PDO::PARAM_NULL => 's', - PDO::PARAM_INT => 'i', - PDO::PARAM_LOB => 's' // TODO Support LOB bigger then max package size. + ParameterType::STRING => 's', + ParameterType::BOOLEAN => 'i', + ParameterType::NULL => 's', + ParameterType::INTEGER => 'i', + + // TODO Support LOB bigger then max package size + ParameterType::LARGE_OBJECT => 's', ]; /** @@ -76,9 +85,9 @@ class MysqliStatement implements \IteratorAggregate, Statement protected $_values = []; /** - * @var integer + * @var int */ - protected $_defaultFetchMode = PDO::FETCH_BOTH; + protected $_defaultFetchMode = FetchMode::MIXED; /** * Indicates whether the statement is in the state when fetching results is possible @@ -111,7 +120,7 @@ public function __construct(\mysqli $conn, $prepareString) /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = null, $length = null) + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null) { if (null === $type) { $type = 's'; @@ -132,7 +141,7 @@ public function bindParam($column, &$variable, $type = null, $length = null) /** * {@inheritdoc} */ - public function bindValue($param, $value, $type = null) + public function bindValue($param, $value, $type = ParameterType::STRING) { if (null === $type) { $type = 's'; @@ -226,7 +235,7 @@ public function execute($params = null) * * @param array $values * - * @return boolean + * @return bool */ private function _bindValues($values) { @@ -242,7 +251,7 @@ private function _bindValues($values) } /** - * @return boolean|array + * @return bool|array */ private function _fetch() { @@ -271,6 +280,12 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE return false; } + $fetchMode = $fetchMode ?: $this->_defaultFetchMode; + + if ($fetchMode === FetchMode::COLUMN) { + return $this->fetchColumn(); + } + $values = $this->_fetch(); if (null === $values) { return false; @@ -280,22 +295,20 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); } - $fetchMode = $fetchMode ?: $this->_defaultFetchMode; - switch ($fetchMode) { - case PDO::FETCH_NUM: + case FetchMode::NUMERIC: return $values; - case PDO::FETCH_ASSOC: + case FetchMode::ASSOCIATIVE: return array_combine($this->_columnNames, $values); - case PDO::FETCH_BOTH: + case FetchMode::MIXED: $ret = array_combine($this->_columnNames, $values); $ret += $values; return $ret; - case PDO::FETCH_OBJ: + case FetchMode::STANDARD_OBJECT: $assoc = array_combine($this->_columnNames, $values); $ret = new \stdClass(); @@ -318,7 +331,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n $fetchMode = $fetchMode ?: $this->_defaultFetchMode; $rows = []; - if (PDO::FETCH_COLUMN == $fetchMode) { + + if ($fetchMode === FetchMode::COLUMN) { while (($row = $this->fetchColumn()) !== false) { $rows[] = $row; } @@ -336,12 +350,13 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n */ public function fetchColumn($columnIndex = 0) { - $row = $this->fetch(PDO::FETCH_NUM); + $row = $this->fetch(FetchMode::NUMERIC); + if (false === $row) { return false; } - return isset($row[$columnIndex]) ? $row[$columnIndex] : null; + return $row[$columnIndex] ?? null; } /** @@ -406,8 +421,6 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) */ public function getIterator() { - $data = $this->fetchAll(); - - return new \ArrayIterator($data); + return new StatementIterator($this); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php index c4552bb18..925e9b70f 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php @@ -21,6 +21,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; +use const OCI_DEFAULT; /** * A Doctrine DBAL driver for the Oracle OCI8 PHP extensions. @@ -40,9 +41,9 @@ public function connect(array $params, $username = null, $password = null, array $username, $password, $this->_constructDsn($params), - isset($params['charset']) ? $params['charset'] : null, - isset($params['sessionMode']) ? $params['sessionMode'] : OCI_DEFAULT, - isset($params['persistent']) ? $params['persistent'] : false + $params['charset'] ?? null, + $params['sessionMode'] ?? OCI_DEFAULT, + $params['persistent'] ?? false ); } catch (OCI8Exception $e) { throw DBALException::driverException($this, $e); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index ecf389911..e2111d474 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -21,7 +21,25 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; -use Doctrine\DBAL\Platforms\OraclePlatform; +use Doctrine\DBAL\ParameterType; +use const OCI_COMMIT_ON_SUCCESS; +use const OCI_DEFAULT; +use const OCI_NO_AUTO_COMMIT; +use function addcslashes; +use function define; +use function defined; +use function func_get_args; +use function is_float; +use function is_int; +use function oci_commit; +use function oci_connect; +use function oci_error; +use function oci_pconnect; +use function oci_rollback; +use function oci_server_version; +use function preg_match; +use function sprintf; +use function str_replace; /** * OCI8 implementation of the Connection interface. @@ -36,7 +54,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection protected $dbh; /** - * @var integer + * @var int */ protected $executeMode = OCI_COMMIT_ON_SUCCESS; @@ -47,8 +65,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection * @param string $password * @param string $db * @param string|null $charset - * @param integer $sessionMode - * @param boolean $persistent + * @param int $sessionMode + * @param bool $persistent * * @throws OCI8Exception */ @@ -121,7 +139,7 @@ public function query() /** * {@inheritdoc} */ - public function quote($value, $type=\PDO::PARAM_STR) + public function quote($value, $type = ParameterType::STRING) { if (is_int($value) || is_float($value)) { return $value; @@ -153,19 +171,19 @@ public function lastInsertId($name = null) $sql = 'SELECT ' . $name . '.CURRVAL FROM DUAL'; $stmt = $this->query($sql); - $result = $stmt->fetch(\PDO::FETCH_ASSOC); + $result = $stmt->fetchColumn(); - if ($result === false || !isset($result['CURRVAL'])) { + if ($result === false) { throw new OCI8Exception("lastInsertId failed: Query was executed but no result was returned."); } - return (int) $result['CURRVAL']; + return (int) $result; } /** * Returns the current execution mode. * - * @return integer + * @return int */ public function getExecuteMode() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 8831a2258..1d771007f 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -19,9 +19,41 @@ namespace Doctrine\DBAL\Driver\OCI8; -use PDO; -use IteratorAggregate; use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Driver\StatementIterator; +use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ParameterType; +use IteratorAggregate; +use const OCI_ASSOC; +use const OCI_B_BLOB; +use const OCI_BOTH; +use const OCI_D_LOB; +use const OCI_FETCHSTATEMENT_BY_COLUMN; +use const OCI_FETCHSTATEMENT_BY_ROW; +use const OCI_NUM; +use const OCI_RETURN_LOBS; +use const OCI_RETURN_NULLS; +use const OCI_TEMP_BLOB; +use const PREG_OFFSET_CAPTURE; +use function array_key_exists; +use function count; +use function implode; +use function is_numeric; +use function oci_bind_by_name; +use function oci_cancel; +use function oci_error; +use function oci_execute; +use function oci_fetch_all; +use function oci_fetch_array; +use function oci_fetch_object; +use function oci_new_descriptor; +use function oci_num_fields; +use function oci_num_rows; +use function oci_parse; +use function preg_match; +use function preg_quote; +use function sprintf; +use function substr; /** * The OCI8 implementation of the Statement interface. @@ -29,7 +61,7 @@ * @since 2.0 * @author Roman Borschel */ -class OCI8Statement implements \IteratorAggregate, Statement +class OCI8Statement implements IteratorAggregate, Statement { /** * @var resource @@ -55,16 +87,16 @@ class OCI8Statement implements \IteratorAggregate, Statement * @var array */ protected static $fetchModeMap = [ - PDO::FETCH_BOTH => OCI_BOTH, - PDO::FETCH_ASSOC => OCI_ASSOC, - PDO::FETCH_NUM => OCI_NUM, - PDO::FETCH_COLUMN => OCI_NUM, + FetchMode::MIXED => OCI_BOTH, + FetchMode::ASSOCIATIVE => OCI_ASSOC, + FetchMode::NUMERIC => OCI_NUM, + FetchMode::COLUMN => OCI_NUM, ]; /** - * @var integer + * @var int */ - protected $_defaultFetchMode = PDO::FETCH_BOTH; + protected $_defaultFetchMode = FetchMode::MIXED; /** * @var array @@ -120,10 +152,10 @@ public function __construct($dbh, $statement, OCI8Connection $conn) * * @param string $statement The SQL statement to convert. * - * @return string + * @return array [0] => the statement value (string), [1] => the paramMap value (array). * @throws \Doctrine\DBAL\Driver\OCI8\OCI8Exception */ - static public function convertPositionalToNamedPlaceholders($statement) + public static function convertPositionalToNamedPlaceholders($statement) { $fragmentOffset = $tokenOffset = 0; $fragments = $paramMap = []; @@ -160,13 +192,13 @@ static public function convertPositionalToNamedPlaceholders($statement) /** * Finds next placeholder or opening quote. * - * @param string $statement The SQL statement to parse - * @param string $tokenOffset The offset to start searching from - * @param int $fragmentOffset The offset to build the next fragment from - * @param string[] $fragments Fragments of the original statement not containing placeholders - * @param string|null $currentLiteralDelimiter The delimiter of the current string literal - * or NULL if not currently in a literal - * @param array $paramMap Mapping of the original parameter positions to their named replacements + * @param string $statement The SQL statement to parse + * @param string $tokenOffset The offset to start searching from + * @param int $fragmentOffset The offset to build the next fragment from + * @param string[] $fragments Fragments of the original statement not containing placeholders + * @param string|null $currentLiteralDelimiter The delimiter of the current string literal + * or NULL if not currently in a literal + * @param array $paramMap Mapping of the original parameter positions to their named replacements * @return bool Whether the token was found */ private static function findPlaceholderOrOpeningQuote( @@ -204,8 +236,8 @@ private static function findPlaceholderOrOpeningQuote( /** * Finds closing quote * - * @param string $statement The SQL statement to parse - * @param string $tokenOffset The offset to start searching from + * @param string $statement The SQL statement to parse + * @param string $tokenOffset The offset to start searching from * @param string|null $currentLiteralDelimiter The delimiter of the current string literal * or NULL if not currently in a literal * @return bool Whether the token was found @@ -236,8 +268,8 @@ private static function findClosingQuote( * where the token was found. * * @param string $statement The SQL statement to parse - * @param string $offset The offset to start searching from - * @param string $regex The regex containing token pattern + * @param string $offset The offset to start searching from + * @param string $regex The regex containing token pattern * @return string|null Token or NULL if not found */ private static function findToken($statement, &$offset, $regex) @@ -253,7 +285,7 @@ private static function findToken($statement, &$offset, $regex) /** * {@inheritdoc} */ - public function bindValue($param, $value, $type = null) + public function bindValue($param, $value, $type = ParameterType::STRING) { return $this->bindParam($param, $value, $type, null); } @@ -261,11 +293,11 @@ public function bindValue($param, $value, $type = null) /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = null, $length = null) + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null) { - $column = isset($this->_paramMap[$column]) ? $this->_paramMap[$column] : $column; + $column = $this->_paramMap[$column] ?? $column; - if ($type == \PDO::PARAM_LOB) { + if ($type === ParameterType::LARGE_OBJECT) { $lob = oci_new_descriptor($this->_dbh, OCI_D_LOB); $lob->writeTemporary($variable, OCI_TEMP_BLOB); @@ -370,9 +402,7 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) */ public function getIterator() { - $data = $this->fetchAll(); - - return new \ArrayIterator($data); + return new StatementIterator($this); } /** @@ -388,7 +418,11 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE $fetchMode = $fetchMode ?: $this->_defaultFetchMode; - if (PDO::FETCH_OBJ == $fetchMode) { + if ($fetchMode === FetchMode::COLUMN) { + return $this->fetchColumn(); + } + + if ($fetchMode === FetchMode::STANDARD_OBJECT) { return oci_fetch_object($this->_sth); } @@ -411,7 +445,7 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n $result = []; - if (PDO::FETCH_OBJ == $fetchMode) { + if ($fetchMode === FetchMode::STANDARD_OBJECT) { while ($row = $this->fetch($fetchMode)) { $result[] = $row; } @@ -429,7 +463,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n } } else { $fetchStructure = OCI_FETCHSTATEMENT_BY_ROW; - if ($fetchMode == PDO::FETCH_COLUMN) { + + if ($fetchMode === FetchMode::COLUMN) { $fetchStructure = OCI_FETCHSTATEMENT_BY_COLUMN; } @@ -442,7 +477,7 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n oci_fetch_all($this->_sth, $result, 0, -1, self::$fetchModeMap[$fetchMode] | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS); - if ($fetchMode == PDO::FETCH_COLUMN) { + if ($fetchMode === FetchMode::COLUMN) { $result = $result[0]; } } @@ -467,7 +502,7 @@ public function fetchColumn($columnIndex = 0) return false; } - return isset($row[$columnIndex]) ? $row[$columnIndex] : null; + return $row[$columnIndex] ?? null; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php index cb47c3e9a..62a214a53 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -19,7 +19,10 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\ParameterType; use PDO; +use function count; +use function func_get_args; /** * PDO implementation of the Connection interface. @@ -110,7 +113,7 @@ public function query() /** * {@inheritdoc} */ - public function quote($input, $type = \PDO::PARAM_STR) + public function quote($input, $type = ParameterType::STRING) { return parent::quote($input, $type); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOException.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOException.php index 7a1a02a43..25689b66e 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOException.php @@ -31,7 +31,7 @@ class PDOException extends \PDOException implements DriverException /** * The driver specific error code. * - * @var integer|string|null + * @var int|string|null */ private $errorCode; @@ -53,8 +53,8 @@ public function __construct(\PDOException $exception) $this->code = $exception->getCode(); $this->errorInfo = $exception->errorInfo; - $this->errorCode = isset($exception->errorInfo[1]) ? $exception->errorInfo[1] : $exception->getCode(); - $this->sqlState = isset($exception->errorInfo[0]) ? $exception->errorInfo[0] : $exception->getCode(); + $this->errorCode = $exception->errorInfo[1] ?? $exception->getCode(); + $this->sqlState = $exception->errorInfo[0] ?? $exception->getCode(); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index fa993e7a5..685e8d777 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -24,6 +24,7 @@ use Doctrine\DBAL\DBALException; use PDOException; use PDO; +use function defined; /** * Driver that connects through pdo_pgsql. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index 4fe4e7201..096f7a2b6 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -23,6 +23,7 @@ use Doctrine\DBAL\Driver\AbstractSQLiteDriver; use Doctrine\DBAL\Driver\PDOConnection; use PDOException; +use function array_merge; /** * The PDO Sqlite driver. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index 8c561555c..7ce7e8a76 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -20,6 +20,9 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\ParameterType; +use function strpos; +use function substr; /** * Sqlsrv Connection implementation. @@ -55,7 +58,7 @@ public function lastInsertId($name = null) /** * {@inheritDoc} */ - public function quote($value, $type=\PDO::PARAM_STR) + public function quote($value, $type = ParameterType::STRING) { $val = parent::quote($value, $type); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php index 3d1b22a65..82e2c3e35 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php @@ -20,6 +20,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver\PDOStatement; +use Doctrine\DBAL\ParameterType; use PDO; /** @@ -30,9 +31,9 @@ class Statement extends PDOStatement /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = PDO::PARAM_STR, $length = null, $driverOptions = null) + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null) { - if ($type === PDO::PARAM_LOB && $driverOptions === null) { + if ($type === ParameterType::LARGE_OBJECT && $driverOptions === null) { $driverOptions = PDO::SQLSRV_ENCODING_BINARY; } @@ -42,7 +43,7 @@ public function bindParam($column, &$variable, $type = PDO::PARAM_STR, $length = /** * {@inheritdoc} */ - public function bindValue($param, $value, $type = PDO::PARAM_STR) + public function bindValue($param, $value, $type = ParameterType::STRING) { return $this->bindParam($param, $value, $type); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php index deb35de01..ca07596b6 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -19,6 +19,13 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ParameterType; +use PDO; +use const E_USER_DEPRECATED; +use function sprintf; +use function trigger_error; + /** * The PDO implementation of the Statement interface. * Used by all PDO-based drivers. @@ -27,6 +34,29 @@ */ class PDOStatement extends \PDOStatement implements Statement { + /** + * @var int[] + */ + private const PARAM_TYPE_MAP = [ + ParameterType::NULL => PDO::PARAM_NULL, + ParameterType::INTEGER => PDO::PARAM_INT, + ParameterType::STRING => PDO::PARAM_STR, + ParameterType::LARGE_OBJECT => PDO::PARAM_LOB, + ParameterType::BOOLEAN => PDO::PARAM_BOOL, + ]; + + /** + * @var int[] + */ + private const FETCH_MODE_MAP = [ + FetchMode::ASSOCIATIVE => PDO::FETCH_ASSOC, + FetchMode::NUMERIC => PDO::FETCH_NUM, + FetchMode::MIXED => PDO::FETCH_BOTH, + FetchMode::STANDARD_OBJECT => PDO::FETCH_OBJ, + FetchMode::COLUMN => PDO::FETCH_COLUMN, + FetchMode::CUSTOM_OBJECT => PDO::FETCH_CLASS, + ]; + /** * Protected constructor. */ @@ -39,6 +69,8 @@ protected function __construct() */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { + $fetchMode = $this->convertFetchMode($fetchMode); + // This thin wrapper is necessary to shield against the weird signature // of PDOStatement::setFetchMode(): even if the second and third // parameters are optional, PHP will not let us remove it from this @@ -61,8 +93,10 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) /** * {@inheritdoc} */ - public function bindValue($param, $value, $type = \PDO::PARAM_STR) + public function bindValue($param, $value, $type = ParameterType::STRING) { + $type = $this->convertParamType($type); + try { return parent::bindValue($param, $value, $type); } catch (\PDOException $exception) { @@ -73,8 +107,10 @@ public function bindValue($param, $value, $type = \PDO::PARAM_STR) /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = \PDO::PARAM_STR, $length = null, $driverOptions = null) + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null) { + $type = $this->convertParamType($type); + try { return parent::bindParam($column, $variable, $type, $length, $driverOptions); } catch (\PDOException $exception) { @@ -113,6 +149,8 @@ public function execute($params = null) */ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { + $fetchMode = $this->convertFetchMode($fetchMode); + try { if ($fetchMode === null && \PDO::FETCH_ORI_NEXT === $cursorOrientation && 0 === $cursorOffset) { return parent::fetch(); @@ -137,6 +175,8 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { + $fetchMode = $this->convertFetchMode($fetchMode); + try { if ($fetchMode === null && null === $fetchArgument && null === $ctorArgs) { return parent::fetchAll(); @@ -167,4 +207,49 @@ public function fetchColumn($columnIndex = 0) throw new PDOException($exception); } } + + /** + * Converts DBAL parameter type to PDO parameter type + * + * @param int $type Parameter type + */ + private function convertParamType(int $type) : int + { + if (! isset(self::PARAM_TYPE_MAP[$type])) { + // TODO: next major: throw an exception + @trigger_error(sprintf( + 'Using a PDO parameter type (%d given) is deprecated and will cause an error in Doctrine 3.0', + $type + ), E_USER_DEPRECATED); + + return $type; + } + + return self::PARAM_TYPE_MAP[$type]; + } + + /** + * Converts DBAL fetch mode to PDO fetch mode + * + * @param int|null $fetchMode Fetch mode + */ + private function convertFetchMode(?int $fetchMode) : ?int + { + if ($fetchMode === null) { + return null; + } + + if (! isset(self::FETCH_MODE_MAP[$fetchMode])) { + // TODO: next major: throw an exception + @trigger_error(sprintf( + 'Using a PDO fetch mode or their combination (%d given)' . + ' is deprecated and will cause an error in Doctrine 3.0', + $fetchMode + ), E_USER_DEPRECATED); + + return $fetchMode; + } + + return self::FETCH_MODE_MAP[$fetchMode]; + } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/ResultStatement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/ResultStatement.php index b73c2cdae..b03862ff6 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/ResultStatement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/ResultStatement.php @@ -29,14 +29,14 @@ interface ResultStatement extends \Traversable /** * Closes the cursor, enabling the statement to be executed again. * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ public function closeCursor(); /** * Returns the number of columns in the result set * - * @return integer The number of columns in the result set represented + * @return int The number of columns in the result set represented * by the PDOStatement object. If there is no result set, * this method should return 0. */ @@ -45,73 +45,69 @@ public function columnCount(); /** * Sets the fetch mode to use while iterating this statement. * - * @param integer $fetchMode The fetch mode must be one of the PDO::FETCH_* constants. - * @param mixed $arg2 - * @param mixed $arg3 + * @param int $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants. + * @param mixed $arg2 + * @param mixed $arg3 * - * @return boolean - * - * @see PDO::FETCH_* constants. + * @return bool */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null); /** * Returns the next row of a result set. * - * @param int|null $fetchMode Controls how the next row will be returned to the caller. - * The value must be one of the \PDO::FETCH_* constants, - * defaulting to \PDO::FETCH_BOTH. - * @param int $cursorOrientation For a ResultStatement object representing a scrollable cursor, - * this value determines which row will be returned to the caller. - * This value must be one of the \PDO::FETCH_ORI_* constants, - * defaulting to \PDO::FETCH_ORI_NEXT. To request a scrollable - * cursor for your ResultStatement object, you must set the \PDO::ATTR_CURSOR - * attribute to \PDO::CURSOR_SCROLL when you prepare the SQL statement with - * \PDO::prepare(). - * @param int $cursorOffset For a ResultStatement object representing a scrollable cursor for which the - * cursorOrientation parameter is set to \PDO::FETCH_ORI_ABS, this value - * specifies the absolute number of the row in the result set that shall be - * fetched. - * For a ResultStatement object representing a scrollable cursor for which the - * cursorOrientation parameter is set to \PDO::FETCH_ORI_REL, this value - * specifies the row to fetch relative to the cursor position before - * ResultStatement::fetch() was called. + * @param int|null $fetchMode Controls how the next row will be returned to the caller. + * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, + * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}. + * @param int $cursorOrientation For a ResultStatement object representing a scrollable cursor, + * this value determines which row will be returned to the caller. + * This value must be one of the \PDO::FETCH_ORI_* constants, + * defaulting to \PDO::FETCH_ORI_NEXT. To request a scrollable + * cursor for your ResultStatement object, you must set the \PDO::ATTR_CURSOR + * attribute to \PDO::CURSOR_SCROLL when you prepare the SQL statement with + * \PDO::prepare(). + * @param int $cursorOffset For a ResultStatement object representing a scrollable cursor for which the + * cursorOrientation parameter is set to \PDO::FETCH_ORI_ABS, this value + * specifies the absolute number of the row in the result set that shall be + * fetched. + * For a ResultStatement object representing a scrollable cursor for which the + * cursorOrientation parameter is set to \PDO::FETCH_ORI_REL, this value + * specifies the row to fetch relative to the cursor position before + * ResultStatement::fetch() was called. * * @return mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is * returned on failure. - * - * @see PDO::FETCH_* constants. */ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0); /** * Returns an array containing all of the result set rows. * - * @param int|null $fetchMode Controls how the next row will be returned to the caller. - * The value must be one of the \PDO::FETCH_* constants, - * defaulting to \PDO::FETCH_BOTH. - * @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter: - * * \PDO::FETCH_COLUMN: Returns the indicated 0-indexed column. - * * \PDO::FETCH_CLASS: Returns instances of the specified class, mapping the columns of each - * row to named properties in the class. - * * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's - * columns as parameters in the call. - * @param array|null $ctorArgs Controls how the next row will be returned to the caller. - * The value must be one of the \PDO::FETCH_* constants, - * defaulting to \PDO::FETCH_BOTH. + * @param int|null $fetchMode Controls how the next row will be returned to the caller. + * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, + * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}. + * @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter: + * * {@link \Doctrine\DBAL\FetchMode::COLUMN}: + * Returns the indicated 0-indexed column. + * * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}: + * Returns instances of the specified class, mapping the columns of each row + * to named properties in the class. + * * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's + * columns as parameters in the call. + * @param array|null $ctorArgs Controls how the next row will be returned to the caller. + * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, + * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}. * * @return array - * - * @see \PDO::FETCH_* constants. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null); /** * Returns a single column from the next row of a result set or FALSE if there are no more rows. * - * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. - * If no value is supplied, PDOStatement->fetchColumn() - * fetches the first column. + * @param int $columnIndex 0-indexed number of the column you wish to retrieve from the row. + * If no value is supplied, PDOStatement->fetchColumn() + * fetches the first column. * * @return string|boolean A single column in the next row of a result set, or FALSE if there are no more rows. */ diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php index c0f6249d4..1ff0b04b1 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php @@ -21,6 +21,9 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver; +use function array_keys; +use function array_map; +use function implode; /** * A Doctrine DBAL driver for the SAP Sybase SQL Anywhere PHP extension. @@ -41,15 +44,15 @@ public function connect(array $params, $username = null, $password = null, array try { return new SQLAnywhereConnection( $this->buildDsn( - isset($params['host']) ? $params['host'] : null, - isset($params['port']) ? $params['port'] : null, - isset($params['server']) ? $params['server'] : null, - isset($params['dbname']) ? $params['dbname'] : null, + $params['host'] ?? null, + $params['port'] ?? null, + $params['server'] ?? null, + $params['dbname'] ?? null, $username, $password, $driverOptions ), - isset($params['persistent']) ? $params['persistent'] : false + $params['persistent'] ?? false ); } catch (SQLAnywhereException $e) { throw DBALException::driverException($this, $e); @@ -67,15 +70,15 @@ public function getName() /** * Build the connection string for given connection parameters and driver options. * - * @param string $host Host address to connect to. - * @param integer $port Port to use for the connection (default to SQL Anywhere standard port 2638). - * @param string $server Database server name on the host to connect to. - * SQL Anywhere allows multiple database server instances on the same host, - * therefore specifying the server instance name to use is mandatory. - * @param string $dbname Name of the database on the server instance to connect to. - * @param string $username User name to use for connection authentication. - * @param string $password Password to use for connection authentication. - * @param array $driverOptions Additional parameters to use for the connection. + * @param string $host Host address to connect to. + * @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638). + * @param string $server Database server name on the host to connect to. + * SQL Anywhere allows multiple database server instances on the same host, + * therefore specifying the server instance name to use is mandatory. + * @param string $dbname Name of the database on the server instance to connect to. + * @param string $username User name to use for connection authentication. + * @param string $password Password to use for connection authentication. + * @param array $driverOptions Additional parameters to use for the connection. * * @return string */ diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index b7777f66f..29542252c 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -21,6 +21,22 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; +use Doctrine\DBAL\ParameterType; +use function func_get_args; +use function is_float; +use function is_int; +use function is_resource; +use function sasql_affected_rows; +use function sasql_commit; +use function sasql_connect; +use function sasql_error; +use function sasql_errorcode; +use function sasql_escape_string; +use function sasql_insert_id; +use function sasql_pconnect; +use function sasql_real_query; +use function sasql_rollback; +use function sasql_set_option; /** * SAP Sybase SQL Anywhere implementation of the Connection interface. @@ -41,8 +57,8 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection * * Connects to database with given connection string. * - * @param string $dsn The connection string. - * @param boolean $persistent Whether or not to establish a persistent connection. + * @param string $dsn The connection string. + * @param bool $persistent Whether or not to establish a persistent connection. * * @throws SQLAnywhereException */ @@ -172,7 +188,7 @@ public function query() /** * {@inheritdoc} */ - public function quote($input, $type = \PDO::PARAM_STR) + public function quote($input, $type = ParameterType::STRING) { if (is_int($input) || is_float($input)) { return $input; @@ -210,7 +226,7 @@ public function rollBack() * * @throws SQLAnywhereException * - * @return boolean Whether or not ending transactional mode succeeded. + * @return bool Whether or not ending transactional mode succeeded. */ private function endTransaction() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php index 046938037..2a89206d7 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php @@ -20,6 +20,12 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; use Doctrine\DBAL\Driver\AbstractDriverException; +use function is_resource; +use function sasql_error; +use function sasql_errorcode; +use function sasql_sqlstate; +use function sasql_stmt_errno; +use function sasql_stmt_error; /** * SAP Sybase SQL Anywhere driver exception. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index aadf02eb7..5605e525f 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -19,9 +19,36 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; -use IteratorAggregate; -use PDO; use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Driver\StatementIterator; +use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ParameterType; +use IteratorAggregate; +use const SASQL_BOTH; +use function array_key_exists; +use function call_user_func_array; +use function func_get_args; +use function func_num_args; +use function gettype; +use function is_array; +use function is_numeric; +use function is_object; +use function is_resource; +use function is_string; +use function sasql_fetch_array; +use function sasql_fetch_assoc; +use function sasql_fetch_object; +use function sasql_fetch_row; +use function sasql_prepare; +use function sasql_stmt_affected_rows; +use function sasql_stmt_bind_param_ex; +use function sasql_stmt_errno; +use function sasql_stmt_error; +use function sasql_stmt_execute; +use function sasql_stmt_field_count; +use function sasql_stmt_reset; +use function sasql_stmt_result_metadata; +use function sprintf; /** * SAP SQL Anywhere implementation of the Statement interface. @@ -38,19 +65,19 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement private $conn; /** - * @var string Name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS. + * @var string Name of the default class to instantiate when fetching class instances. */ private $defaultFetchClass = '\stdClass'; /** - * @var string Constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS. + * @var string Constructor arguments for the default class to instantiate when fetching class instances. */ private $defaultFetchClassCtorArgs = []; /** * @var int Default fetch mode to use. */ - private $defaultFetchMode = PDO::FETCH_BOTH; + private $defaultFetchMode = FetchMode::MIXED; /** * @var resource The result set resource to fetch. @@ -91,20 +118,23 @@ public function __construct($conn, $sql) * * @throws SQLAnywhereException */ - public function bindParam($column, &$variable, $type = null, $length = null) + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null) { switch ($type) { - case PDO::PARAM_INT: - case PDO::PARAM_BOOL: + case ParameterType::INTEGER: + case ParameterType::BOOLEAN: $type = 'i'; break; - case PDO::PARAM_LOB: + + case ParameterType::LARGE_OBJECT: $type = 'b'; break; - case PDO::PARAM_NULL: - case PDO::PARAM_STR: + + case ParameterType::NULL: + case ParameterType::STRING: $type = 's'; break; + default: throw new SQLAnywhereException('Unknown type: ' . $type); } @@ -119,7 +149,7 @@ public function bindParam($column, &$variable, $type = null, $length = null) /** * {@inheritdoc} */ - public function bindValue($param, $value, $type = null) + public function bindValue($param, $value, $type = ParameterType::STRING) { return $this->bindParam($param, $value, $type); } @@ -202,18 +232,23 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE $fetchMode = $fetchMode ?: $this->defaultFetchMode; switch ($fetchMode) { - case PDO::FETCH_ASSOC: + case FetchMode::COLUMN: + return $this->fetchColumn(); + + case FetchMode::ASSOCIATIVE: return sasql_fetch_assoc($this->result); - case PDO::FETCH_BOTH: + + case FetchMode::MIXED: return sasql_fetch_array($this->result, SASQL_BOTH); - case PDO::FETCH_CLASS: + + case FetchMode::CUSTOM_OBJECT: $className = $this->defaultFetchClass; $ctorArgs = $this->defaultFetchClassCtorArgs; if (func_num_args() >= 2) { $args = func_get_args(); $className = $args[1]; - $ctorArgs = isset($args[2]) ? $args[2] : []; + $ctorArgs = $args[2] ?? []; } $result = sasql_fetch_object($this->result); @@ -223,10 +258,13 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE } return $result; - case PDO::FETCH_NUM: + + case FetchMode::NUMERIC: return sasql_fetch_row($this->result); - case PDO::FETCH_OBJ: + + case FetchMode::STANDARD_OBJECT: return sasql_fetch_object($this->result); + default: throw new SQLAnywhereException('Fetch mode is not supported: ' . $fetchMode); } @@ -240,16 +278,18 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n $rows = []; switch ($fetchMode) { - case PDO::FETCH_CLASS: + case FetchMode::CUSTOM_OBJECT: while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) { $rows[] = $row; } break; - case PDO::FETCH_COLUMN: + + case FetchMode::COLUMN: while ($row = $this->fetchColumn()) { $rows[] = $row; } break; + default: while ($row = $this->fetch($fetchMode)) { $rows[] = $row; @@ -264,13 +304,13 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n */ public function fetchColumn($columnIndex = 0) { - $row = $this->fetch(PDO::FETCH_NUM); + $row = $this->fetch(FetchMode::NUMERIC); if (false === $row) { return false; } - return isset($row[$columnIndex]) ? $row[$columnIndex] : null; + return $row[$columnIndex] ?? null; } /** @@ -278,7 +318,7 @@ public function fetchColumn($columnIndex = 0) */ public function getIterator() { - return new \ArrayIterator($this->fetchAll()); + return new StatementIterator($this); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php index 67c7bfa85..909f1e444 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php @@ -28,12 +28,12 @@ class LastInsertId { /** - * @var integer + * @var int */ private $id; /** - * @param integer $id + * @param int $id */ public function setId($id) { @@ -41,7 +41,7 @@ public function setId($id) } /** - * @return integer + * @return int */ public function getId() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 6de138a4a..6cdd4bca9 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -21,6 +21,22 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; +use Doctrine\DBAL\ParameterType; +use const SQLSRV_ERR_ERRORS; +use function func_get_args; +use function is_float; +use function is_int; +use function sprintf; +use function sqlsrv_begin_transaction; +use function sqlsrv_commit; +use function sqlsrv_configure; +use function sqlsrv_connect; +use function sqlsrv_errors; +use function sqlsrv_query; +use function sqlsrv_rollback; +use function sqlsrv_rows_affected; +use function sqlsrv_server_info; +use function str_replace; /** * SQL Server implementation for the Connection interface. @@ -102,7 +118,7 @@ public function query() * {@inheritDoc} * @license New BSD, code from Zend Framework */ - public function quote($value, $type=\PDO::PARAM_STR) + public function quote($value, $type = ParameterType::STRING) { if (is_int($value)) { return $value; @@ -135,11 +151,11 @@ public function lastInsertId($name = null) if ($name !== null) { $stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'); $stmt->execute([$name]); - - return $stmt->fetchColumn(); + } else { + $stmt = $this->query('SELECT @@IDENTITY'); } - return $this->lastInsertId->getId(); + return $stmt->fetchColumn(); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php index b2c463259..3223c1136 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php @@ -21,6 +21,9 @@ use Doctrine\DBAL\Driver\AbstractDriverException; +use const SQLSRV_ERR_ERRORS; +use function rtrim; +use function sqlsrv_errors; class SQLSrvException extends AbstractDriverException { @@ -29,7 +32,7 @@ class SQLSrvException extends AbstractDriverException * * @return \Doctrine\DBAL\Driver\SQLSrv\SQLSrvException */ - static public function fromSqlSrvErrors() + public static function fromSqlSrvErrors() { $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); $message = ""; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 412cbc707..f4d450177 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -19,9 +19,35 @@ namespace Doctrine\DBAL\Driver\SQLSrv; -use PDO; +use Doctrine\DBAL\Driver\StatementIterator; +use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ParameterType; use IteratorAggregate; use Doctrine\DBAL\Driver\Statement; +use const SQLSRV_ENC_BINARY; +use const SQLSRV_ERR_ERRORS; +use const SQLSRV_FETCH_ASSOC; +use const SQLSRV_FETCH_BOTH; +use const SQLSRV_FETCH_NUMERIC; +use const SQLSRV_PARAM_IN; +use function array_key_exists; +use function count; +use function func_get_args; +use function in_array; +use function is_numeric; +use function sqlsrv_errors; +use function sqlsrv_execute; +use function sqlsrv_fetch; +use function sqlsrv_fetch_array; +use function sqlsrv_fetch_object; +use function sqlsrv_get_field; +use function sqlsrv_next_result; +use function sqlsrv_num_fields; +use function SQLSRV_PHPTYPE_STREAM; +use function sqlsrv_prepare; +use function sqlsrv_rows_affected; +use function SQLSRV_SQLTYPE_VARBINARY; +use function stripos; /** * SQL Server Statement. @@ -72,20 +98,20 @@ class SQLSrvStatement implements IteratorAggregate, Statement * @var array */ private static $fetchMap = [ - PDO::FETCH_BOTH => SQLSRV_FETCH_BOTH, - PDO::FETCH_ASSOC => SQLSRV_FETCH_ASSOC, - PDO::FETCH_NUM => SQLSRV_FETCH_NUMERIC, + FetchMode::MIXED => SQLSRV_FETCH_BOTH, + FetchMode::ASSOCIATIVE => SQLSRV_FETCH_ASSOC, + FetchMode::NUMERIC => SQLSRV_FETCH_NUMERIC, ]; /** - * The name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS. + * The name of the default class to instantiate when fetching class instances. * * @var string */ private $defaultFetchClass = '\stdClass'; /** - * The constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS. + * The constructor arguments for the default class to instantiate when fetching class instances. * * @var string */ @@ -94,9 +120,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement /** * The fetch style. * - * @param integer + * @var int */ - private $defaultFetchMode = PDO::FETCH_BOTH; + private $defaultFetchMode = FetchMode::MIXED; /** * The last insert ID. @@ -138,7 +164,7 @@ public function __construct($conn, $sql, LastInsertId $lastInsertId = null) /** * {@inheritdoc} */ - public function bindValue($param, $value, $type = null) + public function bindValue($param, $value, $type = ParameterType::STRING) { if (!is_numeric($param)) { throw new SQLSrvException( @@ -153,7 +179,7 @@ public function bindValue($param, $value, $type = null) /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = null, $length = null) + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null) { if (!is_numeric($column)) { throw new SQLSrvException("sqlsrv does not support named parameters to queries, use question mark (?) placeholders instead."); @@ -257,7 +283,7 @@ private function prepare() $params = []; foreach ($this->variables as $column => &$variable) { - if (PDO::PARAM_LOB === $this->types[$column]) { + if ($this->types[$column] === ParameterType::LARGE_OBJECT) { $params[$column - 1] = [ &$variable, SQLSRV_PARAM_IN, @@ -295,9 +321,7 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) */ public function getIterator() { - $data = $this->fetchAll(); - - return new \ArrayIterator($data); + return new StatementIterator($this); } /** @@ -305,7 +329,7 @@ public function getIterator() * * @throws SQLSrvException */ - public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) + public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { // do not try fetching from the statement if it's not expected to contain result // in order to prevent exceptional situation @@ -316,17 +340,21 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX $args = func_get_args(); $fetchMode = $fetchMode ?: $this->defaultFetchMode; + if ($fetchMode === FetchMode::COLUMN) { + return $this->fetchColumn(); + } + if (isset(self::$fetchMap[$fetchMode])) { return sqlsrv_fetch_array($this->stmt, self::$fetchMap[$fetchMode]) ?: false; } - if (in_array($fetchMode, [PDO::FETCH_OBJ, PDO::FETCH_CLASS], true)) { + if (in_array($fetchMode, [FetchMode::STANDARD_OBJECT, FetchMode::CUSTOM_OBJECT], true)) { $className = $this->defaultFetchClass; $ctorArgs = $this->defaultFetchClassCtorArgs; if (count($args) >= 2) { $className = $args[1]; - $ctorArgs = isset($args[2]) ? $args[2] : []; + $ctorArgs = $args[2] ?? []; } return sqlsrv_fetch_object($this->stmt, $className, $ctorArgs) ?: false; @@ -343,18 +371,20 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n $rows = []; switch ($fetchMode) { - case PDO::FETCH_CLASS: - while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) { + case FetchMode::CUSTOM_OBJECT: + while (($row = $this->fetch(...func_get_args())) !== false) { $rows[] = $row; } break; - case PDO::FETCH_COLUMN: - while ($row = $this->fetchColumn()) { + + case FetchMode::COLUMN: + while (($row = $this->fetchColumn()) !== false) { $rows[] = $row; } break; + default: - while ($row = $this->fetch($fetchMode)) { + while (($row = $this->fetch($fetchMode)) !== false) { $rows[] = $row; } } @@ -367,13 +397,13 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n */ public function fetchColumn($columnIndex = 0) { - $row = $this->fetch(PDO::FETCH_NUM); + $row = $this->fetch(FetchMode::NUMERIC); if (false === $row) { return false; } - return isset($row[$columnIndex]) ? $row[$columnIndex] : null; + return $row[$columnIndex] ?? null; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php index f15ffefcb..f47ad0b27 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php @@ -38,7 +38,7 @@ public function getServerVersion(); /** * Checks whether a query is required to retrieve the database server version. * - * @return boolean True if a query is required to retrieve the database server version, false otherwise. + * @return bool True if a query is required to retrieve the database server version, false otherwise. */ public function requiresQueryForServerVersion(); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php index aedf47b8a..15b6bee1b 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\ParameterType; + /** * Statement interface. * Drivers must implement this interface. @@ -39,16 +41,16 @@ interface Statement extends ResultStatement * As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(), * fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine. * - * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, - * this will be a parameter name of the form :name. For a prepared statement - * using question mark placeholders, this will be the 1-indexed position of the parameter. - * @param mixed $value The value to bind to the parameter. - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter. + * @param mixed $value The value to bind to the parameter. + * @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType} + * constants. * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ - function bindValue($param, $value, $type = null); - + public function bindValue($param, $value, $type = ParameterType::STRING); /** * Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question @@ -64,19 +66,19 @@ function bindValue($param, $value, $type = null); * of stored procedures that return data as output parameters, and some also as input/output * parameters that both send in data and are updated to receive it. * - * @param mixed $column Parameter identifier. For a prepared statement using named placeholders, - * this will be a parameter name of the form :name. For a prepared statement using - * question mark placeholders, this will be the 1-indexed position of the parameter. - * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. - * @param integer|null $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return - * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the - * PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter. - * @param integer|null $length You must specify maxlength when using an OUT bind - * so that PHP allocates enough memory to hold the returned value. - * - * @return boolean TRUE on success or FALSE on failure. + * @param mixed $column Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement using + * question mark placeholders, this will be the 1-indexed position of the parameter. + * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. + * @param int|null $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType} + * constants. To return an INOUT parameter from a stored procedure, use the bitwise + * OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter. + * @param int|null $length You must specify maxlength when using an OUT bind + * so that PHP allocates enough memory to hold the returned value. + * + * @return bool TRUE on success or FALSE on failure. */ - function bindParam($column, &$variable, $type = null, $length = null); + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null); /** * Fetches the SQLSTATE associated with the last operation on the statement handle. @@ -85,7 +87,7 @@ function bindParam($column, &$variable, $type = null, $length = null); * * @return string The error code string. */ - function errorCode(); + public function errorCode(); /** * Fetches extended error information associated with the last operation on the statement handle. @@ -94,7 +96,7 @@ function errorCode(); * * @return array The error info array. */ - function errorInfo(); + public function errorInfo(); /** * Executes a prepared statement @@ -109,9 +111,9 @@ function errorInfo(); * @param array|null $params An array of values with as many elements as there are * bound parameters in the SQL statement being executed. * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ - function execute($params = null); + public function execute($params = null); /** * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement @@ -122,7 +124,7 @@ function execute($params = null); * this behaviour is not guaranteed for all databases and should not be * relied on for portable applications. * - * @return integer The number of rows. + * @return int The number of rows. */ - function rowCount(); + public function rowCount(); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/StatementIterator.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/StatementIterator.php new file mode 100644 index 000000000..2dc3f2b3d --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/StatementIterator.php @@ -0,0 +1,29 @@ +statement = $statement; + } + + /** + * {@inheritdoc} + */ + public function getIterator() + { + while (false !== ($result = $this->statement->fetch())) { + yield $result; + } + } +} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php b/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php index e3488df1e..22ae8ac32 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php @@ -20,6 +20,18 @@ namespace Doctrine\DBAL; use Doctrine\Common\EventManager; +use function array_keys; +use function array_map; +use function array_merge; +use function class_implements; +use function in_array; +use function is_subclass_of; +use function parse_str; +use function parse_url; +use function preg_replace; +use function str_replace; +use function strpos; +use function substr; /** * Factory for creating Doctrine\DBAL\Connection instances. @@ -37,7 +49,7 @@ final class DriverManager * * @var array */ - private static $_driverMap = array( + private static $_driverMap = [ 'pdo_mysql' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', 'pdo_sqlite' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver', 'pdo_pgsql' => 'Doctrine\DBAL\Driver\PDOPgSql\Driver', @@ -49,12 +61,12 @@ final class DriverManager 'drizzle_pdo_mysql' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver', 'sqlanywhere' => 'Doctrine\DBAL\Driver\SQLAnywhere\Driver', 'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver', - ); + ]; /** * List of URL schemes from a database URL and their mappings to driver. */ - private static $driverSchemeAliases = array( + private static $driverSchemeAliases = [ 'db2' => 'ibm_db2', 'mssql' => 'pdo_sqlsrv', 'mysql' => 'pdo_mysql', @@ -64,7 +76,7 @@ final class DriverManager 'pgsql' => 'pdo_pgsql', 'sqlite' => 'pdo_sqlite', 'sqlite3' => 'pdo_sqlite', - ); + ]; /** * Private constructor. This class cannot be instantiated. @@ -131,7 +143,7 @@ private function __construct() public static function getConnection( array $params, Configuration $config = null, - EventManager $eventManager = null) + EventManager $eventManager = null): Connection { // create default config and event manager, if not set if ( ! $config) { @@ -152,11 +164,8 @@ public static function getConnection( } else { self::_checkParams($params); } - if (isset($params['driverClass'])) { - $className = $params['driverClass']; - } else { - $className = self::$_driverMap[$params['driver']]; - } + + $className = $params['driverClass'] ?? self::$_driverMap[$params['driver']]; $driver = new $className(); @@ -177,7 +186,7 @@ public static function getConnection( * * @return array */ - public static function getAvailableDrivers() + public static function getAvailableDrivers(): array { return array_keys(self::$_driverMap); } @@ -191,7 +200,7 @@ public static function getAvailableDrivers() * * @throws \Doctrine\DBAL\DBALException */ - private static function _checkParams(array $params) + private static function _checkParams(array $params): void { // check existence of mandatory parameters @@ -219,7 +228,7 @@ private static function _checkParams(array $params) * * @return string The normalized connection URL path */ - private static function normalizeDatabaseUrlPath($urlPath) + private static function normalizeDatabaseUrlPath(string $urlPath): string { // Trim leading slash from URL path. return substr($urlPath, 1); @@ -236,7 +245,7 @@ private static function normalizeDatabaseUrlPath($urlPath) * * @throws DBALException */ - private static function parseDatabaseUrl(array $params) + private static function parseDatabaseUrl(array $params): array { if (!isset($params['url'])) { return $params; @@ -244,16 +253,7 @@ private static function parseDatabaseUrl(array $params) // (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid $url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $params['url']); - - // PHP < 5.4.8 doesn't parse schemeless urls properly. - // See: https://php.net/parse-url#refsect1-function.parse-url-changelog - if (PHP_VERSION_ID < 50408 && strpos($url, '//') === 0) { - $url = parse_url('fake:' . $url); - - unset($url['scheme']); - } else { - $url = parse_url($url); - } + $url = parse_url($url); if ($url === false) { throw new DBALException('Malformed parameter "url".'); @@ -299,7 +299,7 @@ private static function parseDatabaseUrl(array $params) * * @see parseDatabaseUrlScheme */ - private static function parseDatabaseUrlPath(array $url, array $params) + private static function parseDatabaseUrlPath(array $url, array $params): array { if (! isset($url['path'])) { return $params; @@ -328,13 +328,13 @@ private static function parseDatabaseUrlPath(array $url, array $params) * * @return array The resolved connection parameters. */ - private static function parseDatabaseUrlQuery(array $url, array $params) + private static function parseDatabaseUrlQuery(array $url, array $params): array { if (! isset($url['query'])) { return $params; } - $query = array(); + $query = []; parse_str($url['query'], $query); // simply ingest query as extra params, e.g. charset or sslmode @@ -353,7 +353,7 @@ private static function parseDatabaseUrlQuery(array $url, array $params) * * @see normalizeDatabaseUrlPath */ - private static function parseRegularDatabaseUrlPath(array $url, array $params) + private static function parseRegularDatabaseUrlPath(array $url, array $params): array { $params['dbname'] = $url['path']; @@ -372,7 +372,7 @@ private static function parseRegularDatabaseUrlPath(array $url, array $params) * * @see normalizeDatabaseUrlPath */ - private static function parseSqliteDatabaseUrlPath(array $url, array $params) + private static function parseSqliteDatabaseUrlPath(array $url, array $params): array { if ($url['path'] === ':memory:') { $params['memory'] = true; @@ -395,7 +395,7 @@ private static function parseSqliteDatabaseUrlPath(array $url, array $params) * * @throws DBALException if parsing failed or resolution is not possible. */ - private static function parseDatabaseUrlScheme(array $url, array $params) + private static function parseDatabaseUrlScheme(array $url, array $params): array { if (isset($url['scheme'])) { // The requested driver from the URL scheme takes precedence @@ -405,13 +405,11 @@ private static function parseDatabaseUrlScheme(array $url, array $params) // URL schemes must not contain underscores, but dashes are ok $driver = str_replace('-', '_', $url['scheme']); - // The requested driver from the URL scheme takes precedence - // over the default driver from the connection parameters (if any). - $params['driver'] = isset(self::$driverSchemeAliases[$driver]) - // use alias like "postgres", else we just let checkParams decide later - // if the driver exists (for literal "pdo-pgsql" etc) - ? self::$driverSchemeAliases[$driver] - : $driver; + // The requested driver from the URL scheme takes precedence over the + // default driver from the connection parameters. If the driver is + // an alias (e.g. "postgres"), map it to the actual name ("pdo-pgsql"). + // Otherwise, let checkParams decide later if the driver exists. + $params['driver'] = self::$driverSchemeAliases[$driver] ?? $driver; return $params; } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php index bd362c4cb..043f7b5eb 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php @@ -75,6 +75,6 @@ public function postConnect(ConnectionEventArgs $args) */ public function getSubscribedEvents() { - return array(Events::postConnect); + return [Events::postConnect]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php index 1c7ddec2f..851986cc1 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php @@ -22,6 +22,10 @@ use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; use Doctrine\Common\EventSubscriber; +use function array_change_key_case; +use function array_merge; +use function count; +use function implode; /** * Should be used when Oracle Server default environment does not match the Doctrine requirements. @@ -42,18 +46,18 @@ class OracleSessionInit implements EventSubscriber /** * @var array */ - protected $_defaultSessionVars = array( + protected $_defaultSessionVars = [ 'NLS_TIME_FORMAT' => "HH24:MI:SS", 'NLS_DATE_FORMAT' => "YYYY-MM-DD HH24:MI:SS", 'NLS_TIMESTAMP_FORMAT' => "YYYY-MM-DD HH24:MI:SS", 'NLS_TIMESTAMP_TZ_FORMAT' => "YYYY-MM-DD HH24:MI:SS TZH:TZM", 'NLS_NUMERIC_CHARACTERS' => ".,", - ); + ]; /** * @param array $oracleSessionVars */ - public function __construct(array $oracleSessionVars = array()) + public function __construct(array $oracleSessionVars = []) { $this->_defaultSessionVars = array_merge($this->_defaultSessionVars, $oracleSessionVars); } @@ -67,7 +71,7 @@ public function postConnect(ConnectionEventArgs $args) { if (count($this->_defaultSessionVars)) { array_change_key_case($this->_defaultSessionVars, \CASE_UPPER); - $vars = array(); + $vars = []; foreach ($this->_defaultSessionVars as $option => $value) { if ($option === 'CURRENT_SCHEMA') { $vars[] = $option . " = " . $value; @@ -85,6 +89,6 @@ public function postConnect(ConnectionEventArgs $args) */ public function getSubscribedEvents() { - return array(Events::postConnect); + return [Events::postConnect]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php index cfa42994c..767c80482 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php @@ -61,6 +61,6 @@ public function postConnect(ConnectionEventArgs $args) */ public function getSubscribedEvents() { - return array(Events::postConnect); + return [Events::postConnect]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php index c4477ad8a..7cb235ea1 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php @@ -22,6 +22,8 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; +use function array_merge; +use function is_array; /** * Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -50,7 +52,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs /** * @var array */ - private $_sql = array(); + private $_sql = []; /** * @param \Doctrine\DBAL\Schema\Column $column diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php index 7249b63cb..fdafb45a7 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php @@ -22,6 +22,8 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\TableDiff; +use function array_merge; +use function is_array; /** * Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -50,7 +52,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs /** * @var array */ - private $_sql = array(); + private $_sql = []; /** * @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php index 384315d5a..8e60b2c5f 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php @@ -21,6 +21,8 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\TableDiff; +use function array_merge; +use function is_array; /** * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform. @@ -44,7 +46,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs /** * @var array */ - private $_sql = array(); + private $_sql = []; /** * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php index 06f37888f..52413ce91 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php @@ -22,6 +22,8 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; +use function array_merge; +use function is_array; /** * Event Arguments used when SQL queries for removing table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -50,7 +52,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs /** * @var array */ - private $_sql = array(); + private $_sql = []; /** * @param \Doctrine\DBAL\Schema\Column $column diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php index 94a274c4f..697660442 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php @@ -22,6 +22,8 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; +use function array_merge; +use function is_array; /** * Event Arguments used when SQL queries for renaming table columns are generated inside Doctrine\DBAL\Platform\*Platform. @@ -55,7 +57,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs /** * @var array */ - private $_sql = array(); + private $_sql = []; /** * @param string $oldColumnName diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php index 38b218257..824e243b1 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php @@ -22,6 +22,8 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Table; +use function array_merge; +use function is_array; /** * Event Arguments used when SQL queries for creating table columns are generated inside Doctrine\DBAL\Platform\AbstractPlatform. @@ -50,7 +52,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs /** * @var array */ - private $_sql = array(); + private $_sql = []; /** * @param \Doctrine\DBAL\Schema\Column $column diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php index 175b0e9c3..7993b3adb 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php @@ -21,6 +21,8 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Table; +use function array_merge; +use function is_array; /** * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform. @@ -54,7 +56,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs /** * @var array */ - private $_sql = array(); + private $_sql = []; /** * @param \Doctrine\DBAL\Schema\Table $table diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php index 6ffb6442c..b3c904221 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php @@ -21,6 +21,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Table; +use function is_string; /** * Event Arguments used when the SQL query for dropping tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaEventArgs.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaEventArgs.php index d9648b64f..db12e57ad 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaEventArgs.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaEventArgs.php @@ -31,7 +31,7 @@ class SchemaEventArgs extends EventArgs { /** - * @var boolean + * @var bool */ private $_preventDefault = false; @@ -46,7 +46,7 @@ public function preventDefault() } /** - * @return boolean + * @return bool */ public function isDefaultPrevented() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Exception/DriverException.php b/doctrine/dbal/lib/Doctrine/DBAL/Exception/DriverException.php index 17c9f3a84..08b7935a0 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Exception/DriverException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Exception/DriverException.php @@ -61,7 +61,7 @@ public function __construct($message, \Doctrine\DBAL\Driver\DriverException $dri * * Returns null if no error code was given by the driver. * - * @return integer|string|null + * @return int|string|null */ public function getErrorCode() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/FetchMode.php b/doctrine/dbal/lib/Doctrine/DBAL/FetchMode.php new file mode 100644 index 000000000..a3e7f3ba6 --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/FetchMode.php @@ -0,0 +1,69 @@ +conn->getDatabasePlatform(); - $sql = "SELECT sequence_value, sequence_increment_by " . - "FROM " . $platform->appendLockHint($this->generatorTableName, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) . " " . - "WHERE sequence_name = ? " . $platform->getWriteLockSQL(); - $stmt = $this->conn->executeQuery($sql, array($sequenceName)); + $sql = 'SELECT sequence_value, sequence_increment_by' + . ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE) + . ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL(); + $stmt = $this->conn->executeQuery($sql, [$sequenceName]); + $row = $stmt->fetch(FetchMode::ASSOCIATIVE); - if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + if ($row !== false) { $row = array_change_key_case($row, CASE_LOWER); $value = $row['sequence_value']; $value++; if ($row['sequence_increment_by'] > 1) { - $this->sequences[$sequenceName] = array( + $this->sequences[$sequenceName] = [ 'value' => $value, 'max' => $row['sequence_value'] + $row['sequence_increment_by'] - ); + ]; } $sql = "UPDATE " . $this->generatorTableName . " ". "SET sequence_value = sequence_value + sequence_increment_by " . "WHERE sequence_name = ? AND sequence_value = ?"; - $rows = $this->conn->executeUpdate($sql, array($sequenceName, $row['sequence_value'])); + $rows = $this->conn->executeUpdate($sql, [$sequenceName, $row['sequence_value']]); if ($rows != 1) { throw new \Doctrine\DBAL\DBALException("Race-condition detected while updating sequence. Aborting generation"); @@ -148,7 +153,7 @@ public function nextValue($sequenceName) } else { $this->conn->insert( $this->generatorTableName, - array('sequence_name' => $sequenceName, 'sequence_value' => 1, 'sequence_increment_by' => 1) + ['sequence_name' => $sequenceName, 'sequence_value' => 1, 'sequence_increment_by' => 1] ); $value = 1; } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php b/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php index 25b06aca9..619a92f7b 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php @@ -48,8 +48,8 @@ public function acceptSchema(Schema $schema) { $table = $schema->createTable($this->generatorTableName); $table->addColumn('sequence_name', 'string'); - $table->addColumn('sequence_value', 'integer', array('default' => 1)); - $table->addColumn('sequence_increment_by', 'integer', array('default' => 1)); + $table->addColumn('sequence_value', 'integer', ['default' => 1]); + $table->addColumn('sequence_increment_by', 'integer', ['default' => 1]); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php b/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php index b143a3ee2..4cffaa67f 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Logging; +use function microtime; + /** * Includes executed SQLs in a Debug Stack. * @@ -36,12 +38,12 @@ class DebugStack implements SQLLogger * * @var array */ - public $queries = array(); + public $queries = []; /** * If Debug Stack is enabled (log queries) or not. * - * @var boolean + * @var bool */ public $enabled = true; @@ -51,7 +53,7 @@ class DebugStack implements SQLLogger public $start = null; /** - * @var integer + * @var int */ public $currentQuery = 0; @@ -62,7 +64,7 @@ public function startQuery($sql, array $params = null, array $types = null) { if ($this->enabled) { $this->start = microtime(true); - $this->queries[++$this->currentQuery] = array('sql' => $sql, 'params' => $params, 'types' => $types, 'executionMS' => 0); + $this->queries[++$this->currentQuery] = ['sql' => $sql, 'params' => $params, 'types' => $types, 'executionMS' => 0]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php b/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php index 8ed04788f..a6c1ae5ea 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php @@ -19,6 +19,9 @@ namespace Doctrine\DBAL\Logging; +use const PHP_EOL; +use function var_dump; + /** * A SQL logger that logs to the standard output using echo/var_dump. * diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php b/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php index 81845b1b2..fee05a4a0 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php @@ -31,7 +31,7 @@ class LoggerChain implements SQLLogger /** * @var \Doctrine\DBAL\Logging\SQLLogger[] */ - private $loggers = array(); + private $loggers = []; /** * Adds a logger in the chain. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/ParameterType.php b/doctrine/dbal/lib/Doctrine/DBAL/ParameterType.php new file mode 100644 index 000000000..362a0514d --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/ParameterType.php @@ -0,0 +1,51 @@ +getVarcharDefaultLength(); } - $fixed = (isset($field['fixed'])) ? $field['fixed'] : false; + $fixed = $field['fixed'] ?? false; if ($field['length'] > $this->getVarcharMaxLength()) { return $this->getClobTypeDeclarationSQL($field); @@ -285,7 +317,7 @@ public function getBinaryTypeDeclarationSQL(array $field) $field['length'] = $this->getBinaryDefaultLength(); } - $fixed = isset($field['fixed']) ? $field['fixed'] : false; + $fixed = $field['fixed'] ?? false; if ($field['length'] > $this->getBinaryMaxLength()) { return $this->getBlobTypeDeclarationSQL($field); @@ -328,8 +360,8 @@ public function getJsonTypeDeclarationSQL(array $field) } /** - * @param integer $length - * @param boolean $fixed + * @param int $length + * @param bool $fixed * * @return string * @@ -343,8 +375,8 @@ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) /** * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. * - * @param integer $length The length of the column. - * @param boolean $fixed Whether the column length is fixed. + * @param int $length The length of the column. + * @param bool $fixed Whether the column length is fixed. * * @return string * @@ -437,7 +469,7 @@ public function getDoctrineTypeMapping($dbType) * * @param string $dbType * - * @return boolean + * @return bool */ public function hasDoctrineTypeMappingFor($dbType) { @@ -457,7 +489,7 @@ public function hasDoctrineTypeMappingFor($dbType) */ protected function initializeCommentedDoctrineTypes() { - $this->doctrineTypeComments = array(); + $this->doctrineTypeComments = []; foreach (Type::getTypesMap() as $typeName => $className) { $type = Type::getType($typeName); @@ -473,7 +505,7 @@ protected function initializeCommentedDoctrineTypes() * * @param \Doctrine\DBAL\Types\Type $doctrineType * - * @return boolean + * @return bool */ public function isCommentedDoctrineType(Type $doctrineType) { @@ -563,7 +595,7 @@ public function getSqlCommentEndString() /** * Gets the maximum length of a varchar field. * - * @return integer + * @return int */ public function getVarcharMaxLength() { @@ -573,7 +605,7 @@ public function getVarcharMaxLength() /** * Gets the default length of a varchar field. * - * @return integer + * @return int */ public function getVarcharDefaultLength() { @@ -583,7 +615,7 @@ public function getVarcharDefaultLength() /** * Gets the maximum length of a binary field. * - * @return integer + * @return int */ public function getBinaryMaxLength() { @@ -593,7 +625,7 @@ public function getBinaryMaxLength() /** * Gets the default length of a binary field. * - * @return integer + * @return int */ public function getBinaryDefaultLength() { @@ -607,7 +639,7 @@ public function getBinaryDefaultLength() */ public function getWildcards() { - return array('%', '_'); + return ['%', '_']; } /** @@ -739,8 +771,8 @@ public function getSqrtExpression($column) /** * Returns the SQL snippet to round a numeric field to the number of decimals specified. * - * @param string $column - * @param integer $decimals + * @param string $column + * @param int $decimals * * @return string */ @@ -765,35 +797,35 @@ public function getModExpression($expression1, $expression2) /** * Returns the SQL snippet to trim a string. * - * @param string $str The expression to apply the trim to. - * @param integer $pos The position of the trim (leading/trailing/both). - * @param string|boolean $char The char to trim, has to be quoted already. Defaults to space. + * @param string $str The expression to apply the trim to. + * @param int $mode The position of the trim (leading/trailing/both). + * @param string|bool $char The char to trim, has to be quoted already. Defaults to space. * * @return string */ - public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = false) + public function getTrimExpression($str, $mode = TrimMode::UNSPECIFIED, $char = false) { $expression = ''; - switch ($pos) { - case self::TRIM_LEADING: + switch ($mode) { + case TrimMode::LEADING: $expression = 'LEADING '; break; - case self::TRIM_TRAILING: + case TrimMode::TRAILING: $expression = 'TRAILING '; break; - case self::TRIM_BOTH: + case TrimMode::BOTH: $expression = 'BOTH '; break; } - if (false !== $char) { + if ($char !== false) { $expression .= $char . ' '; } - if ($pos || false !== $char) { + if ($mode || $char !== false) { $expression .= 'FROM '; } @@ -853,9 +885,9 @@ public function getLowerExpression($str) /** * Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str. * - * @param string $str Literal string. - * @param string $substr Literal string to find. - * @param integer|boolean $startPos Position to start at, beginning of string by default. + * @param string $str Literal string. + * @param string $substr Literal string to find. + * @param int|bool $startPos Position to start at, beginning of string by default. * * @return string * @@ -883,9 +915,9 @@ public function getNowExpression() * * SQLite only supports the 2 parameter variant of this function. * - * @param string $value An sql string literal or column name/alias. - * @param integer $from Where to start the substring portion. - * @param integer|null $length The substring portion length. + * @param string $value An sql string literal or column name/alias. + * @param int $from Where to start the substring portion. + * @param int|null $length The substring portion length. * * @return string */ @@ -1040,8 +1072,8 @@ public function getDateDiffExpression($date1, $date2) /** * Returns the SQL to add the number of given seconds to a date. * - * @param string $date - * @param integer $seconds + * @param string $date + * @param int $seconds * * @return string * @@ -1049,14 +1081,14 @@ public function getDateDiffExpression($date1, $date2) */ public function getDateAddSecondsExpression($date, $seconds) { - return $this->getDateArithmeticIntervalExpression($date, '+', $seconds, self::DATE_INTERVAL_UNIT_SECOND); + return $this->getDateArithmeticIntervalExpression($date, '+', $seconds, DateIntervalUnit::SECOND); } /** * Returns the SQL to subtract the number of given seconds from a date. * - * @param string $date - * @param integer $seconds + * @param string $date + * @param int $seconds * * @return string * @@ -1064,14 +1096,14 @@ public function getDateAddSecondsExpression($date, $seconds) */ public function getDateSubSecondsExpression($date, $seconds) { - return $this->getDateArithmeticIntervalExpression($date, '-', $seconds, self::DATE_INTERVAL_UNIT_SECOND); + return $this->getDateArithmeticIntervalExpression($date, '-', $seconds, DateIntervalUnit::SECOND); } /** * Returns the SQL to add the number of given minutes to a date. * - * @param string $date - * @param integer $minutes + * @param string $date + * @param int $minutes * * @return string * @@ -1079,14 +1111,14 @@ public function getDateSubSecondsExpression($date, $seconds) */ public function getDateAddMinutesExpression($date, $minutes) { - return $this->getDateArithmeticIntervalExpression($date, '+', $minutes, self::DATE_INTERVAL_UNIT_MINUTE); + return $this->getDateArithmeticIntervalExpression($date, '+', $minutes, DateIntervalUnit::MINUTE); } /** * Returns the SQL to subtract the number of given minutes from a date. * - * @param string $date - * @param integer $minutes + * @param string $date + * @param int $minutes * * @return string * @@ -1094,14 +1126,14 @@ public function getDateAddMinutesExpression($date, $minutes) */ public function getDateSubMinutesExpression($date, $minutes) { - return $this->getDateArithmeticIntervalExpression($date, '-', $minutes, self::DATE_INTERVAL_UNIT_MINUTE); + return $this->getDateArithmeticIntervalExpression($date, '-', $minutes, DateIntervalUnit::MINUTE); } /** * Returns the SQL to add the number of given hours to a date. * - * @param string $date - * @param integer $hours + * @param string $date + * @param int $hours * * @return string * @@ -1109,14 +1141,14 @@ public function getDateSubMinutesExpression($date, $minutes) */ public function getDateAddHourExpression($date, $hours) { - return $this->getDateArithmeticIntervalExpression($date, '+', $hours, self::DATE_INTERVAL_UNIT_HOUR); + return $this->getDateArithmeticIntervalExpression($date, '+', $hours, DateIntervalUnit::HOUR); } /** * Returns the SQL to subtract the number of given hours to a date. * - * @param string $date - * @param integer $hours + * @param string $date + * @param int $hours * * @return string * @@ -1124,14 +1156,14 @@ public function getDateAddHourExpression($date, $hours) */ public function getDateSubHourExpression($date, $hours) { - return $this->getDateArithmeticIntervalExpression($date, '-', $hours, self::DATE_INTERVAL_UNIT_HOUR); + return $this->getDateArithmeticIntervalExpression($date, '-', $hours, DateIntervalUnit::HOUR); } /** * Returns the SQL to add the number of given days to a date. * - * @param string $date - * @param integer $days + * @param string $date + * @param int $days * * @return string * @@ -1139,14 +1171,14 @@ public function getDateSubHourExpression($date, $hours) */ public function getDateAddDaysExpression($date, $days) { - return $this->getDateArithmeticIntervalExpression($date, '+', $days, self::DATE_INTERVAL_UNIT_DAY); + return $this->getDateArithmeticIntervalExpression($date, '+', $days, DateIntervalUnit::DAY); } /** * Returns the SQL to subtract the number of given days to a date. * - * @param string $date - * @param integer $days + * @param string $date + * @param int $days * * @return string * @@ -1154,14 +1186,14 @@ public function getDateAddDaysExpression($date, $days) */ public function getDateSubDaysExpression($date, $days) { - return $this->getDateArithmeticIntervalExpression($date, '-', $days, self::DATE_INTERVAL_UNIT_DAY); + return $this->getDateArithmeticIntervalExpression($date, '-', $days, DateIntervalUnit::DAY); } /** * Returns the SQL to add the number of given weeks to a date. * - * @param string $date - * @param integer $weeks + * @param string $date + * @param int $weeks * * @return string * @@ -1169,14 +1201,14 @@ public function getDateSubDaysExpression($date, $days) */ public function getDateAddWeeksExpression($date, $weeks) { - return $this->getDateArithmeticIntervalExpression($date, '+', $weeks, self::DATE_INTERVAL_UNIT_WEEK); + return $this->getDateArithmeticIntervalExpression($date, '+', $weeks, DateIntervalUnit::WEEK); } /** * Returns the SQL to subtract the number of given weeks from a date. * - * @param string $date - * @param integer $weeks + * @param string $date + * @param int $weeks * * @return string * @@ -1184,14 +1216,14 @@ public function getDateAddWeeksExpression($date, $weeks) */ public function getDateSubWeeksExpression($date, $weeks) { - return $this->getDateArithmeticIntervalExpression($date, '-', $weeks, self::DATE_INTERVAL_UNIT_WEEK); + return $this->getDateArithmeticIntervalExpression($date, '-', $weeks, DateIntervalUnit::WEEK); } /** * Returns the SQL to add the number of given months to a date. * - * @param string $date - * @param integer $months + * @param string $date + * @param int $months * * @return string * @@ -1199,14 +1231,14 @@ public function getDateSubWeeksExpression($date, $weeks) */ public function getDateAddMonthExpression($date, $months) { - return $this->getDateArithmeticIntervalExpression($date, '+', $months, self::DATE_INTERVAL_UNIT_MONTH); + return $this->getDateArithmeticIntervalExpression($date, '+', $months, DateIntervalUnit::MONTH); } /** * Returns the SQL to subtract the number of given months to a date. * - * @param string $date - * @param integer $months + * @param string $date + * @param int $months * * @return string * @@ -1214,14 +1246,14 @@ public function getDateAddMonthExpression($date, $months) */ public function getDateSubMonthExpression($date, $months) { - return $this->getDateArithmeticIntervalExpression($date, '-', $months, self::DATE_INTERVAL_UNIT_MONTH); + return $this->getDateArithmeticIntervalExpression($date, '-', $months, DateIntervalUnit::MONTH); } /** * Returns the SQL to add the number of given quarters to a date. * - * @param string $date - * @param integer $quarters + * @param string $date + * @param int $quarters * * @return string * @@ -1229,14 +1261,14 @@ public function getDateSubMonthExpression($date, $months) */ public function getDateAddQuartersExpression($date, $quarters) { - return $this->getDateArithmeticIntervalExpression($date, '+', $quarters, self::DATE_INTERVAL_UNIT_QUARTER); + return $this->getDateArithmeticIntervalExpression($date, '+', $quarters, DateIntervalUnit::QUARTER); } /** * Returns the SQL to subtract the number of given quarters from a date. * - * @param string $date - * @param integer $quarters + * @param string $date + * @param int $quarters * * @return string * @@ -1244,14 +1276,14 @@ public function getDateAddQuartersExpression($date, $quarters) */ public function getDateSubQuartersExpression($date, $quarters) { - return $this->getDateArithmeticIntervalExpression($date, '-', $quarters, self::DATE_INTERVAL_UNIT_QUARTER); + return $this->getDateArithmeticIntervalExpression($date, '-', $quarters, DateIntervalUnit::QUARTER); } /** * Returns the SQL to add the number of given years to a date. * - * @param string $date - * @param integer $years + * @param string $date + * @param int $years * * @return string * @@ -1259,14 +1291,14 @@ public function getDateSubQuartersExpression($date, $quarters) */ public function getDateAddYearsExpression($date, $years) { - return $this->getDateArithmeticIntervalExpression($date, '+', $years, self::DATE_INTERVAL_UNIT_YEAR); + return $this->getDateArithmeticIntervalExpression($date, '+', $years, DateIntervalUnit::YEAR); } /** * Returns the SQL to subtract the number of given years from a date. * - * @param string $date - * @param integer $years + * @param string $date + * @param int $years * * @return string * @@ -1274,17 +1306,17 @@ public function getDateAddYearsExpression($date, $years) */ public function getDateSubYearsExpression($date, $years) { - return $this->getDateArithmeticIntervalExpression($date, '-', $years, self::DATE_INTERVAL_UNIT_YEAR); + return $this->getDateArithmeticIntervalExpression($date, '-', $years, DateIntervalUnit::YEAR); } /** * Returns the SQL for a date arithmetic expression. * - * @param string $date The column or literal representing a date to perform the arithmetic operation on. - * @param string $operator The arithmetic operator (+ or -). - * @param integer $interval The interval that shall be calculated into the date. - * @param string $unit The unit of the interval that shall be calculated into the date. - * One of the DATE_INTERVAL_UNIT_* constants. + * @param string $date The column or literal representing a date to perform the arithmetic operation on. + * @param string $operator The arithmetic operator (+ or -). + * @param int $interval The interval that shall be calculated into the date. + * @param string $unit The unit of the interval that shall be calculated into the date. + * One of the DATE_INTERVAL_UNIT_* constants. * * @return string * @@ -1334,9 +1366,9 @@ public function getForUpdateSQL() /** * Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification. * - * @param string $fromClause The FROM clause to append the hint for the given lock mode to. - * @param integer|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. If null is given, nothing will - * be appended to the FROM clause. + * @param string $fromClause The FROM clause to append the hint for the given lock mode to. + * @param int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. If null is given, nothing will + * be appended to the FROM clause. * * @return string */ @@ -1498,8 +1530,8 @@ public function getDropForeignKeySQL($foreignKey, $table) * Returns the SQL statement(s) to create a table with the specified name, columns and constraints * on this platform. * - * @param \Doctrine\DBAL\Schema\Table $table - * @param integer $createFlags + * @param \Doctrine\DBAL\Schema\Table $table + * @param int $createFlags * * @return array The sequence of SQL statements. * @@ -1518,9 +1550,9 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE $tableName = $table->getQuotedName($this); $options = $table->getOptions(); - $options['uniqueConstraints'] = array(); - $options['indexes'] = array(); - $options['primary'] = array(); + $options['uniqueConstraints'] = []; + $options['indexes'] = []; + $options['primary'] = []; if (($createFlags&self::CREATE_INDEXES) > 0) { foreach ($table->getIndexes() as $index) { @@ -1534,8 +1566,8 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE } } - $columnSql = array(); - $columns = array(); + $columnSql = []; + $columns = []; foreach ($table->getColumns() as $column) { /* @var \Doctrine\DBAL\Schema\Column $column */ @@ -1556,7 +1588,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE $columnData['version'] = $column->hasPlatformOption("version") ? $column->getPlatformOption('version') : false; $columnData['comment'] = $this->getColumnComment($column); - if (strtolower($columnData['type']) == "string" && $columnData['length'] === null) { + if ($columnData['type'] instanceof Types\StringType && $columnData['length'] === null) { $columnData['length'] = 255; } @@ -1568,7 +1600,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE } if (($createFlags&self::CREATE_FOREIGNKEYS) > 0) { - $options['foreignKeys'] = array(); + $options['foreignKeys'] = []; foreach ($table->getForeignKeys() as $fkConstraint) { $options['foreignKeys'][] = $fkConstraint; } @@ -1641,7 +1673,7 @@ public function getInlineColumnCommentSQL($comment) * * @return array */ - protected function _getCreateTableSQL($tableName, array $columns, array $options = array()) + protected function _getCreateTableSQL($tableName, array $columns, array $options = []) { $columnListSql = $this->getColumnDeclarationListSQL($columns); @@ -1860,7 +1892,7 @@ public function getCreateSchemaSQL($schemaName) public function quoteIdentifier($str) { if (strpos($str, ".") !== false) { - $parts = array_map(array($this, "quoteSingleIdentifier"), explode(".", $str)); + $parts = array_map([$this, "quoteSingleIdentifier"], explode(".", $str)); return implode(".", $parts); } @@ -1922,7 +1954,7 @@ public function getAlterTableSQL(TableDiff $diff) * @param \Doctrine\DBAL\Schema\TableDiff $diff * @param array $columnSql * - * @return boolean + * @return bool */ protected function onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, &$columnSql) { @@ -1947,7 +1979,7 @@ protected function onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, * @param \Doctrine\DBAL\Schema\TableDiff $diff * @param array $columnSql * - * @return boolean + * @return bool */ protected function onSchemaAlterTableRemoveColumn(Column $column, TableDiff $diff, &$columnSql) { @@ -1972,7 +2004,7 @@ protected function onSchemaAlterTableRemoveColumn(Column $column, TableDiff $dif * @param \Doctrine\DBAL\Schema\TableDiff $diff * @param array $columnSql * - * @return boolean + * @return bool */ protected function onSchemaAlterTableChangeColumn(ColumnDiff $columnDiff, TableDiff $diff, &$columnSql) { @@ -1998,7 +2030,7 @@ protected function onSchemaAlterTableChangeColumn(ColumnDiff $columnDiff, TableD * @param \Doctrine\DBAL\Schema\TableDiff $diff * @param array $columnSql * - * @return boolean + * @return bool */ protected function onSchemaAlterTableRenameColumn($oldColumnName, Column $column, TableDiff $diff, &$columnSql) { @@ -2022,7 +2054,7 @@ protected function onSchemaAlterTableRenameColumn($oldColumnName, Column $column * @param \Doctrine\DBAL\Schema\TableDiff $diff * @param array $sql * - * @return boolean + * @return bool */ protected function onSchemaAlterTable(TableDiff $diff, &$sql) { @@ -2051,7 +2083,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) { $tableName = $diff->getName($this)->getQuotedName($this); - $sql = array(); + $sql = []; if ($this->supportsForeignKeyConstraints()) { foreach ($diff->removedForeignKeys as $foreignKey) { $sql[] = $this->getDropForeignKeySQL($foreignKey, $tableName); @@ -2082,7 +2114,7 @@ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) ? $diff->getNewName()->getQuotedName($this) : $diff->getName($this)->getQuotedName($this); - $sql = array(); + $sql = []; if ($this->supportsForeignKeyConstraints()) { foreach ($diff->addedForeignKeys as $foreignKey) { @@ -2124,10 +2156,10 @@ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) */ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) { - return array( + return [ $this->getDropIndexSQL($oldIndexName, $tableName), $this->getCreateIndexSQL($index, $tableName) - ); + ]; } /** @@ -2173,7 +2205,7 @@ protected function _getAlterTableIndexForeignKeySQL(TableDiff $diff) */ public function getColumnDeclarationListSQL(array $fields) { - $queryFields = array(); + $queryFields = []; foreach ($fields as $fieldName => $field) { $queryFields[] = $this->getColumnDeclarationSQL($fieldName, $field); @@ -2223,18 +2255,18 @@ public function getColumnDeclarationSQL($name, array $field) $default = $this->getDefaultValueDeclarationSQL($field); $charset = (isset($field['charset']) && $field['charset']) ? - ' ' . $this->getColumnCharsetDeclarationSQL($field['charset']) : ''; + ' ' . $this->getColumnCharsetDeclarationSQL($field['charset']) : ''; $collation = (isset($field['collation']) && $field['collation']) ? - ' ' . $this->getColumnCollationDeclarationSQL($field['collation']) : ''; + ' ' . $this->getColumnCollationDeclarationSQL($field['collation']) : ''; $notnull = (isset($field['notnull']) && $field['notnull']) ? ' NOT NULL' : ''; $unique = (isset($field['unique']) && $field['unique']) ? - ' ' . $this->getUniqueFieldDeclarationSQL() : ''; + ' ' . $this->getUniqueFieldDeclarationSQL() : ''; $check = (isset($field['check']) && $field['check']) ? - ' ' . $field['check'] : ''; + ' ' . $field['check'] : ''; $typeDecl = $field['type']->getSQLDeclaration($field, $this); $columnDef = $typeDecl . $charset . $default . $notnull . $unique . $check . $collation; @@ -2284,25 +2316,25 @@ public function getDefaultValueDeclarationSQL($field) return " DEFAULT '" . $default . "'"; } - $type = (string) $field['type']; + $type = $field['type']; - if (in_array($type, ["Integer", "BigInt", "SmallInt"], true)) { - return " DEFAULT " . $default; + if ($type instanceof Types\PhpIntegerMappingType) { + return ' DEFAULT ' . $default; } - if (in_array($type, ['DateTime', 'DateTimeTz', 'DateTimeImmutable', 'DateTimeTzImmutable'], true) && $default === $this->getCurrentTimestampSQL()) { - return " DEFAULT " . $this->getCurrentTimestampSQL(); + if ($type instanceof Types\PhpDateTimeMappingType && $default === $this->getCurrentTimestampSQL()) { + return ' DEFAULT ' . $this->getCurrentTimestampSQL(); } - if (in_array($type, ['Time', 'TimeImmutable'], true) && $default === $this->getCurrentTimeSQL()) { - return " DEFAULT " . $this->getCurrentTimeSQL(); + if ($type instanceof Types\TimeType && $default === $this->getCurrentTimeSQL()) { + return ' DEFAULT ' . $this->getCurrentTimeSQL(); } - if (in_array($type, ['Date', 'DateImmutable'], true) && $default === $this->getCurrentDateSQL()) { - return " DEFAULT " . $this->getCurrentDateSQL(); + if ($type instanceof Types\DateType && $default === $this->getCurrentDateSQL()) { + return ' DEFAULT ' . $this->getCurrentDateSQL(); } - if ($type === 'Boolean') { + if ($type instanceof Types\BooleanType) { return " DEFAULT '" . $this->convertBooleans($default) . "'"; } @@ -2319,7 +2351,7 @@ public function getDefaultValueDeclarationSQL($field) */ public function getCheckDeclarationSQL(array $definition) { - $constraints = array(); + $constraints = []; foreach ($definition as $field => $def) { if (is_string($def)) { $constraints[] = 'CHECK (' . $def . ')'; @@ -2358,8 +2390,8 @@ public function getUniqueConstraintDeclarationSQL($name, Index $index) } return 'CONSTRAINT ' . $name->getQuotedName($this) . ' UNIQUE (' - . $this->getIndexFieldDeclarationListSQL($columns) - . ')' . $this->getPartialIndexSQL($index); + . $this->getIndexFieldDeclarationListSQL($columns) + . ')' . $this->getPartialIndexSQL($index); } /** @@ -2411,7 +2443,7 @@ public function getCustomTypeDeclarationSQL(array $columnDef) */ public function getIndexFieldDeclarationListSQL(array $fields) { - $ret = array(); + $ret = []; foreach ($fields as $field => $definition) { if (is_array($definition)) { @@ -2546,9 +2578,9 @@ public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey } $sql .= implode(', ', $foreignKey->getQuotedLocalColumns($this)) - . ') REFERENCES ' - . $foreignKey->getQuotedForeignTableName($this) . ' (' - . implode(', ', $foreignKey->getQuotedForeignColumns($this)) . ')'; + . ') REFERENCES ' + . $foreignKey->getQuotedForeignTableName($this) . ' (' + . implode(', ', $foreignKey->getQuotedForeignColumns($this)) . ')'; return $sql; } @@ -2597,7 +2629,7 @@ public function getColumnCollationDeclarationSQL($collation) * Whether the platform prefers sequences for ID generation. * Subclasses should override this method to return TRUE if they prefer sequences. * - * @return boolean + * @return bool */ public function prefersSequences() { @@ -2608,7 +2640,7 @@ public function prefersSequences() * Whether the platform prefers identity columns (eg. autoincrement) for ID generation. * Subclasses should override this method to return TRUE if they prefer identity columns. * - * @return boolean + * @return bool */ public function prefersIdentityColumns() { @@ -2706,7 +2738,7 @@ public function getCurrentTimestampSQL() /** * Returns the SQL for a given transaction isolation level Connection constant. * - * @param integer $level + * @param int $level * * @return string * @@ -2715,13 +2747,13 @@ public function getCurrentTimestampSQL() protected function _getTransactionIsolationLevelSQL($level) { switch ($level) { - case Connection::TRANSACTION_READ_UNCOMMITTED: + case TransactionIsolationLevel::READ_UNCOMMITTED: return 'READ UNCOMMITTED'; - case Connection::TRANSACTION_READ_COMMITTED: + case TransactionIsolationLevel::READ_COMMITTED: return 'READ COMMITTED'; - case Connection::TRANSACTION_REPEATABLE_READ: + case TransactionIsolationLevel::REPEATABLE_READ: return 'REPEATABLE READ'; - case Connection::TRANSACTION_SERIALIZABLE: + case TransactionIsolationLevel::SERIALIZABLE: return 'SERIALIZABLE'; default: throw new \InvalidArgumentException('Invalid isolation level:' . $level); @@ -2923,7 +2955,7 @@ public function getCreateDatabaseSQL($database) /** * Returns the SQL to set the transaction isolation level. * - * @param integer $level + * @param int $level * * @return string * @@ -3005,13 +3037,13 @@ public function getFloatDeclarationSQL(array $fieldDeclaration) /** * Gets the default transaction isolation level of the platform. * - * @return integer The default isolation level. + * @return int The default isolation level. * - * @see Doctrine\DBAL\Connection\TRANSACTION_* constants. + * @see TransactionIsolationLevel */ public function getDefaultTransactionIsolationLevel() { - return Connection::TRANSACTION_READ_COMMITTED; + return TransactionIsolationLevel::READ_COMMITTED; } /* supports*() methods */ @@ -3019,7 +3051,7 @@ public function getDefaultTransactionIsolationLevel() /** * Whether the platform supports sequences. * - * @return boolean + * @return bool */ public function supportsSequences() { @@ -3032,7 +3064,7 @@ public function supportsSequences() * Identity columns are columns that receive an auto-generated value from the * database on insert of a row. * - * @return boolean + * @return bool */ public function supportsIdentityColumns() { @@ -3046,7 +3078,7 @@ public function supportsIdentityColumns() * but support sequences can emulate identity columns by using * sequences. * - * @return boolean + * @return bool */ public function usesSequenceEmulatedIdentityColumns() { @@ -3073,7 +3105,7 @@ public function getIdentitySequenceName($tableName, $columnName) /** * Whether the platform supports indexes. * - * @return boolean + * @return bool */ public function supportsIndexes() { @@ -3083,7 +3115,7 @@ public function supportsIndexes() /** * Whether the platform supports partial indexes. * - * @return boolean + * @return bool */ public function supportsPartialIndexes() { @@ -3093,7 +3125,7 @@ public function supportsPartialIndexes() /** * Whether the platform supports altering tables. * - * @return boolean + * @return bool */ public function supportsAlterTable() { @@ -3103,7 +3135,7 @@ public function supportsAlterTable() /** * Whether the platform supports transactions. * - * @return boolean + * @return bool */ public function supportsTransactions() { @@ -3113,7 +3145,7 @@ public function supportsTransactions() /** * Whether the platform supports savepoints. * - * @return boolean + * @return bool */ public function supportsSavepoints() { @@ -3123,7 +3155,7 @@ public function supportsSavepoints() /** * Whether the platform supports releasing savepoints. * - * @return boolean + * @return bool */ public function supportsReleaseSavepoints() { @@ -3133,7 +3165,7 @@ public function supportsReleaseSavepoints() /** * Whether the platform supports primary key constraints. * - * @return boolean + * @return bool */ public function supportsPrimaryConstraints() { @@ -3143,7 +3175,7 @@ public function supportsPrimaryConstraints() /** * Whether the platform supports foreign key constraints. * - * @return boolean + * @return bool */ public function supportsForeignKeyConstraints() { @@ -3153,7 +3185,7 @@ public function supportsForeignKeyConstraints() /** * Whether this platform supports onUpdate in foreign key constraints. * - * @return boolean + * @return bool */ public function supportsForeignKeyOnUpdate() { @@ -3163,7 +3195,7 @@ public function supportsForeignKeyOnUpdate() /** * Whether the platform supports database schemas. * - * @return boolean + * @return bool */ public function supportsSchemas() { @@ -3177,7 +3209,7 @@ public function supportsSchemas() * filter a schema for the namespaced elements in {@link * AbstractManager#createSchema}. * - * @return boolean + * @return bool */ public function canEmulateSchemas() { @@ -3201,7 +3233,7 @@ public function getDefaultSchemaName() * * Some databases don't allow to create and drop databases at all or only with certain tools. * - * @return boolean + * @return bool */ public function supportsCreateDropDatabase() { @@ -3211,7 +3243,7 @@ public function supportsCreateDropDatabase() /** * Whether the platform supports getting the affected rows of a recent update/delete type query. * - * @return boolean + * @return bool */ public function supportsGettingAffectedRows() { @@ -3221,7 +3253,7 @@ public function supportsGettingAffectedRows() /** * Whether this platform support to add inline column comments as postfix. * - * @return boolean + * @return bool */ public function supportsInlineColumnComments() { @@ -3231,7 +3263,7 @@ public function supportsInlineColumnComments() /** * Whether this platform support the proprietary syntax "COMMENT ON asset". * - * @return boolean + * @return bool */ public function supportsCommentOnStatement() { @@ -3241,7 +3273,7 @@ public function supportsCommentOnStatement() /** * Does this platform have native guid type. * - * @return boolean + * @return bool */ public function hasNativeGuidType() { @@ -3251,7 +3283,7 @@ public function hasNativeGuidType() /** * Does this platform have native JSON type. * - * @return boolean + * @return bool */ public function hasNativeJsonType() { @@ -3270,7 +3302,7 @@ public function getIdentityColumnNullInsertSQL() /** * Whether this platform supports views. * - * @return boolean + * @return bool */ public function supportsViews() { @@ -3280,7 +3312,7 @@ public function supportsViews() /** * Does this platform support column collation? * - * @return boolean + * @return bool */ public function supportsColumnCollation() { @@ -3334,9 +3366,9 @@ public function getTimeFormatString() /** * Adds an driver-specific LIMIT clause to the query. * - * @param string $query - * @param integer|null $limit - * @param integer|null $offset + * @param string $query + * @param int|null $limit + * @param int|null $offset * * @return string * @@ -3365,9 +3397,9 @@ final public function modifyLimitQuery($query, $limit, $offset = null) /** * Adds an driver-specific LIMIT clause to the query. * - * @param string $query - * @param integer|null $limit - * @param integer|null $offset + * @param string $query + * @param int|null $limit + * @param int|null $offset * * @return string */ @@ -3387,7 +3419,7 @@ protected function doModifyLimitQuery($query, $limit, $offset) /** * Whether the database platform support offsets in modify limit clauses. * - * @return boolean + * @return bool */ public function supportsLimitOffset() { @@ -3422,7 +3454,7 @@ public function fixSchemaElementName($schemaElementName) /** * Maximum length of any given database identifier, like tables or column names. * - * @return integer + * @return int */ public function getMaxIdentifierLength() { @@ -3448,8 +3480,8 @@ public function getEmptyIdentityInsertSQL($tableName, $identifierColumnName) * Cascade is not supported on many platforms but would optionally cascade the truncate by * following the foreign keys. * - * @param string $tableName - * @param boolean $cascade + * @param string $tableName + * @param bool $cascade * * @return string */ @@ -3570,4 +3602,26 @@ public function getStringLiteralQuoteCharacter() { return "'"; } + + /** + * Escapes metacharacters in a string intended to be used with a LIKE + * operator. + * + * @param string $inputString a literal, unquoted string + * @param string $escapeChar should be reused by the caller in the LIKE + * expression. + */ + final public function escapeStringForLike(string $inputString, string $escapeChar) : string + { + return preg_replace( + '~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u', + addcslashes($escapeChar, '\\') . '$1', + $inputString + ); + } + + protected function getLikeWildcardCharacters() : string + { + return '%_'; + } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php index cac98333e..df2faab44 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -26,6 +26,14 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; +use function array_merge; +use function count; +use function current; +use function explode; +use function implode; +use function sprintf; +use function strpos; +use function strtoupper; class DB2Platform extends AbstractPlatform { @@ -59,7 +67,7 @@ public function getBlobTypeDeclarationSQL(array $field) */ public function initializeDoctrineTypeMappings() { - $this->doctrineTypeMapping = array( + $this->doctrineTypeMapping = [ 'smallint' => 'smallint', 'bigint' => 'bigint', 'integer' => 'integer', @@ -75,7 +83,7 @@ public function initializeDoctrineTypeMappings() 'double' => 'float', 'real' => 'float', 'timestamp' => 'datetime', - ); + ]; } /** @@ -193,14 +201,14 @@ public function getBitOrComparisonExpression($value1, $value2) protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) { switch ($unit) { - case self::DATE_INTERVAL_UNIT_WEEK: + case DateIntervalUnit::WEEK: $interval *= 7; - $unit = self::DATE_INTERVAL_UNIT_DAY; + $unit = DateIntervalUnit::DAY; break; - case self::DATE_INTERVAL_UNIT_QUARTER: + case DateIntervalUnit::QUARTER: $interval *= 3; - $unit = self::DATE_INTERVAL_UNIT_MONTH; + $unit = DateIntervalUnit::MONTH; break; } @@ -477,13 +485,13 @@ public function getIndexDeclarationSQL($name, Index $index) /** * {@inheritDoc} */ - protected function _getCreateTableSQL($tableName, array $columns, array $options = array()) + protected function _getCreateTableSQL($tableName, array $columns, array $options = []) { - $indexes = array(); + $indexes = []; if (isset($options['indexes'])) { $indexes = $options['indexes']; } - $options['indexes'] = array(); + $options['indexes'] = []; $sqls = parent::_getCreateTableSQL($tableName, $columns, $options); @@ -498,11 +506,11 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options */ public function getAlterTableSQL(TableDiff $diff) { - $sql = array(); - $columnSql = array(); - $commentsSQL = array(); + $sql = []; + $columnSql = []; + $commentsSQL = []; - $queryParts = array(); + $queryParts = []; foreach ($diff->addedColumns as $column) { if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { continue; @@ -571,7 +579,7 @@ public function getAlterTableSQL(TableDiff $diff) ' TO ' . $column->getQuotedName($this); } - $tableSql = array(); + $tableSql = []; if ( ! $this->onSchemaAlterTable($diff, $tableSql)) { if (count($queryParts) > 0) { @@ -644,10 +652,10 @@ private function getAlterColumnClausesSQL(ColumnDiff $columnDiff) $alterClause = 'ALTER COLUMN ' . $columnDiff->column->getQuotedName($this); if ($column['columnDefinition']) { - return array($alterClause . ' ' . $column['columnDefinition']); + return [$alterClause . ' ' . $column['columnDefinition']]; } - $clauses = array(); + $clauses = []; if ($columnDiff->hasChanged('type') || $columnDiff->hasChanged('length') || @@ -682,7 +690,7 @@ private function getAlterColumnClausesSQL(ColumnDiff $columnDiff) */ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) { - $sql = array(); + $sql = []; $table = $diff->getName($this)->getQuotedName($this); foreach ($diff->removedIndexes as $remKey => $remIndex) { @@ -698,8 +706,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) $sql[] = $this->getCreateIndexSQL($addIndex, $table); - unset($diff->removedIndexes[$remKey]); - unset($diff->addedIndexes[$addKey]); + unset($diff->removedIndexes[$remKey], $diff->addedIndexes[$addKey]); break; } @@ -721,7 +728,7 @@ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) $oldIndexName = $schema . '.' . $oldIndexName; } - return array('RENAME INDEX ' . $oldIndexName . ' TO ' . $index->getQuotedName($this)); + return ['RENAME INDEX ' . $oldIndexName . ' TO ' . $index->getQuotedName($this)]; } /** @@ -771,7 +778,7 @@ public function getTemporaryTableName($tableName) */ protected function doModifyLimitQuery($query, $limit, $offset = null) { - $where = array(); + $where = []; if ($offset > 0) { $where[] = sprintf('db22.DC_ROWNUM >= %d', $offset + 1); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DateIntervalUnit.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DateIntervalUnit.php new file mode 100644 index 000000000..ec97d0ef3 --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DateIntervalUnit.php @@ -0,0 +1,28 @@ +doctrineTypeMapping = array( + $this->doctrineTypeMapping = [ 'boolean' => 'boolean', 'varchar' => 'string', 'varbinary' => 'binary', @@ -156,7 +169,7 @@ protected function initializeDoctrineTypeMappings() 'timestamp' => 'datetime', 'double' => 'float', 'bigint' => 'bigint', - ); + ]; } /** @@ -194,7 +207,7 @@ public function getDropDatabaseSQL($name) /** * {@inheritDoc} */ - protected function _getCreateTableSQL($tableName, array $columns, array $options = array()) + protected function _getCreateTableSQL($tableName, array $columns, array $options = []) { $queryFields = $this->getColumnDeclarationListSQL($columns); @@ -251,7 +264,7 @@ private function buildTableOptions(array $options) return $options['table_options']; } - $tableOptions = array(); + $tableOptions = []; // Collate if ( ! isset($options['collate'])) { @@ -483,8 +496,8 @@ public function getDateTypeDeclarationSQL(array $fieldDeclaration) */ public function getAlterTableSQL(TableDiff $diff) { - $columnSql = array(); - $queryParts = array(); + $columnSql = []; + $queryParts = []; if ($diff->newName !== false) { $queryParts[] = 'RENAME TO ' . $diff->getNewName()->getQuotedName($this); @@ -545,8 +558,8 @@ public function getAlterTableSQL(TableDiff $diff) . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); } - $sql = array(); - $tableSql = array(); + $sql = []; + $tableSql = []; if ( ! $this->onSchemaAlterTable($diff, $tableSql)) { if (count($queryParts) > 0) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php index ff8aac81c..884cc8ec7 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php @@ -41,7 +41,7 @@ public function getName() */ protected function getKeywords() { - return array( + return [ 'ACTIVATE', 'ADD', 'AFTER', @@ -436,6 +436,6 @@ protected function getKeywords() 'LOCATORS', 'ROLLBACK', 'YEARS', - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php index 21d59d8c5..46c8b2463 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php @@ -39,7 +39,7 @@ public function getName() */ protected function getKeywords() { - return array( + return [ 'ABS', 'ALL', 'ALLOCATE', @@ -340,6 +340,6 @@ protected function getKeywords() 'XMLROOT', 'XMLSERIALIZE', 'YEAR', - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php index 5b8d74d01..e8933a386 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php @@ -19,6 +19,10 @@ namespace Doctrine\DBAL\Platforms\Keywords; +use function array_flip; +use function array_map; +use function strtoupper; + /** * Abstract interface for a SQL reserved keyword dictionary. * @@ -38,7 +42,7 @@ abstract class KeywordList * * @param string $word * - * @return boolean + * @return bool */ public function isKeyword($word) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php new file mode 100644 index 000000000..3fb66934f --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php @@ -0,0 +1,290 @@ +. + */ + +namespace Doctrine\DBAL\Platforms\Keywords; + +/** + * MariaDb reserved keywords list. + * @link https://mariadb.com/kb/en/the-mariadb-library/reserved-words/ + */ +final class MariaDb102Keywords extends MySQLKeywords +{ + /** + * {@inheritdoc} + */ + public function getName() : string + { + return 'MariaDb102'; + } + + /** + * {@inheritdoc} + */ + protected function getKeywords() : array + { + return [ + 'ACCESSIBLE', + 'ADD', + 'ALL', + 'ALTER', + 'ANALYZE', + 'AND', + 'AS', + 'ASC', + 'ASENSITIVE', + 'BEFORE', + 'BETWEEN', + 'BIGINT', + 'BINARY', + 'BLOB', + 'BOTH', + 'BY', + 'CALL', + 'CASCADE', + 'CASE', + 'CHANGE', + 'CHAR', + 'CHARACTER', + 'CHECK', + 'COLLATE', + 'COLUMN', + 'CONDITION', + 'CONSTRAINT', + 'CONTINUE', + 'CONVERT', + 'CREATE', + 'CROSS', + 'CURRENT_DATE', + 'CURRENT_TIME', + 'CURRENT_TIMESTAMP', + 'CURRENT_USER', + 'CURSOR', + 'DATABASE', + 'DATABASES', + 'DAY_HOUR', + 'DAY_MICROSECOND', + 'DAY_MINUTE', + 'DAY_SECOND', + 'DEC', + 'DECIMAL', + 'DECLARE', + 'DEFAULT', + 'DELAYED', + 'DELETE', + 'DESC', + 'DESCRIBE', + 'DETERMINISTIC', + 'DISTINCT', + 'DISTINCTROW', + 'DIV', + 'DOUBLE', + 'DROP', + 'DUAL', + 'EACH', + 'ELSE', + 'ELSEIF', + 'ENCLOSED', + 'ESCAPED', + 'EXCEPT', + 'EXISTS', + 'EXIT', + 'EXPLAIN', + 'FALSE', + 'FETCH', + 'FLOAT', + 'FLOAT4', + 'FLOAT8', + 'FOR', + 'FORCE', + 'FOREIGN', + 'FROM', + 'FULLTEXT', + 'GENERATED', + 'GET', + 'GENERAL', + 'GRANT', + 'GROUP', + 'HAVING', + 'HIGH_PRIORITY', + 'HOUR_MICROSECOND', + 'HOUR_MINUTE', + 'HOUR_SECOND', + 'IF', + 'IGNORE', + 'IGNORE_SERVER_IDS', + 'IN', + 'INDEX', + 'INFILE', + 'INNER', + 'INOUT', + 'INSENSITIVE', + 'INSERT', + 'INT', + 'INT1', + 'INT2', + 'INT3', + 'INT4', + 'INT8', + 'INTEGER', + 'INTERSECT', + 'INTERVAL', + 'INTO', + 'IO_AFTER_GTIDS', + 'IO_BEFORE_GTIDS', + 'IS', + 'ITERATE', + 'JOIN', + 'KEY', + 'KEYS', + 'KILL', + 'LEADING', + 'LEAVE', + 'LEFT', + 'LIKE', + 'LIMIT', + 'LINEAR', + 'LINES', + 'LOAD', + 'LOCALTIME', + 'LOCALTIMESTAMP', + 'LOCK', + 'LONG', + 'LONGBLOB', + 'LONGTEXT', + 'LOOP', + 'LOW_PRIORITY', + 'MASTER_BIND', + 'MASTER_HEARTBEAT_PERIOD', + 'MASTER_SSL_VERIFY_SERVER_CERT', + 'MATCH', + 'MAXVALUE', + 'MEDIUMBLOB', + 'MEDIUMINT', + 'MEDIUMTEXT', + 'MIDDLEINT', + 'MINUTE_MICROSECOND', + 'MINUTE_SECOND', + 'MOD', + 'MODIFIES', + 'NATURAL', + 'NO_WRITE_TO_BINLOG', + 'NOT', + 'NULL', + 'NUMERIC', + 'ON', + 'OPTIMIZE', + 'OPTIMIZER_COSTS', + 'OPTION', + 'OPTIONALLY', + 'OR', + 'ORDER', + 'OUT', + 'OUTER', + 'OUTFILE', + 'OVER', + 'PARTITION', + 'PRECISION', + 'PRIMARY', + 'PROCEDURE', + 'PURGE', + 'RANGE', + 'READ', + 'READ_WRITE', + 'READS', + 'REAL', + 'RECURSIVE', + 'REFERENCES', + 'REGEXP', + 'RELEASE', + 'RENAME', + 'REPEAT', + 'REPLACE', + 'REQUIRE', + 'RESIGNAL', + 'RESTRICT', + 'RETURN', + 'RETURNING', + 'REVOKE', + 'RIGHT', + 'RLIKE', + 'ROWS', + 'SCHEMA', + 'SCHEMAS', + 'SECOND_MICROSECOND', + 'SELECT', + 'SENSITIVE', + 'SEPARATOR', + 'SET', + 'SHOW', + 'SIGNAL', + 'SLOW', + 'SMALLINT', + 'SPATIAL', + 'SPECIFIC', + 'SQL', + 'SQL_BIG_RESULT', + 'SQL_CALC_FOUND_ROWS', + 'SQL_SMALL_RESULT', + 'SQLEXCEPTION', + 'SQLSTATE', + 'SQLWARNING', + 'SSL', + 'STARTING', + 'STORED', + 'STRAIGHT_JOIN', + 'TABLE', + 'TERMINATED', + 'THEN', + 'TINYBLOB', + 'TINYINT', + 'TINYTEXT', + 'TO', + 'TRAILING', + 'TRIGGER', + 'TRUE', + 'UNDO', + 'UNION', + 'UNIQUE', + 'UNLOCK', + 'UNSIGNED', + 'UPDATE', + 'USAGE', + 'USE', + 'USING', + 'UTC_DATE', + 'UTC_TIME', + 'UTC_TIMESTAMP', + 'VALUES', + 'VARBINARY', + 'VARCHAR', + 'VARCHARACTER', + 'VARYING', + 'VIRTUAL', + 'WHEN', + 'WHERE', + 'WHILE', + 'WINDOW', + 'WITH', + 'WRITE', + 'XOR', + 'YEAR_MONTH', + 'ZEROFILL', + ]; + } +} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php index ae2f5bc73..ef7c389ed 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php @@ -43,7 +43,7 @@ public function getName() */ protected function getKeywords() { - return array( + return [ 'ACCESSIBLE', 'ADD', 'ALL', @@ -279,6 +279,6 @@ protected function getKeywords() 'XOR', 'YEAR_MONTH', 'ZEROFILL', - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php index fad3aa153..8ba9b4d74 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php @@ -42,7 +42,7 @@ public function getName() */ protected function getKeywords() { - return array( + return [ 'ACCESSIBLE', 'ADD', 'ALL', @@ -282,6 +282,6 @@ protected function getKeywords() 'XOR', 'YEAR_MONTH', 'ZEROFILL', - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php index b37fdad3d..4914d2e9d 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php @@ -42,7 +42,7 @@ public function getName() */ protected function getKeywords() { - return array( + return [ 'ACCESS', 'ELSE', 'MODIFY', @@ -156,6 +156,6 @@ protected function getKeywords() 'ROWS', 'WITH', 'RANGE', - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php new file mode 100644 index 000000000..3402db190 --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php @@ -0,0 +1,19 @@ +keywordLists as $keywordList) { if ($keywordList->isKeyword($word)) { $keywordLists[] = $keywordList->getName(); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php index 12eacbf9b..6e67ee2e6 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere11Keywords.php @@ -19,6 +19,9 @@ namespace Doctrine\DBAL\Platforms\Keywords; +use function array_diff; +use function array_merge; + /** * SAP Sybase SQL Anywhere 11 reserved keywords list. * @@ -44,12 +47,12 @@ protected function getKeywords() return array_merge( array_diff( parent::getKeywords(), - array('IQ') + ['IQ'] ), - array( + [ 'MERGE', 'OPENSTRING' - ) + ] ); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere12Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere12Keywords.php index 22e04893e..ebc38bf84 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere12Keywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere12Keywords.php @@ -19,6 +19,9 @@ namespace Doctrine\DBAL\Platforms\Keywords; +use function array_diff; +use function array_merge; + /** * SAP Sybase SQL Anywhere 12 reserved keywords list. * @@ -44,21 +47,21 @@ protected function getKeywords() return array_merge( array_diff( parent::getKeywords(), - array( + [ 'INDEX_LPAREN', 'SYNTAX_ERROR', 'WITH_CUBE', 'WITH_LPAREN', 'WITH_ROLLUP' - ) + ] ), - array( + [ 'DATETIMEOFFSET', 'LIMIT', 'OPENXML', 'SPATIAL', 'TREAT' - ) + ] ); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere16Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere16Keywords.php index 4d78b8410..1ec984e78 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere16Keywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhere16Keywords.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Platforms\Keywords; +use function array_merge; + /** * SAP Sybase SQL Anywhere 16 reserved keywords list. * @@ -43,14 +45,14 @@ protected function getKeywords() { return array_merge( parent::getKeywords(), - array( + [ 'ARRAY', 'JSON', 'ROW', 'ROWTYPE', 'UNNEST', 'VARRAY' - ) + ] ); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php index cabf1e449..9d5ab5db8 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLAnywhereKeywords.php @@ -41,7 +41,7 @@ public function getName() */ protected function getKeywords() { - return array( + return [ 'ADD', 'ALL', 'ALTER', @@ -276,6 +276,6 @@ protected function getKeywords() 'WORK', 'WRITETEXT', 'XML' - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php index 3a7434910..02b465620 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php @@ -19,6 +19,9 @@ namespace Doctrine\DBAL\Platforms\Keywords; +use function array_diff; +use function array_merge; + /** * Microsoft SQL Server 2005 reserved keyword dictionary. * @@ -44,13 +47,13 @@ public function getName() */ protected function getKeywords() { - return array_merge(array_diff(parent::getKeywords(), array('DUMMY')), array( + return array_merge(array_diff(parent::getKeywords(), ['DUMMY']), [ 'EXTERNAL', 'PIVOT', 'REVERT', 'SECURITYAUDIT', 'TABLESAMPLE', 'UNPIVOT' - )); + ]); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php index 38556b505..b5c38610a 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Platforms\Keywords; +use function array_merge; + /** * Microsoft SQL Server 2008 reserved keyword dictionary. * @@ -44,8 +46,8 @@ public function getName() */ protected function getKeywords() { - return array_merge(parent::getKeywords(), array( + return array_merge(parent::getKeywords(), [ 'MERGE' - )); + ]); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php index ada1c026b..bf621bff8 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Platforms\Keywords; +use function array_merge; + /** * Microsoft SQL Server 2012 reserved keyword dictionary. * @@ -44,12 +46,12 @@ public function getName() */ protected function getKeywords() { - return array_merge(parent::getKeywords(), array( + return array_merge(parent::getKeywords(), [ 'SEMANTICKEYPHRASETABLE', 'SEMANTICSIMILARITYDETAILSTABLE', 'SEMANTICSIMILARITYTABLE', 'TRY_CONVERT', 'WITHIN GROUP' - )); + ]); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php index fb43d2d53..5b65cbc87 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php @@ -46,7 +46,7 @@ public function getName() */ protected function getKeywords() { - return array( + return [ 'ADD', 'ALL', 'ALTER', @@ -226,6 +226,6 @@ protected function getKeywords() 'WHILE', 'WITH', 'WRITETEXT' - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php index a162d3d53..f240aa644 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php @@ -41,7 +41,7 @@ public function getName() */ protected function getKeywords() { - return array( + return [ 'ABORT', 'ACTION', 'ADD', @@ -163,6 +163,6 @@ protected function getKeywords() 'VIRTUAL', 'WHEN', 'WHERE' - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php new file mode 100644 index 000000000..1955fb059 --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php @@ -0,0 +1,69 @@ +. + */ + +namespace Doctrine\DBAL\Platforms; + +use Doctrine\DBAL\Types\Type; + +/** + * Provides the behavior, features and SQL dialect of the MariaDB 10.2 (10.2.7 GA) database platform. + * + * Note: Should not be used with versions prior ro 10.2.7. + * + * @author Vanvelthem Sébastien + * @link www.doctrine-project.org + */ +final class MariaDb1027Platform extends MySqlPlatform +{ + /** + * {@inheritdoc} + */ + public function hasNativeJsonType() : bool + { + return false; + } + + /** + * {@inheritdoc} + * + * @link https://mariadb.com/kb/en/library/json-data-type/ + */ + public function getJsonTypeDeclarationSQL(array $field) : string + { + return 'LONGTEXT'; + } + + /** + * {@inheritdoc} + */ + protected function getReservedKeywordsClass() : string + { + return Keywords\MariaDb102Keywords::class; + } + + /** + * {@inheritdoc} + */ + protected function initializeDoctrineTypeMappings() : void + { + parent::initializeDoctrineTypeMappings(); + + $this->doctrineTypeMapping['json'] = Type::JSON; + } +} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php index 44132a743..5b2328b2e 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySQL57Platform.php @@ -54,7 +54,7 @@ public function getJsonTypeDeclarationSQL(array $field) */ protected function getPreAlterTableRenameIndexForeignKeySQL(TableDiff $diff) { - return array(); + return []; } /** @@ -62,7 +62,7 @@ protected function getPreAlterTableRenameIndexForeignKeySQL(TableDiff $diff) */ protected function getPostAlterTableRenameIndexForeignKeySQL(TableDiff $diff) { - return array(); + return []; } /** @@ -70,9 +70,9 @@ protected function getPostAlterTableRenameIndexForeignKeySQL(TableDiff $diff) */ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) { - return array( + return [ 'ALTER TABLE ' . $tableName . ' RENAME INDEX ' . $oldIndexName . ' TO ' . $index->getQuotedName($this) - ); + ]; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index eb4b4ff53..e318c2650 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -19,13 +19,28 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Connection; use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\TextType; +use function array_diff_key; +use function array_merge; +use function array_unique; +use function array_values; +use function count; +use function func_get_args; +use function implode; +use function in_array; +use function is_numeric; +use function is_string; +use function join; +use function sprintf; +use function str_replace; +use function strtoupper; +use function trim; /** * The MySqlPlatform provides the behavior, features and SQL dialect of the @@ -51,9 +66,9 @@ class MySqlPlatform extends AbstractPlatform * Adds MySQL-specific LIMIT clause to the query * 18446744073709551615 is 2^64-1 maximum of unsigned BIGINT the biggest limit possible * - * @param string $query - * @param integer $limit - * @param integer $offset + * @param string $query + * @param int $limit + * @param int $offset * * @return string */ @@ -409,7 +424,7 @@ public function getDropDatabaseSQL($name) /** * {@inheritDoc} */ - protected function _getCreateTableSQL($tableName, array $columns, array $options = array()) + protected function _getCreateTableSQL($tableName, array $columns, array $options = []) { $queryFields = $this->getColumnDeclarationListSQL($columns); @@ -485,7 +500,7 @@ private function buildTableOptions(array $options) return $options['table_options']; } - $tableOptions = array(); + $tableOptions = []; // Charset if ( ! isset($options['charset'])) { @@ -496,7 +511,7 @@ private function buildTableOptions(array $options) // Collate if ( ! isset($options['collate'])) { - $options['collate'] = 'utf8_unicode_ci'; + $options['collate'] = $options['charset'] . '_unicode_ci'; } $tableOptions[] = sprintf('COLLATE %s', $options['collate']); @@ -547,8 +562,8 @@ private function buildPartitionOptions(array $options) */ public function getAlterTableSQL(TableDiff $diff) { - $columnSql = array(); - $queryParts = array(); + $columnSql = []; + $queryParts = []; if ($diff->newName !== false) { $queryParts[] = 'RENAME TO ' . $diff->getNewName()->getQuotedName($this); } @@ -611,8 +626,8 @@ public function getAlterTableSQL(TableDiff $diff) unset($diff->addedIndexes['primary']); } - $sql = array(); - $tableSql = array(); + $sql = []; + $tableSql = []; if ( ! $this->onSchemaAlterTable($diff, $tableSql)) { if (count($queryParts) > 0) { @@ -633,7 +648,7 @@ public function getAlterTableSQL(TableDiff $diff) */ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) { - $sql = array(); + $sql = []; $table = $diff->getName($this)->getQuotedName($this); foreach ($diff->changedIndexes as $changedIndex) { @@ -660,8 +675,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) $sql[] = $query; - unset($diff->removedIndexes[$remKey]); - unset($diff->addedIndexes[$addKey]); + unset($diff->removedIndexes[$remKey], $diff->addedIndexes[$addKey]); break; } @@ -676,9 +690,9 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) // Suppress foreign key constraint propagation on non-supporting engines. if ('INNODB' !== $engine) { - $diff->addedForeignKeys = array(); - $diff->changedForeignKeys = array(); - $diff->removedForeignKeys = array(); + $diff->addedForeignKeys = []; + $diff->changedForeignKeys = []; + $diff->removedForeignKeys = []; } $sql = array_merge( @@ -699,7 +713,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) */ private function getPreAlterTableAlterPrimaryKeySQL(TableDiff $diff, Index $index) { - $sql = array(); + $sql = []; if (! $index->isPrimary() || ! $diff->fromTable instanceof Table) { return $sql; @@ -736,7 +750,7 @@ private function getPreAlterTableAlterPrimaryKeySQL(TableDiff $diff, Index $inde */ private function getPreAlterTableAlterIndexForeignKeySQL(TableDiff $diff) { - $sql = array(); + $sql = []; $table = $diff->getName($this)->getQuotedName($this); foreach ($diff->changedIndexes as $changedIndex) { @@ -772,7 +786,7 @@ private function getPreAlterTableAlterIndexForeignKeySQL(TableDiff $diff) */ protected function getPreAlterTableRenameIndexForeignKeySQL(TableDiff $diff) { - $sql = array(); + $sql = []; $tableName = $diff->getName($this)->getQuotedName($this); foreach ($this->getRemainingForeignKeyConstraintsRequiringRenamedIndexes($diff) as $foreignKey) { @@ -797,10 +811,10 @@ protected function getPreAlterTableRenameIndexForeignKeySQL(TableDiff $diff) private function getRemainingForeignKeyConstraintsRequiringRenamedIndexes(TableDiff $diff) { if (empty($diff->renamedIndexes) || ! $diff->fromTable instanceof Table) { - return array(); + return []; } - $foreignKeys = array(); + $foreignKeys = []; /** @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] $remainingForeignKeys */ $remainingForeignKeys = array_diff_key( $diff->fromTable->getForeignKeys(), @@ -838,7 +852,7 @@ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) */ protected function getPostAlterTableRenameIndexForeignKeySQL(TableDiff $diff) { - $sql = array(); + $sql = []; $tableName = (false !== $diff->newName) ? $diff->getNewName()->getQuotedName($this) : $diff->getName($this)->getQuotedName($this); @@ -1015,7 +1029,7 @@ public function getReadLockSQL() */ protected function initializeDoctrineTypeMappings() { - $this->doctrineTypeMapping = array( + $this->doctrineTypeMapping = [ 'tinyint' => 'boolean', 'smallint' => 'smallint', 'mediumint' => 'integer', @@ -1046,7 +1060,7 @@ protected function initializeDoctrineTypeMappings() 'binary' => 'binary', 'varbinary' => 'binary', 'set' => 'simple_array', - ); + ]; } /** @@ -1137,6 +1151,6 @@ public function quoteStringLiteral($str) */ public function getDefaultTransactionIsolationLevel() { - return Connection::TRANSACTION_REPEATABLE_READ; + return TransactionIsolationLevel::REPEATABLE_READ; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index a0b01a853..1abc6cba1 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -26,7 +26,19 @@ use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\BinaryType; +use function array_merge; +use function count; +use function explode; +use function implode; +use function preg_match; +use function sprintf; +use function str_replace; +use function strlen; +use function strpos; +use function strtoupper; +use function substr; /** * OraclePlatform. @@ -47,7 +59,7 @@ class OraclePlatform extends AbstractPlatform * * @throws DBALException */ - static public function assertValidIdentifier($identifier) + public static function assertValidIdentifier($identifier) { if ( ! preg_match('(^(([a-zA-Z]{1}[a-zA-Z0-9_$#]{0,})|("[^"]+"))$)', $identifier)) { throw new DBALException("Invalid Oracle identifier"); @@ -106,15 +118,15 @@ public function getGuidExpression() protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) { switch ($unit) { - case self::DATE_INTERVAL_UNIT_MONTH: - case self::DATE_INTERVAL_UNIT_QUARTER: - case self::DATE_INTERVAL_UNIT_YEAR: + case DateIntervalUnit::MONTH: + case DateIntervalUnit::QUARTER: + case DateIntervalUnit::YEAR: switch ($unit) { - case self::DATE_INTERVAL_UNIT_QUARTER: + case DateIntervalUnit::QUARTER: $interval *= 3; break; - case self::DATE_INTERVAL_UNIT_YEAR: + case DateIntervalUnit::YEAR: $interval *= 12; break; } @@ -125,19 +137,19 @@ protected function getDateArithmeticIntervalExpression($date, $operator, $interv $calculationClause = ''; switch ($unit) { - case self::DATE_INTERVAL_UNIT_SECOND: + case DateIntervalUnit::SECOND: $calculationClause = '/24/60/60'; break; - case self::DATE_INTERVAL_UNIT_MINUTE: + case DateIntervalUnit::MINUTE: $calculationClause = '/24/60'; break; - case self::DATE_INTERVAL_UNIT_HOUR: + case DateIntervalUnit::HOUR: $calculationClause = '/24'; break; - case self::DATE_INTERVAL_UNIT_WEEK: + case DateIntervalUnit::WEEK: $calculationClause = '*7'; break; } @@ -244,12 +256,12 @@ public function getSetTransactionIsolationSQL($level) protected function _getTransactionIsolationLevelSQL($level) { switch ($level) { - case \Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED: + case TransactionIsolationLevel::READ_UNCOMMITTED: return 'READ UNCOMMITTED'; - case \Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED: + case TransactionIsolationLevel::READ_COMMITTED: return 'READ COMMITTED'; - case \Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ: - case \Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE: + case TransactionIsolationLevel::REPEATABLE_READ: + case TransactionIsolationLevel::SERIALIZABLE: return 'SERIALIZABLE'; default: return parent::_getTransactionIsolationLevelSQL($level); @@ -384,11 +396,11 @@ public function getListSequencesSQL($database) /** * {@inheritDoc} */ - protected function _getCreateTableSQL($table, array $columns, array $options = array()) + protected function _getCreateTableSQL($table, array $columns, array $options = []) { - $indexes = isset($options['indexes']) ? $options['indexes'] : array(); - $options['indexes'] = array(); - $sql = parent::_getCreateTableSQL($table, $columns, $options); + $indexes = $options['indexes'] ?? []; + $options['indexes'] = []; + $sql = parent::_getCreateTableSQL($table, $columns, $options); foreach ($columns as $name => $column) { if (isset($column['sequence'])) { @@ -483,9 +495,9 @@ public function getDropViewSQL($name) } /** - * @param string $name - * @param string $table - * @param integer $start + * @param string $name + * @param string $table + * @param int $start * * @return array */ @@ -499,11 +511,11 @@ public function getCreateAutoincrementSql($name, $table, $start = 1) $quotedName = $nameIdentifier->getQuotedName($this); $unquotedName = $nameIdentifier->getName(); - $sql = array(); + $sql = []; $autoincrementIdentifierName = $this->getAutoincrementIdentifierName($tableIdentifier); - $idx = new Index($autoincrementIdentifierName, array($quotedName), true, true); + $idx = new Index($autoincrementIdentifierName, [$quotedName], true, true); $sql[] = 'DECLARE constraints_Count NUMBER; @@ -562,11 +574,11 @@ public function getDropAutoincrementSql($table) '' ); - return array( + return [ 'DROP TRIGGER ' . $autoincrementIdentifierName, $this->getDropSequenceSQL($identitySequenceName), $this->getDropConstraintSQL($autoincrementIdentifierName, $table->getQuotedName($this)), - ); + ]; } /** @@ -764,11 +776,11 @@ public function getDropDatabaseSQL($database) */ public function getAlterTableSQL(TableDiff $diff) { - $sql = array(); - $commentsSQL = array(); - $columnSql = array(); + $sql = []; + $commentsSQL = []; + $columnSql = []; - $fields = array(); + $fields = []; foreach ($diff->addedColumns as $column) { if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { @@ -789,7 +801,7 @@ public function getAlterTableSQL(TableDiff $diff) $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ADD (' . implode(', ', $fields) . ')'; } - $fields = array(); + $fields = []; foreach ($diff->changedColumns as $columnDiff) { if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) { continue; @@ -847,7 +859,7 @@ public function getAlterTableSQL(TableDiff $diff) ' RENAME COLUMN ' . $oldColumnName->getQuotedName($this) .' TO ' . $column->getQuotedName($this); } - $fields = array(); + $fields = []; foreach ($diff->removedColumns as $column) { if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) { continue; @@ -860,7 +872,7 @@ public function getAlterTableSQL(TableDiff $diff) $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' DROP (' . implode(', ', $fields).')'; } - $tableSql = array(); + $tableSql = []; if ( ! $this->onSchemaAlterTable($diff, $tableSql)) { $sql = array_merge($sql, $commentsSQL); @@ -918,7 +930,7 @@ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) $oldIndexName = $schema . '.' . $oldIndexName; } - return array('ALTER INDEX ' . $oldIndexName . ' RENAME TO ' . $index->getQuotedName($this)); + return ['ALTER INDEX ' . $oldIndexName . ' RENAME TO ' . $index->getQuotedName($this)]; } /** @@ -986,7 +998,7 @@ protected function doModifyLimitQuery($query, $limit, $offset = null) $query .= " FROM dual"; } - $columns = array('a.*'); + $columns = ['a.*']; if ($offset > 0) { $columns[] = 'ROWNUM AS doctrine_rownum'; @@ -1116,7 +1128,7 @@ public function getDummySelectSQL() */ protected function initializeDoctrineTypeMappings() { - $this->doctrineTypeMapping = array( + $this->doctrineTypeMapping = [ 'integer' => 'integer', 'number' => 'integer', 'pls_integer' => 'boolean', @@ -1140,7 +1152,7 @@ protected function initializeDoctrineTypeMappings() 'rowid' => 'string', 'urowid' => 'string', 'blob' => 'blob', - ); + ]; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php new file mode 100644 index 000000000..0d379f2fb --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php @@ -0,0 +1,33 @@ +quoteStringLiteral($database) . " + AND sequence_schema NOT LIKE 'pg\_%' + AND sequence_schema != 'information_schema'"; + } +} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php index 1ba03153b..94d810483 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Platforms; +use function explode; + /** * Provides the behavior, features and SQL dialect of the PostgreSQL 9.1 database platform. * diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index bc9fe2fa0..61f6e09c4 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -29,6 +29,23 @@ use Doctrine\DBAL\Types\BigIntType; use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\IntegerType; +use Doctrine\DBAL\Types\Type; +use function array_diff; +use function array_merge; +use function array_unique; +use function array_values; +use function count; +use function explode; +use function implode; +use function in_array; +use function is_array; +use function is_bool; +use function is_numeric; +use function is_string; +use function str_replace; +use function strpos; +use function strtolower; +use function trim; /** * PostgreSqlPlatform. @@ -49,24 +66,24 @@ class PostgreSqlPlatform extends AbstractPlatform /** * @var array PostgreSQL booleans literals */ - private $booleanLiterals = array( - 'true' => array( + private $booleanLiterals = [ + 'true' => [ 't', 'true', 'y', 'yes', 'on', '1' - ), - 'false' => array( + ], + 'false' => [ 'f', 'false', 'n', 'no', 'off', '0' - ) - ); + ] + ]; /** * PostgreSQL has different behavior with some drivers @@ -128,9 +145,9 @@ public function getLocateExpression($str, $substr, $startPos = false) */ protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) { - if (self::DATE_INTERVAL_UNIT_QUARTER === $unit) { + if ($unit === DateIntervalUnit::QUARTER) { $interval *= 3; - $unit = self::DATE_INTERVAL_UNIT_MONTH; + $unit = DateIntervalUnit::MONTH; } return "(" . $date ." " . $operator . " (" . $interval . " || ' " . $unit . "')::interval)"; @@ -488,9 +505,9 @@ public function getAdvancedForeignKeyOptionsSQL(\Doctrine\DBAL\Schema\ForeignKey */ public function getAlterTableSQL(TableDiff $diff) { - $sql = array(); - $commentsSQL = array(); - $columnSql = array(); + $sql = []; + $commentsSQL = []; + $columnSql = []; foreach ($diff->addedColumns as $column) { if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { @@ -536,12 +553,16 @@ public function getAlterTableSQL(TableDiff $diff) if ($columnDiff->hasChanged('type') || $columnDiff->hasChanged('precision') || $columnDiff->hasChanged('scale') || $columnDiff->hasChanged('fixed')) { $type = $column->getType(); + // SERIAL/BIGSERIAL are not "real" types and we can't alter a column to that type + $columnDefinition = $column->toArray(); + $columnDefinition['autoincrement'] = false; + // here was a server version check before, but DBAL API does not support this anymore. - $query = 'ALTER ' . $oldColumnName . ' TYPE ' . $type->getSQLDeclaration($column->toArray(), $this); + $query = 'ALTER ' . $oldColumnName . ' TYPE ' . $type->getSQLDeclaration($columnDefinition, $this); $sql[] = 'ALTER TABLE ' . $diff->getName($this)->getQuotedName($this) . ' ' . $query; } - if ($columnDiff->hasChanged('default') || $columnDiff->hasChanged('type')) { + if ($columnDiff->hasChanged('default') || $this->typeChangeBreaksDefaultValue($columnDiff)) { $defaultClause = null === $column->getDefault() ? ' DROP DEFAULT' : ' SET' . $this->getDefaultValueDeclarationSQL($column->toArray()); @@ -595,7 +616,7 @@ public function getAlterTableSQL(TableDiff $diff) ' RENAME COLUMN ' . $oldColumnName->getQuotedName($this) . ' TO ' . $column->getQuotedName($this); } - $tableSql = array(); + $tableSql = []; if ( ! $this->onSchemaAlterTable($diff, $tableSql)) { $sql = array_merge($sql, $commentsSQL); @@ -626,7 +647,7 @@ public function getAlterTableSQL(TableDiff $diff) * * @param ColumnDiff $columnDiff The column diff to check against. * - * @return boolean True if the given column diff is an unchanged binary type column, false otherwise. + * @return bool True if the given column diff is an unchanged binary type column, false otherwise. */ private function isUnchangedBinaryColumn(ColumnDiff $columnDiff) { @@ -645,14 +666,14 @@ private function isUnchangedBinaryColumn(ColumnDiff $columnDiff) return false; } - return count(array_diff($columnDiff->changedProperties, array('type', 'length', 'fixed'))) === 0; + return count(array_diff($columnDiff->changedProperties, ['type', 'length', 'fixed'])) === 0; } if ($columnDiff->hasChanged('type')) { return false; } - return count(array_diff($columnDiff->changedProperties, array('length', 'fixed'))) === 0; + return count(array_diff($columnDiff->changedProperties, ['length', 'fixed'])) === 0; } /** @@ -665,7 +686,7 @@ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) $oldIndexName = $schema . '.' . $oldIndexName; } - return array('ALTER INDEX ' . $oldIndexName . ' RENAME TO ' . $index->getQuotedName($this)); + return ['ALTER INDEX ' . $oldIndexName . ' RENAME TO ' . $index->getQuotedName($this)]; } /** @@ -687,10 +708,10 @@ public function getCommentOnColumnSQL($tableName, $columnName, $comment) public function getCreateSequenceSQL(Sequence $sequence) { return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) . - ' INCREMENT BY ' . $sequence->getAllocationSize() . - ' MINVALUE ' . $sequence->getInitialValue() . - ' START ' . $sequence->getInitialValue() . - $this->getSequenceCacheSQL($sequence); + ' INCREMENT BY ' . $sequence->getAllocationSize() . + ' MINVALUE ' . $sequence->getInitialValue() . + ' START ' . $sequence->getInitialValue() . + $this->getSequenceCacheSQL($sequence); } /** @@ -699,8 +720,8 @@ public function getCreateSequenceSQL(Sequence $sequence) public function getAlterSequenceSQL(Sequence $sequence) { return 'ALTER SEQUENCE ' . $sequence->getQuotedName($this) . - ' INCREMENT BY ' . $sequence->getAllocationSize() . - $this->getSequenceCacheSQL($sequence); + ' INCREMENT BY ' . $sequence->getAllocationSize() . + $this->getSequenceCacheSQL($sequence); } /** @@ -750,7 +771,7 @@ public function getDropForeignKeySQL($foreignKey, $table) /** * {@inheritDoc} */ - protected function _getCreateTableSQL($tableName, array $columns, array $options = array()) + protected function _getCreateTableSQL($tableName, array $columns, array $options = []) { $queryFields = $this->getColumnDeclarationListSQL($columns); @@ -910,7 +931,7 @@ public function getSequenceNextValSQL($sequenceName) public function getSetTransactionIsolationSQL($level) { return 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ' - . $this->_getTransactionIsolationLevelSQL($level); + . $this->_getTransactionIsolationLevelSQL($level); } /** @@ -1015,7 +1036,7 @@ protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) { return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)') - : ($length ? 'VARCHAR(' . $length . ')' : 'VARCHAR(255)'); + : ($length ? 'VARCHAR(' . $length . ')' : 'VARCHAR(255)'); } /** @@ -1096,7 +1117,7 @@ public function getReadLockSQL() */ protected function initializeDoctrineTypeMappings() { - $this->doctrineTypeMapping = array( + $this->doctrineTypeMapping = [ 'smallint' => 'smallint', 'int2' => 'smallint', 'serial' => 'integer', @@ -1136,7 +1157,7 @@ protected function initializeDoctrineTypeMappings() 'year' => 'date', 'uuid' => 'guid', 'bytea' => 'blob', - ); + ]; } /** @@ -1204,6 +1225,31 @@ public function getDefaultValueDeclarationSQL($field) private function isSerialField(array $field) : bool { return $field['autoincrement'] ?? false === true && isset($field['type']) - && ($field['type'] instanceof IntegerType || $field['type'] instanceof BigIntType); + && $this->isNumericType($field['type']); + } + + /** + * Check whether the type of a column is changed in a way that invalidates the default value for the column + * + * @param ColumnDiff $columnDiff + * @return bool + */ + private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff) : bool + { + if (! $columnDiff->fromColumn) { + return $columnDiff->hasChanged('type'); + } + + $oldTypeIsNumeric = $this->isNumericType($columnDiff->fromColumn->getType()); + $newTypeIsNumeric = $this->isNumericType($columnDiff->column->getType()); + + // default should not be changed when switching between numeric types and the default comes from a sequence + return $columnDiff->hasChanged('type') + && ! ($oldTypeIsNumeric && $newTypeIsNumeric && $columnDiff->column->getAutoincrement()); + } + + private function isNumericType(Type $type) : bool + { + return $type instanceof IntegerType || $type instanceof BigIntType; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php index a55918bc6..98bc4689a 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -19,7 +19,6 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Schema\Column; @@ -30,6 +29,21 @@ use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\TransactionIsolationLevel; +use function array_merge; +use function array_unique; +use function array_values; +use function count; +use function explode; +use function func_get_args; +use function get_class; +use function implode; +use function is_string; +use function preg_replace; +use function strlen; +use function strpos; +use function strtoupper; +use function substr; /** * The SQLAnywherePlatform provides the behavior, features and SQL dialect of the @@ -42,19 +56,19 @@ class SQLAnywherePlatform extends AbstractPlatform { /** - * @var integer + * @var int */ const FOREIGN_KEY_MATCH_SIMPLE = 1; /** - * @var integer + * @var int */ const FOREIGN_KEY_MATCH_FULL = 2; /** - * @var integer + * @var int */ const FOREIGN_KEY_MATCH_SIMPLE_UNIQUE = 129; /** - * @var integer + * @var int */ const FOREIGN_KEY_MATCH_FULL_UNIQUE = 130; @@ -127,11 +141,11 @@ public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey */ public function getAlterTableSQL(TableDiff $diff) { - $sql = array(); - $columnSql = array(); - $commentsSQL = array(); - $tableSql = array(); - $alterClauses = array(); + $sql = []; + $columnSql = []; + $commentsSQL = []; + $tableSql = []; + $alterClauses = []; /** @var \Doctrine\DBAL\Schema\Column $column */ foreach ($diff->addedColumns as $column) { @@ -303,6 +317,8 @@ protected function getAlterTableChangeColumnClause(ColumnDiff $columnDiff) return $columnAlterationClause; } + + return null; } /** @@ -531,7 +547,7 @@ public function getDateTypeDeclarationSQL(array $fieldDeclaration) */ public function getDefaultTransactionIsolationLevel() { - return Connection::TRANSACTION_READ_UNCOMMITTED; + return TransactionIsolationLevel::READ_UNCOMMITTED; } /** @@ -626,7 +642,7 @@ public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey /** * Returns foreign key MATCH clause for given type. * - * @param integer $type The foreign key match type + * @param int $type The foreign key match type * * @return string * @@ -1101,13 +1117,13 @@ public function getTimeTypeDeclarationSQL(array $fieldDeclaration) /** * {@inheritdoc} */ - public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = false) + public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = false) { if ( ! $char) { switch ($pos) { - case self::TRIM_LEADING: + case TrimMode::LEADING: return $this->getLtrimExpression($str); - case self::TRIM_TRAILING: + case TrimMode::TRAILING: return $this->getRtrimExpression($str); default: return 'TRIM(' . $str . ')'; @@ -1117,9 +1133,9 @@ public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = f $pattern = "'%[^' + $char + ']%'"; switch ($pos) { - case self::TRIM_LEADING: + case TrimMode::LEADING: return 'SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))'; - case self::TRIM_TRAILING: + case TrimMode::TRAILING: return 'REVERSE(SUBSTR(REVERSE(' . $str . '), PATINDEX(' . $pattern . ', REVERSE(' . $str . '))))'; default: return @@ -1221,10 +1237,10 @@ protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) /** * {@inheritdoc} */ - protected function _getCreateTableSQL($tableName, array $columns, array $options = array()) + protected function _getCreateTableSQL($tableName, array $columns, array $options = []) { $columnListSql = $this->getColumnDeclarationListSQL($columns); - $indexSql = array(); + $indexSql = []; if ( ! empty($options['uniqueConstraints'])) { foreach ((array) $options['uniqueConstraints'] as $name => $definition) { @@ -1264,7 +1280,7 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options $query .= ')'; - return array_merge(array($query), $indexSql); + return array_merge([$query], $indexSql); } /** @@ -1273,13 +1289,13 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options protected function _getTransactionIsolationLevelSQL($level) { switch ($level) { - case Connection::TRANSACTION_READ_UNCOMMITTED: + case TransactionIsolationLevel::READ_UNCOMMITTED: return 0; - case Connection::TRANSACTION_READ_COMMITTED: + case TransactionIsolationLevel::READ_COMMITTED: return 1; - case Connection::TRANSACTION_REPEATABLE_READ: + case TransactionIsolationLevel::REPEATABLE_READ: return 2; - case Connection::TRANSACTION_SERIALIZABLE: + case TransactionIsolationLevel::SERIALIZABLE: return 3; default: throw new \InvalidArgumentException('Invalid isolation level:' . $level); @@ -1419,9 +1435,9 @@ protected function getCreateIndexSQLFlags(Index $index) */ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) { - return array( + return [ 'ALTER INDEX ' . $oldIndexName . ' ON ' . $tableName . ' RENAME TO ' . $index->getQuotedName($this) - ); + ]; } /** @@ -1447,7 +1463,7 @@ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) */ protected function initializeDoctrineTypeMappings() { - $this->doctrineTypeMapping = array( + $this->doctrineTypeMapping = [ 'char' => 'string', 'long nvarchar' => 'text', 'long varchar' => 'text', @@ -1486,6 +1502,6 @@ protected function initializeDoctrineTypeMappings() 'long binary' => 'blob', 'uniqueidentifier' => 'guid', 'varbinary' => 'binary', - ); + ]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php index d9f308567..b9a672e6c 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php @@ -27,6 +27,16 @@ */ class SQLServer2008Platform extends SQLServer2005Platform { + /** + * {@inheritDoc} + */ + public function getListTablesSQL() + { + // "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams + // Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication + return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name"; + } + /** * {@inheritDoc} */ @@ -116,4 +126,9 @@ protected function getReservedKeywordsClass() { return Keywords\SQLServer2008Keywords::class; } + + protected function getLikeWildcardCharacters() : string + { + return parent::getLikeWildcardCharacters() . '[]^'; + } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php index 4cdff77bf..df523ca76 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php @@ -20,6 +20,10 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Schema\Sequence; +use const PREG_OFFSET_CAPTURE; +use function preg_match; +use function preg_match_all; +use function substr_count; /** * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2012 version. @@ -116,7 +120,7 @@ protected function doModifyLimitQuery($query, $limit, $offset = null) // Queries using OFFSET... FETCH MUST have an ORDER BY clause // Find the position of the last instance of ORDER BY and ensure it is not within a parenthetical statement // but can be in a newline - $matches = array(); + $matches = []; $matchesCount = preg_match_all("/[\\s]+order\\s+by\\s/im", $query, $matches, PREG_OFFSET_CAPTURE); $orderByPos = false; if ($matchesCount > 0) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index 08a454c5b..3531afb98 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -27,6 +27,32 @@ use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Types; +use function array_merge; +use function array_unique; +use function array_values; +use function count; +use function crc32; +use function dechex; +use function explode; +use function func_get_args; +use function implode; +use function is_array; +use function is_bool; +use function is_null; +use function is_numeric; +use function is_string; +use function preg_match; +use function preg_replace; +use function sprintf; +use function str_replace; +use function stripos; +use function stristr; +use function strlen; +use function strpos; +use function strtoupper; +use function substr; +use function substr_count; /** * The SQLServerPlatform provides the behavior, features and SQL dialect of the @@ -231,10 +257,10 @@ public function getDropIndexSQL($index, $table = null) /** * {@inheritDoc} */ - protected function _getCreateTableSQL($tableName, array $columns, array $options = array()) + protected function _getCreateTableSQL($tableName, array $columns, array $options = []) { - $defaultConstraintsSql = array(); - $commentsSql = array(); + $defaultConstraintsSql = []; + $commentsSql = []; // @todo does other code breaks because of this? // force primary keys to be not null @@ -327,13 +353,22 @@ public function getCreatePrimaryKeySQL(Index $index, $table) */ protected function getCreateColumnCommentSQL($tableName, $columnName, $comment) { + if (strpos($tableName, '.') !== false) { + [$schemaSQL, $tableSQL] = explode('.', $tableName); + $schemaSQL = $this->quoteStringLiteral($schemaSQL); + $tableSQL = $this->quoteStringLiteral($tableSQL); + } else { + $schemaSQL = "'dbo'"; + $tableSQL = $this->quoteStringLiteral($tableName); + } + return $this->getAddExtendedPropertySQL( 'MS_Description', $comment, 'SCHEMA', - 'dbo', + $schemaSQL, 'TABLE', - $tableName, + $tableSQL, 'COLUMN', $columnName ); @@ -419,7 +454,7 @@ protected function getCreateIndexSQLFlags(Index $index) */ private function _appendUniqueConstraintDefinition($sql, Index $index) { - $fields = array(); + $fields = []; foreach ($index->getQuotedColumns($this) as $field) { $fields[] = $field . ' IS NOT NULL'; @@ -433,10 +468,10 @@ private function _appendUniqueConstraintDefinition($sql, Index $index) */ public function getAlterTableSQL(TableDiff $diff) { - $queryParts = array(); - $sql = array(); - $columnSql = array(); - $commentsSql = array(); + $queryParts = []; + $sql = []; + $columnSql = []; + $commentsSql = []; /** @var \Doctrine\DBAL\Schema\Column $column */ foreach ($diff->addedColumns as $column) { @@ -548,7 +583,7 @@ public function getAlterTableSQL(TableDiff $diff) } } - $tableSql = array(); + $tableSql = []; if ($this->onSchemaAlterTable($diff, $tableSql)) { return array_merge($tableSql, $columnSql); @@ -629,7 +664,7 @@ private function getAlterTableDropDefaultConstraintClause($tableName, $columnNam * * @param ColumnDiff $columnDiff The column diff to evaluate. * - * @return boolean True if the column alteration requires dropping its default constraint first, false otherwise. + * @return bool True if the column alteration requires dropping its default constraint first, false otherwise. */ private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff) { @@ -653,11 +688,7 @@ private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff // We need to drop an existing default constraint if the column was // defined with a default value before and the native column type has changed. - if ($columnDiff->hasChanged('type') || $columnDiff->hasChanged('fixed')) { - return true; - } - - return false; + return $columnDiff->hasChanged('type') || $columnDiff->hasChanged('fixed'); } /** @@ -679,13 +710,22 @@ private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff */ protected function getAlterColumnCommentSQL($tableName, $columnName, $comment) { + if (strpos($tableName, '.') !== false) { + [$schemaSQL, $tableSQL] = explode('.', $tableName); + $schemaSQL = $this->quoteStringLiteral($schemaSQL); + $tableSQL = $this->quoteStringLiteral($tableSQL); + } else { + $schemaSQL = "'dbo'"; + $tableSQL = $this->quoteStringLiteral($tableName); + } + return $this->getUpdateExtendedPropertySQL( 'MS_Description', $comment, 'SCHEMA', - 'dbo', + $schemaSQL, 'TABLE', - $tableName, + $tableSQL, 'COLUMN', $columnName ); @@ -709,12 +749,21 @@ protected function getAlterColumnCommentSQL($tableName, $columnName, $comment) */ protected function getDropColumnCommentSQL($tableName, $columnName) { + if (strpos($tableName, '.') !== false) { + [$schemaSQL, $tableSQL] = explode('.', $tableName); + $schemaSQL = $this->quoteStringLiteral($schemaSQL); + $tableSQL = $this->quoteStringLiteral($tableSQL); + } else { + $schemaSQL = "'dbo'"; + $tableSQL = $this->quoteStringLiteral($tableName); + } + return $this->getDropExtendedPropertySQL( 'MS_Description', 'SCHEMA', - 'dbo', + $schemaSQL, 'TABLE', - $tableName, + $tableSQL, 'COLUMN', $columnName ); @@ -725,14 +774,14 @@ protected function getDropColumnCommentSQL($tableName, $columnName) */ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) { - return array( + return [ sprintf( "EXEC sp_RENAME N'%s.%s', N'%s', N'INDEX'", $tableName, $oldIndexName, $index->getQuotedName($this) ) - ); + ]; } /** @@ -1006,15 +1055,15 @@ public function getModExpression($expression1, $expression2) /** * {@inheritDoc} */ - public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = false) + public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = false) { if ( ! $char) { switch ($pos) { - case self::TRIM_LEADING: + case TrimMode::LEADING: $trimFn = 'LTRIM'; break; - case self::TRIM_TRAILING: + case TrimMode::TRAILING: $trimFn = 'RTRIM'; break; @@ -1036,11 +1085,11 @@ public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = f */ $pattern = "'%[^' + $char + ']%'"; - if ($pos == self::TRIM_LEADING) { + if ($pos === TrimMode::LEADING) { return 'stuff(' . $str . ', 1, patindex(' . $pattern . ', ' . $str . ') - 1, null)'; } - if ($pos == self::TRIM_TRAILING) { + if ($pos === TrimMode::TRAILING) { return 'reverse(stuff(reverse(' . $str . '), 1, patindex(' . $pattern . ', reverse(' . $str . ')) - 1, null))'; } @@ -1210,19 +1259,29 @@ public function getBooleanTypeDeclarationSQL(array $field) */ protected function doModifyLimitQuery($query, $limit, $offset = null) { - if ($limit === null) { - return $query; + $where = []; + + if ($offset > 0) { + $where[] = sprintf('doctrine_rownum >= %d', $offset + 1); } - $start = $offset + 1; - $end = $offset + $limit; + if ($limit !== null) { + $where[] = sprintf('doctrine_rownum <= %d', $offset + $limit); + $top = sprintf('TOP %d', $offset + $limit); + } else { + $top = 'TOP 9223372036854775807'; + } + + if (empty($where)) { + return $query; + } // We'll find a SELECT or SELECT distinct and prepend TOP n to it // Even if the TOP n is very large, the use of a CTE will // allow the SQL Server query planner to optimize it so it doesn't // actually scan the entire range covered by the TOP clause. $selectPattern = '/^(\s*SELECT\s+(?:DISTINCT\s+)?)(.*)$/im'; - $replacePattern = sprintf('$1%s $2', "TOP $end"); + $replacePattern = sprintf('$1%s $2', $top); $query = preg_replace($selectPattern, $replacePattern, $query); if (stristr($query, "ORDER BY")) { @@ -1237,10 +1296,9 @@ protected function doModifyLimitQuery($query, $limit, $offset = null) . "SELECT * FROM (" . "SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte" . ") AS doctrine_tbl " - . "WHERE doctrine_rownum BETWEEN %d AND %d ORDER BY doctrine_rownum ASC", + . 'WHERE %s ORDER BY doctrine_rownum ASC', $query, - $start, - $end + implode(' AND ', $where) ); } @@ -1294,8 +1352,8 @@ private function scrubInnerOrderBy($query) /** * Check an ORDER BY clause to see if it is in a TOP N query or subquery. * - * @param string $query The query - * @param int $currentPosition Start position of ORDER BY clause + * @param string $query The query + * @param int $currentPosition Start position of ORDER BY clause * @return bool true if ORDER BY is in a TOP N query, false otherwise */ private function isOrderByInTopNSubquery($query, $currentPosition) @@ -1319,11 +1377,7 @@ private function isOrderByInTopNSubquery($query, $currentPosition) $currentPosition--; } - if (preg_match('/SELECT\s+(DISTINCT\s+)?TOP\s/i', $subQueryBuffer)) { - return true; - } - - return false; + return (bool) preg_match('/SELECT\s+(DISTINCT\s+)?TOP\s/i', $subQueryBuffer); } /** @@ -1413,7 +1467,7 @@ public function getName() */ protected function initializeDoctrineTypeMappings() { - $this->doctrineTypeMapping = array( + $this->doctrineTypeMapping = [ 'bigint' => 'bigint', 'numeric' => 'decimal', 'bit' => 'boolean', @@ -1439,7 +1493,7 @@ protected function initializeDoctrineTypeMappings() 'varbinary' => 'binary', 'image' => 'blob', 'uniqueidentifier' => 'guid', - ); + ]; } /** @@ -1554,17 +1608,17 @@ public function getDefaultValueDeclarationSQL($field) return " DEFAULT '" . $field['default'] . "'"; } - $type = (string) $field['type']; + $type = $field['type']; - if (in_array($type, ['Integer', 'BigInt', 'SmallInt'], true)) { + if ($type instanceof Types\PhpIntegerMappingType) { return " DEFAULT " . $field['default']; } - if (in_array($type, ['DateTime', 'DateTimeTz', 'DateTimeImmutable', 'DateTimeTzImmutable'], true) && $field['default'] === $this->getCurrentTimestampSQL()) { + if ($type instanceof Types\PhpDateTimeMappingType && $field['default'] === $this->getCurrentTimestampSQL()) { return " DEFAULT " . $this->getCurrentTimestampSQL(); } - if ($type === 'Boolean') { + if ($type instanceof Types\BooleanType) { return " DEFAULT '" . $this->convertBooleans($field['default']) . "'"; } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index f52e384d8..251500d06 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -27,6 +27,19 @@ use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\TransactionIsolationLevel; +use Doctrine\DBAL\Types; +use function array_merge; +use function array_unique; +use function array_values; +use function implode; +use function is_numeric; +use function sprintf; +use function sqrt; +use function str_replace; +use function strlen; +use function strpos; +use function strtolower; /** * The SqlitePlatform class describes the specifics and dialects of the SQLite @@ -78,16 +91,16 @@ public function getNowExpression($type = 'timestamp') /** * {@inheritDoc} */ - public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = false) + public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = false) { $trimChar = ($char != false) ? (', ' . $char) : ''; switch ($pos) { - case self::TRIM_LEADING: + case TrimMode::LEADING: $trimFn = 'LTRIM'; break; - case self::TRIM_TRAILING: + case TrimMode::TRAILING: $trimFn = 'RTRIM'; break; @@ -130,24 +143,28 @@ public function getLocateExpression($str, $substr, $startPos = false) protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) { switch ($unit) { - case self::DATE_INTERVAL_UNIT_SECOND: - case self::DATE_INTERVAL_UNIT_MINUTE: - case self::DATE_INTERVAL_UNIT_HOUR: + case DateIntervalUnit::SECOND: + case DateIntervalUnit::MINUTE: + case DateIntervalUnit::HOUR: return "DATETIME(" . $date . ",'" . $operator . $interval . " " . $unit . "')"; default: switch ($unit) { - case self::DATE_INTERVAL_UNIT_WEEK: + case DateIntervalUnit::WEEK: $interval *= 7; - $unit = self::DATE_INTERVAL_UNIT_DAY; + $unit = DateIntervalUnit::DAY; break; - case self::DATE_INTERVAL_UNIT_QUARTER: + case DateIntervalUnit::QUARTER: $interval *= 3; - $unit = self::DATE_INTERVAL_UNIT_MONTH; + $unit = DateIntervalUnit::MONTH; break; } + if (! is_numeric($interval)) { + $interval = "' || " . $interval . " || '"; + } + return "DATE(" . $date . ",'" . $operator . $interval . " " . $unit . "')"; } } @@ -166,11 +183,11 @@ public function getDateDiffExpression($date1, $date2) protected function _getTransactionIsolationLevelSQL($level) { switch ($level) { - case \Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED: + case TransactionIsolationLevel::READ_UNCOMMITTED: return 0; - case \Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED: - case \Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ: - case \Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE: + case TransactionIsolationLevel::READ_COMMITTED: + case TransactionIsolationLevel::REPEATABLE_READ: + case TransactionIsolationLevel::SERIALIZABLE: return 1; default: return parent::_getTransactionIsolationLevelSQL($level); @@ -315,7 +332,7 @@ public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) /** * {@inheritDoc} */ - protected function _getCreateTableSQL($name, array $columns, array $options = array()) + protected function _getCreateTableSQL($name, array $columns, array $options = []) { $name = str_replace('.', '__', $name); $queryFields = $this->getColumnDeclarationListSQL($columns); @@ -525,11 +542,11 @@ public function getTruncateTableSQL($tableName, $cascade = false) /** * User-defined function for Sqlite that is used with PDO::sqliteCreateFunction(). * - * @param integer|float $value + * @param int|float $value * * @return float */ - static public function udfSqrt($value) + public static function udfSqrt($value) { return sqrt($value); } @@ -537,24 +554,24 @@ static public function udfSqrt($value) /** * User-defined function for Sqlite that implements MOD(a, b). * - * @param integer $a - * @param integer $b + * @param int $a + * @param int $b * - * @return integer + * @return int */ - static public function udfMod($a, $b) + public static function udfMod($a, $b) { return ($a % $b); } /** - * @param string $str - * @param string $substr - * @param integer $offset + * @param string $str + * @param string $substr + * @param int $offset * - * @return integer + * @return int */ - static public function udfLocate($str, $substr, $offset = 0) + public static function udfLocate($str, $substr, $offset = 0) { // SQL's LOCATE function works on 1-based positions, while PHP's strpos works on 0-based positions. // So we have to make them compatible if an offset is given. @@ -592,7 +609,7 @@ public function getInlineColumnCommentSQL($comment) */ protected function initializeDoctrineTypeMappings() { - $this->doctrineTypeMapping = array( + $this->doctrineTypeMapping = [ 'boolean' => 'boolean', 'tinyint' => 'boolean', 'smallint' => 'smallint', @@ -625,7 +642,7 @@ protected function initializeDoctrineTypeMappings() 'decimal' => 'decimal', 'numeric' => 'decimal', 'blob' => 'blob', - ); + ]; } /** @@ -645,7 +662,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) throw new DBALException('Sqlite platform requires for alter table the table diff with reference to original table schema'); } - $sql = array(); + $sql = []; foreach ($diff->fromTable->getIndexes() as $index) { if ( ! $index->isPrimary()) { $sql[] = $this->getDropIndexSQL($index, $diff->name); @@ -664,7 +681,7 @@ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) throw new DBALException('Sqlite platform requires for alter table the table diff with reference to original table schema'); } - $sql = array(); + $sql = []; $tableName = $diff->newName ? $diff->getNewName(): $diff->getName($this); foreach ($this->getIndexesInAlteredTable($diff) as $index) { if ($index->isPrimary()) { @@ -799,10 +816,10 @@ public function getAlterTableSQL(TableDiff $diff) $table = clone $fromTable; - $columns = array(); - $oldColumnNames = array(); - $newColumnNames = array(); - $columnSql = array(); + $columns = []; + $oldColumnNames = []; + $newColumnNames = []; + $columnSql = []; foreach ($table->getColumns() as $columnName => $column) { $columnName = strtolower($columnName); @@ -817,9 +834,11 @@ public function getAlterTableSQL(TableDiff $diff) $columnName = strtolower($columnName); if (isset($columns[$columnName])) { - unset($columns[$columnName]); - unset($oldColumnNames[$columnName]); - unset($newColumnNames[$columnName]); + unset( + $columns[$columnName], + $oldColumnNames[$columnName], + $newColumnNames[$columnName] + ); } } @@ -864,8 +883,8 @@ public function getAlterTableSQL(TableDiff $diff) $columns[strtolower($columnName)] = $column; } - $sql = array(); - $tableSql = array(); + $sql = []; + $tableSql = []; if ( ! $this->onSchemaAlterTable($diff, $tableSql)) { $dataTable = new Table('__temp__'.$table->getName()); @@ -904,7 +923,7 @@ private function getSimpleAlterTableSQL(TableDiff $diff) if ( ! $columnDiff->fromColumn instanceof Column || ! $columnDiff->column instanceof Column || ! $columnDiff->column->getAutoincrement() || - ! (string) $columnDiff->column->getType() === 'Integer' + ! $columnDiff->column->getType() instanceof Types\IntegerType ) { continue; } @@ -915,9 +934,9 @@ private function getSimpleAlterTableSQL(TableDiff $diff) continue; } - $fromColumnType = (string) $columnDiff->fromColumn->getType(); + $fromColumnType = $columnDiff->fromColumn->getType(); - if ($fromColumnType === 'SmallInt' || $fromColumnType === 'BigInt') { + if ($fromColumnType instanceof Types\SmallIntType || $fromColumnType instanceof Types\BigIntType) { unset($diff->changedColumns[$oldColumnName]); } } @@ -932,27 +951,27 @@ private function getSimpleAlterTableSQL(TableDiff $diff) $table = new Table($diff->name); - $sql = array(); - $tableSql = array(); - $columnSql = array(); + $sql = []; + $tableSql = []; + $columnSql = []; foreach ($diff->addedColumns as $column) { if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { continue; } - $field = array_merge(array('unique' => null, 'autoincrement' => null, 'default' => null), $column->toArray()); - $type = (string) $field['type']; + $field = array_merge(['unique' => null, 'autoincrement' => null, 'default' => null], $column->toArray()); + $type = $field['type']; switch (true) { case isset($field['columnDefinition']) || $field['autoincrement'] || $field['unique']: - case $type == 'DateTime' && $field['default'] == $this->getCurrentTimestampSQL(): - case $type == 'Date' && $field['default'] == $this->getCurrentDateSQL(): - case $type == 'Time' && $field['default'] == $this->getCurrentTimeSQL(): + case $type instanceof Types\DateTimeType && $field['default'] == $this->getCurrentTimestampSQL(): + case $type instanceof Types\DateType && $field['default'] == $this->getCurrentDateSQL(): + case $type instanceof Types\TimeType && $field['default'] == $this->getCurrentTimeSQL(): return false; } $field['name'] = $column->getQuotedName($this); - if (strtolower($field['type']) == 'string' && $field['length'] === null) { + if ($type instanceof Types\StringType && $field['length'] === null) { $field['length'] = 255; } @@ -976,7 +995,7 @@ private function getSimpleAlterTableSQL(TableDiff $diff) */ private function getColumnNamesInAlteredTable(TableDiff $diff) { - $columns = array(); + $columns = []; foreach ($diff->fromTable->getColumns() as $columnName => $column) { $columns[strtolower($columnName)] = $column->getName(); @@ -1026,7 +1045,7 @@ private function getIndexesInAlteredTable(TableDiff $diff) } $changed = false; - $indexColumns = array(); + $indexColumns = []; foreach ($index->getColumns() as $columnName) { $normalizedColumnName = strtolower($columnName); if ( ! isset($columnNames[$normalizedColumnName])) { @@ -1076,7 +1095,7 @@ private function getForeignKeysInAlteredTable(TableDiff $diff) foreach ($foreignKeys as $key => $constraint) { $changed = false; - $localColumns = array(); + $localColumns = []; foreach ($constraint->getLocalColumns() as $columnName) { $normalizedColumnName = strtolower($columnName); if ( ! isset($columnNames[$normalizedColumnName])) { @@ -1121,11 +1140,11 @@ private function getForeignKeysInAlteredTable(TableDiff $diff) */ private function getPrimaryIndexInAlteredTable(TableDiff $diff) { - $primaryIndex = array(); + $primaryIndex = []; foreach ($this->getIndexesInAlteredTable($diff) as $index) { if ($index->isPrimary()) { - $primaryIndex = array($index->getName() => $index); + $primaryIndex = [$index->getName() => $index]; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/TrimMode.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/TrimMode.php new file mode 100644 index 000000000..0a4b6ea8c --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/TrimMode.php @@ -0,0 +1,20 @@ +portability = $params['portability']; } + if (isset($params['fetch_case']) && $this->portability & self::PORTABILITY_FIX_CASE) { if ($this->_conn instanceof \Doctrine\DBAL\Driver\PDOConnection) { // make use of c-level support for case handling $this->_conn->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']); } else { - $this->case = ($params['fetch_case'] == \PDO::CASE_LOWER) ? CASE_LOWER : CASE_UPPER; + $this->case = ($params['fetch_case'] === ColumnCase::LOWER) ? CASE_LOWER : CASE_UPPER; } } } @@ -97,7 +102,7 @@ public function connect() } /** - * @return integer + * @return int */ public function getPortability() { @@ -105,7 +110,7 @@ public function getPortability() } /** - * @return integer + * @return int */ public function getFetchCase() { @@ -115,7 +120,7 @@ public function getFetchCase() /** * {@inheritdoc} */ - public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null) + public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null) { $stmt = new Statement(parent::executeQuery($query, $params, $types, $qcp), $this); $stmt->setFetchMode($this->defaultFetchMode); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php b/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php index 15741e372..48d8e4ac9 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php @@ -19,7 +19,13 @@ namespace Doctrine\DBAL\Portability; -use PDO; +use Doctrine\DBAL\Driver\StatementIterator; +use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ParameterType; +use function array_change_key_case; +use function is_null; +use function is_string; +use function rtrim; /** * Portability wrapper for a Statement. @@ -31,7 +37,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement { /** - * @var integer + * @var int */ private $portability; @@ -41,14 +47,14 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement private $stmt; /** - * @var integer + * @var int */ private $case; /** - * @var integer + * @var int */ - private $defaultFetchMode = PDO::FETCH_BOTH; + private $defaultFetchMode = FetchMode::MIXED; /** * Wraps Statement and applies portability measures. @@ -66,15 +72,15 @@ public function __construct($stmt, Connection $conn) /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = null, $length = null) + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null) { return $this->stmt->bindParam($column, $variable, $type, $length); } + /** * {@inheritdoc} */ - - public function bindValue($param, $value, $type = null) + public function bindValue($param, $value, $type = ParameterType::STRING) { return $this->stmt->bindValue($param, $value, $type); } @@ -134,9 +140,7 @@ public function setFetchMode($fetchMode, $arg1 = null, $arg2 = null) */ public function getIterator() { - $data = $this->fetchAll(); - - return new \ArrayIterator($data); + return new StatementIterator($this); } /** @@ -148,10 +152,12 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE $row = $this->stmt->fetch($fetchMode); - $row = $this->fixRow($row, - $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM), - !is_null($this->case) && ($fetchMode == PDO::FETCH_ASSOC || $fetchMode == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE) - ); + $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); + $fixCase = ! is_null($this->case) + && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) + && ($this->portability & Connection::PORTABILITY_FIX_CASE); + + $row = $this->fixRow($row, $iterateRow, $fixCase); return $row; } @@ -170,14 +176,17 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n } $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); - $fixCase = !is_null($this->case) && ($fetchMode == PDO::FETCH_ASSOC || $fetchMode == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE); + $fixCase = ! is_null($this->case) + && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) + && ($this->portability & Connection::PORTABILITY_FIX_CASE); + if ( ! $iterateRow && !$fixCase) { return $rows; } - if ($fetchMode === PDO::FETCH_COLUMN) { + if ($fetchMode === FetchMode::COLUMN) { foreach ($rows as $num => $row) { - $rows[$num] = array($row); + $rows[$num] = [$row]; } } @@ -185,7 +194,7 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n $rows[$num] = $this->fixRow($row, $iterateRow, $fixCase); } - if ($fetchMode === PDO::FETCH_COLUMN) { + if ($fetchMode === FetchMode::COLUMN) { foreach ($rows as $num => $row) { $rows[$num] = $row[0]; } @@ -195,9 +204,9 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n } /** - * @param mixed $row - * @param integer $iterateRow - * @param boolean $fixCase + * @param mixed $row + * @param int $iterateRow + * @param bool $fixCase * * @return array */ diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php index 40dae5fcc..00802a44e 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php @@ -19,6 +19,9 @@ namespace Doctrine\DBAL\Query\Expression; +use function count; +use function implode; + /** * Composite expression is responsible to build a group of similar expression. * @@ -75,7 +78,7 @@ public function __construct($type, array $parts = []) */ public function addMultiple(array $parts = []) { - foreach ((array) $parts as $part) { + foreach ($parts as $part) { $this->add($part); } @@ -107,7 +110,7 @@ public function add($part) /** * Retrieves the amount of expressions on composite expression. * - * @return integer + * @return int */ public function count() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php index 2736fcf22..1ee724847 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php @@ -20,6 +20,11 @@ namespace Doctrine\DBAL\Query\Expression; use Doctrine\DBAL\Connection; +use function func_get_arg; +use function func_get_args; +use function func_num_args; +use function implode; +use function sprintf; /** * ExpressionBuilder class is responsible to dynamically create SQL query parts. @@ -254,9 +259,10 @@ public function isNotNull($x) * * @return string */ - public function like($x, $y) + public function like($x, $y/*, ?string $escapeChar = null */) { - return $this->comparison($x, 'LIKE', $y); + return $this->comparison($x, 'LIKE', $y) . + (func_num_args() >= 3 ? sprintf(' ESCAPE %s', func_get_arg(2)) : ''); } /** @@ -267,9 +273,10 @@ public function like($x, $y) * * @return string */ - public function notLike($x, $y) + public function notLike($x, $y/*, ?string $escapeChar = null */) { - return $this->comparison($x, 'NOT LIKE', $y); + return $this->comparison($x, 'NOT LIKE', $y) . + (func_num_args() >= 3 ? sprintf(' ESCAPE %s', func_get_arg(2)) : ''); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php b/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php index 1b1bc3165..0eac78a56 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -19,8 +19,21 @@ namespace Doctrine\DBAL\Query; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\Expression\CompositeExpression; use Doctrine\DBAL\Connection; +use function array_key_exists; +use function array_keys; +use function array_unshift; +use function func_get_args; +use function func_num_args; +use function implode; +use function is_array; +use function is_null; +use function is_object; +use function key; +use function strtoupper; +use function substr; /** * QueryBuilder class is responsible to dynamically create SQL queries. @@ -99,35 +112,35 @@ class QueryBuilder /** * The type of query this is. Can be select, update or delete. * - * @var integer + * @var int */ private $type = self::SELECT; /** * The state of the query object. Can be dirty or clean. * - * @var integer + * @var int */ private $state = self::STATE_CLEAN; /** * The index of the first result to retrieve. * - * @var integer + * @var int */ private $firstResult = null; /** * The maximum number of results to retrieve. * - * @var integer + * @var int */ private $maxResults = null; /** * The counter of bound parameters used with {@see bindValue). * - * @var integer + * @var int */ private $boundCounter = 0; @@ -165,7 +178,7 @@ public function expr() /** * Gets the type of the currently built query. * - * @return integer + * @return int */ public function getType() { @@ -185,7 +198,7 @@ public function getConnection() /** * Gets the state of this query builder instance. * - * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. + * @return int Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. */ public function getState() { @@ -204,9 +217,9 @@ public function execute() { if ($this->type == self::SELECT) { return $this->connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes); - } else { - return $this->connection->executeUpdate($this->getSQL(), $this->params, $this->paramTypes); } + + return $this->connection->executeUpdate($this->getSQL(), $this->params, $this->paramTypes); } /** @@ -262,9 +275,9 @@ public function getSQL() * ->setParameter(':user_id', 1); * * - * @param string|integer $key The parameter position or name. - * @param mixed $value The parameter value. - * @param string|integer|null $type One of the PDO::PARAM_* constants. + * @param string|int $key The parameter position or name. + * @param mixed $value The parameter value. + * @param string|int|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants. * * @return $this This QueryBuilder instance. */ @@ -325,7 +338,7 @@ public function getParameters() */ public function getParameter($key) { - return isset($this->params[$key]) ? $this->params[$key] : null; + return $this->params[$key] ?? null; } /** @@ -347,13 +360,13 @@ public function getParameterTypes() */ public function getParameterType($key) { - return isset($this->paramTypes[$key]) ? $this->paramTypes[$key] : null; + return $this->paramTypes[$key] ?? null; } /** * Sets the position of the first result to retrieve (the "offset"). * - * @param integer $firstResult The first result to return. + * @param int $firstResult The first result to return. * * @return $this This QueryBuilder instance. */ @@ -369,7 +382,7 @@ public function setFirstResult($firstResult) * Gets the position of the first result the query object was set to retrieve (the "offset"). * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder. * - * @return integer The position of the first result. + * @return int The position of the first result. */ public function getFirstResult() { @@ -379,7 +392,7 @@ public function getFirstResult() /** * Sets the maximum number of results to retrieve (the "limit"). * - * @param integer $maxResults The maximum number of results to retrieve. + * @param int $maxResults The maximum number of results to retrieve. * * @return $this This QueryBuilder instance. */ @@ -395,7 +408,7 @@ public function setMaxResults($maxResults) * Gets the maximum number of results the query object was set to retrieve (the "limit"). * Returns NULL if {@link setMaxResults} was not applied to this query builder. * - * @return integer The maximum number of results. + * @return int The maximum number of results. */ public function getMaxResults() { @@ -408,9 +421,9 @@ public function getMaxResults() * The available parts are: 'select', 'from', 'set', 'where', * 'groupBy', 'having' and 'orderBy'. * - * @param string $sqlPartName - * @param string $sqlPart - * @param boolean $append + * @param string $sqlPartName + * @param string $sqlPart + * @param bool $append * * @return $this This QueryBuilder instance. */ @@ -420,7 +433,7 @@ public function add($sqlPartName, $sqlPart, $append = false) $isMultiple = is_array($this->sqlParts[$sqlPartName]); if ($isMultiple && !$isArray) { - $sqlPart = array($sqlPart); + $sqlPart = [$sqlPart]; } $this->state = self::STATE_DIRTY; @@ -472,7 +485,7 @@ public function select($select = null) $selects = is_array($select) ? $select : func_get_args(); - return $this->add('select', $selects, false); + return $this->add('select', $selects); } /** @@ -540,7 +553,7 @@ public function delete($delete = null, $alias = null) * * $qb = $conn->createQueryBuilder() * ->update('users', 'u') - * ->set('u.password', md5('password')) + * ->set('u.last_login', 'NOW()') * ->where('u.id = ?'); * * @@ -733,7 +746,7 @@ public function rightJoin($fromAlias, $join, $alias, $condition = null) * * $qb = $conn->createQueryBuilder() * ->update('users', 'u') - * ->set('u.password', md5('password')) + * ->set('u.last_login', 'NOW()') * ->where('u.id = ?'); * * @@ -765,7 +778,7 @@ public function set($key, $value) * $or->add($qb->expr()->eq('u.id', 2)); * * $qb->update('users', 'u') - * ->set('u.password', md5('password')) + * ->set('u.last_login', 'NOW()') * ->where($or); * * @@ -1093,7 +1106,7 @@ public function resetQueryParts($queryPartNames = null) public function resetQueryPart($queryPartName) { $this->sqlParts[$queryPartName] = is_array($this->sqlParts[$queryPartName]) - ? array() : null; + ? [] : null; $this->state = self::STATE_DIRTY; @@ -1131,8 +1144,8 @@ private function getSQLForSelect() */ private function getFromClauses() { - $fromClauses = array(); - $knownAliases = array(); + $fromClauses = []; + $knownAliases = []; // Loop through all FROM clauses foreach ($this->sqlParts['from'] as $from) { @@ -1256,7 +1269,7 @@ public function __toString() * * @return string the placeholder name used. */ - public function createNamedParameter($value, $type = \PDO::PARAM_STR, $placeHolder = null) + public function createNamedParameter($value, $type = ParameterType::STRING, $placeHolder = null) { if ($placeHolder === null) { $this->boundCounter++; @@ -1280,16 +1293,16 @@ public function createNamedParameter($value, $type = \PDO::PARAM_STR, $placeHold * $qb = $conn->createQueryBuilder(); * $qb->select('u.*') * ->from('users', 'u') - * ->where('u.username = ' . $qb->createPositionalParameter('Foo', PDO::PARAM_STR)) - * ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', PDO::PARAM_STR)) + * ->where('u.username = ' . $qb->createPositionalParameter('Foo', ParameterType::STRING)) + * ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', ParameterType::STRING)) * * - * @param mixed $value - * @param integer $type + * @param mixed $value + * @param int $type * * @return string */ - public function createPositionalParameter($value, $type = \PDO::PARAM_STR) + public function createPositionalParameter($value, $type = ParameterType::STRING) { $this->boundCounter++; $this->setParameter($this->boundCounter, $value, $type); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryException.php b/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryException.php index 92c9336d6..45a3d55f6 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryException.php @@ -20,6 +20,7 @@ namespace Doctrine\DBAL\Query; use Doctrine\DBAL\DBALException; +use function implode; /** * @since 2.1.4 @@ -32,7 +33,7 @@ class QueryException extends DBALException * * @return \Doctrine\DBAL\Query\QueryException */ - static public function unknownAlias($alias, $registeredAliases) + public static function unknownAlias($alias, $registeredAliases) { return new self("The given alias '" . $alias . "' is not part of " . "any FROM or JOIN clause table. The currently registered " . @@ -45,7 +46,7 @@ static public function unknownAlias($alias, $registeredAliases) * * @return \Doctrine\DBAL\Query\QueryException */ - static public function nonUniqueAlias($alias, $registeredAliases) + public static function nonUniqueAlias($alias, $registeredAliases) { return new self("The given alias '" . $alias . "' is not unique " . "in FROM and JOIN clause table. The currently registered " . diff --git a/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php b/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php index 4242989cb..09448d18e 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php @@ -19,6 +19,22 @@ namespace Doctrine\DBAL; +use const PREG_OFFSET_CAPTURE; +use function array_fill; +use function array_key_exists; +use function array_merge; +use function array_slice; +use function array_values; +use function count; +use function implode; +use function is_int; +use function key; +use function ksort; +use function preg_match_all; +use function strlen; +use function strpos; +use function substr; + /** * Utility class that parses sql statements with regard to types and parameters. * @@ -32,9 +48,9 @@ class SQLParserUtils const NAMED_TOKEN = '(? integer pair (indexed from zero) for a positional statement * and a string => int[] pair for a named statement. * - * @param string $statement - * @param boolean $isPositional + * @param string $statement + * @param bool $isPositional * * @return array */ - static public function getPlaceholderPositions($statement, $isPositional = true) + public static function getPlaceholderPositions($statement, $isPositional = true) { $match = ($isPositional) ? '?' : ':'; if (strpos($statement, $match) === false) { - return array(); + return []; } $token = ($isPositional) ? self::POSITIONAL_TOKEN : self::NAMED_TOKEN; - $paramMap = array(); + $paramMap = []; foreach (self::getUnquotedStatementFragments($statement) as $fragment) { preg_match_all("/$token/", $fragment[0], $matches, PREG_OFFSET_CAPTURE); @@ -84,10 +100,10 @@ static public function getPlaceholderPositions($statement, $isPositional = true) * * @throws SQLParserUtilsException */ - static public function expandListParameters($query, $params, $types) + public static function expandListParameters($query, $params, $types) { $isPositional = is_int(key($params)); - $arrayPositions = array(); + $arrayPositions = []; $bindIndex = -1; if ($isPositional) { @@ -110,7 +126,7 @@ static public function expandListParameters($query, $params, $types) } if (( ! $arrayPositions && $isPositional)) { - return array($query, $params, $types); + return [$query, $params, $types]; } $paramPos = self::getPlaceholderPositions($query, $isPositional); @@ -139,8 +155,10 @@ static public function expandListParameters($query, $params, $types) $types = array_merge( array_slice($types, 0, $needle), $count ? - array_fill(0, $count, $types[$needle] - Connection::ARRAY_PARAM_OFFSET) : // array needles are at PDO::PARAM_* + 100 - array(), + // array needles are at {@link \Doctrine\DBAL\ParameterType} constants + // + {@link Doctrine\DBAL\Connection::ARRAY_PARAM_OFFSET} + array_fill(0, $count, $types[$needle] - Connection::ARRAY_PARAM_OFFSET) : + [], array_slice($types, $needle + 1) ); @@ -151,12 +169,12 @@ static public function expandListParameters($query, $params, $types) $queryOffset += (strlen($expandStr) - 1); } - return array($query, $params, $types); + return [$query, $params, $types]; } $queryOffset = 0; - $typesOrd = array(); - $paramsOrd = array(); + $typesOrd = []; + $paramsOrd = []; foreach ($paramPos as $pos => $paramName) { $paramLen = strlen($paramName) + 1; @@ -166,7 +184,7 @@ static public function expandListParameters($query, $params, $types) $pos += $queryOffset; $queryOffset -= ($paramLen - 1); $paramsOrd[] = $value; - $typesOrd[] = static::extractParam($paramName, $types, false, \PDO::PARAM_STR); + $typesOrd[] = static::extractParam($paramName, $types, false, ParameterType::STRING); $query = substr($query, 0, $pos) . '?' . substr($query, ($pos + $paramLen)); continue; @@ -185,7 +203,7 @@ static public function expandListParameters($query, $params, $types) $query = substr($query, 0, $pos) . $expandStr . substr($query, ($pos + $paramLen)); } - return array($query, $paramsOrd, $typesOrd); + return [$query, $paramsOrd, $typesOrd]; } /** @@ -199,7 +217,7 @@ static public function expandListParameters($query, $params, $types) * @param string $statement * @return array */ - static private function getUnquotedStatementFragments($statement) + private static function getUnquotedStatementFragments($statement) { $literal = self::ESCAPED_SINGLE_QUOTED_TEXT . '|' . self::ESCAPED_DOUBLE_QUOTED_TEXT . '|' . @@ -211,15 +229,15 @@ static private function getUnquotedStatementFragments($statement) } /** - * @param string $paramName The name of the parameter (without a colon in front) - * @param array $paramsOrTypes A hash of parameters or types - * @param bool $isParam - * @param mixed $defaultValue An optional default value. If omitted, an exception is thrown + * @param string $paramName The name of the parameter (without a colon in front) + * @param array $paramsOrTypes A hash of parameters or types + * @param bool $isParam + * @param mixed $defaultValue An optional default value. If omitted, an exception is thrown * * @throws SQLParserUtilsException * @return mixed */ - static private function extractParam($paramName, $paramsOrTypes, $isParam, $defaultValue = null) + private static function extractParam($paramName, $paramsOrTypes, $isParam, $defaultValue = null) { if (array_key_exists($paramName, $paramsOrTypes)) { return $paramsOrTypes[$paramName]; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtilsException.php b/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtilsException.php index 25c7209c7..e7c15c53e 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtilsException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtilsException.php @@ -21,6 +21,8 @@ namespace Doctrine\DBAL; +use function sprintf; + /** * Doctrine\DBAL\ConnectionException * diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractAsset.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractAsset.php index 051dce92c..3ac7fb8bd 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractAsset.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractAsset.php @@ -20,6 +20,16 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function array_map; +use function crc32; +use function dechex; +use function explode; +use function implode; +use function str_replace; +use function strpos; +use function strtolower; +use function strtoupper; +use function substr; /** * The abstract asset allows to reset the name of all assets without publishing this to the public userland. @@ -46,7 +56,7 @@ abstract class AbstractAsset protected $_namespace = null; /** - * @var boolean + * @var bool */ protected $_quoted = false; @@ -76,7 +86,7 @@ protected function _setName($name) * * @param string $defaultNamespaceName * - * @return boolean + * @return bool */ public function isInDefaultNamespace($defaultNamespaceName) { @@ -139,7 +149,7 @@ public function getFullQualifiedName($defaultNamespaceName) /** * Checks if this asset's name is quoted. * - * @return boolean + * @return bool */ public function isQuoted() { @@ -151,7 +161,7 @@ public function isQuoted() * * @param string $identifier * - * @return boolean + * @return bool */ protected function isIdentifierQuoted($identifier) { @@ -167,7 +177,7 @@ protected function isIdentifierQuoted($identifier) */ protected function trimQuotes($identifier) { - return str_replace(array('`', '"', '[', ']'), '', $identifier); + return str_replace(['`', '"', '[', ']'], '', $identifier); } /** @@ -210,9 +220,9 @@ public function getQuotedName(AbstractPlatform $platform) * however building idents automatically for foreign keys, composite keys or such can easily create * very long names. * - * @param array $columnNames - * @param string $prefix - * @param integer $maxSize + * @param array $columnNames + * @param string $prefix + * @param int $maxSize * * @return string */ diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index ab3b9d68f..c86779011 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -24,6 +24,17 @@ use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function array_filter; +use function array_map; +use function array_values; +use function call_user_func_array; +use function count; +use function func_get_args; +use function is_array; +use function is_null; +use function preg_match; +use function str_replace; +use function strtolower; /** * Base class for schema managers. Schema managers are used to inspect and/or @@ -94,7 +105,7 @@ public function tryMethod() $args = array_values($args); try { - return call_user_func_array(array($this, $method), $args); + return call_user_func_array([$this, $method], $args); } catch (\Exception $e) { return false; } @@ -198,7 +209,7 @@ public function listTableIndexes($table) * * @param array $tableNames * - * @return boolean + * @return bool */ public function tablesExist($tableNames) { @@ -263,7 +274,7 @@ public function listTables() { $tableNames = $this->listTableNames(); - $tables = array(); + $tables = []; foreach ($tableNames as $tableName) { $tables[] = $this->listTableDetails($tableName); } @@ -279,13 +290,13 @@ public function listTables() public function listTableDetails($tableName) { $columns = $this->listTableColumns($tableName); - $foreignKeys = array(); + $foreignKeys = []; if ($this->_platform->supportsForeignKeyConstraints()) { $foreignKeys = $this->listTableForeignKeys($tableName); } $indexes = $this->listTableIndexes($tableName); - return new Table($tableName, $columns, $indexes, $foreignKeys, false, array()); + return new Table($tableName, $columns, $indexes, $foreignKeys, false, []); } /** @@ -655,7 +666,7 @@ public function renameTable($name, $newName) */ protected function _getPortableDatabasesList($databases) { - $list = array(); + $list = []; foreach ($databases as $value) { if ($value = $this->_getPortableDatabaseDefinition($value)) { $list[] = $value; @@ -674,7 +685,7 @@ protected function _getPortableDatabasesList($databases) */ protected function getPortableNamespacesList(array $namespaces) { - $namespacesList = array(); + $namespacesList = []; foreach ($namespaces as $namespace) { $namespacesList[] = $this->getPortableNamespaceDefinition($namespace); @@ -712,7 +723,7 @@ protected function getPortableNamespaceDefinition(array $namespace) */ protected function _getPortableFunctionsList($functions) { - $list = array(); + $list = []; foreach ($functions as $value) { if ($value = $this->_getPortableFunctionDefinition($value)) { $list[] = $value; @@ -739,7 +750,7 @@ protected function _getPortableFunctionDefinition($function) */ protected function _getPortableTriggersList($triggers) { - $list = array(); + $list = []; foreach ($triggers as $value) { if ($value = $this->_getPortableTriggerDefinition($value)) { $list[] = $value; @@ -766,7 +777,7 @@ protected function _getPortableTriggerDefinition($trigger) */ protected function _getPortableSequencesList($sequences) { - $list = array(); + $list = []; foreach ($sequences as $value) { if ($value = $this->_getPortableSequenceDefinition($value)) { $list[] = $value; @@ -803,7 +814,7 @@ protected function _getPortableTableColumnList($table, $database, $tableColumns) { $eventManager = $this->_platform->getEventManager(); - $list = array(); + $list = []; foreach ($tableColumns as $tableColumn) { $column = null; $defaultPrevented = false; @@ -848,7 +859,7 @@ abstract protected function _getPortableTableColumnDefinition($tableColumn); */ protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null) { - $result = array(); + $result = []; foreach ($tableIndexRows as $tableIndex) { $indexName = $keyName = $tableIndex['key_name']; if ($tableIndex['primary']) { @@ -857,14 +868,14 @@ protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null $keyName = strtolower($keyName); if (!isset($result[$keyName])) { - $result[$keyName] = array( + $result[$keyName] = [ 'name' => $indexName, - 'columns' => array($tableIndex['column_name']), + 'columns' => [$tableIndex['column_name']], 'unique' => $tableIndex['non_unique'] ? false : true, 'primary' => $tableIndex['primary'], - 'flags' => isset($tableIndex['flags']) ? $tableIndex['flags'] : array(), - 'options' => isset($tableIndex['where']) ? array('where' => $tableIndex['where']) : array(), - ); + 'flags' => $tableIndex['flags'] ?? [], + 'options' => isset($tableIndex['where']) ? ['where' => $tableIndex['where']] : [], + ]; } else { $result[$keyName]['columns'][] = $tableIndex['column_name']; } @@ -872,7 +883,7 @@ protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null $eventManager = $this->_platform->getEventManager(); - $indexes = array(); + $indexes = []; foreach ($result as $indexKey => $data) { $index = null; $defaultPrevented = false; @@ -904,7 +915,7 @@ protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null */ protected function _getPortableTablesList($tables) { - $list = array(); + $list = []; foreach ($tables as $value) { if ($value = $this->_getPortableTableDefinition($value)) { $list[] = $value; @@ -931,7 +942,7 @@ protected function _getPortableTableDefinition($table) */ protected function _getPortableUsersList($users) { - $list = array(); + $list = []; foreach ($users as $value) { if ($value = $this->_getPortableUserDefinition($value)) { $list[] = $value; @@ -958,7 +969,7 @@ protected function _getPortableUserDefinition($user) */ protected function _getPortableViewsList($views) { - $list = array(); + $list = []; foreach ($views as $value) { if ($view = $this->_getPortableViewDefinition($value)) { $viewName = strtolower($view->getQuotedName($this->_platform)); @@ -986,7 +997,7 @@ protected function _getPortableViewDefinition($view) */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { - $list = array(); + $list = []; foreach ($tableForeignKeys as $value) { if ($value = $this->_getPortableTableForeignKeyDefinition($value)) { $list[] = $value; @@ -1025,13 +1036,13 @@ protected function _execSql($sql) */ public function createSchema() { - $namespaces = array(); + $namespaces = []; if ($this->_platform->supportsSchemas()) { $namespaces = $this->listNamespaceNames(); } - $sequences = array(); + $sequences = []; if ($this->_platform->supportsSequences()) { $sequences = $this->listSequences(); @@ -1058,9 +1069,13 @@ public function createSchemaConfig() } $params = $this->_conn->getParams(); - if (isset($params['defaultTableOptions'])) { - $schemaConfig->setDefaultTableOptions($params['defaultTableOptions']); + if (! isset($params['defaultTableOptions'])) { + $params['defaultTableOptions'] = []; } + if (! isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) { + $params['defaultTableOptions']['charset'] = $params['charset']; + } + $schemaConfig->setDefaultTableOptions($params['defaultTableOptions']); return $schemaConfig; } @@ -1079,7 +1094,7 @@ public function createSchemaConfig() */ public function getSchemaSearchPaths() { - return array($this->_conn->getDatabase()); + return [$this->_conn->getDatabase()]; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php index 192ce1d2e..eead5e6aa 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php @@ -20,6 +20,12 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types\Type; +use const E_USER_DEPRECATED; +use function array_merge; +use function is_numeric; +use function method_exists; +use function sprintf; +use function trigger_error; /** * Object representation of a database column. @@ -36,32 +42,32 @@ class Column extends AbstractAsset protected $_type; /** - * @var integer|null + * @var int|null */ protected $_length = null; /** - * @var integer + * @var int */ protected $_precision = 10; /** - * @var integer + * @var int */ protected $_scale = 0; /** - * @var boolean + * @var bool */ protected $_unsigned = false; /** - * @var boolean + * @var bool */ protected $_fixed = false; /** - * @var boolean + * @var bool */ protected $_notnull = true; @@ -71,14 +77,14 @@ class Column extends AbstractAsset protected $_default = null; /** - * @var boolean + * @var bool */ protected $_autoincrement = false; /** * @var array */ - protected $_platformOptions = array(); + protected $_platformOptions = []; /** * @var string|null @@ -93,7 +99,7 @@ class Column extends AbstractAsset /** * @var array */ - protected $_customSchemaOptions = array(); + protected $_customSchemaOptions = []; /** * Creates a new Column. @@ -102,7 +108,7 @@ class Column extends AbstractAsset * @param Type $type * @param array $options */ - public function __construct($columnName, Type $type, array $options=array()) + public function __construct($columnName, Type $type, array $options=[]) { $this->_setName($columnName); $this->setType($type); @@ -118,9 +124,17 @@ public function setOptions(array $options) { foreach ($options as $name => $value) { $method = "set".$name; - if (method_exists($this, $method)) { - $this->$method($value); + if ( ! method_exists($this, $method)) { + // next major: throw an exception + @trigger_error(sprintf( + 'The "%s" column option is not supported,'. + ' setting it is deprecated and will cause an error in Doctrine 3.0', + $name + ), E_USER_DEPRECATED); + + continue; } + $this->$method($value); } return $this; @@ -139,7 +153,7 @@ public function setType(Type $type) } /** - * @param integer|null $length + * @param int|null $length * * @return Column */ @@ -155,7 +169,7 @@ public function setLength($length) } /** - * @param integer $precision + * @param int $precision * * @return Column */ @@ -171,7 +185,7 @@ public function setPrecision($precision) } /** - * @param integer $scale + * @param int $scale * * @return Column */ @@ -187,7 +201,7 @@ public function setScale($scale) } /** - * @param boolean $unsigned + * @param bool $unsigned * * @return Column */ @@ -199,7 +213,7 @@ public function setUnsigned($unsigned) } /** - * @param boolean $fixed + * @param bool $fixed * * @return Column */ @@ -211,7 +225,7 @@ public function setFixed($fixed) } /** - * @param boolean $notnull + * @param bool $notnull * * @return Column */ @@ -280,7 +294,7 @@ public function getType() } /** - * @return integer|null + * @return int|null */ public function getLength() { @@ -288,7 +302,7 @@ public function getLength() } /** - * @return integer + * @return int */ public function getPrecision() { @@ -296,7 +310,7 @@ public function getPrecision() } /** - * @return integer + * @return int */ public function getScale() { @@ -304,7 +318,7 @@ public function getScale() } /** - * @return boolean + * @return bool */ public function getUnsigned() { @@ -312,7 +326,7 @@ public function getUnsigned() } /** - * @return boolean + * @return bool */ public function getFixed() { @@ -320,7 +334,7 @@ public function getFixed() } /** - * @return boolean + * @return bool */ public function getNotnull() { @@ -346,7 +360,7 @@ public function getPlatformOptions() /** * @param string $name * - * @return boolean + * @return bool */ public function hasPlatformOption($name) { @@ -372,7 +386,7 @@ public function getColumnDefinition() } /** - * @return boolean + * @return bool */ public function getAutoincrement() { @@ -380,7 +394,7 @@ public function getAutoincrement() } /** - * @param boolean $flag + * @param bool $flag * * @return Column */ @@ -427,7 +441,7 @@ public function setCustomSchemaOption($name, $value) /** * @param string $name * - * @return boolean + * @return bool */ public function hasCustomSchemaOption($name) { @@ -469,7 +483,7 @@ public function getCustomSchemaOptions() */ public function toArray() { - return array_merge(array( + return array_merge([ 'name' => $this->_name, 'type' => $this->_type, 'default' => $this->_default, @@ -482,6 +496,6 @@ public function toArray() 'autoincrement' => $this->_autoincrement, 'columnDefinition' => $this->_columnDefinition, 'comment' => $this->_comment, - ), $this->_platformOptions, $this->_customSchemaOptions); + ], $this->_platformOptions, $this->_customSchemaOptions); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php index 61d7f7319..65517d75c 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php @@ -19,6 +19,8 @@ namespace Doctrine\DBAL\Schema; +use function in_array; + /** * Represents the change of a column. * @@ -41,7 +43,7 @@ class ColumnDiff /** * @var array */ - public $changedProperties = array(); + public $changedProperties = []; /** * @var Column @@ -54,7 +56,7 @@ class ColumnDiff * @param string[] $changedProperties * @param Column $fromColumn */ - public function __construct($oldColumnName, Column $column, array $changedProperties = array(), Column $fromColumn = null) + public function __construct($oldColumnName, Column $column, array $changedProperties = [], Column $fromColumn = null) { $this->oldColumnName = $oldColumnName; $this->column = $column; @@ -65,7 +67,7 @@ public function __construct($oldColumnName, Column $column, array $changedProper /** * @param string $propertyName * - * @return boolean + * @return bool */ public function hasChanged($propertyName) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php index 107d1beb5..6e0c42fe4 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php @@ -20,6 +20,15 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types; +use function array_intersect_key; +use function array_key_exists; +use function array_keys; +use function array_map; +use function array_merge; +use function array_shift; +use function array_unique; +use function count; +use function strtolower; /** * Compares two Schemas and return an instance of SchemaDiff. @@ -36,7 +45,7 @@ class Comparator * * @return \Doctrine\DBAL\Schema\SchemaDiff */ - static public function compareSchemas(Schema $fromSchema, Schema $toSchema) + public static function compareSchemas(Schema $fromSchema, Schema $toSchema) { $c = new self(); @@ -60,7 +69,7 @@ public function compare(Schema $fromSchema, Schema $toSchema) $diff = new SchemaDiff(); $diff->fromSchema = $fromSchema; - $foreignKeysToTable = array(); + $foreignKeysToTable = []; foreach ($toSchema->getNamespaces() as $namespace) { if ( ! $fromSchema->hasNamespace($namespace)) { @@ -99,7 +108,7 @@ public function compare(Schema $fromSchema, Schema $toSchema) foreach ($table->getForeignKeys() as $foreignKey) { $foreignTable = strtolower($foreignKey->getForeignTableName()); if (!isset($foreignKeysToTable[$foreignTable])) { - $foreignKeysToTable[$foreignTable] = array(); + $foreignKeysToTable[$foreignTable] = []; } $foreignKeysToTable[$foreignTable][] = $foreignKey; } @@ -159,7 +168,7 @@ public function compare(Schema $fromSchema, Schema $toSchema) * @param \Doctrine\DBAL\Schema\Schema $schema * @param \Doctrine\DBAL\Schema\Sequence $sequence * - * @return boolean + * @return bool */ private function isAutoIncrementSequenceInSchema($schema, $sequence) { @@ -176,7 +185,7 @@ private function isAutoIncrementSequenceInSchema($schema, $sequence) * @param \Doctrine\DBAL\Schema\Sequence $sequence1 * @param \Doctrine\DBAL\Schema\Sequence $sequence2 * - * @return boolean + * @return bool */ public function diffSequence(Sequence $sequence1, Sequence $sequence2) { @@ -184,11 +193,7 @@ public function diffSequence(Sequence $sequence1, Sequence $sequence2) return true; } - if ($sequence1->getInitialValue() != $sequence2->getInitialValue()) { - return true; - } - - return false; + return $sequence1->getInitialValue() !== $sequence2->getInitialValue(); } /** @@ -199,7 +204,7 @@ public function diffSequence(Sequence $sequence1, Sequence $sequence2) * @param \Doctrine\DBAL\Schema\Table $table1 * @param \Doctrine\DBAL\Schema\Table $table2 * - * @return boolean|\Doctrine\DBAL\Schema\TableDiff + * @return bool|\Doctrine\DBAL\Schema\TableDiff */ public function diffTable(Table $table1, Table $table2) { @@ -279,14 +284,12 @@ public function diffTable(Table $table1, Table $table2) foreach ($fromFkeys as $key1 => $constraint1) { foreach ($toFkeys as $key2 => $constraint2) { if ($this->diffForeignKey($constraint1, $constraint2) === false) { - unset($fromFkeys[$key1]); - unset($toFkeys[$key2]); + unset($fromFkeys[$key1], $toFkeys[$key2]); } else { if (strtolower($constraint1->getName()) == strtolower($constraint2->getName())) { $tableDifferences->changedForeignKeys[] = $constraint2; $changes++; - unset($fromFkeys[$key1]); - unset($toFkeys[$key2]); + unset($fromFkeys[$key1], $toFkeys[$key2]); } } } @@ -315,11 +318,11 @@ public function diffTable(Table $table1, Table $table2) */ private function detectColumnRenamings(TableDiff $tableDifferences) { - $renameCandidates = array(); + $renameCandidates = []; foreach ($tableDifferences->addedColumns as $addedColumnName => $addedColumn) { foreach ($tableDifferences->removedColumns as $removedColumn) { if (count($this->diffColumn($addedColumn, $removedColumn)) == 0) { - $renameCandidates[$addedColumn->getName()][] = array($removedColumn, $addedColumn, $addedColumnName); + $renameCandidates[$addedColumn->getName()][] = [$removedColumn, $addedColumn, $addedColumnName]; } } } @@ -332,8 +335,10 @@ private function detectColumnRenamings(TableDiff $tableDifferences) if ( ! isset($tableDifferences->renamedColumns[$removedColumnName])) { $tableDifferences->renamedColumns[$removedColumnName] = $addedColumn; - unset($tableDifferences->addedColumns[$addedColumnName]); - unset($tableDifferences->removedColumns[$removedColumnName]); + unset( + $tableDifferences->addedColumns[$addedColumnName], + $tableDifferences->removedColumns[$removedColumnName] + ); } } } @@ -349,13 +354,13 @@ private function detectColumnRenamings(TableDiff $tableDifferences) */ private function detectIndexRenamings(TableDiff $tableDifferences) { - $renameCandidates = array(); + $renameCandidates = []; // Gather possible rename candidates by comparing each added and removed index based on semantics. foreach ($tableDifferences->addedIndexes as $addedIndexName => $addedIndex) { foreach ($tableDifferences->removedIndexes as $removedIndex) { if (! $this->diffIndex($addedIndex, $removedIndex)) { - $renameCandidates[$addedIndex->getName()][] = array($removedIndex, $addedIndex, $addedIndexName); + $renameCandidates[$addedIndex->getName()][] = [$removedIndex, $addedIndex, $addedIndexName]; } } } @@ -373,8 +378,10 @@ private function detectIndexRenamings(TableDiff $tableDifferences) if (! isset($tableDifferences->renamedIndexes[$removedIndexName])) { $tableDifferences->renamedIndexes[$removedIndexName] = $addedIndex; - unset($tableDifferences->addedIndexes[$addedIndexName]); - unset($tableDifferences->removedIndexes[$removedIndexName]); + unset( + $tableDifferences->addedIndexes[$addedIndexName], + $tableDifferences->removedIndexes[$removedIndexName] + ); } } } @@ -384,7 +391,7 @@ private function detectIndexRenamings(TableDiff $tableDifferences) * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $key1 * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $key2 * - * @return boolean + * @return bool */ public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2) { @@ -404,11 +411,7 @@ public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint return true; } - if ($key1->onDelete() != $key2->onDelete()) { - return true; - } - - return false; + return $key1->onDelete() !== $key2->onDelete(); } /** @@ -427,9 +430,9 @@ public function diffColumn(Column $column1, Column $column2) $properties1 = $column1->toArray(); $properties2 = $column2->toArray(); - $changedProperties = array(); + $changedProperties = []; - foreach (array('type', 'notnull', 'unsigned', 'autoincrement') as $property) { + foreach (['type', 'notnull', 'unsigned', 'autoincrement'] as $property) { if ($properties1[$property] != $properties2[$property]) { $changedProperties[] = $property; } @@ -528,14 +531,10 @@ private function isALegacyJsonComparison(Types\Type $one, Types\Type $other) : b * @param \Doctrine\DBAL\Schema\Index $index1 * @param \Doctrine\DBAL\Schema\Index $index2 * - * @return boolean + * @return bool */ public function diffIndex(Index $index1, Index $index2) { - if ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1)) { - return false; - } - - return true; + return ! ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1)); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php index dc48e009f..c97685b5d 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -19,6 +19,13 @@ namespace Doctrine\DBAL\Schema; +use function array_change_key_case; +use function is_resource; +use function strpos; +use function strtolower; +use function substr; +use function trim; + /** * IBM Db2 Schema Manager. * @@ -90,7 +97,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) break; } - $options = array( + $options = [ 'length' => $length, 'unsigned' => (bool) $unsigned, 'fixed' => (bool) $fixed, @@ -102,8 +109,8 @@ protected function _getPortableTableColumnDefinition($tableColumn) 'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null, - 'platformOptions' => array(), - ); + 'platformOptions' => [], + ]; if ($scale !== null && $precision !== null) { $options['scale'] = $scale; @@ -118,7 +125,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) */ protected function _getPortableTablesList($tables) { - $tableNames = array(); + $tableNames = []; foreach ($tables as $tableRow) { $tableRow = array_change_key_case($tableRow, \CASE_LOWER); $tableNames[] = $tableRow['name']; @@ -159,22 +166,22 @@ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { - $foreignKeys = array(); + $foreignKeys = []; foreach ($tableForeignKeys as $tableForeignKey) { $tableForeignKey = array_change_key_case($tableForeignKey, \CASE_LOWER); if (!isset($foreignKeys[$tableForeignKey['index_name']])) { - $foreignKeys[$tableForeignKey['index_name']] = array( - 'local_columns' => array($tableForeignKey['local_column']), + $foreignKeys[$tableForeignKey['index_name']] = [ + 'local_columns' => [$tableForeignKey['local_column']], 'foreign_table' => $tableForeignKey['foreign_table'], - 'foreign_columns' => array($tableForeignKey['foreign_column']), + 'foreign_columns' => [$tableForeignKey['foreign_column']], 'name' => $tableForeignKey['index_name'], - 'options' => array( + 'options' => [ 'onUpdate' => $tableForeignKey['on_update'], 'onDelete' => $tableForeignKey['on_delete'], - ) - ); + ] + ]; } else { $foreignKeys[$tableForeignKey['index_name']]['local_columns'][] = $tableForeignKey['local_column']; $foreignKeys[$tableForeignKey['index_name']]['foreign_columns'][] = $tableForeignKey['foreign_column']; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php index e9503c359..a10eb3da0 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php @@ -20,6 +20,9 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types\Type; +use function explode; +use function strtolower; +use function trim; /** * Schema manager for the Drizzle RDBMS. @@ -39,17 +42,17 @@ protected function _getPortableTableColumnDefinition($tableColumn) $type = $this->extractDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type); $tableColumn['COLUMN_COMMENT'] = $this->removeDoctrineTypeFromComment($tableColumn['COLUMN_COMMENT'], $type); - $options = array( + $options = [ 'notnull' => !(bool) $tableColumn['IS_NULLABLE'], 'length' => (int) $tableColumn['CHARACTER_MAXIMUM_LENGTH'], - 'default' => isset($tableColumn['COLUMN_DEFAULT']) ? $tableColumn['COLUMN_DEFAULT'] : null, + 'default' => $tableColumn['COLUMN_DEFAULT'] ?? null, 'autoincrement' => (bool) $tableColumn['IS_AUTO_INCREMENT'], 'scale' => (int) $tableColumn['NUMERIC_SCALE'], 'precision' => (int) $tableColumn['NUMERIC_PRECISION'], 'comment' => isset($tableColumn['COLUMN_COMMENT']) && '' !== $tableColumn['COLUMN_COMMENT'] ? $tableColumn['COLUMN_COMMENT'] : null, - ); + ]; $column = new Column($tableColumn['COLUMN_NAME'], Type::getType($type), $options); @@ -81,12 +84,12 @@ protected function _getPortableTableDefinition($table) */ public function _getPortableTableForeignKeyDefinition($tableForeignKey) { - $columns = array(); + $columns = []; foreach (explode(',', $tableForeignKey['CONSTRAINT_COLUMNS']) as $value) { $columns[] = trim($value, ' `'); } - $refColumns = array(); + $refColumns = []; foreach (explode(',', $tableForeignKey['REFERENCED_TABLE_COLUMNS']) as $value) { $refColumns[] = trim($value, ' `'); } @@ -96,10 +99,10 @@ public function _getPortableTableForeignKeyDefinition($tableForeignKey) $tableForeignKey['REFERENCED_TABLE_NAME'], $refColumns, $tableForeignKey['CONSTRAINT_NAME'], - array( + [ 'onUpdate' => $tableForeignKey['UPDATE_RULE'], 'onDelete' => $tableForeignKey['DELETE_RULE'], - ) + ] ); } @@ -108,7 +111,7 @@ public function _getPortableTableForeignKeyDefinition($tableForeignKey) */ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { - $indexes = array(); + $indexes = []; foreach ($tableIndexes as $k) { $k['primary'] = (boolean) $k['primary']; $indexes[] = $k; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php index 6070eb2e5..a50b7a0b5 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php @@ -20,6 +20,14 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function array_combine; +use function array_keys; +use function array_map; +use function end; +use function explode; +use function in_array; +use function strtolower; +use function strtoupper; /** * An abstraction class for a foreign key constraint. @@ -75,7 +83,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint * @param string|null $name Name of the foreign key constraint. * @param array $options Options associated with the foreign key constraint. */ - public function __construct(array $localColumnNames, $foreignTableName, array $foreignColumnNames, $name = null, array $options = array()) + public function __construct(array $localColumnNames, $foreignTableName, array $foreignColumnNames, $name = null, array $options = []) { $this->_setName($name); $identifierConstructorCallback = function ($column) { @@ -83,7 +91,7 @@ public function __construct(array $localColumnNames, $foreignTableName, array $f }; $this->_localColumnNames = $localColumnNames ? array_combine($localColumnNames, array_map($identifierConstructorCallback, $localColumnNames)) - : array(); + : []; if ($foreignTableName instanceof Table) { $this->_foreignTableName = $foreignTableName; @@ -93,7 +101,7 @@ public function __construct(array $localColumnNames, $foreignTableName, array $f $this->_foreignColumnNames = $foreignColumnNames ? array_combine($foreignColumnNames, array_map($identifierConstructorCallback, $foreignColumnNames)) - : array(); + : []; $this->_options = $options; } @@ -154,7 +162,7 @@ public function getLocalColumns() */ public function getQuotedLocalColumns(AbstractPlatform $platform) { - $columns = array(); + $columns = []; foreach ($this->_localColumnNames as $column) { $columns[] = $column->getQuotedName($platform); @@ -170,7 +178,7 @@ public function getQuotedLocalColumns(AbstractPlatform $platform) */ public function getUnquotedLocalColumns() { - return array_map(array($this, 'trimQuotes'), $this->getLocalColumns()); + return array_map([$this, 'trimQuotes'], $this->getLocalColumns()); } /** @@ -180,7 +188,7 @@ public function getUnquotedLocalColumns() */ public function getUnquotedForeignColumns() { - return array_map(array($this, 'trimQuotes'), $this->getForeignColumns()); + return array_map([$this, 'trimQuotes'], $this->getForeignColumns()); } /** @@ -277,7 +285,7 @@ public function getForeignColumns() */ public function getQuotedForeignColumns(AbstractPlatform $platform) { - $columns = array(); + $columns = []; foreach ($this->_foreignColumnNames as $column) { $columns[] = $column->getQuotedName($platform); @@ -292,7 +300,7 @@ public function getQuotedForeignColumns(AbstractPlatform $platform) * * @param string $name Name of the option to check. * - * @return boolean + * @return bool */ public function hasOption($name) { @@ -356,7 +364,7 @@ private function onEvent($event) if (isset($this->_options[$event])) { $onEvent = strtoupper($this->_options[$event]); - if ( ! in_array($onEvent, array('NO ACTION', 'RESTRICT'))) { + if ( ! in_array($onEvent, ['NO ACTION', 'RESTRICT'])) { return $onEvent; } } @@ -372,7 +380,7 @@ private function onEvent($event) * * @param Index $index The index to be checked against. * - * @return boolean + * @return bool */ public function intersectsIndexColumns(Index $index) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Index.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Index.php index 554d80f78..78a2322c8 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Index.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Index.php @@ -20,6 +20,12 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function array_keys; +use function array_map; +use function array_search; +use function count; +use function is_string; +use function strtolower; class Index extends AbstractAsset implements Constraint { @@ -29,15 +35,15 @@ class Index extends AbstractAsset implements Constraint * * @var Identifier[] */ - protected $_columns = array(); + protected $_columns = []; /** - * @var boolean + * @var bool */ protected $_isUnique = false; /** - * @var boolean + * @var bool */ protected $_isPrimary = false; @@ -47,7 +53,7 @@ class Index extends AbstractAsset implements Constraint * * @var array */ - protected $_flags = array(); + protected $_flags = []; /** * Platform specific options @@ -56,17 +62,17 @@ class Index extends AbstractAsset implements Constraint * * @var array */ - private $options = array(); + private $options = []; /** * @param string $indexName * @param string[] $columns - * @param boolean $isUnique - * @param boolean $isPrimary + * @param bool $isUnique + * @param bool $isPrimary * @param string[] $flags * @param array $options */ - public function __construct($indexName, array $columns, $isUnique = false, $isPrimary = false, array $flags = array(), array $options = array()) + public function __construct($indexName, array $columns, $isUnique = false, $isPrimary = false, array $flags = [], array $options = []) { $isUnique = $isUnique || $isPrimary; @@ -112,7 +118,7 @@ public function getColumns() */ public function getQuotedColumns(AbstractPlatform $platform) { - $columns = array(); + $columns = []; foreach ($this->_columns as $column) { $columns[] = $column->getQuotedName($platform); @@ -126,13 +132,13 @@ public function getQuotedColumns(AbstractPlatform $platform) */ public function getUnquotedColumns() { - return array_map(array($this, 'trimQuotes'), $this->getColumns()); + return array_map([$this, 'trimQuotes'], $this->getColumns()); } /** * Is the index neither unique nor primary key? * - * @return boolean + * @return bool */ public function isSimpleIndex() { @@ -140,7 +146,7 @@ public function isSimpleIndex() } /** - * @return boolean + * @return bool */ public function isUnique() { @@ -148,7 +154,7 @@ public function isUnique() } /** - * @return boolean + * @return bool */ public function isPrimary() { @@ -156,10 +162,10 @@ public function isPrimary() } /** - * @param string $columnName - * @param integer $pos + * @param string $columnName + * @param int $pos * - * @return boolean + * @return bool */ public function hasColumnAtPosition($columnName, $pos = 0) { @@ -174,7 +180,7 @@ public function hasColumnAtPosition($columnName, $pos = 0) * * @param array $columnNames * - * @return boolean + * @return bool */ public function spansColumns(array $columnNames) { @@ -196,7 +202,7 @@ public function spansColumns(array $columnNames) * * @param Index $other * - * @return boolean + * @return bool */ public function isFullfilledBy(Index $other) { @@ -226,11 +232,7 @@ public function isFullfilledBy(Index $other) return false; } - if ($other->isUnique() != $this->isUnique()) { - return false; - } - - return true; + return $other->isUnique() === $this->isUnique(); } return false; @@ -241,7 +243,7 @@ public function isFullfilledBy(Index $other) * * @param Index $other * - * @return boolean + * @return bool */ public function overrules(Index $other) { @@ -251,11 +253,7 @@ public function overrules(Index $other) return false; } - if ($this->spansColumns($other->getColumns()) && ($this->isPrimary() || $this->isUnique()) && $this->samePartialIndex($other)) { - return true; - } - - return false; + return $this->spansColumns($other->getColumns()) && ($this->isPrimary() || $this->isUnique()) && $this->samePartialIndex($other); } /** @@ -289,7 +287,7 @@ public function addFlag($flag) * * @param string $flag * - * @return boolean + * @return bool */ public function hasFlag($flag) { @@ -311,7 +309,7 @@ public function removeFlag($flag) /** * @param string $name * - * @return boolean + * @return bool */ public function hasOption($name) { @@ -340,7 +338,7 @@ public function getOptions() * Return whether the two indexes have the same partial index * @param \Doctrine\DBAL\Schema\Index $other * - * @return boolean + * @return bool */ private function samePartialIndex(Index $other) { @@ -348,11 +346,7 @@ private function samePartialIndex(Index $other) return true; } - if ( ! $this->hasOption('where') && ! $other->hasOption('where')) { - return true; - } - - return false; + return ! $this->hasOption('where') && ! $other->hasOption('where'); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index 0b36762b6..a56a6af86 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -19,8 +19,21 @@ namespace Doctrine\DBAL\Schema; +use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Types\Type; +use const CASE_LOWER; +use function array_change_key_case; +use function array_shift; +use function array_values; +use function end; +use function preg_match; +use function preg_replace; +use function str_replace; +use function stripslashes; +use function strpos; +use function strtok; +use function strtolower; /** * Schema manager for the MySql RDBMS. @@ -54,28 +67,28 @@ protected function _getPortableTableDefinition($table) */ protected function _getPortableUserDefinition($user) { - return array( + return [ 'user' => $user['User'], 'password' => $user['Password'], - ); + ]; } /** * {@inheritdoc} */ - protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) + protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { foreach ($tableIndexes as $k => $v) { $v = array_change_key_case($v, CASE_LOWER); - if ($v['key_name'] == 'PRIMARY') { + if ($v['key_name'] === 'PRIMARY') { $v['primary'] = true; } else { $v['primary'] = false; } if (strpos($v['index_type'], 'FULLTEXT') !== false) { - $v['flags'] = array('FULLTEXT'); + $v['flags'] = ['FULLTEXT']; } elseif (strpos($v['index_type'], 'SPATIAL') !== false) { - $v['flags'] = array('SPATIAL'); + $v['flags'] = ['SPATIAL']; } $tableIndexes[$k] = $v; } @@ -108,11 +121,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) $dbType = strtolower($tableColumn['type']); $dbType = strtok($dbType, '(), '); - if (isset($tableColumn['length'])) { - $length = $tableColumn['length']; - } else { - $length = strtok('(), '); - } + $length = $tableColumn['length'] ?? strtok('(), '); $fixed = null; @@ -120,14 +129,14 @@ protected function _getPortableTableColumnDefinition($tableColumn) $tableColumn['name'] = ''; } - $scale = null; + $scale = null; $precision = null; $type = $this->_platform->getDoctrineTypeMapping($dbType); // In cases where not connected to a database DESCRIBE $table does not return 'Comment' if (isset($tableColumn['comment'])) { - $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type); + $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type); $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type); } @@ -143,8 +152,8 @@ protected function _getPortableTableColumnDefinition($tableColumn) case 'decimal': if (preg_match('([A-Za-z]+\(([0-9]+)\,([0-9]+)\))', $tableColumn['type'], $match)) { $precision = $match[1]; - $scale = $match[2]; - $length = null; + $scale = $match[2]; + $length = null; } break; case 'tinytext': @@ -176,25 +185,29 @@ protected function _getPortableTableColumnDefinition($tableColumn) break; } - $length = ((int) $length == 0) ? null : (int) $length; + if ($this->_platform instanceof MariaDb1027Platform) { + $columnDefault = $this->getMariaDb1027ColumnDefault($this->_platform, $tableColumn['default']); + } else { + $columnDefault = $tableColumn['default']; + } - $options = array( - 'length' => $length, - 'unsigned' => (bool) (strpos($tableColumn['type'], 'unsigned') !== false), + $options = [ + 'length' => $length !== null ? (int) $length : null, + 'unsigned' => strpos($tableColumn['type'], 'unsigned') !== false, 'fixed' => (bool) $fixed, - 'default' => isset($tableColumn['default']) ? $tableColumn['default'] : null, - 'notnull' => (bool) ($tableColumn['null'] != 'YES'), + 'default' => $columnDefault, + 'notnull' => $tableColumn['null'] !== 'YES', 'scale' => null, 'precision' => null, - 'autoincrement' => (bool) (strpos($tableColumn['extra'], 'auto_increment') !== false), + 'autoincrement' => strpos($tableColumn['extra'], 'auto_increment') !== false, 'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null, - ); + ]; if ($scale !== null && $precision !== null) { - $options['scale'] = $scale; - $options['precision'] = $precision; + $options['scale'] = (int) $scale; + $options['precision'] = (int) $precision; } $column = new Column($tableColumn['field'], Type::getType($type), $options); @@ -206,44 +219,85 @@ protected function _getPortableTableColumnDefinition($tableColumn) return $column; } + /** + * Return Doctrine/Mysql-compatible column default values for MariaDB 10.2.7+ servers. + * + * - Since MariaDb 10.2.7 column defaults stored in information_schema are now quoted + * to distinguish them from expressions (see MDEV-10134). + * - CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE are stored in information_schema + * as current_timestamp(), currdate(), currtime() + * - Quoted 'NULL' is not enforced by Maria, it is technically possible to have + * null in some circumstances (see https://jira.mariadb.org/browse/MDEV-14053) + * - \' is always stored as '' in information_schema (normalized) + * + * @link https://mariadb.com/kb/en/library/information-schema-columns-table/ + * @link https://jira.mariadb.org/browse/MDEV-13132 + * + * @param null|string $columnDefault default value as stored in information_schema for MariaDB >= 10.2.7 + */ + private function getMariaDb1027ColumnDefault(MariaDb1027Platform $platform, ?string $columnDefault) : ?string + { + if ($columnDefault === 'NULL' || $columnDefault === null) { + return null; + } + if ($columnDefault[0] === "'") { + return stripslashes( + str_replace("''", "'", + preg_replace('/^\'(.*)\'$/', '$1', $columnDefault) + ) + ); + } + switch ($columnDefault) { + case 'current_timestamp()': + return $platform->getCurrentTimestampSQL(); + case 'curdate()': + return $platform->getCurrentDateSQL(); + case 'curtime()': + return $platform->getCurrentTimeSQL(); + } + return $columnDefault; + } + /** * {@inheritdoc} */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { - $list = array(); + $list = []; foreach ($tableForeignKeys as $value) { $value = array_change_key_case($value, CASE_LOWER); - if (!isset($list[$value['constraint_name']])) { - if (!isset($value['delete_rule']) || $value['delete_rule'] == "RESTRICT") { + if ( ! isset($list[$value['constraint_name']])) { + if ( ! isset($value['delete_rule']) || $value['delete_rule'] === "RESTRICT") { $value['delete_rule'] = null; } - if (!isset($value['update_rule']) || $value['update_rule'] == "RESTRICT") { + if ( ! isset($value['update_rule']) || $value['update_rule'] === "RESTRICT") { $value['update_rule'] = null; } - $list[$value['constraint_name']] = array( + $list[$value['constraint_name']] = [ 'name' => $value['constraint_name'], - 'local' => array(), - 'foreign' => array(), + 'local' => [], + 'foreign' => [], 'foreignTable' => $value['referenced_table_name'], 'onDelete' => $value['delete_rule'], 'onUpdate' => $value['update_rule'], - ); + ]; } - $list[$value['constraint_name']]['local'][] = $value['column_name']; + $list[$value['constraint_name']]['local'][] = $value['column_name']; $list[$value['constraint_name']]['foreign'][] = $value['referenced_column_name']; } - $result = array(); + $result = []; foreach ($list as $constraint) { $result[] = new ForeignKeyConstraint( - array_values($constraint['local']), $constraint['foreignTable'], - array_values($constraint['foreign']), $constraint['name'], - array( + array_values($constraint['local']), + $constraint['foreignTable'], + array_values($constraint['foreign']), + $constraint['name'], + [ 'onDelete' => $constraint['onDelete'], 'onUpdate' => $constraint['onUpdate'], - ) + ] ); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index 9feecdc76..aa83d8083 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -22,6 +22,16 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Types\Type; +use const CASE_LOWER; +use function array_change_key_case; +use function array_values; +use function is_null; +use function preg_match; +use function sprintf; +use function strpos; +use function strtolower; +use function strtoupper; +use function trim; /** * Oracle Schema Manager. @@ -78,9 +88,9 @@ protected function _getPortableUserDefinition($user) { $user = \array_change_key_case($user, CASE_LOWER); - return array( + return [ 'user' => $user['username'], - ); + ]; } /** @@ -101,7 +111,7 @@ protected function _getPortableTableDefinition($table) */ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { - $indexBuffer = array(); + $indexBuffer = []; foreach ($tableIndexes as $tableIndex) { $tableIndex = \array_change_key_case($tableIndex, CASE_LOWER); @@ -227,7 +237,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) $length = null; } - $options = array( + $options = [ 'notnull' => (bool) ($tableColumn['nullable'] === 'N'), 'fixed' => (bool) $fixed, 'unsigned' => (bool) $unsigned, @@ -238,8 +248,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) 'comment' => isset($tableColumn['comments']) && '' !== $tableColumn['comments'] ? $tableColumn['comments'] : null, - 'platformDetails' => array(), - ); + ]; return new Column($this->getQuotedIdentifierName($tableColumn['column_name']), Type::getType($type), $options); } @@ -249,7 +258,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { - $list = array(); + $list = []; foreach ($tableForeignKeys as $value) { $value = \array_change_key_case($value, CASE_LOWER); if (!isset($list[$value['constraint_name']])) { @@ -257,13 +266,13 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) $value['delete_rule'] = null; } - $list[$value['constraint_name']] = array( + $list[$value['constraint_name']] = [ 'name' => $this->getQuotedIdentifierName($value['constraint_name']), - 'local' => array(), - 'foreign' => array(), + 'local' => [], + 'foreign' => [], 'foreignTable' => $value['references_table'], 'onDelete' => $value['delete_rule'], - ); + ]; } $localColumn = $this->getQuotedIdentifierName($value['local_column']); @@ -273,12 +282,12 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) $list[$value['constraint_name']]['foreign'][$value['position']] = $foreignColumn; } - $result = array(); + $result = []; foreach ($list as $constraint) { $result[] = new ForeignKeyConstraint( array_values($constraint['local']), $this->getQuotedIdentifierName($constraint['foreignTable']), array_values($constraint['foreign']), $this->getQuotedIdentifierName($constraint['name']), - array('onDelete' => $constraint['onDelete']) + ['onDelete' => $constraint['onDelete']] ); } @@ -294,8 +303,8 @@ protected function _getPortableSequenceDefinition($sequence) return new Sequence( $this->getQuotedIdentifierName($sequence['sequence_name']), - $sequence['increment_by'], - $sequence['min_value'] + (int) $sequence['increment_by'], + (int) $sequence['min_value'] ); } @@ -344,7 +353,7 @@ public function createDatabase($database = null) /** * @param string $table * - * @return boolean + * @return bool */ public function dropAutoincrement($table) { @@ -408,7 +417,7 @@ private function killUserSessions($user) AND p.addr(+) = s.paddr SQL; - $activeUserSessions = $this->_conn->fetchAll($sql, array(strtoupper($user))); + $activeUserSessions = $this->_conn->fetchAll($sql, [strtoupper($user)]); foreach ($activeUserSessions as $activeUserSession) { $activeUserSession = array_change_key_case($activeUserSession, \CASE_LOWER); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index 395ad95af..a0cc5fbd0 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -21,6 +21,23 @@ use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Types\Type; +use const CASE_LOWER; +use function array_change_key_case; +use function array_filter; +use function array_keys; +use function array_map; +use function array_shift; +use function explode; +use function in_array; +use function join; +use function preg_match; +use function preg_replace; +use function str_replace; +use function stripos; +use function strlen; +use function strpos; +use function strtolower; +use function trim; /** * PostgreSQL Schema Manager. @@ -118,10 +135,10 @@ public function dropDatabase($database) } $this->_execSql( - array( + [ $this->_platform->getDisallowDatabaseConnectionsSQL($database), $this->_platform->getCloseActiveDatabaseConnectionsSQL($database), - ) + ] ); parent::dropDatabase($database); @@ -153,7 +170,7 @@ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) return new ForeignKeyConstraint( $localColumns, $foreignTable, $foreignColumns, $tableForeignKey['conname'], - array('onUpdate' => $onUpdate, 'onDelete' => $onDelete) + ['onUpdate' => $onUpdate, 'onDelete' => $onDelete] ); } @@ -178,10 +195,10 @@ protected function _getPortableViewDefinition($view) */ protected function _getPortableUserDefinition($user) { - return array( + return [ 'user' => $user['usename'], 'password' => $user['passwd'] - ); + ]; } /** @@ -194,9 +211,9 @@ protected function _getPortableTableDefinition($table) if ($table['schema_name'] == $firstSchema) { return $table['table_name']; - } else { - return $table['schema_name'] . "." . $table['table_name']; } + + return $table['schema_name'] . "." . $table['table_name']; } /** @@ -207,7 +224,7 @@ protected function _getPortableTableDefinition($table) */ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { - $buffer = array(); + $buffer = []; foreach ($tableIndexes as $row) { $colNumbers = explode(' ', $row['indkey']); $colNumbersSql = 'IN (' . join(' ,', $colNumbers) . ' )'; @@ -221,13 +238,13 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) foreach ($colNumbers as $colNum) { foreach ($indexColumns as $colRow) { if ($colNum == $colRow['attnum']) { - $buffer[] = array( + $buffer[] = [ 'key_name' => $row['relname'], 'column_name' => trim($colRow['attname']), 'non_unique' => !$row['indisunique'], 'primary' => $row['indisprimary'], 'where' => $row['where'], - ); + ]; } } } @@ -249,7 +266,7 @@ protected function _getPortableDatabaseDefinition($database) */ protected function _getPortableSequencesList($sequences) { - $sequenceDefinitions = array(); + $sequenceDefinitions = []; foreach ($sequences as $sequence) { if ($sequence['schemaname'] != 'public') { @@ -261,7 +278,7 @@ protected function _getPortableSequencesList($sequences) $sequenceDefinitions[$sequenceName] = $sequence; } - $list = array(); + $list = []; foreach ($this->filterAssetNames(array_keys($sequenceDefinitions)) as $sequenceName) { $list[] = $this->_getPortableSequenceDefinition($sequenceDefinitions[$sequenceName]); @@ -283,15 +300,18 @@ protected function getPortableNamespaceDefinition(array $namespace) */ protected function _getPortableSequenceDefinition($sequence) { - if ($sequence['schemaname'] != 'public') { + if ($sequence['schemaname'] !== 'public') { $sequenceName = $sequence['schemaname'] . "." . $sequence['relname']; } else { $sequenceName = $sequence['relname']; } - $data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName)); + if ( ! isset($sequence['increment_by'], $sequence['min_value'])) { + $data = $this->_conn->fetchAssoc('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName)); + $sequence += $data; + } - return new Sequence($sequenceName, $data[0]['increment_by'], $data[0]['min_value']); + return new Sequence($sequenceName, (int) $sequence['increment_by'], (int) $sequence['min_value']); } /** @@ -307,7 +327,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) $tableColumn['length'] = $length; } - $matches = array(); + $matches = []; $autoincrement = false; if (preg_match("/^nextval\('(.*)'(::.*)?\)$/", $tableColumn['default'], $matches)) { @@ -324,7 +344,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) $tableColumn['default'] = null; } - $length = (isset($tableColumn['length'])) ? $tableColumn['length'] : null; + $length = $tableColumn['length'] ?? null; if ($length == '-1' && isset($tableColumn['atttypmod'])) { $length = $tableColumn['atttypmod'] - 4; } @@ -423,11 +443,10 @@ protected function _getPortableTableColumnDefinition($tableColumn) $tableColumn['default'] = $match[1]; } - $options = array( + $options = [ 'length' => $length, 'notnull' => (bool) $tableColumn['isnotnull'], 'default' => $tableColumn['default'], - 'primary' => (bool) ($tableColumn['pri'] == 't'), 'precision' => $precision, 'scale' => $scale, 'fixed' => $fixed, @@ -436,7 +455,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) 'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null, - ); + ]; $column = new Column($tableColumn['field'], Type::getType($type), $options); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php index 793a5fe8b..4025c0345 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php @@ -20,6 +20,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types\Type; +use function preg_replace; /** * SAP Sybase SQL Anywhere schema manager. @@ -111,7 +112,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) if (null !== $tableColumn['default']) { // Strip quotes from default value. - $default = preg_replace(array("/^'(.*)'$/", "/''/"), array("$1", "'"), $tableColumn['default']); + $default = preg_replace(["/^'(.*)'$/", "/''/"], ["$1", "'"], $tableColumn['default']); if ('autoincrement' == $default) { $default = null; @@ -135,7 +136,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) return new Column( $tableColumn['column_name'], Type::getType($type), - array( + [ 'length' => $type == 'string' ? $tableColumn['length'] : null, 'precision' => $precision, 'scale' => $scale, @@ -147,7 +148,8 @@ protected function _getPortableTableColumnDefinition($tableColumn) 'comment' => isset($tableColumn['comment']) && '' !== $tableColumn['comment'] ? $tableColumn['comment'] : null, - )); + ] + ); } /** @@ -177,16 +179,16 @@ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { - $foreignKeys = array(); + $foreignKeys = []; foreach ($tableForeignKeys as $tableForeignKey) { if (!isset($foreignKeys[$tableForeignKey['index_name']])) { - $foreignKeys[$tableForeignKey['index_name']] = array( - 'local_columns' => array($tableForeignKey['local_column']), + $foreignKeys[$tableForeignKey['index_name']] = [ + 'local_columns' => [$tableForeignKey['local_column']], 'foreign_table' => $tableForeignKey['foreign_table'], - 'foreign_columns' => array($tableForeignKey['foreign_column']), + 'foreign_columns' => [$tableForeignKey['foreign_column']], 'name' => $tableForeignKey['index_name'], - 'options' => array( + 'options' => [ 'notnull' => $tableForeignKey['notnull'], 'match' => $tableForeignKey['match'], 'onUpdate' => $tableForeignKey['on_update'], @@ -194,8 +196,8 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) 'check_on_commit' => $tableForeignKey['check_on_commit'], 'clustered' => $tableForeignKey['clustered'], 'for_olap_workload' => $tableForeignKey['for_olap_workload'] - ) - ); + ] + ]; } else { $foreignKeys[$tableForeignKey['index_name']]['local_columns'][] = $tableForeignKey['local_column']; $foreignKeys[$tableForeignKey['index_name']]['foreign_columns'][] = $tableForeignKey['foreign_column']; @@ -212,7 +214,7 @@ protected function _getPortableTableIndexesList($tableIndexRows, $tableName = nu { foreach ($tableIndexRows as &$tableIndex) { $tableIndex['primary'] = (boolean) $tableIndex['primary']; - $tableIndex['flags'] = array(); + $tableIndex['flags'] = []; if ($tableIndex['clustered']) { $tableIndex['flags'][] = 'clustered'; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php index 100a64c22..f5383fb7f 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php @@ -22,6 +22,14 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Types\Type; +use function count; +use function in_array; +use function preg_replace; +use function sprintf; +use function str_replace; +use function strpos; +use function strtok; +use function trim; /** * SQL Server Schema Manager. @@ -68,7 +76,7 @@ public function dropDatabase($database) */ protected function _getPortableSequenceDefinition($sequence) { - return new Sequence($sequence['name'], $sequence['increment'], $sequence['start_value']); + return new Sequence($sequence['name'], (int) $sequence['increment'], (int) $sequence['start_value']); } /** @@ -116,8 +124,8 @@ protected function _getPortableTableColumnDefinition($tableColumn) $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type); $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type); - $options = array( - 'length' => ($length == 0 || !in_array($type, array('text', 'string'))) ? null : $length, + $options = [ + 'length' => ($length == 0 || !in_array($type, ['text', 'string'])) ? null : $length, 'unsigned' => false, 'fixed' => (bool) $fixed, 'default' => $default !== 'NULL' ? $default : null, @@ -126,7 +134,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) 'precision' => $tableColumn['precision'], 'autoincrement' => (bool) $tableColumn['autoincrement'], 'comment' => $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null, - ); + ]; $column = new Column($tableColumn['name'], Type::getType($type), $options); @@ -142,20 +150,20 @@ protected function _getPortableTableColumnDefinition($tableColumn) */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { - $foreignKeys = array(); + $foreignKeys = []; foreach ($tableForeignKeys as $tableForeignKey) { if ( ! isset($foreignKeys[$tableForeignKey['ForeignKey']])) { - $foreignKeys[$tableForeignKey['ForeignKey']] = array( - 'local_columns' => array($tableForeignKey['ColumnName']), + $foreignKeys[$tableForeignKey['ForeignKey']] = [ + 'local_columns' => [$tableForeignKey['ColumnName']], 'foreign_table' => $tableForeignKey['ReferenceTableName'], - 'foreign_columns' => array($tableForeignKey['ReferenceColumnName']), + 'foreign_columns' => [$tableForeignKey['ReferenceColumnName']], 'name' => $tableForeignKey['ForeignKey'], - 'options' => array( + 'options' => [ 'onUpdate' => str_replace('_', ' ', $tableForeignKey['update_referential_action_desc']), 'onDelete' => str_replace('_', ' ', $tableForeignKey['delete_referential_action_desc']) - ) - ); + ] + ]; } else { $foreignKeys[$tableForeignKey['ForeignKey']]['local_columns'][] = $tableForeignKey['ColumnName']; $foreignKeys[$tableForeignKey['ForeignKey']]['foreign_columns'][] = $tableForeignKey['ReferenceColumnName']; @@ -173,7 +181,7 @@ protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null foreach ($tableIndexRows as &$tableIndex) { $tableIndex['non_unique'] = (boolean) $tableIndex['non_unique']; $tableIndex['primary'] = (boolean) $tableIndex['primary']; - $tableIndex['flags'] = $tableIndex['flags'] ? array($tableIndex['flags']) : null; + $tableIndex['flags'] = $tableIndex['flags'] ? [$tableIndex['flags']] : null; } return parent::_getPortableTableIndexesList($tableIndexRows, $tableName); @@ -198,6 +206,10 @@ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) */ protected function _getPortableTableDefinition($table) { + if (isset($table['schema_name']) && $table['schema_name'] !== 'dbo') { + return $table['schema_name'] . '.' . $table['name']; + } + return $table['name']; } @@ -237,13 +249,13 @@ public function listTableIndexes($table) $tableIndexes = $this->_conn->fetchAll($sql); } catch (\PDOException $e) { if ($e->getCode() == "IMSSP") { - return array(); + return []; } else { throw $e; } } catch (DBALException $e) { if (strpos($e->getMessage(), 'SQLSTATE [01000, 15472]') === 0) { - return array(); + return []; } else { throw $e; } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php index 3277ad72c..88e5ed0de 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php @@ -24,6 +24,9 @@ use Doctrine\DBAL\Schema\Visitor\NamespaceVisitor; use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function array_keys; +use function strpos; +use function strtolower; /** * Object representation of a database schema. @@ -60,17 +63,17 @@ class Schema extends AbstractAsset * * @var array */ - private $namespaces = array(); + private $namespaces = []; /** * @var \Doctrine\DBAL\Schema\Table[] */ - protected $_tables = array(); + protected $_tables = []; /** * @var \Doctrine\DBAL\Schema\Sequence[] */ - protected $_sequences = array(); + protected $_sequences = []; /** * @var \Doctrine\DBAL\Schema\SchemaConfig @@ -84,10 +87,10 @@ class Schema extends AbstractAsset * @param array $namespaces */ public function __construct( - array $tables = array(), - array $sequences = array(), + array $tables = [], + array $sequences = [], SchemaConfig $schemaConfig = null, - array $namespaces = array() + array $namespaces = [] ) { if ($schemaConfig == null) { $schemaConfig = new SchemaConfig(); @@ -109,7 +112,7 @@ public function __construct( } /** - * @return boolean + * @return bool */ public function hasExplicitForeignKeyIndexes() { @@ -237,7 +240,7 @@ private function getUnquotedAssetName($assetName) * * @param string $namespaceName * - * @return boolean + * @return bool */ public function hasNamespace($namespaceName) { @@ -251,7 +254,7 @@ public function hasNamespace($namespaceName) * * @param string $tableName * - * @return boolean + * @return bool */ public function hasTable($tableName) { @@ -273,7 +276,7 @@ public function getTableNames() /** * @param string $sequenceName * - * @return boolean + * @return bool */ public function hasSequence($sequenceName) { @@ -386,9 +389,9 @@ public function dropTable($tableName) /** * Creates a new sequence. * - * @param string $sequenceName - * @param integer $allocationSize - * @param integer $initialValue + * @param string $sequenceName + * @param int $allocationSize + * @param int $initialValue * * @return \Doctrine\DBAL\Schema\Sequence */ diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaConfig.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaConfig.php index cc23237d8..c8c7673ba 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaConfig.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaConfig.php @@ -29,12 +29,12 @@ class SchemaConfig { /** - * @var boolean + * @var bool */ protected $hasExplicitForeignKeyIndexes = false; /** - * @var integer + * @var int */ protected $maxIdentifierLength = 63; @@ -46,10 +46,10 @@ class SchemaConfig /** * @var array */ - protected $defaultTableOptions = array(); + protected $defaultTableOptions = []; /** - * @return boolean + * @return bool */ public function hasExplicitForeignKeyIndexes() { @@ -57,7 +57,7 @@ public function hasExplicitForeignKeyIndexes() } /** - * @param boolean $flag + * @param bool $flag * * @return void */ @@ -67,7 +67,7 @@ public function setExplicitForeignKeyIndexes($flag) } /** - * @param integer $length + * @param int $length * * @return void */ @@ -77,7 +77,7 @@ public function setMaxIdentifierLength($length) } /** - * @return integer + * @return int */ public function getMaxIdentifierLength() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php index 23eccdad8..ec9ccba93 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php @@ -20,6 +20,7 @@ namespace Doctrine\DBAL\Schema; use \Doctrine\DBAL\Platforms\AbstractPlatform; +use function array_merge; /** * Schema Diff. @@ -42,55 +43,55 @@ class SchemaDiff * * @var string[] */ - public $newNamespaces = array(); + public $newNamespaces = []; /** * All removed namespaces. * * @var string[] */ - public $removedNamespaces = array(); + public $removedNamespaces = []; /** * All added tables. * * @var \Doctrine\DBAL\Schema\Table[] */ - public $newTables = array(); + public $newTables = []; /** * All changed tables. * * @var \Doctrine\DBAL\Schema\TableDiff[] */ - public $changedTables = array(); + public $changedTables = []; /** * All removed tables. * * @var \Doctrine\DBAL\Schema\Table[] */ - public $removedTables = array(); + public $removedTables = []; /** * @var \Doctrine\DBAL\Schema\Sequence[] */ - public $newSequences = array(); + public $newSequences = []; /** * @var \Doctrine\DBAL\Schema\Sequence[] */ - public $changedSequences = array(); + public $changedSequences = []; /** * @var \Doctrine\DBAL\Schema\Sequence[] */ - public $removedSequences = array(); + public $removedSequences = []; /** * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ - public $orphanedForeignKeys = array(); + public $orphanedForeignKeys = []; /** * Constructs an SchemaDiff object. @@ -100,7 +101,7 @@ class SchemaDiff * @param \Doctrine\DBAL\Schema\Table[] $removedTables * @param \Doctrine\DBAL\Schema\Schema|null $fromSchema */ - public function __construct($newTables = array(), $changedTables = array(), $removedTables = array(), Schema $fromSchema = null) + public function __construct($newTables = [], $changedTables = [], $removedTables = [], Schema $fromSchema = null) { $this->newTables = $newTables; $this->changedTables = $changedTables; @@ -138,13 +139,13 @@ public function toSql(AbstractPlatform $platform) /** * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform - * @param boolean $saveMode + * @param bool $saveMode * * @return array */ protected function _toSql(AbstractPlatform $platform, $saveMode = false) { - $sql = array(); + $sql = []; if ($platform->supportsSchemas()) { foreach ($this->newNamespaces as $newNamespace) { @@ -174,7 +175,7 @@ protected function _toSql(AbstractPlatform $platform, $saveMode = false) } } - $foreignKeySql = array(); + $foreignKeySql = []; foreach ($this->newTables as $table) { $sql = array_merge( $sql, diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php index 152f374da..7285d81cb 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php @@ -19,6 +19,9 @@ namespace Doctrine\DBAL\Schema; +use function implode; +use function sprintf; + class SchemaException extends \Doctrine\DBAL\DBALException { const TABLE_DOESNT_EXIST = 10; @@ -38,7 +41,7 @@ class SchemaException extends \Doctrine\DBAL\DBALException * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function tableDoesNotExist($tableName) + public static function tableDoesNotExist($tableName) { return new self("There is no table with name '".$tableName."' in the schema.", self::TABLE_DOESNT_EXIST); } @@ -48,7 +51,7 @@ static public function tableDoesNotExist($tableName) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function indexNameInvalid($indexName) + public static function indexNameInvalid($indexName) { return new self("Invalid index-name $indexName given, has to be [a-zA-Z0-9_]", self::INDEX_INVALID_NAME); } @@ -59,7 +62,7 @@ static public function indexNameInvalid($indexName) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function indexDoesNotExist($indexName, $table) + public static function indexDoesNotExist($indexName, $table) { return new self("Index '$indexName' does not exist on table '$table'.", self::INDEX_DOESNT_EXIST); } @@ -70,7 +73,7 @@ static public function indexDoesNotExist($indexName, $table) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function indexAlreadyExists($indexName, $table) + public static function indexAlreadyExists($indexName, $table) { return new self("An index with name '$indexName' was already defined on table '$table'.", self::INDEX_ALREADY_EXISTS); } @@ -81,7 +84,7 @@ static public function indexAlreadyExists($indexName, $table) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function columnDoesNotExist($columnName, $table) + public static function columnDoesNotExist($columnName, $table) { return new self("There is no column with name '$columnName' on table '$table'.", self::COLUMN_DOESNT_EXIST); } @@ -91,7 +94,7 @@ static public function columnDoesNotExist($columnName, $table) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function namespaceAlreadyExists($namespaceName) + public static function namespaceAlreadyExists($namespaceName) { return new self( sprintf("The namespace with name '%s' already exists.", $namespaceName), @@ -104,7 +107,7 @@ static public function namespaceAlreadyExists($namespaceName) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function tableAlreadyExists($tableName) + public static function tableAlreadyExists($tableName) { return new self("The table with name '".$tableName."' already exists.", self::TABLE_ALREADY_EXISTS); } @@ -115,7 +118,7 @@ static public function tableAlreadyExists($tableName) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function columnAlreadyExists($tableName, $columnName) + public static function columnAlreadyExists($tableName, $columnName) { return new self( "The column '".$columnName."' on table '".$tableName."' already exists.", self::COLUMN_ALREADY_EXISTS @@ -127,7 +130,7 @@ static public function columnAlreadyExists($tableName, $columnName) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function sequenceAlreadyExists($sequenceName) + public static function sequenceAlreadyExists($sequenceName) { return new self("The sequence '".$sequenceName."' already exists.", self::SEQUENCE_ALREADY_EXISTS); } @@ -137,7 +140,7 @@ static public function sequenceAlreadyExists($sequenceName) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function sequenceDoesNotExist($sequenceName) + public static function sequenceDoesNotExist($sequenceName) { return new self("There exists no sequence with the name '".$sequenceName."'.", self::SEQUENCE_DOENST_EXIST); } @@ -148,7 +151,7 @@ static public function sequenceDoesNotExist($sequenceName) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function foreignKeyDoesNotExist($fkName, $table) + public static function foreignKeyDoesNotExist($fkName, $table) { return new self("There exists no foreign key with the name '$fkName' on table '$table'.", self::FOREIGNKEY_DOESNT_EXIST); } @@ -159,7 +162,7 @@ static public function foreignKeyDoesNotExist($fkName, $table) * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey) + public static function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey) { return new self( "The performed schema operation on ".$localTable->getName()." requires a named foreign key, ". @@ -174,7 +177,7 @@ static public function namedForeignKeyRequired(Table $localTable, ForeignKeyCons * * @return \Doctrine\DBAL\Schema\SchemaException */ - static public function alterTableChangeNotSupported($changeName) + public static function alterTableChangeNotSupported($changeName) { return new self("Alter table change not supported, given '$changeName'"); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php index 98c9cd1c5..6d304cde4 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php @@ -20,6 +20,9 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Visitor\Visitor; +use function count; +use function is_numeric; +use function sprintf; /** * Sequence structure. @@ -31,36 +34,36 @@ class Sequence extends AbstractAsset { /** - * @var integer + * @var int */ protected $allocationSize = 1; /** - * @var integer + * @var int */ protected $initialValue = 1; /** - * @var integer|null + * @var int|null */ protected $cache = null; /** - * @param string $name - * @param integer $allocationSize - * @param integer $initialValue - * @param integer|null $cache + * @param string $name + * @param int $allocationSize + * @param int $initialValue + * @param int|null $cache */ public function __construct($name, $allocationSize = 1, $initialValue = 1, $cache = null) { $this->_setName($name); $this->allocationSize = is_numeric($allocationSize) ? $allocationSize : 1; - $this->initialValue = is_numeric($initialValue) ? $initialValue : 1; - $this->cache = $cache; + $this->initialValue = is_numeric($initialValue) ? $initialValue : 1; + $this->cache = $cache; } /** - * @return integer + * @return int */ public function getAllocationSize() { @@ -68,7 +71,7 @@ public function getAllocationSize() } /** - * @return integer + * @return int */ public function getInitialValue() { @@ -76,7 +79,7 @@ public function getInitialValue() } /** - * @return integer|null + * @return int|null */ public function getCache() { @@ -84,7 +87,7 @@ public function getCache() } /** - * @param integer $allocationSize + * @param int $allocationSize * * @return \Doctrine\DBAL\Schema\Sequence */ @@ -96,7 +99,7 @@ public function setAllocationSize($allocationSize) } /** - * @param integer $initialValue + * @param int $initialValue * * @return \Doctrine\DBAL\Schema\Sequence */ @@ -108,7 +111,7 @@ public function setInitialValue($initialValue) } /** - * @param integer $cache + * @param int $cache * * @return \Doctrine\DBAL\Schema\Sequence */ @@ -127,7 +130,7 @@ public function setCache($cache) * * @param \Doctrine\DBAL\Schema\Table $table * - * @return boolean + * @return bool */ public function isAutoIncrementsFor(Table $table) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index b3f0ef2bd..ee11049aa 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -20,9 +20,29 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; +use const CASE_LOWER; +use function array_change_key_case; +use function array_map; +use function array_reverse; +use function array_values; +use function explode; +use function file_exists; +use function preg_match; +use function preg_match_all; +use function preg_quote; +use function preg_replace; +use function rtrim; +use function sprintf; +use function str_replace; +use function strpos; +use function strtolower; +use function trim; +use function unlink; +use function usort; /** * Sqlite SchemaManager. @@ -52,10 +72,10 @@ public function createDatabase($database) { $params = $this->_conn->getParams(); $driver = $params['driver']; - $options = array( + $options = [ 'driver' => $driver, 'path' => $database - ); + ]; $conn = \Doctrine\DBAL\DriverManager::getConnection($options); $conn->connect(); $conn->close(); @@ -118,7 +138,7 @@ public function listTableForeignKeys($table, $database = null) if ( ! empty($tableForeignKeys)) { $createSql = $this->_conn->fetchAll("SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type = 'table' AND name = '$table'"); - $createSql = isset($createSql[0]['sql']) ? $createSql[0]['sql'] : ''; + $createSql = $createSql[0]['sql'] ?? ''; if (preg_match_all('# (?:CONSTRAINT\s+([^\s]+)\s+)? @@ -135,7 +155,7 @@ public function listTableForeignKeys($table, $database = null) $deferrable = array_reverse($match[2]); $deferred = array_reverse($match[3]); } else { - $names = $deferrable = $deferred = array(); + $names = $deferrable = $deferred = []; } foreach ($tableForeignKeys as $key => $value) { @@ -165,11 +185,11 @@ protected function _getPortableTableDefinition($table) */ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { - $indexBuffer = array(); + $indexBuffer = []; // fetch primary $stmt = $this->_conn->executeQuery("PRAGMA TABLE_INFO ('$tableName')"); - $indexArray = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $indexArray = $stmt->fetchAll(FetchMode::ASSOCIATIVE); usort($indexArray, function($a, $b) { if ($a['pk'] == $b['pk']) { @@ -180,12 +200,12 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) }); foreach ($indexArray as $indexColumnRow) { if ($indexColumnRow['pk'] != "0") { - $indexBuffer[] = array( + $indexBuffer[] = [ 'key_name' => 'primary', 'primary' => true, 'non_unique' => false, 'column_name' => $indexColumnRow['name'] - ); + ]; } } @@ -194,13 +214,13 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) // Ignore indexes with reserved names, e.g. autoindexes if (strpos($tableIndex['name'], 'sqlite_') !== 0) { $keyName = $tableIndex['name']; - $idx = array(); + $idx = []; $idx['key_name'] = $keyName; $idx['primary'] = false; $idx['non_unique'] = $tableIndex['unique']?false:true; $stmt = $this->_conn->executeQuery("PRAGMA INDEX_INFO ('{$keyName}')"); - $indexArray = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $indexArray = $stmt->fetchAll(FetchMode::ASSOCIATIVE); foreach ($indexArray as $indexColumnRow) { $idx['column_name'] = $indexColumnRow['name']; @@ -217,10 +237,10 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) */ protected function _getPortableTableIndexDefinition($tableIndex) { - return array( + return [ 'name' => $tableIndex['name'], 'unique' => (bool) $tableIndex['unique'] - ); + ]; } /** @@ -253,7 +273,7 @@ protected function _getPortableTableColumnList($table, $database, $tableColumns) // inspect column collation and comments $createSql = $this->_conn->fetchAll("SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type = 'table' AND name = '$table'"); - $createSql = isset($createSql[0]['sql']) ? $createSql[0]['sql'] : ''; + $createSql = $createSql[0]['sql'] ?? ''; foreach ($list as $columnName => $column) { $type = $column->getType(); @@ -264,7 +284,7 @@ protected function _getPortableTableColumnList($table, $database, $tableColumns) $comment = $this->parseColumnCommentFromSQL($columnName, $createSql); - if (false !== $comment) { + if ($comment !== null) { $type = $this->extractDoctrineTypeFromComment($comment, null); if (null !== $type) { @@ -292,8 +312,8 @@ protected function _getPortableTableColumnDefinition($tableColumn) $tableColumn['length'] = $length; } - $dbType = strtolower($tableColumn['type']); - $length = isset($tableColumn['length']) ? $tableColumn['length'] : null; + $dbType = strtolower($tableColumn['type']); + $length = $tableColumn['length'] ?? null; $unsigned = false; if (strpos($dbType, ' unsigned') !== false) { @@ -339,7 +359,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) break; } - $options = array( + $options = [ 'length' => $length, 'unsigned' => (bool) $unsigned, 'fixed' => $fixed, @@ -348,7 +368,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) 'precision' => $precision, 'scale' => $scale, 'autoincrement' => false, - ); + ]; return new Column($tableColumn['name'], \Doctrine\DBAL\Types\Type::getType($type), $options); } @@ -366,7 +386,7 @@ protected function _getPortableViewDefinition($view) */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { - $list = array(); + $list = []; foreach ($tableForeignKeys as $value) { $value = array_change_key_case($value, CASE_LOWER); $name = $value['constraint_name']; @@ -378,32 +398,32 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) $value['on_update'] = null; } - $list[$name] = array( + $list[$name] = [ 'name' => $name, - 'local' => array(), - 'foreign' => array(), + 'local' => [], + 'foreign' => [], 'foreignTable' => $value['table'], 'onDelete' => $value['on_delete'], 'onUpdate' => $value['on_update'], 'deferrable' => $value['deferrable'], 'deferred'=> $value['deferred'], - ); + ]; } $list[$name]['local'][] = $value['from']; $list[$name]['foreign'][] = $value['to']; } - $result = array(); + $result = []; foreach ($list as $constraint) { $result[] = new ForeignKeyConstraint( array_values($constraint['local']), $constraint['foreignTable'], array_values($constraint['foreign']), $constraint['name'], - array( + [ 'onDelete' => $constraint['onDelete'], 'onUpdate' => $constraint['onUpdate'], 'deferrable' => $constraint['deferrable'], 'deferred'=> $constraint['deferred'], - ) + ] ); } @@ -435,43 +455,29 @@ private function getTableDiffForAlterForeignKey(ForeignKeyConstraint $foreignKey return $tableDiff; } - /** - * @param string $column - * @param string $sql - * - * @return string|false - */ - private function parseColumnCollationFromSQL($column, $sql) + private function parseColumnCollationFromSQL(string $column, string $sql) : ?string { - if (preg_match( - '{(?:'.preg_quote($column).'|'.preg_quote($this->_platform->quoteSingleIdentifier($column)).') - [^,(]+(?:\([^()]+\)[^,]*)? - (?:(?:DEFAULT|CHECK)\s*(?:\(.*?\))?[^,]*)* - COLLATE\s+["\']?([^\s,"\')]+)}isx', $sql, $match)) { - return $match[1]; + $pattern = '{(?:\W' . preg_quote($column) . '\W|\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) + . '\W)[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:DEFAULT|CHECK)\s*(?:\(.*?\))?[^,]*)*COLLATE\s+["\']?([^\s,"\')]+)}is'; + + if (preg_match($pattern, $sql, $match) !== 1) { + return null; } - return false; + return $match[1]; } - /** - * @param string $column - * @param string $sql - * - * @return string|false - */ - private function parseColumnCommentFromSQL($column, $sql) + private function parseColumnCommentFromSQL(string $column, string $sql) : ?string { - if (preg_match( - '{[\s(,](?:'.preg_quote($this->_platform->quoteSingleIdentifier($column)).'|'.preg_quote($column).') - (?:\(.*?\)|[^,(])*?,?((?:\s*--[^\n]*\n?)+) - }isx', $sql, $match - )) { - $comment = preg_replace('{^\s*--}m', '', rtrim($match[1], "\n")); - - return '' === $comment ? false : $comment; + $pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W|\W' . preg_quote($column) + . '\W)(?:\(.*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i'; + + if (preg_match($pattern, $sql, $match) !== 1) { + return null; } - return false; + $comment = preg_replace('{^\s*--}m', '', rtrim($match[1], "\n")); + + return '' === $comment ? null : $comment; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php index 1a5552ea6..b65efbbb9 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php @@ -42,7 +42,7 @@ function getCreateSchema(Schema $createSchema); * Gets the SQL Statements to update given schema with the underlying db. * * @param \Doctrine\DBAL\Schema\Schema $toSchema - * @param boolean $noDrops + * @param bool $noDrops * * @return array */ @@ -77,7 +77,7 @@ function createSchema(Schema $createSchema); * Updates the Schema to new schema version. * * @param \Doctrine\DBAL\Schema\Schema $toSchema - * @param boolean $noDrops + * @param bool $noDrops * * @return void */ diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php index 7cab7a5b3..f22607e6b 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php @@ -23,6 +23,7 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; +use function count; /** * Schema Synchronizer for Default DBAL Connection. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php index 428761ea3..40af2b219 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php @@ -22,6 +22,15 @@ use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\DBALException; +use const ARRAY_FILTER_USE_KEY; +use function array_filter; +use function array_merge; +use function in_array; +use function is_numeric; +use function is_string; +use function preg_match; +use function strlen; +use function strtolower; /** * Object Representation of a table. @@ -40,17 +49,17 @@ class Table extends AbstractAsset /** * @var Column[] */ - protected $_columns = array(); + protected $_columns = []; /** * @var Index[] */ - private $implicitIndexes = array(); + private $implicitIndexes = []; /** * @var Index[] */ - protected $_indexes = array(); + protected $_indexes = []; /** * @var string @@ -60,12 +69,12 @@ class Table extends AbstractAsset /** * @var ForeignKeyConstraint[] */ - protected $_fkConstraints = array(); + protected $_fkConstraints = []; /** * @var array */ - protected $_options = array(); + protected $_options = []; /** * @var SchemaConfig @@ -77,12 +86,12 @@ class Table extends AbstractAsset * @param Column[] $columns * @param Index[] $indexes * @param ForeignKeyConstraint[] $fkConstraints - * @param integer $idGeneratorType + * @param int $idGeneratorType * @param array $options * * @throws DBALException */ - public function __construct($tableName, array $columns=array(), array $indexes=array(), array $fkConstraints=array(), $idGeneratorType = 0, array $options=array()) + public function __construct($tableName, array $columns=[], array $indexes=[], array $fkConstraints=[], $idGeneratorType = 0, array $options=[]) { if (strlen($tableName) == 0) { throw DBALException::invalidTableName($tableName); @@ -116,15 +125,15 @@ public function setSchemaConfig(SchemaConfig $schemaConfig) } /** - * @return integer + * @return int */ protected function _getMaxIdentifierLength() { if ($this->_schemaConfig instanceof SchemaConfig) { return $this->_schemaConfig->getMaxIdentifierLength(); - } else { - return 63; } + + return 63; } /** @@ -155,11 +164,11 @@ public function setPrimaryKey(array $columns, $indexName = false) * * @return self */ - public function addIndex(array $columnNames, $indexName = null, array $flags = array(), array $options = array()) + public function addIndex(array $columnNames, $indexName = null, array $flags = [], array $options = []) { if ($indexName == null) { $indexName = $this->_generateIdentifierName( - array_merge(array($this->getName()), $columnNames), "idx", $this->_getMaxIdentifierLength() + array_merge([$this->getName()], $columnNames), "idx", $this->_getMaxIdentifierLength() ); } @@ -202,15 +211,15 @@ public function dropIndex($indexName) * * @return self */ - public function addUniqueIndex(array $columnNames, $indexName = null, array $options = array()) + public function addUniqueIndex(array $columnNames, $indexName = null, array $options = []) { if ($indexName === null) { $indexName = $this->_generateIdentifierName( - array_merge(array($this->getName()), $columnNames), "uniq", $this->_getMaxIdentifierLength() + array_merge([$this->getName()], $columnNames), "uniq", $this->_getMaxIdentifierLength() ); } - return $this->_addIndex($this->_createIndex($columnNames, $indexName, true, false, array(), $options)); + return $this->_addIndex($this->_createIndex($columnNames, $indexName, true, false, [], $options)); } /** @@ -264,7 +273,7 @@ public function renameIndex($oldIndexName, $newIndexName = null) * * @param array $columnsNames * - * @return boolean + * @return bool */ public function columnsAreIndexed(array $columnsNames) { @@ -279,18 +288,18 @@ public function columnsAreIndexed(array $columnsNames) } /** - * @param array $columnNames - * @param string $indexName - * @param boolean $isUnique - * @param boolean $isPrimary - * @param array $flags - * @param array $options + * @param array $columnNames + * @param string $indexName + * @param bool $isUnique + * @param bool $isPrimary + * @param array $flags + * @param array $options * * @return Index * * @throws SchemaException */ - private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = array(), array $options = array()) + private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = [], array $options = []) { if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) { throw SchemaException::indexNameInvalid($indexName); @@ -316,7 +325,7 @@ private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrim * * @return Column */ - public function addColumn($columnName, $typeName, array $options=array()) + public function addColumn($columnName, $typeName, array $options=[]) { $column = new Column($columnName, Type::getType($typeName), $options); @@ -378,7 +387,7 @@ public function dropColumn($columnName) * * Name is inferred from the local columns. * - * @param Table|string $foreignTable Table schema instance or table name + * @param Table|string $foreignTable Table schema instance or table name * @param array $localColumnNames * @param array $foreignColumnNames * @param array $options @@ -386,7 +395,7 @@ public function dropColumn($columnName) * * @return self */ - public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array(), $constraintName = null) + public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=[], $constraintName = null) { $constraintName = $constraintName ?: $this->_generateIdentifierName(array_merge((array) $this->getName(), $localColumnNames), "fk", $this->_getMaxIdentifierLength()); @@ -400,14 +409,14 @@ public function addForeignKeyConstraint($foreignTable, array $localColumnNames, * * @deprecated Use {@link addForeignKeyConstraint} * - * @param Table|string $foreignTable Table schema instance or table name + * @param Table|string $foreignTable Table schema instance or table name * @param array $localColumnNames * @param array $foreignColumnNames * @param array $options * * @return self */ - public function addUnnamedForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array()) + public function addUnnamedForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=[]) { return $this->addForeignKeyConstraint($foreignTable, $localColumnNames, $foreignColumnNames, $options); } @@ -418,7 +427,7 @@ public function addUnnamedForeignKeyConstraint($foreignTable, array $localColumn * @deprecated Use {@link addForeignKeyConstraint} * * @param string $name - * @param Table|string $foreignTable Table schema instance or table name + * @param Table|string $foreignTable Table schema instance or table name * @param array $localColumnNames * @param array $foreignColumnNames * @param array $options @@ -427,7 +436,7 @@ public function addUnnamedForeignKeyConstraint($foreignTable, array $localColumn * * @throws SchemaException */ - public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array()) + public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=[]) { if ($foreignTable instanceof Table) { foreach ($foreignColumnNames as $columnName) { @@ -496,7 +505,7 @@ protected function _addIndex(Index $indexCandidate) { $indexName = $indexCandidate->getName(); $indexName = $this->normalizeIdentifier($indexName); - $replacedImplicitIndexes = array(); + $replacedImplicitIndexes = []; foreach ($this->implicitIndexes as $name => $implicitIndex) { if ($implicitIndex->isFullfilledBy($indexCandidate) && isset($this->_indexes[$name])) { @@ -547,7 +556,7 @@ protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint) // In the case of __construct calling this method during hydration from schema-details all the explicitly added indexes // lead to duplicates. This creates computation overhead in this case, however no duplicate indexes are ever added (based on columns). $indexName = $this->_generateIdentifierName( - array_merge(array($this->getName()), $constraint->getColumns()), + array_merge([$this->getName()], $constraint->getColumns()), "idx", $this->_getMaxIdentifierLength() ); @@ -568,7 +577,7 @@ protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint) * * @param string $constraintName * - * @return boolean + * @return bool */ public function hasForeignKey($constraintName) { @@ -660,7 +669,7 @@ private function filterColumns(array $columnNames) * * @param string $columnName The column name. * - * @return boolean + * @return bool */ public function hasColumn($columnName) { @@ -720,7 +729,7 @@ public function getPrimaryKeyColumns() /** * Returns whether this table has a primary key. * - * @return boolean + * @return bool */ public function hasPrimaryKey() { @@ -732,7 +741,7 @@ public function hasPrimaryKey() * * @param string $indexName The index name. * - * @return boolean + * @return bool */ public function hasIndex($indexName) { @@ -781,7 +790,7 @@ public function getForeignKeys() /** * @param string $name * - * @return boolean + * @return bool */ public function hasOption($name) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/TableDiff.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/TableDiff.php index a837fab67..50d2a6c30 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/TableDiff.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/TableDiff.php @@ -52,70 +52,70 @@ class TableDiff * * @var \Doctrine\DBAL\Schema\ColumnDiff[] */ - public $changedColumns = array(); + public $changedColumns = []; /** * All removed fields. * * @var \Doctrine\DBAL\Schema\Column[] */ - public $removedColumns = array(); + public $removedColumns = []; /** * Columns that are only renamed from key to column instance name. * * @var \Doctrine\DBAL\Schema\Column[] */ - public $renamedColumns = array(); + public $renamedColumns = []; /** * All added indexes. * * @var \Doctrine\DBAL\Schema\Index[] */ - public $addedIndexes = array(); + public $addedIndexes = []; /** * All changed indexes. * * @var \Doctrine\DBAL\Schema\Index[] */ - public $changedIndexes = array(); + public $changedIndexes = []; /** * All removed indexes * * @var \Doctrine\DBAL\Schema\Index[] */ - public $removedIndexes = array(); + public $removedIndexes = []; /** * Indexes that are only renamed but are identical otherwise. * * @var \Doctrine\DBAL\Schema\Index[] */ - public $renamedIndexes = array(); + public $renamedIndexes = []; /** * All added foreign key definitions * * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ - public $addedForeignKeys = array(); + public $addedForeignKeys = []; /** * All changed foreign keys * * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ - public $changedForeignKeys = array(); + public $changedForeignKeys = []; /** * All removed foreign keys * * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ - public $removedForeignKeys = array(); + public $removedForeignKeys = []; /** * @var \Doctrine\DBAL\Schema\Table @@ -134,9 +134,9 @@ class TableDiff * @param \Doctrine\DBAL\Schema\Index[] $removedIndexes * @param \Doctrine\DBAL\Schema\Table|null $fromTable */ - public function __construct($tableName, $addedColumns = array(), - $changedColumns = array(), $removedColumns = array(), $addedIndexes = array(), - $changedIndexes = array(), $removedIndexes = array(), Table $fromTable = null) + public function __construct($tableName, $addedColumns = [], + $changedColumns = [], $removedColumns = [], $addedIndexes = [], + $changedIndexes = [], $removedIndexes = [], Table $fromTable = null) { $this->name = $tableName; $this->addedColumns = $addedColumns; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php index ba196d0b4..0d92edb09 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php @@ -23,28 +23,29 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Sequence; +use function array_merge; class CreateSchemaSqlCollector extends AbstractVisitor { /** * @var array */ - private $createNamespaceQueries = array(); + private $createNamespaceQueries = []; /** * @var array */ - private $createTableQueries = array(); + private $createTableQueries = []; /** * @var array */ - private $createSequenceQueries = array(); + private $createSequenceQueries = []; /** * @var array */ - private $createFkConstraintQueries = array(); + private $createFkConstraintQueries = []; /** * @@ -101,10 +102,10 @@ public function acceptSequence(Sequence $sequence) */ public function resetQueries() { - $this->createNamespaceQueries = array(); - $this->createTableQueries = array(); - $this->createSequenceQueries = array(); - $this->createFkConstraintQueries = array(); + $this->createNamespaceQueries = []; + $this->createTableQueries = []; + $this->createSequenceQueries = []; + $this->createFkConstraintQueries = []; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php index ab9752d58..abd183d5a 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php @@ -24,6 +24,7 @@ use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\SchemaException; +use function strlen; /** * Gathers SQL statements that allow to completely drop the current schema. @@ -106,7 +107,7 @@ public function clearQueries() */ public function getQueries() { - $sql = array(); + $sql = []; foreach ($this->constraints as $fkConstraint) { $localTable = $this->constraints[$fkConstraint]; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php index 1573ddf5b..daec58ef0 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php @@ -22,6 +22,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use function current; +use function file_put_contents; +use function in_array; +use function mt_rand; +use function sha1; +use function strtolower; /** * Create a Graphviz output of a Schema. @@ -41,11 +47,11 @@ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkCons $this->output .= $this->createNodeRelation( $fkConstraint->getLocalTableName() . ":col" . current($fkConstraint->getLocalColumns()).":se", $fkConstraint->getForeignTableName() . ":col" . current($fkConstraint->getForeignColumns()).":se", - array( + [ 'dir' => 'back', 'arrowtail' => 'dot', 'arrowhead' => 'normal', - ) + ] ); } @@ -69,10 +75,10 @@ public function acceptTable(Table $table) { $this->output .= $this->createNode( $table->getName(), - array( + [ 'label' => $this->createTableLabel($table), 'shape' => 'plaintext', - ) + ] ); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php index 8b9d9210e..8145480d8 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php @@ -26,6 +26,9 @@ use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser; +use function array_merge; +use function is_numeric; +use function is_string; /** * Sharding implementation that pools many different connections @@ -70,7 +73,7 @@ class PoolingShardConnection extends Connection private $activeConnections; /** - * @var integer + * @var int */ private $activeShardId; @@ -128,8 +131,8 @@ public function __construct(array $params, Driver $driver, Configuration $config /** * Get active shard id. - * - * @return integer + * + * @return int */ public function getActiveShardId() { @@ -151,7 +154,7 @@ public function getHost() { $params = $this->getParams(); - return isset($params['host']) ? $params['host'] : parent::getHost(); + return $params['host'] ?? parent::getHost(); } /** @@ -161,7 +164,7 @@ public function getPort() { $params = $this->getParams(); - return isset($params['port']) ? $params['port'] : parent::getPort(); + return $params['port'] ?? parent::getPort(); } /** @@ -171,7 +174,7 @@ public function getUsername() { $params = $this->getParams(); - return isset($params['user']) ? $params['user'] : parent::getUsername(); + return $params['user'] ?? parent::getUsername(); } /** @@ -181,7 +184,7 @@ public function getPassword() { $params = $this->getParams(); - return isset($params['password']) ? $params['password'] : parent::getPassword(); + return $params['password'] ?? parent::getPassword(); } /** @@ -189,7 +192,7 @@ public function getPassword() * * @param mixed $shardId * - * @return boolean + * @return bool * * @throws \Doctrine\DBAL\Sharding\ShardingException */ @@ -207,7 +210,7 @@ public function connect($shardId = null) throw new ShardingException("Cannot switch shard when transaction is active."); } - $this->activeShardId = (int)$shardId; + $this->activeShardId = (int) $shardId; if (isset($this->activeConnections[$this->activeShardId])) { $this->_conn = $this->activeConnections[$this->activeShardId]; @@ -236,12 +239,12 @@ protected function connectTo($shardId) { $params = $this->getParams(); - $driverOptions = isset($params['driverOptions']) ? $params['driverOptions'] : []; + $driverOptions = $params['driverOptions'] ?? []; $connectionParams = $this->connections[$shardId]; - $user = isset($connectionParams['user']) ? $connectionParams['user'] : null; - $password = isset($connectionParams['password']) ? $connectionParams['password'] : null; + $user = $connectionParams['user'] ?? null; + $password = $connectionParams['password'] ?? null; return $this->_driver->connect($connectionParams, $user, $password, $driverOptions); } @@ -249,7 +252,7 @@ protected function connectTo($shardId) /** * @param string|null $shardId * - * @return boolean + * @return bool */ public function isConnected($shardId = null) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php index 798e3c493..7f9a33fc5 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php @@ -54,7 +54,7 @@ public function __construct(PoolingShardConnection $conn) } /** - * @return void + * {@inheritDoc} */ public function selectGlobal() { @@ -63,9 +63,7 @@ public function selectGlobal() } /** - * @param string $distributionValue - * - * @return void + * {@inheritDoc} */ public function selectShard($distributionValue) { @@ -75,7 +73,7 @@ public function selectShard($distributionValue) } /** - * @return string|null + * {@inheritDoc} */ public function getCurrentDistributionValue() { @@ -83,7 +81,7 @@ public function getCurrentDistributionValue() } /** - * @return array + * {@inheritDoc} */ public function getShards() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php index b7830fa3c..2b700b38a 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php @@ -26,6 +26,7 @@ use Doctrine\DBAL\Schema\Synchronizer\AbstractSchemaSynchronizer; use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer; use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer; +use function array_merge; /** * SQL Azure Schema Synchronizer. @@ -183,15 +184,15 @@ public function dropAllSchema() */ private function partitionSchema(Schema $schema) { - return array( + return [ $this->extractSchemaFederation($schema, false), $this->extractSchemaFederation($schema, true), - ); + ]; } /** * @param \Doctrine\DBAL\Schema\Schema $schema - * @param boolean $isFederation + * @param bool $isFederation * * @return \Doctrine\DBAL\Schema\Schema * diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php index 028b50974..255ca8b41 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php @@ -19,10 +19,13 @@ namespace Doctrine\DBAL\Sharding\SQLAzure; -use Doctrine\DBAL\Sharding\ShardManager; -use Doctrine\DBAL\Sharding\ShardingException; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Sharding\ShardingException; +use Doctrine\DBAL\Sharding\ShardManager; use Doctrine\DBAL\Types\Type; +use function is_bool; +use function is_scalar; +use function sprintf; /** * Sharding using the SQL Azure Federations support. @@ -37,7 +40,7 @@ class SQLAzureShardManager implements ShardManager private $federationName; /** - * @var boolean + * @var bool */ private $filteringEnabled; @@ -57,7 +60,7 @@ class SQLAzureShardManager implements ShardManager private $conn; /** - * @var string + * @var string|null */ private $currentDistributionValue; @@ -86,7 +89,7 @@ public function __construct(Connection $conn) $this->federationName = $params['sharding']['federationName']; $this->distributionKey = $params['sharding']['distributionKey']; $this->distributionType = $params['sharding']['distributionType']; - $this->filteringEnabled = (isset($params['sharding']['filteringEnabled'])) ? (bool) $params['sharding']['filteringEnabled'] : false; + $this->filteringEnabled = (bool) ($params['sharding']['filteringEnabled'] ?? false); } /** @@ -122,7 +125,7 @@ public function getDistributionType() /** * Sets Enabled/Disable filtering on the fly. * - * @param boolean $flag + * @param bool $flag * * @return void */ diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php index 7e45cb756..92851d001 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php @@ -26,6 +26,7 @@ use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Index; +use function in_array; /** * Converts a single tenant schema into a multi-tenant schema for SQL Azure @@ -53,7 +54,7 @@ class MultiTenantVisitor implements Visitor /** * @var array */ - private $excludedTables = array(); + private $excludedTables = []; /** * @var string diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php index a7b85a66b..f02337227 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php @@ -35,7 +35,7 @@ interface ShardChoser * @param string $distributionValue * @param \Doctrine\DBAL\Sharding\PoolingShardConnection $conn * - * @return integer + * @return int */ function pickShard($distributionValue, PoolingShardConnection $conn); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardManager.php index b742793b8..98c8351d7 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardManager.php @@ -63,7 +63,7 @@ function selectShard($distributionValue); /** * Gets the distribution value currently used for sharding. * - * @return string + * @return string|null */ function getCurrentDistributionValue(); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardingException.php b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardingException.php index 407bf847d..aa14d32af 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardingException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardingException.php @@ -31,7 +31,7 @@ class ShardingException extends DBALException /** * @return \Doctrine\DBAL\Sharding\ShardingException */ - static public function notImplemented() + public static function notImplemented() { return new self("This functionality is not implemented with this sharding provider.", 1331557937); } @@ -39,7 +39,7 @@ static public function notImplemented() /** * @return \Doctrine\DBAL\Sharding\ShardingException */ - static public function missingDefaultFederationName() + public static function missingDefaultFederationName() { return new self("SQLAzure requires a federation name to be set during sharding configuration.", 1332141280); } @@ -47,7 +47,7 @@ static public function missingDefaultFederationName() /** * @return \Doctrine\DBAL\Sharding\ShardingException */ - static public function missingDefaultDistributionKey() + public static function missingDefaultDistributionKey() { return new self("SQLAzure requires a distribution key to be set during sharding configuration.", 1332141329); } @@ -55,7 +55,7 @@ static public function missingDefaultDistributionKey() /** * @return \Doctrine\DBAL\Sharding\ShardingException */ - static public function activeTransaction() + public static function activeTransaction() { return new self("Cannot switch shard during an active transaction.", 1332141766); } @@ -63,7 +63,7 @@ static public function activeTransaction() /** * @return \Doctrine\DBAL\Sharding\ShardingException */ - static public function noShardDistributionValue() + public static function noShardDistributionValue() { return new self("You have to specify a string or integer as shard distribution value.", 1332142103); } @@ -71,7 +71,7 @@ static public function noShardDistributionValue() /** * @return \Doctrine\DBAL\Sharding\ShardingException */ - static public function missingDistributionType() + public static function missingDistributionType() { return new self("You have to specify a sharding distribution type such as 'integer', 'string', 'guid'."); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Statement.php b/doctrine/dbal/lib/Doctrine/DBAL/Statement.php index 88038dc61..9774e4afe 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Statement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Statement.php @@ -19,9 +19,10 @@ namespace Doctrine\DBAL; -use PDO; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Driver\Statement as DriverStatement; +use function is_array; +use function is_string; /** * A thin wrapper around a Doctrine\DBAL\Driver\Statement that adds support @@ -44,14 +45,14 @@ class Statement implements \IteratorAggregate, DriverStatement * * @var array */ - protected $params = array(); + protected $params = []; /** * The parameter types. * * @var array */ - protected $types = array(); + protected $types = []; /** * The underlying driver statement. @@ -100,9 +101,9 @@ public function __construct($sql, Connection $conn) * @param mixed $value The value of the parameter. * @param mixed $type Either a PDO binding type or a DBAL mapping type name or instance. * - * @return boolean TRUE on success, FALSE on failure. + * @return bool TRUE on success, FALSE on failure. */ - public function bindValue($name, $value, $type = null) + public function bindValue($name, $value, $type = ParameterType::STRING) { $this->params[$name] = $value; $this->types[$name] = $type; @@ -114,13 +115,13 @@ public function bindValue($name, $value, $type = null) $value = $type->convertToDatabaseValue($value, $this->platform); $bindingType = $type->getBindingType(); } else { - $bindingType = $type; // PDO::PARAM_* constants + $bindingType = $type; } return $this->stmt->bindValue($name, $value, $bindingType); - } else { - return $this->stmt->bindValue($name, $value); } + + return $this->stmt->bindValue($name, $value); } /** @@ -128,15 +129,15 @@ public function bindValue($name, $value, $type = null) * * Binding a parameter by reference does not support DBAL mapping types. * - * @param string $name The name or position of the parameter. - * @param mixed $var The reference to the variable to bind. - * @param integer $type The PDO binding type. - * @param integer|null $length Must be specified when using an OUT bind - * so that PHP allocates enough memory to hold the returned value. + * @param string $name The name or position of the parameter. + * @param mixed $var The reference to the variable to bind. + * @param int $type The PDO binding type. + * @param int|null $length Must be specified when using an OUT bind + * so that PHP allocates enough memory to hold the returned value. * - * @return boolean TRUE on success, FALSE on failure. + * @return bool TRUE on success, FALSE on failure. */ - public function bindParam($name, &$var, $type = PDO::PARAM_STR, $length = null) + public function bindParam($name, &$var, $type = ParameterType::STRING, $length = null) { $this->params[$name] = $var; $this->types[$name] = $type; @@ -149,7 +150,7 @@ public function bindParam($name, &$var, $type = PDO::PARAM_STR, $length = null) * * @param array|null $params * - * @return boolean TRUE on success, FALSE on failure. + * @return bool TRUE on success, FALSE on failure. * * @throws \Doctrine\DBAL\DBALException */ @@ -181,8 +182,8 @@ public function execute($params = null) if ($logger) { $logger->stopQuery(); } - $this->params = array(); - $this->types = array(); + $this->params = []; + $this->types = []; return $stmt; } @@ -190,7 +191,7 @@ public function execute($params = null) /** * Closes the cursor, freeing the database resources used by this statement. * - * @return boolean TRUE on success, FALSE on failure. + * @return bool TRUE on success, FALSE on failure. */ public function closeCursor() { @@ -200,7 +201,7 @@ public function closeCursor() /** * Returns the number of columns in the result set. * - * @return integer + * @return int */ public function columnCount() { @@ -274,7 +275,7 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * Returns a single column from the next row of a result set. * - * @param integer $columnIndex + * @param int $columnIndex * * @return mixed A single column from the next row of a result set or FALSE if there are no more rows. */ @@ -286,7 +287,7 @@ public function fetchColumn($columnIndex = 0) /** * Returns the number of rows affected by the last execution of this statement. * - * @return integer The number of affected rows. + * @return int The number of affected rows. */ public function rowCount() { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php b/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php index 4d76ca92b..78921f39c 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php @@ -23,6 +23,12 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use const PHP_EOL; +use function file_exists; +use function file_get_contents; +use function is_readable; +use function realpath; +use function sprintf; /** * Task for executing arbitrary SQL that can come from a file or directly from @@ -45,11 +51,11 @@ protected function configure() $this ->setName('dbal:import') ->setDescription('Import SQL file(s) directly to Database.') - ->setDefinition(array( + ->setDefinition([ new InputArgument( 'file', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'File path(s) of SQL to be executed.' ) - )) + ]) ->setHelp(<< 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords', 'mysql57' => 'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords', 'sqlserver' => 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords', @@ -47,7 +50,7 @@ class ReservedWordsCommand extends Command 'sqlanywhere11' => 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere11Keywords', 'sqlanywhere12' => 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere12Keywords', 'sqlanywhere16' => 'Doctrine\DBAL\Platforms\Keywords\SQLAnywhere16Keywords', - ); + ]; /** * If you want to add or replace a keywords list use this command. @@ -120,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $keywordLists = (array) $input->getOption('list'); if ( ! $keywordLists) { - $keywordLists = array( + $keywordLists = [ 'mysql', 'mysql57', 'pgsql', @@ -135,7 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 'sqlanywhere11', 'sqlanywhere12', 'sqlanywhere16', - ); + ]; } $keywords = []; @@ -168,5 +171,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } + + return 0; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index 0b0f7ba2c..27982d089 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -24,6 +24,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; +use function is_numeric; +use function ob_get_clean; +use function ob_start; +use function stripos; /** * Task for executing arbitrary SQL that can come from a file or directly from diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php b/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php index 4af8d1284..61412a7cc 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php @@ -23,10 +23,10 @@ use Doctrine\DBAL\Tools\Console\Command\ImportCommand; use Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand; use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand; -use Symfony\Component\Console\Helper\HelperSet; use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; -use Symfony\Component\Console\Application; use Doctrine\DBAL\Version; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Helper\HelperSet; /** * Handles running the Console Tools inside Symfony Console context. @@ -40,7 +40,7 @@ class ConsoleRunner * * @return HelperSet */ - static public function createHelperSet(Connection $connection) + public static function createHelperSet(Connection $connection) { return new HelperSet([ 'db' => new ConnectionHelper($connection) @@ -55,7 +55,7 @@ static public function createHelperSet(Connection $connection) * * @return void */ - static public function run(HelperSet $helperSet, $commands = []) + public static function run(HelperSet $helperSet, $commands = []) { $cli = new Application('Doctrine Command Line Interface', Version::VERSION); @@ -73,7 +73,7 @@ static public function run(HelperSet $helperSet, $commands = []) * * @return void */ - static public function addCommands(Application $cli) + public static function addCommands(Application $cli) { $cli->addCommands([ new RunSqlCommand(), @@ -85,7 +85,7 @@ static public function addCommands(Application $cli) /** * Prints the instructions to create a configuration file */ - static public function printCliConfigTemplate() + public static function printCliConfigTemplate() { echo <<<'HELP' You are missing a "cli-config.php" or "config/cli-config.php" file in your diff --git a/doctrine/dbal/lib/Doctrine/DBAL/TransactionIsolationLevel.php b/doctrine/dbal/lib/Doctrine/DBAL/TransactionIsolationLevel.php new file mode 100644 index 000000000..4e35639fb --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/TransactionIsolationLevel.php @@ -0,0 +1,32 @@ + 32) ? substr($value, 0, 20) . '...' : $value; @@ -57,7 +66,7 @@ static public function conversionFailed($value, $toType) * * @return \Doctrine\DBAL\Types\ConversionException */ - static public function conversionFailedFormat($value, $toType, $expectedFormat, \Exception $previous = null) + public static function conversionFailedFormat($value, $toType, $expectedFormat, \Exception $previous = null) { $value = (strlen($value) > 32) ? substr($value, 0, 20) . '...' : $value; @@ -78,7 +87,7 @@ static public function conversionFailedFormat($value, $toType, $expectedFormat, * * @return \Doctrine\DBAL\Types\ConversionException */ - static public function conversionFailedInvalidType($value, $toType, array $possibleTypes) + public static function conversionFailedInvalidType($value, $toType, array $possibleTypes) { $actualType = is_object($value) ? get_class($value) : gettype($value); @@ -100,7 +109,7 @@ static public function conversionFailedInvalidType($value, $toType, array $possi )); } - static public function conversionFailedSerialization($value, $format, $error) + public static function conversionFailedSerialization($value, $format, $error) { $actualType = is_object($value) ? get_class($value) : gettype($value); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/DateIntervalType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/DateIntervalType.php index 4ad9c42f2..7208da97c 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/DateIntervalType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/DateIntervalType.php @@ -3,12 +3,15 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function substr; /** * Type that maps interval string to a PHP DateInterval Object. */ class DateIntervalType extends Type { + public const FORMAT = '%RP%YY%MM%DDT%HH%IM%SS'; + /** * {@inheritdoc} */ @@ -38,7 +41,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) } if ($value instanceof \DateInterval) { - return $value->format('P%YY%MM%DDT%HH%IM%SS'); + return $value->format(self::FORMAT); } throw ConversionException::conversionFailedInvalidType($value, $this->getName(), ['null', 'DateInterval']); @@ -53,10 +56,23 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $value; } + $negative = false; + + if (isset($value[0]) && ($value[0] === '+' || $value[0] === '-')) { + $negative = $value[0] === '-'; + $value = substr($value, 1); + } + try { - return new \DateInterval($value); + $interval = new \DateInterval($value); + + if ($negative) { + $interval->invert = 1; + } + + return $interval; } catch (\Exception $exception) { - throw ConversionException::conversionFailedFormat($value, $this->getName(), 'P%YY%MM%DDT%HH%IM%SS', $exception); + throw ConversionException::conversionFailedFormat($value, $this->getName(), self::FORMAT, $exception); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php index a1830dce4..3cb76ee5b 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php @@ -20,13 +20,14 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function date_create; /** * Type that maps an SQL DATETIME/TIMESTAMP to a PHP DateTime object. * * @since 2.0 */ -class DateTimeType extends Type +class DateTimeType extends Type implements PhpDateTimeMappingType { /** * {@inheritdoc} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeTzType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeTzType.php index e73bcc907..f731baf14 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeTzType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeTzType.php @@ -44,7 +44,7 @@ * @author Jonathan Wage * @author Roman Borschel */ -class DateTimeTzType extends Type +class DateTimeTzType extends Type implements PhpDateTimeMappingType { /** * {@inheritdoc} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/IntegerType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/IntegerType.php index 6fe6375ec..3c83341de 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/IntegerType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/IntegerType.php @@ -19,6 +19,7 @@ namespace Doctrine\DBAL\Types; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; /** @@ -27,7 +28,7 @@ * @author Roman Borschel * @since 2.0 */ -class IntegerType extends Type +class IntegerType extends Type implements PhpIntegerMappingType { /** * {@inheritdoc} @@ -58,6 +59,6 @@ public function convertToPHPValue($value, AbstractPlatform $platform) */ public function getBindingType() { - return \PDO::PARAM_INT; + return ParameterType::INTEGER; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php index af5b54134..5650eb518 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php @@ -20,6 +20,9 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function is_resource; +use function json_decode; +use function stream_get_contents; /** * Array Type which can be used to generate json arrays. @@ -36,7 +39,7 @@ class JsonArrayType extends JsonType public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null || $value === '') { - return array(); + return []; } $value = (is_resource($value)) ? stream_get_contents($value) : $value; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonType.php index 7db496c14..6395332c6 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonType.php @@ -20,6 +20,13 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use const JSON_ERROR_NONE; +use function is_resource; +use function json_decode; +use function json_encode; +use function json_last_error; +use function json_last_error_msg; +use function stream_get_contents; /** * Type generating json objects values @@ -49,7 +56,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) $encoded = json_encode($value); if (JSON_ERROR_NONE !== json_last_error()) { - throw ConversionException::conversionFailedSerialization($value, 'json', $this->getLastErrorMessage()); + throw ConversionException::conversionFailedSerialization($value, 'json', json_last_error_msg()); } return $encoded; @@ -92,44 +99,4 @@ public function requiresSQLCommentHint(AbstractPlatform $platform) { return ! $platform->hasNativeJsonType(); } - - /** - * Get the latest json error message - * - * This method declaration has been extracted from symfony's php 5.5 polyfill - * - * @link https://github.com/symfony/polyfill-php55/blob/master/Php55.php - * @link http://nl1.php.net/manual/en/function.json-last-error-msg.php - * - * @return string - */ - private function getLastErrorMessage() - { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - switch (json_last_error()) { - case JSON_ERROR_NONE: - return 'No error'; - - case JSON_ERROR_DEPTH: - return 'Maximum stack depth exceeded'; - - case JSON_ERROR_STATE_MISMATCH: - return 'State mismatch (invalid or malformed JSON)'; - - case JSON_ERROR_CTRL_CHAR: - return 'Control character error, possibly incorrectly encoded'; - - case JSON_ERROR_SYNTAX: - return 'Syntax error'; - - case JSON_ERROR_UTF8: - return 'Malformed UTF-8 characters, possibly incorrectly encoded'; - - default: - return 'Unknown error'; - } - } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php index 0b1f87a23..95fe84a5a 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php @@ -20,6 +20,10 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function is_resource; +use function serialize; +use function stream_get_contents; +use function unserialize; /** * Type that maps a PHP object to a clob SQL type. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpDateTimeMappingType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpDateTimeMappingType.php new file mode 100644 index 000000000..d530d8cf0 --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpDateTimeMappingType.php @@ -0,0 +1,28 @@ +. + */ + +namespace Doctrine\DBAL\Types; + +/** + * Implementations should map a database type to a PHP DateTimeInterface instance. + * @internal + */ +interface PhpDateTimeMappingType +{ +} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpIntegerMappingType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpIntegerMappingType.php new file mode 100644 index 000000000..034aaecb3 --- /dev/null +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/PhpIntegerMappingType.php @@ -0,0 +1,28 @@ +. + */ + +namespace Doctrine\DBAL\Types; + +/** + * Implementations should map a database type to a PHP integer. + * @internal + */ +interface PhpIntegerMappingType +{ +} diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php index 47c821be4..fb01479e3 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php @@ -20,6 +20,10 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function explode; +use function implode; +use function is_resource; +use function stream_get_contents; /** * Array Type which can be used for simple values. @@ -57,7 +61,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { - return array(); + return []; } $value = (is_resource($value)) ? stream_get_contents($value) : $value; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php index 7ebae6ebe..1a2abdbe0 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php @@ -19,6 +19,7 @@ namespace Doctrine\DBAL\Types; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; /** @@ -26,7 +27,7 @@ * * @author robo */ -class SmallIntType extends Type +class SmallIntType extends Type implements PhpIntegerMappingType { /** * {@inheritdoc} @@ -57,6 +58,6 @@ public function convertToPHPValue($value, AbstractPlatform $platform) */ public function getBindingType() { - return \PDO::PARAM_INT; + return ParameterType::INTEGER; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/TextType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/TextType.php index 4055ac88d..bd7235546 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/TextType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/TextType.php @@ -20,6 +20,8 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function is_resource; +use function stream_get_contents; /** * Type that maps an SQL CLOB to a PHP string. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php index 1379bb203..453631e0a 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php @@ -19,8 +19,13 @@ namespace Doctrine\DBAL\Types; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\DBALException; +use function end; +use function explode; +use function get_class; +use function str_replace; /** * The base class for so-called Doctrine mapping types. @@ -64,14 +69,14 @@ abstract class Type * * @var array */ - private static $_typeObjects = array(); + private static $_typeObjects = []; /** * The map of supported doctrine mapping types. * * @var array */ - private static $_typesMap = array( + private static $_typesMap = [ self::TARRAY => ArrayType::class, self::SIMPLE_ARRAY => SimpleArrayType::class, self::JSON_ARRAY => JsonArrayType::class, @@ -97,7 +102,7 @@ abstract class Type self::BLOB => BlobType::class, self::GUID => GuidType::class, self::DATEINTERVAL => DateIntervalType::class, - ); + ]; /** * Prevents instantiation and forces use of the factory method. @@ -139,7 +144,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) * * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform * - * @return integer|null + * @return int|null * * @todo Needed? */ @@ -213,7 +218,7 @@ public static function addType($name, $className) * * @param string $name The name of the type. * - * @return boolean TRUE if type is supported; FALSE otherwise. + * @return bool TRUE if type is supported; FALSE otherwise. */ public static function hasType($name) { @@ -247,19 +252,13 @@ public static function overrideType($name, $className) * Gets the (preferred) binding type for values of this type that * can be used when binding parameters to prepared statements. * - * This method should return one of the PDO::PARAM_* constants, that is, one of: + * This method should return one of the {@link \Doctrine\DBAL\ParameterType} constants. * - * PDO::PARAM_BOOL - * PDO::PARAM_NULL - * PDO::PARAM_INT - * PDO::PARAM_STR - * PDO::PARAM_LOB - * - * @return integer + * @return int */ public function getBindingType() { - return \PDO::PARAM_STR; + return ParameterType::STRING; } /** @@ -291,7 +290,7 @@ public function __toString() * {@link convertToPHPValueSQL} works for any type and mostly * does nothing. This method can additionally be used for optimization purposes. * - * @return boolean + * @return bool */ public function canRequireSQLConversion() { @@ -333,18 +332,18 @@ public function convertToPHPValueSQL($sqlExpr, $platform) */ public function getMappedDatabaseTypes(AbstractPlatform $platform) { - return array(); + return []; } /** * If this Doctrine Type maps to an already mapped database type, - * reverse schema engineering can't take them apart. You need to mark + * reverse schema engineering can't tell them apart. You need to mark * one of those types as commented, which will have Doctrine use an SQL * comment to typehint the actual Doctrine Type. * * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform * - * @return boolean + * @return bool */ public function requiresSQLCommentHint(AbstractPlatform $platform) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php index 3a3735b04..f0e8ff844 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php @@ -20,6 +20,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function date_create_immutable; /** * Immutable type of {@see VarDateTimeType}. diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php b/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php index 5cf35f795..b55e0b05b 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php @@ -20,6 +20,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; +use function date_create; /** * Variable DateTime Type using date_create() instead of DateTime::createFromFormat(). diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Version.php b/doctrine/dbal/lib/Doctrine/DBAL/Version.php index 6e1da9ba1..05781f858 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Version.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Version.php @@ -19,6 +19,10 @@ namespace Doctrine\DBAL; +use function str_replace; +use function strtolower; +use function version_compare; + /** * Class to store and retrieve the version of Doctrine. * @@ -34,14 +38,14 @@ class Version /** * Current Doctrine Version. */ - const VERSION = '2.6.3'; + public const VERSION = '2.7.2'; /** * Compares a Doctrine version with the current one. * * @param string $version The Doctrine version to compare to. * - * @return integer -1 if older, 0 if it is the same, 1 if version passed as argument is newer. + * @return int -1 if older, 0 if it is the same, 1 if version passed as argument is newer. */ public static function compare($version) { diff --git a/doctrine/dbal/phpcs.xml.dist b/doctrine/dbal/phpcs.xml.dist new file mode 100644 index 000000000..84033c9a7 --- /dev/null +++ b/doctrine/dbal/phpcs.xml.dist @@ -0,0 +1,34 @@ + + + + + + + + + + + + lib + tests + + + + + + + + + + + */tests/* + + + + */tests/* + + + + lib/Doctrine/DBAL/Events.php + +