Phpdocumentor: 3.0.0: import use statements are disregarded

Created on 15 Jun 2020  路  5Comments  路  Source: phpDocumentor/phpDocumentor

Given the following piece of code in file src/issue-2425-a.php:

<?php
namespace Project\Sub\Level;

use Project\Other\Level\Issue2425B;
use Project\Other\Level\Issue2425C as Aliased;

/**
 * Class summary.
 *
 * A description containing an inline {@see Issue2425B::bar()} tag
 * to a class inside of the project referenced via a use statement.
 *
 * And here is another inline {@see Aliased::bar()} tag to a class
 * aliased via a use statement.
 */
class Issue2425A {}

and this code in file src/issue-2425-b.php:

<?php
namespace Project\Other\Level;

class Issue2425B
{
    public function bar() {}
}

and this code in file src/issue-2425-c.php:

<?php
namespace Project\Other\Level;

class Issue2425C
{
    public function bar() {}
}


with the following config:

<?xml version="1.0" encoding="UTF-8" ?>
<phpdocumentor
    configVersion="3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="https://www.phpdoc.org"
    xsi:noNamespaceSchemaLocation="https://docs.phpdoc.org/latest/phpdoc.xsd"
>
    <title>Demo</title>
    <version number="latest">
        <api format="php">
            <source dsn=".">
                <path>src</path>
            </source>
        </api>
    </version>
    <template name="default"/>
</phpdocumentor>

Expected behavior

I'd expect the unqualified names used in the @see tags to be resolved to the fully qualified name using the import use statement and to be recognized as classes within the project for which a documentation page exists.

Actual behavior

The unqualified names do not get resolved using the import use statement, but are using the current namespace and therefore cannot be found in the project and don't get linked properly.

issue-2425

Steps to reproduce the problem

  1. Issue can be reproduced with the above code samples and config.
  2. Run php -f /path/to/phpDocumentor/bin/phpdoc

Your environment

  • Version used: phpDocumentor v3.0.x-dev@d15f2d6
  • Install method: git clone
  • PHP version: 7.4.6
  • Operating system and version: Windows 7
bug

All 5 comments

Investigated the issue and it seems to be related to the passing of this value into the templates and not with the template itself. As discussed with @jaapio, I am skipping any issue not related to the templates at the moment

I pushed a first draft of the improved version to handle descriptions in a more flexible way. Now switching to some other work, because the reported issue is deeper. Nobody ever tried using aliases in see tags?

Created a second PR to fix the actual issue: https://github.com/phpDocumentor/ReflectionDocBlock/pull/226

@jaapio Thank you for all your work on this! I can't say much about the PRs themselves, but I'm excited to see this handled! :heart:

PR is merged, some pending other PR is holding me back from creating a new tag right now. But I expect this other PR to be merged soon. So we can prepare a new phpDocumentor nightly with this fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niden picture niden  路  4Comments

jrfnl picture jrfnl  路  5Comments

PhrozenByte picture PhrozenByte  路  5Comments

mvriel picture mvriel  路  5Comments

olvlvl picture olvlvl  路  6Comments