[php-src] Issue #10550: Single backslash triggers autoloading with empty string

From: Date: Thu, 09 Feb 2023 15:28:31 +0000
Subject: [php-src] Issue #10550: Single backslash triggers autoloading with empty string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243699@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10550
Author: istepaniuk

### Description

The following code:

```php
<?php

spl_autoload_register(function ($class_name) {
    var_dump($class_name);
});

class_exists('\\');
```

Resulted in this output:
```
string(0) ""
```

But I expected **NO** output instead.

This seems unexpected. Calling class_exists(''); does not trigger the
autoload callback, but a single backslash in the class name _does_ (as does invoking
method_exists('\\', 'test'), etc.)

I might be wrong but I can't think of a reason why to invoke the callback in this case, in
fact, composer fails because it assumes that $class_name is [never
empty](https://github.com/composer/composer/issues/11305).


### PHP Version

8.1

### Operating System

Debian 11


Thread (1 message)

  • istepaniuk
« previous php.bugs (#243699) next »