[php-src] Issue #22282: spl: class_* functions should ignore leading slash in class name in non-autoload mode

[email protected] (jorgsowa) Thu, 11 Jun 2026 23:22:06 +0000
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/22282
Author: jorgsowa

### Description

The following code:

```php
<?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

```plain
master
```

### Operating System

_No response_