Skip to content

Commit 1dcc15d

Browse files
committed
update: ArrayPhpFile::getAliasOf() returns non-formatted alias.
1 parent 0c5b787 commit 1dcc15d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Src/ArrayPhpFile.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getContent(): array {
6767
*/
6868
public function getAliasOf( string|array|Closure $item, string $type = PhpNamespace::NAME_NORMAL ): string {
6969
$import = $this->normalizeCallable( $item, onlyImportable: true );
70-
$alias = $this->using( $import )?->ofType( $type )->getFormattedAlias();
70+
$alias = $this->using( $import )?->ofType( $type )->getAlias();
7171

7272
return match ( true ) {
7373
default => throw new OutOfBoundsException( sprintf( self::NON_IMPORTABLE_ITEM, $import ) ),

Tests/ArrayPhpFileTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,20 @@ public function itEnsuresAddedCallablesAreFormattedForPrint( ArrayPhpFile $file
9696
#[Test]
9797
#[Depends( 'itAddsCallableOfVariousTypes' )]
9898
public function itEnsuresImportedItemAliasCanBeRetrieved( ArrayPhpFile $file ): void {
99-
$this->assertSame( 'TestCase::class', $file->getAliasOf( TestCase::class ) );
100-
$this->assertSame( 'ArrayPhpFileTest::class', $file->getAliasOf( $this->itAddsCallableOfVariousTypes( ... ) ) );
99+
$this->assertSame( 'TestCase', $file->getAliasOf( TestCase::class ) );
100+
$this->assertSame( 'ArrayPhpFileTest', $file->getAliasOf( $this->itAddsCallableOfVariousTypes( ... ) ) );
101101
$this->assertSame(
102-
'ArrayPhpFileTest::class',
102+
'ArrayPhpFileTest',
103103
$file->getAliasOf( array( self::class, __FUNCTION__ ) ),
104104
'Does not matter with method name if classname is same'
105105
);
106-
$this->assertSame( 'TestCase::class', $file->getAliasOf( TestCase::assertIsString( ... ) ) );
106+
$this->assertSame( 'TestCase', $file->getAliasOf( TestCase::assertIsString( ... ) ) );
107107
$this->assertSame(
108108
'testFirstClassCallable',
109109
$file->getAliasOf( testFirstClassCallable( ... ), PhpNamespace::NAME_FUNCTION )
110110
);
111111

112-
$this->assertSame( 'DateTime::class', $file->getAliasOf( \DateTime::createFromFormat( ... ) ) );
112+
$this->assertSame( 'DateTime', $file->getAliasOf( \DateTime::createFromFormat( ... ) ) );
113113

114114
// Global function is not imported. So, no alias.
115115
$this->expectException( OutOfBoundsException::class );

0 commit comments

Comments
 (0)