php / php/doc-en

"void" and "never" are not atomic types

Open
#5,388 0 comments 0 reactions 0 assignees View on GitHub

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.type-system.php

Current issue

Suggestion: Remove "void" and "never" from Built-in types and put them in a seperate list Return-only types, outside the Atomic types section. Because both are not atomic types like int, string etc.

Void

Currently void is listed as an atomic type.

  • But void is not a type at all. It is a keyword checked at compile time.
  • There is no comparison possible if a function returned void.
  • The RFC https://wiki.php.net/rfc/void_return_type also states the return value is null and not void.

function VoidIsNotAType() : void
{
}

$ret = VoidIsNotAType();
var_dump(VoidIsNotAType());
// NULL

// Comparison not possible, because VOID is not a type
// if ($ret !== void) echo 'Not void'."\n";
function UntypedVoidIsNotAType()
{
}

$ret = VoidIsNotAType();
var_dump(VoidIsNotAType());
// NULL

// Comparison not possible, because VOID is not a type
// if ($ret !== void) echo 'Not void'."\n";

Never

Currently never is listed as an atomic type.

  • But never is not a type at all. It is a keyword checked at compile time.
  • The RFC https://wiki.php.net/rfc/noreturn_type states Both noreturn and void are both only valid as return types, but there the similarity ends.
Suggested improvement

...

Additional context (optional)

...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the affected language.types.type-system.php page and review how “void” and “never” are currently presented under Built-in types and Atomic types. Check the linked void and noreturn RFCs for the intended terminology and return-only behavior. Done means the page clearly separates these entries from atomic types without losing relevant PHP documentation.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.