Use __METHOD__ and ::class to build exception messages

parent eefb771e
...@@ -1423,7 +1423,9 @@ abstract class AbstractPlatform ...@@ -1423,7 +1423,9 @@ abstract class AbstractPlatform
} }
if (! is_string($table)) { if (! is_string($table)) {
throw new InvalidArgumentException('getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $table parameter to be string or ' . Table::class . '.'
);
} }
if ($this->_eventManager !== null && $this->_eventManager->hasListeners(Events::onSchemaDropTable)) { if ($this->_eventManager !== null && $this->_eventManager->hasListeners(Events::onSchemaDropTable)) {
...@@ -1471,7 +1473,9 @@ abstract class AbstractPlatform ...@@ -1471,7 +1473,9 @@ abstract class AbstractPlatform
if ($index instanceof Index) { if ($index instanceof Index) {
$index = $index->getQuotedName($this); $index = $index->getQuotedName($this);
} elseif (! is_string($index)) { } elseif (! is_string($index)) {
throw new InvalidArgumentException('AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $index parameter to be string or ' . Index::class . '.'
);
} }
return 'DROP INDEX ' . $index; return 'DROP INDEX ' . $index;
......
...@@ -420,13 +420,17 @@ class DrizzlePlatform extends AbstractPlatform ...@@ -420,13 +420,17 @@ class DrizzlePlatform extends AbstractPlatform
} elseif (is_string($index)) { } elseif (is_string($index)) {
$indexName = $index; $indexName = $index;
} else { } else {
throw new InvalidArgumentException('DrizzlePlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $index parameter to be string or ' . Index::class . '.'
);
} }
if ($table instanceof Table) { if ($table instanceof Table) {
$table = $table->getQuotedName($this); $table = $table->getQuotedName($this);
} elseif (! is_string($table)) { } elseif (! is_string($table)) {
throw new InvalidArgumentException('DrizzlePlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $table parameter to be string or ' . Table::class . '.'
);
} }
if ($index instanceof Index && $index->isPrimary()) { if ($index instanceof Index && $index->isPrimary()) {
...@@ -571,7 +575,9 @@ class DrizzlePlatform extends AbstractPlatform ...@@ -571,7 +575,9 @@ class DrizzlePlatform extends AbstractPlatform
if ($table instanceof Table) { if ($table instanceof Table) {
$table = $table->getQuotedName($this); $table = $table->getQuotedName($this);
} elseif (! is_string($table)) { } elseif (! is_string($table)) {
throw new InvalidArgumentException('getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $table parameter to be string or ' . Table::class . '.'
);
} }
return 'DROP TEMPORARY TABLE ' . $table; return 'DROP TEMPORARY TABLE ' . $table;
......
...@@ -1006,13 +1006,17 @@ SQL ...@@ -1006,13 +1006,17 @@ SQL
} elseif (is_string($index)) { } elseif (is_string($index)) {
$indexName = $index; $indexName = $index;
} else { } else {
throw new InvalidArgumentException('MysqlPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $index parameter to be string or ' . Index::class . '.'
);
} }
if ($table instanceof Table) { if ($table instanceof Table) {
$table = $table->getQuotedName($this); $table = $table->getQuotedName($this);
} elseif (! is_string($table)) { } elseif (! is_string($table)) {
throw new InvalidArgumentException('MysqlPlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $table parameter to be string or ' . Table::class . '.'
);
} }
if ($index instanceof Index && $index->isPrimary()) { if ($index instanceof Index && $index->isPrimary()) {
...@@ -1132,7 +1136,9 @@ SQL ...@@ -1132,7 +1136,9 @@ SQL
if ($table instanceof Table) { if ($table instanceof Table) {
$table = $table->getQuotedName($this); $table = $table->getQuotedName($this);
} elseif (! is_string($table)) { } elseif (! is_string($table)) {
throw new InvalidArgumentException('getDropTemporaryTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $table parameter to be string or ' . Table::class . '.'
);
} }
return 'DROP TEMPORARY TABLE ' . $table; return 'DROP TEMPORARY TABLE ' . $table;
......
...@@ -549,7 +549,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -549,7 +549,7 @@ class SQLAnywherePlatform extends AbstractPlatform
if (! is_string($index)) { if (! is_string($index)) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
'SQLAnywherePlatform::getDropIndexSQL() expects $index parameter to be string or ' . Index::class . '.' __METHOD__ . '() expects $index parameter to be string or ' . Index::class . '.'
); );
} }
...@@ -563,7 +563,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -563,7 +563,7 @@ class SQLAnywherePlatform extends AbstractPlatform
if (! is_string($table)) { if (! is_string($table)) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
'SQLAnywherePlatform::getDropIndexSQL() expects $table parameter to be string or ' . Index::class . '.' __METHOD__ . '() expects $table parameter to be string or ' . Index::class . '.'
); );
} }
......
...@@ -213,7 +213,9 @@ class SQLServerPlatform extends AbstractPlatform ...@@ -213,7 +213,9 @@ class SQLServerPlatform extends AbstractPlatform
if ($index instanceof Index) { if ($index instanceof Index) {
$index = $index->getQuotedName($this); $index = $index->getQuotedName($this);
} elseif (! is_string($index)) { } elseif (! is_string($index)) {
throw new InvalidArgumentException('AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'); throw new InvalidArgumentException(
__METHOD__ . '() expects $index parameter to be string or ' . Index::class . '.'
);
} }
if (! isset($table)) { if (! isset($table)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment