Skip to content

Commit c9dcb68

Browse files
committed
Remove AbstractAsset::_setName()
1 parent 05b74b2 commit c9dcb68

File tree

3 files changed

+17
-51
lines changed

3 files changed

+17
-51
lines changed

UPGRADE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ awareness about deprecated code.
88

99
# Upgrade to 5.0
1010

11+
## BC BREAK: Removed `AbstractAsset::_setName()`
12+
13+
The `AbstractAsset::_setName()` method has been removed.
14+
1115
## BC BREAK: Removed Reserved Keyword Lists
1216

1317
The following components have been removed:
@@ -36,7 +40,7 @@ The `AbstractPlatform::quoteIdentifier()` and `Connection::quoteIdentifier()` me
3640

3741
## BC BREAK: Removed `Table::removeForeignKey()` and `::removeUniqueConstraint()`
3842

39-
The `Table::removeForeignKey()` and `::removeUniqueConstraint()` have been removed.
43+
The `Table::removeForeignKey()` and `::removeUniqueConstraint()` methods have been removed.
4044

4145
## BC BREAK: Removed `AbstractPlatform` constants
4246

psalm.xml.dist

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@
5555

5656
<!-- TODO for PHPUnit 11 -->
5757
<referencedMethod name="PHPUnit\Framework\TestCase::iniSet"/>
58-
59-
<!--
60-
https://github.com/doctrine/dbal/pull/6610
61-
TODO: remove in 5.0.0
62-
-->
63-
<referencedMethod name="Doctrine\DBAL\Schema\AbstractAsset::_setName" />
6458
</errorLevel>
6559
</DeprecatedMethod>
6660
<DocblockTypeContradiction>

src/Schema/AbstractAsset.php

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
use Doctrine\DBAL\Schema\Exception\InvalidObjectName;
99
use Doctrine\DBAL\Schema\Name\Parser;
1010
use Doctrine\DBAL\Schema\Name\Parser\Identifier;
11-
use Doctrine\Deprecations\Deprecation;
1211

1312
use function array_map;
13+
use function assert;
1414
use function count;
1515
use function crc32;
1616
use function dechex;
@@ -41,56 +41,24 @@ abstract class AbstractAsset
4141
/** @var list<Identifier> */
4242
private array $identifiers = [];
4343

44-
public function __construct(?string $name = null)
44+
public function __construct(string $name)
4545
{
46-
if ($name === null) {
47-
Deprecation::trigger(
48-
'doctrine/dbal',
49-
'https://github.com/doctrine/dbal/pull/6610',
50-
'Not passing $name to %s is deprecated.',
51-
__METHOD__,
52-
);
53-
46+
if ($name === '') {
5447
return;
5548
}
5649

57-
$this->_setName($name);
58-
}
50+
$parser = new Parser();
5951

60-
/**
61-
* Sets the name of this asset.
62-
*
63-
* @deprecated Use the constructor instead.
64-
*/
65-
protected function _setName(string $name): void
66-
{
67-
Deprecation::triggerIfCalledFromOutside(
68-
'doctrine/dbal',
69-
'https://github.com/doctrine/dbal/pull/6610',
70-
'%s is deprecated. Use the constructor instead.',
71-
__METHOD__,
72-
);
73-
74-
if ($name !== '') {
75-
$parser = new Parser();
76-
77-
try {
78-
$identifiers = $parser->parse($name);
79-
} catch (Parser\Exception $e) {
80-
throw InvalidObjectName::fromParserException($name, $e);
81-
}
82-
} else {
83-
$identifiers = [];
52+
try {
53+
$identifiers = $parser->parse($name);
54+
} catch (Parser\Exception $e) {
55+
throw InvalidObjectName::fromParserException($name, $e);
8456
}
8557

86-
switch (count($identifiers)) {
87-
case 0:
88-
$this->_name = '';
89-
$this->_quoted = false;
90-
$this->_namespace = null;
91-
$this->identifiers = [];
58+
$count = count($identifiers);
59+
assert($count > 0);
9260

93-
return;
61+
switch ($count) {
9462
case 1:
9563
$namespace = null;
9664
$name = $identifiers[0];
@@ -102,7 +70,7 @@ protected function _setName(string $name): void
10270
break;
10371

10472
default:
105-
throw InvalidObjectName::tooManyQualifiers($name, count($identifiers) - 1);
73+
throw InvalidObjectName::tooManyQualifiers($name, $count - 1);
10674
}
10775

10876
$this->_name = $name->getValue();

0 commit comments

Comments
 (0)