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

PHPStan configuration treats files relative to itself #3

Open
szepeviktor opened this issue Jun 30, 2023 · 4 comments
Open

PHPStan configuration treats files relative to itself #3

szepeviktor opened this issue Jun 30, 2023 · 4 comments

Comments

@szepeviktor
Copy link

szepeviktor commented Jun 30, 2023

Hello! 👋🏻 Thank you for following.

This goes into an extension.

parameters:
    bootstrapFiles:
        # Missing constants
        - ft-stubs.php
        - ../../php-stubs/wordpress-globals/wordpress-globals.php

Like here https://github.com/szepeviktor/phpstan-wordpress/blob/6eccde1161f46f95aa1e3fe6cf1eb46efc557344/extension.neon#L117

Other settings go into projects using this extension.

@szepeviktor
Copy link
Author

szepeviktor commented Jun 30, 2023

I see you want a central "default configuration" but an extension cannot do that because configuration is project-level stuff.

For example you can have a file in this repo called phpstan-defaults.neon
and include it in your projects

includes:
    - vendor/figuren-theater/phpstan/phpstan-defaults.neon

But this is not the task of an extension.
Has a much better place in another repo: figuren-theater/default-configurations or similar.

Paths do not work in included configuration files! %currentWorkingDirectory% works but it is highly unstable: has no known anchor.

@szepeviktor
Copy link
Author

szepeviktor commented Jun 30, 2023

One more thing. PHPStan does not look at the value of constants, only their type.
So a simple non-empty string, a true or a 0 will suffice.
Although some constants must be listed as "dynamic constant".

BTW Storing values in constants smells like PHP 4 :) ... you could use an object in 2023 and archive this repo.

@carstingaxion
Copy link
Member

Dear @szepeviktor thank you very, very much for opening this issue and just coming in contact. I really appreciate it, because I'm often not brave enough to just that.

Hello! 👋🏻 Thank you for following.

Thank you! for creating and publicly sharing so many great ideas within your repositories!

You probably understood better what I wanted to approach than I did and do.

I see you want a central "default configuration" ....

Exactly that. I wanted to prepare some future-proof and well-known guiding for my cowboycoding.
And I hoped to achieve this, by using just composer, without the need for additional phpstan.neonfiles in all desired repositories.

but an extension cannot do that because configuration is project-level stuff.

🙏 Yes & thank you. I learned this already in the last couple of hours . I'm going to add phpstan.neonfiles in all of my desired repositories.

I will open up some more Issues to bring your enlightments to life within my code.
For now: Just thank you, thank you very much!

@carstingaxion
Copy link
Member

P.S. Having you @szepeviktor here as a guest and contributor is a stunning moment for me and a valid proof that it is great to be part of the open source community.

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

No branches or pull requests

2 participants