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

Process Improvement - PHP Static Analysis #8082

Open
cpalv opened this issue Nov 23, 2024 · 1 comment
Open

Process Improvement - PHP Static Analysis #8082

cpalv opened this issue Nov 23, 2024 · 1 comment
Labels
support Community support

Comments

@cpalv
Copy link

cpalv commented Nov 23, 2024

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is including your motivation for the request,
i.e. "For the purpose of [...] I am missing a solution that will [...]."

Not really a problem, mostly just a process improvement. I'd like to suggest adding a static analysis build option to ensure code quality.

Describe the solution you like

A clear and concise description of what you want to happen.
(e.g. I would like an input field in the /ui/firewall/alias which would add .... to ....)

Include phpstan or another PHP static analyzer.

Describe alternatives you considered

A clear and concise description of any alternative solutions or features you considered.

none

Additional context

Add any other context or screenshots about the feature request here or links to relevant forum thread or similar

@cpalv
Copy link
Author

cpalv commented Nov 23, 2024

I've done some preliminary research on this and at a minimum PHP Composer would need to be added to the OPNsense repositories.

After going through some of the initial steps on a plain FreeBSD install I ran into the following error

# vendor/bin/phpstan anaylse src/opnsense/mvc/app/controllers/OPNsense/
Fatal error: Uncaught Error: Class "PhpToken" not found in phar:///usr/opnsense/core/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php:7
Stack trace:
#0 phar:///usr/opnsense/core/vendor/phpstan/phpstan/phpstan.phar/preload.php(1329): require_once()
#1 phar:///usr/opnsense/core/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(20): require_once('phar:///usr/opn...')
#2 phar:///usr/opnsense/core/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(115): _PHPStan_c684505c9\{closure}()
#3 /usr/opnsense/core/vendor/phpstan/phpstan/phpstan(8): require('phar:///usr/opn...')
#4 /usr/opnsense/core/vendor/bin/phpstan(119): include('/usr/opnsense/c...')
#5 {main}
  thrown in phar:///usr/opnsense/core/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php on line 7

But from what I can tell TokenPolyfill.php is included in phpstan.phar

# grep -rni 'TokenPolyfill.php' **
Binary file vendor/phpstan/phpstan/phpstan.phar matches

After resolving this, sifting through the results from phpstan would take some effort

@AdSchellevis AdSchellevis added the support Community support label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Community support
Development

No branches or pull requests

2 participants