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

FR: Handle the values passed via CLI arguments in a case-insensitive manner #2434

Closed
jrfnl opened this issue Jun 15, 2020 · 5 comments
Closed

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Jun 15, 2020

Feature request

When providing CLI arguments, it is common for tools to allow passing those in a case-insensitive manner.

At this moment, this is not the case in phpDocumentor and I would like to suggest changing this to treat all values passed to CLI arguments in a case-insensitive manner.

Precedent

PHPUnit

Given a test class called MyArbitraryTest, I can run just that test by calling:

phpunit --filter=myarbitrarytest

I.e. the value of the command line argument is handled in a case-insensitive manner.

PHP_CodeSniffer

If I'd want to run the PHPCompatibility standard over a codebase (provided the standard is installed), I can do this by calling:

phpcs . --standard=phpcompatibility
phpcs . --standard=PHPCompatibility
phpcs . --standard=PHPCOMPATIBILITY

I.e. the value of the command line argument is handled in a case-insensitive manner.

Current behaviour in phpDocumentor - example 1

Given a simple test file saved as ./src/Issue2434.php containing the following:

<?php
class Issue2434 {}

Running phpDocumentor 3 with the following command:

phpdoc -f ./src/issue2434.php

Results in:

phpDocumentor v3.0.x-dev@d15f2d6                                              
                                                                              
23:50:14 WARNING   [app] Your project seems to be empty!                      
Parsing files                                                                 
                                                                              
Applying transformations (can take a while)                                   
 19/19 [============================] 100%                                    
All done in 1 seconds!                                                        

And no docs being generated:

issue-2434-index-page

issue-2434-global-page

issue-2434-files-page

Running phpDocumentor 3 with the following command (correct case):

phpdoc -f ./src/Issue2434.php

... works fine as expected:

phpDocumentor v3.0.x-dev@d15f2d6                                              
                                                                              
Parsing files                                                                 
 1/1 [============================] 100%                                      
Applying transformations (can take a while)                                   
 19/19 [============================] 100%                                    
All done in 1 seconds!                                                        

Current behaviour in phpDocumentor - example 2

# phpdoc --visibility=PRIVATE
PHP 7.4.6 (cli) (built: May 12 2020 11:41:06) ( ZTS Visual C++ 2017 x86 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

phpDocumentor v3.0.x-dev@d15f2d6

23:43:35 ERROR     [console] Error thrown while running command "--visibility=PRIVATE". Message: "PRIVATE is not a type of visibility, supported is: api, public, protected, private or internal" ["exception" => RuntimeException { …},"command" => "--visibility=PRIVATE","message" => "PRIVATE is not a type of visibility, supported is: api, public, protected, private or internal"]
23:43:35 ERROR     [console] Error thrown while running command "--visibility=PRIVATE". Message: "PRIVATE is not a type of visibility, supported is: api, public, protected, private or internal" ["exception" => RuntimeException { …},"command" => "--visibility=PRIVATE","message" => "PRIVATE is not a type of visibility, supported is: api, public, protected, private or internal"]

In ProjectDescriptorBuilder.php line 207:

  PRIVATE is not a type of visibility, supported is: api, public, protected, private or internal
@jaapio jaapio added this to Needs triage in phpDoc issue triage board Jun 15, 2020
@jrfnl jrfnl changed the title Handle the values passed via CLI arguments in a case-insensitive manner FR: Handle the values passed via CLI arguments in a case-insensitive manner Jun 15, 2020
jrfnl added a commit to jrfnl/phpDocumentor-issue-demo that referenced this issue Jun 16, 2020
To see the issue, first run:
```bash
phpdoc -f ./src/issue2434.php
```

The generated documentation will be empty.

Next, run:
```bash
phpdoc -f ./src/Issue2434.php
```

And all works fine.

Ref: phpDocumentor/phpDocumentor#2434
@mvriel
Copy link
Member

mvriel commented Jun 16, 2020

For quite a few things I agree, but file and folders handling needs to be case sensitive because some filesystems are case sensitive, and files with the same name but a different case can co-exist. (let's not debate whether this is a good idea; that would be a short debate 😆 )

I see you also mention visibility, and that can very well be case insensitive. Sounds like a good improvement :)

@jrfnl
Copy link
Contributor Author

jrfnl commented Jun 17, 2020

I understand your point of view regarding file/folder names, though that could possibly be solved by doing a case-sensitive check to find the file first and if not found, falling back to a case-insensitive one.

If you like, I could look into how other tools do this as I'm fairly confident that both tools I mentioned before, do support it.

Glad to hear though that, at a minimum, for everything else this is accepted as a viable feature request.
Not a priority, but a nice feature for the future to look forward to! ❤️

@mvriel
Copy link
Member

mvriel commented Jun 17, 2020

Those checks can be bad for performance, especially when working with remote filesystems. We try to follow the rules for glob (although these are not in a proper specification). Although I am interested in how other tools deal with this; I do think that changing this specific part may have edge cases that can be problematic.

@jaapio jaapio closed this as completed in 28c67a6 Jun 14, 2024
phpDoc issue triage board automation moved this from Needs triage to Closed Jun 14, 2024
@jaapio
Copy link
Member

jaapio commented Jun 14, 2024

I made the visibility case insensitive. For now that will be the only change.

@jrfnl
Copy link
Contributor Author

jrfnl commented Jun 16, 2024

Thanks @jaapio !

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

No branches or pull requests

3 participants