Skip to content

Commit

Permalink
Adjust lang.reflection.Type::package() to return Package() for global…
Browse files Browse the repository at this point in the history
… classes
  • Loading branch information
thekid committed Mar 28, 2024
1 parent 043dd55 commit b472246
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/main/php/lang/reflection/Type.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ public function is($type): bool {
}

/**
* Returns this type's package, or NULL if this type is in the global namespace.
* Returns this type's package
*
* @return ?lang.reflection.Package
* @return lang.reflection.Package
*/
public function package() {
$name= $this->reflect->getNamespaceName();
return $name ? new Package($name) : null;
return new Package($this->reflect->getNamespaceName());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/reflection/unittest/TypeTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function package() {

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

#[Test]
Expand Down

0 comments on commit b472246

Please sign in to comment.