phpDocumentor / phpDocumentor/phpDocumentor

Paths for --filename and <file> are not resolved correctly

Open
#2,046 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
4.3k
Forks
648
Avg merge
28m
Merged PRs (30d)
13

Description

The --filename command line argument cannot be given absolute paths or relative paths that start at the current directory or a parent directory. The same goes for the -f alias and for <file> in a config file.

Given the following directory structure:

├── CURRENT_DIR
│   ├── subdir
│   │   └── Test.php
│   └── Test.php
└── other
    └── Test.php

Actual Behavior

Running phpdoc from CURRENT_DIR may or may not find the file "Test.php" using the command line phpdoc parse --filename path --force -vvv. I get the following results for different paths:

  • Test.php - found
  • ./Test.php - not found
  • ../CURRENT_DIR/Test.php - not found
  • subdir/Test.php - found
  • subdir/../Test.php - not found
  • ./subdir/Test.php - not found
  • ../other/Test.php - not found
  • /abs/path/to/other/Test.php - not found

The debug output is

[2018-12-23 17:19:32] app.INFO: One of the project's settings have changed, forcing a complete rebuild [] []
[2018-12-23 17:19:32] app.INFO: Elapsed time to parse all files: 0s [] []
[2018-12-23 17:19:32] app.INFO: Peak memory usage: 10M [] []

Expected Behavior

A "Test.php" file should be found in all of these paths.

Steps to Reproduce the Problem

  • $ mkdir -p dirtest/CURRENT_DIR/subdir dirtest/other
  • $ cd dirtest/CURRENT_DIR
  • $ touch Test.php
  • $ cp Test.php subdir
  • $ cp Test.php ../other
  • $ phpdoc parse --filename ../other/Test.php --force -vvv

Your environment

  • Version used: v3.0.x-dev@ee92b8f
  • Install method: cloned "develop" branch
  • php version: 7.2.10
  • Operating system and version: Kubuntu 18.04

Contributor guide

Open the contributing guide

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 at the phpdoc parse command and trace handling for --filename, its -f alias, and <file> values from a config file. Reproduce the listed paths from CURRENT_DIR, then verify that absolute paths, parent-directory paths, and paths containing ./ or .. all locate the expected files.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.