Single backslash triggers autoloading with empty string
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Description
The following code:
<?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.
PHP Version
8.2 (and others)
Operating System
Debian 11
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the PHP 8.2 example using spl_autoload_register and class_exists('\'), then compare it with class_exists('') and method_exists('\', 'test'). The issue names no doc-en file or test; determine which PHP documentation entry covers these calls and whether the expected result is a documentation clarification or a runtime bug report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100