A "never" function is checked at compile time and runtime, and may still throw
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Affected page
https://www.php.net/manual/en/language.types.never.php
Current issue
- There is no mention that a "never" function is checked by the compiler. And that the check is that no "return;" is used.
- There is no mention that a "never" function can produce a TypeError at runtime.
- There is no mention that a "never" function can still throw an Exception.
- There is no mention that "never" is not a type, but only a return-only type.
Suggested improvement
Mention these points.
Additional context (optional)
- Never can throw a TypeError at runtime:
// Simulate auto loading
$php =
<<<'EOD'
class Unknown
{
public static function Nothing()
{
}
}
EOD;
eval($php);
function NeverReturns() : never
{
Unknown::Nothing();
// exit;
}
NeverReturns();
// Fatal error: Uncaught TypeError: NeverReturns(): never-returning function must not implicitly return in /in/GMMAC:19
// Stack trace:
// #0 /in/GMMAC(21): NeverReturns()
// #1 {main}
// thrown in /in/GMMAC on line 19
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 with the affected page, language.types.never.php, and review its existing explanation of the never return type. Update the page to mention compile-time checking for return statements, possible runtime TypeError, exceptions, and that never is a return-only type. Use the supplied example as context when checking that the documented behavior is accurate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100