Skip to content

Commit fccc30e

Browse files
committed
Remove handling of non-initialized object names
1 parent 77ce281 commit fccc30e

File tree

6 files changed

+0
-74
lines changed

6 files changed

+0
-74
lines changed

src/Schema/AbstractAsset.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ abstract class AbstractAsset
3838
{
3939
protected string $_name = '';
4040

41-
/**
42-
* Indicates whether the object name has been initialized.
43-
*/
44-
protected bool $isNameInitialized = false;
45-
4641
/**
4742
* Namespace of the asset. If none isset the default namespace is assumed.
4843
*/
@@ -67,8 +62,6 @@ public function __construct(string $name)
6762

6863
$this->setName($parsedName);
6964

70-
$this->isNameInitialized = true;
71-
7265
if ($parsedName === null) {
7366
return;
7467
}

src/Schema/AbstractNamedObject.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Doctrine\DBAL\Schema;
66

77
use Doctrine\DBAL\Schema\Exception\InvalidName;
8-
use Doctrine\DBAL\Schema\Exception\NameIsNotInitialized;
98

109
/**
1110
* An abstract {@see NamedObject}.
@@ -19,9 +18,6 @@ abstract class AbstractNamedObject extends AbstractAsset implements NamedObject
1918
/**
2019
* The name of the database object.
2120
*
22-
* Until the validity of the name is enforced, this property isn't guaranteed to be always initialized. The property
23-
* can be accessed only if {@see $isNameInitialized} is set to true.
24-
*
2521
* @var N
2622
*/
2723
protected Name $name;
@@ -35,15 +31,9 @@ public function __construct(string $name)
3531
* Returns the object name.
3632
*
3733
* @return N
38-
*
39-
* @throws NameIsNotInitialized
4034
*/
4135
public function getObjectName(): Name
4236
{
43-
if (! $this->isNameInitialized) {
44-
throw NameIsNotInitialized::new();
45-
}
46-
4737
return $this->name;
4838
}
4939

src/Schema/AbstractOptionallyNamedObject.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Doctrine\DBAL\Schema;
66

7-
use Doctrine\DBAL\Schema\Exception\NameIsNotInitialized;
8-
97
/**
108
* An abstract {@see OptionallyNamedObject}.
119
*
@@ -18,9 +16,6 @@ abstract class AbstractOptionallyNamedObject extends AbstractAsset implements Op
1816
/**
1917
* The name of the database object.
2018
*
21-
* Until the validity of the name is enforced, this property isn't guaranteed to be always initialized. The property
22-
* can be accessed only if {@see $isNameInitialized} is set to true.
23-
*
2419
* @var ?N
2520
*/
2621
protected ?Name $name;
@@ -32,10 +27,6 @@ public function __construct(?string $name)
3227

3328
public function getObjectName(): ?Name
3429
{
35-
if (! $this->isNameInitialized) {
36-
throw NameIsNotInitialized::new();
37-
}
38-
3930
return $this->name;
4031
}
4132

src/Schema/Exception/NameIsNotInitialized.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/Schema/AbstractNamedObjectTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
namespace Doctrine\DBAL\Tests\Schema;
66

77
use Doctrine\DBAL\Schema\AbstractNamedObject;
8-
use Doctrine\DBAL\Schema\AbstractOptionallyNamedObject;
98
use Doctrine\DBAL\Schema\Exception\InvalidName;
10-
use Doctrine\DBAL\Schema\Exception\NameIsNotInitialized;
119
use Doctrine\DBAL\Schema\Name;
1210
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
1311
use PHPUnit\Framework\TestCase;
@@ -24,18 +22,4 @@ public function testEmptyName(): void
2422
class ('') extends AbstractNamedObject {
2523
};
2624
}
27-
28-
public function testAccessToUninitializedName(): void
29-
{
30-
$object = new /** @extends AbstractOptionallyNamedObject<Name> */
31-
class () extends AbstractOptionallyNamedObject {
32-
/** @phpstan-ignore constructor.missingParentCall */
33-
public function __construct()
34-
{
35-
}
36-
};
37-
38-
$this->expectException(NameIsNotInitialized::class);
39-
$object->getObjectName();
40-
}
4125
}

tests/Schema/AbstractOptionallyNamedObjectTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Doctrine\DBAL\Tests\Schema;
66

77
use Doctrine\DBAL\Schema\AbstractOptionallyNamedObject;
8-
use Doctrine\DBAL\Schema\Exception\NameIsNotInitialized;
98
use Doctrine\DBAL\Schema\Name;
109
use PHPUnit\Framework\Attributes\DataProvider;
1110
use PHPUnit\Framework\TestCase;
@@ -28,18 +27,4 @@ public static function emptyNameProvider(): iterable
2827
yield 'empty-string' => [''];
2928
yield 'empty-null' => [null];
3029
}
31-
32-
public function testAccessToUninitializedName(): void
33-
{
34-
$object = new /** @extends AbstractOptionallyNamedObject<Name> */
35-
class () extends AbstractOptionallyNamedObject {
36-
/** @phpstan-ignore constructor.missingParentCall */
37-
public function __construct()
38-
{
39-
}
40-
};
41-
42-
$this->expectException(NameIsNotInitialized::class);
43-
$object->getObjectName();
44-
}
4530
}

0 commit comments

Comments
 (0)