Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Tag "@property" has error when both ? and null types are included #3987

Closed as not planned

Description

@valzargaming

If a @property tag is used where both |null and ? are used in the typing, phpDocumentor will throw a compilation error.

Expected behavior

The compilation should succeed instead of error.

Actual behavior

Tag "@Property" with body "@@Property ?type|null $variable Description." has error

Steps to reproduce the problem

  1. Create a PHPDoc block that uses the ?type|null syntax.

Your environment

  • Version used: 3.0.0-alpha1
  • Install method: composer require
  • PHP version: 8.4.12
  • Operating system and version (e.g. Ubuntu 20.04, Windows 10): Windows 11
  • Link to your project: https://github.com/discord-php/DiscordPHP/ & https://discord-php.github.io/DiscordPHP/reports/errors.html
  • Additional context: This becomes an issue in the DPHP library because it specifically uses ? in the PHPDocs to indicate which parameters are considered optional by Discord's API, and therefore may be optional to set in a userland environment when making an API query. It always includes the traditional syntax of type|null but also prepends ? for these cases.

Activity

  1. jaapio commented on Oct 21, 2025

    @jaapio
    Member

    The reason we support ? is because that was the way php indicated nullable parameters before union types became a feature.

    Using this for a different purpose doesn't make sense to me. And will only confuse people. Therefore I think this should not be a feature in phpDocumentor to support this.

    It's probably better to add this in your description as it will display better in your docs. You could even use a custom tag like @optional in the description. And customized the template for properties to display them in a different way when they have the custom tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions