Skip to content

Commit b472246

Browse files
committed
Adjust lang.reflection.Type::package() to return Package() for global classes
1 parent 043dd55 commit b472246

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/main/php/lang/reflection/Type.class.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@ public function is($type): bool {
8383
}
8484

8585
/**
86-
* Returns this type's package, or NULL if this type is in the global namespace.
86+
* Returns this type's package
8787
*
88-
* @return ?lang.reflection.Package
88+
* @return lang.reflection.Package
8989
*/
9090
public function package() {
91-
$name= $this->reflect->getNamespaceName();
92-
return $name ? new Package($name) : null;
91+
return new Package($this->reflect->getNamespaceName());
9392
}
9493

9594
/**

src/test/php/lang/reflection/unittest/TypeTest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function package() {
5151

5252
#[Test]
5353
public function global_namespace() {
54-
Assert::null(Reflection::of(\Throwable::class)->package());
54+
Assert::equals(new Package(), Reflection::of(\Throwable::class)->package());
5555
}
5656

5757
#[Test]

0 commit comments

Comments
 (0)