phpstan icon indicating copy to clipboard operation
phpstan copied to clipboard

Put configuration in other folder

Open mauriau opened this issue 2 months ago • 4 comments

Bug report

Hello, i'm in version 1.12.

So, I generate some baseline files. I put the files (I have different splited bundle) somewhere other than the root directory, and they are detected but not taken into account. All the baseline errors are then displayed.

Has this been fixed in version 2? I am required to work with a package mirror for my company, and version 2 is not available at the moment.

Code snippet that reproduces the problem

No response

Expected output

each baseline files, in my each bundle should run correctly

Did PHPStan help you today? Did it make you happy in any way?

I used phpstan since 2018 in different enterprise and experience. It's very usefull ! I will be happy to used it in my new job and base code.

mauriau avatar Dec 04 '25 08:12 mauriau

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

mergeable[bot] avatar Dec 04 '25 08:12 mergeable[bot]

Can you be more specific? Pleaase show some sample contents of your config files, where you put them, where are your source files etc.

And do yourself a favour and at least enable bleding edge (https://phpstan.org/blog/what-is-bleeding-edge) with your 1.12.x version. With that you can actually do most of the work in the upgrading guide too: https://github.com/phpstan/phpstan/blob/2.1.x/UPGRADING.md

ondrejmirtes avatar Dec 04 '25 09:12 ondrejmirtes

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

It's not reproductable with this tools :/

So when I run vendor/bin/phpstan -c ./somes/path/baseline.neon With baseline.neon included phpstan.neon .

exemple : The file is in src/Path/MyBundle/my-bundle-baseline.neon and ./config/phpstan/phpstan.neon is the common part of all others bundle.

src/Path/MyBundle/my-bundle-baseline.neon :

includes:
  - ./config/phpstan/phpstan.neon

parameters:
	ignoreErrors:
		-
			message: "#^Cannot access offset 'blablabla…' on mixed\\.$#"
			count: 1
			path: src/Path/MyBundle/Controller/AIPController.php

		-
			message: "#^Cannot access offset 'blablabla2' on mixed\\.$#"
			count: 1
			path: src/Path/MyBundle/Controller/AIPController.php

So when I run vendor/bin/phpstan analyze -c src/Path/MyBundle/my-bundle-baseline.neon

the errors in the baseline file are displayed in the output of the command. The configuration look good, because, before I had some errors about path not found or file included not found.

But if I put this file into the root of my projet, and run it, it's works well, there is no errors displayed

I try to simply, because the environnement is more complexe ^^. But this is the principle idea.

I hope I have been able to explain myself more clearly so that I can be understood ^^

edit : and reportUnmatchedIgnoredErrors: false is ever present in my configuration

mauriau avatar Dec 04 '25 14:12 mauriau

You're making multiple mistakes here.

Baseline file is supposed to be generated, the config file you pass with -c is supposed to be manually written. The baseline file is supposed to be included in the passed config file, not vice-versa.

Also, the paths in src/Path/MyBundle/my-bundle-baseline.neon are wrong. Paths in a config file are relative to that file.

To fix your problems:

  1. Delete src/Path/MyBundle/my-bundle-baseline.neon.
  2. Run PHPStan with -c src/Path/MyBundle/config/phpstan/phpstan.neon.
  3. To generate baseline, run PHPStan with vendor/bin/phpstan analyse -c src/Path/MyBundle/config/phpstan/phpstan.neon --generate-baseline src/Path/MyBundle/my-bundle-baseline.neon. PHPStan will put correct paths in that by itself. The correct paths for the file in that directory are for example path: Controller/AIPController.php.
  4. Include the generated baseline in src/Path/MyBundle/config/phpstan/phpstan.neon by adding includes section with - ../../my-bundle-baseline.neon.

ondrejmirtes avatar Dec 04 '25 15:12 ondrejmirtes