Skip to content

spl: class_* functions should ignore leading slash in class name in non-autoload mode #22282

@jorgsowa

Description

@jorgsowa

Description

The following code:

<?php
interface Iface {}
trait Tr {}
class ParentC implements Iface {}
class ChildC extends ParentC {
    use Tr;
}

var_dump(class_parents('\ChildC', false));
var_dump(class_parents('\ChildC'));
var_dump(class_implements('\ParentC', false));
var_dump(class_uses('\ChildC', false));

Resulted in this output:

Warning: class_parents(): Class \ChildC does not exist in /in/T5JUQ on line 11
bool(false)
array(1) {
  ["ParentC"]=>
  string(7) "ParentC"
}

Warning: class_implements(): Class \ParentC does not exist in /in/T5JUQ on line 13
bool(false)

Warning: class_uses(): Class \ChildC does not exist in /in/T5JUQ on line 14
bool(false)

But I expected this output instead:

array(1) {
  ["ParentC"]=>
  string(7) "ParentC"
}
array(1) {
  ["ParentC"]=>
  string(7) "ParentC"
}
array(1) {
  ["Iface"]=>
  string(5) "Iface"
}
array(1) {
  ["Tr"]=>
  string(2) "Tr"
}

PHP Version

master

Operating System

No response

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions