Skip to content

Setup PHPStan#1922

Open
staabm wants to merge 3 commits into
php:masterfrom
staabm:stan
Open

Setup PHPStan#1922
staabm wants to merge 3 commits into
php:masterfrom
staabm:stan

Conversation

@staabm

@staabm staabm commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

adding a minimal PHPStan setup. this is the starting point so iterating on the PHPStan level can be achieved in future PRs.

as requested in #892 (comment)

Comment thread phpstan-baseline.neon
Comment on lines +4 to +13
message: '#^Variable \$version might not be defined\.$#'
identifier: variable.undefined
count: 1
path: include/download-instructions/linux-debian-cli-community.php

-
message: '#^Variable \$version might not be defined\.$#'
identifier: variable.undefined
count: 1
path: include/download-instructions/linux-debian-web-community.php

@staabm staabm Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one way to get rid of these errors in the future would be declaring variables expected to be passed in from global scope via

<?php
/** @var string $version */
?>

at the top of the files.


alternatively a more aggressive approach could be asserting the variables instead of just making the tooling aware of it using e.g.

<?php
assert(isset($version) && is_string($version));
?>

@staabm staabm marked this pull request as ready for review June 13, 2026 07:31
Comment thread phpstan.neon.dist
Comment on lines +4 to +14
parameters:
level: 3
paths:
- .
fileExtensions:
- php
- inc

excludePaths:
analyse:
- vendor/

@staabm staabm Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after getting more used to the project structure I think for now its best to scan all php files, but exclude only the vendor/. that way we don't miss anything.

initially I configured to only scan certain folders, but this would e.g. miss .php files in the repo root.

this may be fine tuned in future PRs of course

@markrandall

Copy link
Copy Markdown

I'd be glad to have phpstan in, although FWIW as I'm rewriting pretty much everything I am aiming for level 8.

@staabm

staabm commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

having it more strict is great to have. but for a start and for all these legacy scripts we need to start somewhere :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants