Skip to content

Commit

Permalink
Merge branch '3.7.x' into 4.0.x
Browse files Browse the repository at this point in the history
* 3.7.x:
  Support Symfony 7 by adding return types conditionally (#6136)
  Add Type::lookupName() shortcut method (#6130)
  fix: correct the deprecation method name
  fix: don't trigger deprecation if called internally
  • Loading branch information
derrabus committed Aug 24, 2023
2 parents 904ed71 + d279b8f commit cf8177e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ public static function getType(string $name): self
return self::getTypeRegistry()->get($name);
}

/**
* Finds a name for the given type.
*
* @throws Exception
*/
public static function lookupName(self $type): string
{
return self::getTypeRegistry()->lookupName($type);
}

/**
* Adds a custom type to the type map.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/Types/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public function testDefaultTypesAreRegistered(string $name): void
self::assertTrue(Type::hasType($name));
}

/** @dataProvider defaultTypesProvider() */
public function testDefaultTypesReverseLookup(string $name): void
{
$type = Type::getType($name);
self::assertSame($name, Type::lookupName($type));
}

/** @return iterable<string[]> */
public static function defaultTypesProvider(): iterable
{
Expand Down

0 comments on commit cf8177e

Please sign in to comment.