Skip to content

Commit bba03d6

Browse files
committed
Rename TypeRegistry::guessTypeFromValue
1 parent 3c81485 commit bba03d6

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/Types/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static function getTypeFromPHPVariable($variable): ?Type
142142
{
143143
trigger_deprecation('doctrine/mongodb-odm', '2.16', 'Type::getTypeFromPHPVariable() is deprecated without replacement.');
144144

145-
return TypeRegistry::getSharedInstance()->fromVariable($variable);
145+
return TypeRegistry::getSharedInstance()->guessTypeFromValue($variable);
146146
}
147147

148148
/**

src/Types/TypeRegistry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function get(string $name): Type
107107
*/
108108
public function convertToDatabaseValue(mixed $value): mixed
109109
{
110-
$type = $this->fromVariable($value);
110+
$type = $this->guessTypeFromValue($value);
111111

112112
if ($type === null) {
113113
return $value;
@@ -121,7 +121,7 @@ public function convertToDatabaseValue(mixed $value): mixed
121121
*
122122
* @internal
123123
*/
124-
public function fromVariable(mixed $variable): ?Type
124+
public function guessTypeFromValue(mixed $variable): ?Type
125125
{
126126
if (is_object($variable)) {
127127
if ($variable instanceof DateTimeImmutable) {

tests/Tests/Functional/CustomTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function testCustomTypeDetection(): void
8282
public function testConvertToDatabaseValue(): void
8383
{
8484
$lang = new Language('French', 'fr');
85-
$type = $this->registry->fromVariable($lang);
85+
$type = $this->registry->guessTypeFromValue($lang);
8686
self::assertInstanceOf(LanguageType::class, $type);
8787

8888
$databaseValue = $this->registry->convertToDatabaseValue($lang);

tests/Tests/Types/TypeRegistryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
class TypeRegistryTest extends BaseTestCase
2323
{
24-
#[DataProvider('provideTypeFromVariable')]
24+
#[DataProvider('provideTypeToGuessFromValue')]
2525
public function testTypeFromVariable(?string $expectedType, mixed $variable): void
2626
{
2727
$registry = new TypeRegistry();
28-
$type = $registry->fromVariable($variable);
28+
$type = $registry->guessTypeFromValue($variable);
2929

3030
if ($expectedType === null) {
3131
self::assertNull($type);
@@ -36,7 +36,7 @@ public function testTypeFromVariable(?string $expectedType, mixed $variable): vo
3636
}
3737
}
3838

39-
public static function provideTypeFromVariable(): Generator
39+
public static function provideTypeToGuessFromValue(): Generator
4040
{
4141
yield 'null' => [null, null];
4242
yield 'bool' => [Type::BOOL, true];

0 commit comments

Comments
 (0)