Skip to content

Bug in Expression Support ? | null/true as default value gets namespace treatment for mouse over #4012

@jrfnl

Description

@jrfnl

Expected behavior

That a null default value is recognized as the global constant null, same with true.

And that an unqualified class constant with a import use statement for the class gets resolved to the correct class.

Actual behavior

null/true (and I suspect false) now gets annotated with a mouse-over as if it is a namespaced constant/class: <abbr title="\Project\NS\null">null</abbr>

And the unqualified class constant now gets turned into a fully qualified class constant in the global namespace, not the namespace it belongs to.

Steps to reproduce the problem

Given the following code:

namespace WpOrg\Requests\Auth;

class Basic implements Auth {
	/**
	 * Constructor
	 *
	 * @since 2.0 Throws an `InvalidArgument` exception.
	 * @since 2.0 Throws an `ArgumentCount` exception instead of the Requests base `Exception.
	 *
	 * @param array|null $args Array of user and password. Must have exactly two elements
	 *
	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not an array or null.
	 * @throws \WpOrg\Requests\Exception\ArgumentCount   On incorrect number of array elements (`authbasicbadargs`).
	 */
	public function __construct($args = null) {
		// Do something.
	}
}

Source:
https://github.com/WordPress/Requests/blob/e02a8b9d7ae5bd1e5101b301182ef9032adcd748/src/Auth/Basic.php#L51

And generating the docs like so:
phpDocumentor

... with the following quite plain config: https://github.com/WordPress/Requests/blob/babd303d2084cf2690db536aeb6eef58326ee3ff/phpdoc.dist.xml

With phpDocumentor 3.6.0, the output for the constructor would look like so:

Image

Relevant example lines in committed generated docs:

PR showing the diff with the previously published docs: WordPress/Requests#982
The previously published docs were generated with phpDocumentor v3.6.0. The PR was generated using phpDocumentor 3.8.1.

While with phpDocumentor 3.9.0, the output looks like so:

Image

Live web link: https://requests.ryanmccue.info/api-2.x/classes/WpOrg-Requests-Auth-Basic.html#method___construct

Relevant example lines in committed generated docs:

PR showing the diff with the previously published docs: WordPress/Requests#991
The previously published docs were generated with phpDocumentor v3.6.0. The PR was generated using phpDocumentor 3.9.0.

Other examples

The same thing is happening in multiple places in the codebase.

Here is an example of the same happening with a true default value:

And here is another weird one - the class constant Requests::GET used as a default value gets turned into \Requests::GET (incorrect), not \WpOrg\Requests\Requests::GET (correct):

Your environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions