class_exists throws on missing extends/implements and fatal on missing trait
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Affected page
https://www.php.net/manual/en/function.class-exists.php
Issue description
class_exists will throw if a class is autoloaded (= 2nd arg is true = default!), but any extends/implements of that class do not exist and cannot be autoloaded
Steps to reproduce
spl_autoload_register( function ( $class_name ) {
if ( $class_name === 'Foo' ) {
require __DIR__ . '/foo.php';
}
} );
class_exists( Foo::class );
foo.php
class Foo extends Bar {}
Suggested fix
Mention that it can throw an exception if the any of the classes that class extends/implements fails
Mention that it will result in a fatal E_ERROR if any of the "trait use" of the class do not exist (https://github.com/php/php-src/issues/21106)
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
Read the class_exists documentation at the affected PHP manual page and compare its current autoloading behavior description with the reproduction examples. Update the documentation to mention exceptions from missing parent classes or interfaces and fatal errors from missing traits, using the linked PHP issue for the trait behavior. Done means both failure modes are accurately documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100