Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uses resolved to incorrect namespaced function #3527

Closed
onairmarc opened this issue Jul 2, 2023 · 2 comments
Closed

@uses resolved to incorrect namespaced function #3527

onairmarc opened this issue Jul 2, 2023 · 2 comments

Comments

@onairmarc
Copy link

The current behavior of the "@uses" tag is resolving a namespace as if it were a child of the current namespace.
Current Namespace: "The\Current\Namespace\Section2"

Expected behavior

I am expecting the "@uses" tag to resolve to "The\Current\Namespace\Section1\SomeFunction()"

Actual behavior

The "@uses" tag resolved to a non-existent namespace and function "The\Current\Namespace\Section2\The\Current\Namespace\Section1\SomeFunction()"

Steps to reproduce the problem

  1. Create two Namespaces, each with a function. Namespace1 and Namespace2
  2. Function in Namespace2 uses Namespace1\Function()
  3. Place a docblock above Namespace2\Function() containing "@uses Namespace1\Function()"
  4. Outcome currently is "Namespace2\Namespace1\Function()" but should be "Namespace1\Function()"

Your environment

  • Version used: 3.3.1
  • Install method: PHAR in project root.
  • PHP version: 8.2.7
  • Operating system and version: macOS Ventura 13.4.1
  • Link to your project: Proprietary, not open-sourced, but a code sample is provided below.
  • Attach code that is involved
    The offending docblock is:
namespace ServicePoint\Module\ServiceCatalog\Solution;
use ServicePoint\Module\ServiceCatalog\Division as scDivision;
use ServicePoint\Core\Util\Data as spData;

/**
 *
 * Use this method to read a single record
 * 
 * @uses ServicePoint\Module\ServiceCatalog\Division\Read()
 * @param object $db 
 * @param Body $Args
 * The following fields are required:
 * - **orgId** Type: String
 * - **scSolutionRefId** Type: String
 * @return Body View this object to see the response structure.\
 * Single records are returned as a singluar object outside of uiRecords.
 */
function Read($db, $Args)
{
    $RESPOND = new spData\Data();
    $RESPOND->header = new spData\Header();

    $Query = $db->createQueryBuilder();

    $Query
        ->select('*')
        ->from('SC_SOLUTION_MSTR')
        ->andWhere('ORG_ID = ?')
        ->andWhere('SC_SOLUTION_REF_ID = ?')
        ->setParameter(0, $Args->orgId)
        ->setParameter(1, $Args->scSolutionRefId);

    $Result = $Query->executeQuery();
    $UI_RECORDS = $Result->fetchAll();
    $UI_RECORD_COUNT = $Result->rowCount();

    $UI_RECORDS = PrepareApiResponse($UI_RECORDS);

    $RESPOND->header->success = true;
    $RESPOND->body = $UI_RECORDS[0];

    if (empty($RESPOND->body->taskAsgGrpRefId) || $RESPOND->body->taskAsgGrpRefId == "0") {
        $RECORD_REF = new Body();
        $RECORD_REF->orgId = $Args->orgId;
        $RECORD_REF->scDivisionRefId = $UI_RECORDS[0]->scDivisionRefId;
        $RECORD_REF = scDivision\Read($db, $RECORD_REF);
        $RESPOND->body->taskAsgGrpRefId = $RECORD_REF->body->taskAsgGrpRefId;
    }

    return $RESPOND;
}
@phpdoc-bot phpdoc-bot added this to Needs triage in phpDoc issue triage board Jul 2, 2023
@onairmarc
Copy link
Author

I was able to identify part of the issue. I did not place the leading slash in front of the Namespace. Adding the leading slash allowed the link to be created.

However, the corresponding "@Used-By" is still not being created. I found some similar issues that have since been closed here. I am not able to link them at the moment I'm writing this (GitHub on iOS) but will link them as soon as I am able.

@jaapio
Copy link
Member

jaapio commented Jul 2, 2023

You are correct, the leading slash is required for the namespace, as the parser is working per file. There is no relation between the files, so we cannot discover the relation. This is equal to the behavior of normal class usages in php.

The used-by feature was implemented a while ago. But we haven't done a release since then. So there is no release available containing this feature. However our docker image is applying a rolling release flow. So you could use that to give it a try.

Due to the limited time I have for phpDocumentor it is hard to have a steady release schedule. I want to do a release soonish but I cannot make any promises when that will happen. I'm very sorry for that. I would love to spend more time on this lovely project, but with the current sponsoring I can just spend less than an hour a month. The rest has to be done in spare time.

Thanks for using phpDocumentor and contributing to this project by opening an issue! People like you do help me a lot to keep energy working on this.

@jaapio jaapio closed this as completed Jul 2, 2023
phpDoc issue triage board automation moved this from Needs triage to Closed Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants