Skip to content

get_class_methods() with a class-name string returns [] for a namespaced class #540

Closed

Description

@samdark

get_class_methods() with a class name string returns an empty array for a namespaced class. The object form works.

<?php
namespace Tests;

final class FooTest
{
    public function testOne(): void {}
    public function testTwo(): void {}
}

$class = FooTest::class;
var_dump(get_class_methods($class));
var_dump(get_class_methods(new FooTest()));

Expected (php): both calls print array(2) { [0]=> string(7) "testOne" [1]=> string(7) "testTwo" }.

Actual (manticore compile gcm.php -o gcm && ./gcm):

array(0) {
}
array(2) {
  [0]=>
  string(7) "testOne"
  [1]=>
  string(7) "testTwo"
}

The methods themselves are there: method_exists($class, 'testOne') is true, and (new $class())->$m() works. Without the namespace, the string form works. This breaks test runners that discover test* methods by class name.

Manticore 0.17.0 (ghcr.io/manticorephp/compiler:latest, image built 2026-10-24, Linux x86_64). PHP reference: 8.5.4.

Activity

  1. added
    bug
    wrong-answer
    on Oct 30, 2026
  2. blacktrs commented on Oct 30, 2026

    @blacktrs
    Contributor

    Thanks for the report!
    Looks like a string value falls back into the global namespace. Thus, the result is wrong.
    Definitely it will be fixed in the next release.

  3. added theissue type on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions