Skip to content

Generated baseline doesn't match errors whose message starts with @ (since 2.2.6) #15337

Description

@aivchen

Bug report

With bleedingEdge enabled, a baseline generated by --generate-baseline doesn't ignore errors whose message starts with @. The next run reports the original error again, and the baseline entry is reported as unmatched. Regenerating the baseline doesn't help.

This works in 2.2.5 and fails from 2.2.6 up to 2.2.16.

Reproduction

src/Foo.php:

<?php

declare(strict_types = 1);

namespace App;

final class Foo
{

    /** @readonly */
    public int $bar = 1;

}

phpstan.neon:

includes:
	- phar://phpstan.phar/conf/bleedingEdge.neon
	- phpstan-baseline.neon

parameters:
	level: 0
	paths:
		- src
touch phpstan-baseline.neon
vendor/bin/phpstan analyse --generate-baseline
vendor/bin/phpstan analyse

Generated baseline:

parameters:
	ignoreErrors:
		-
			rawMessage: @@readonly property cannot have a default value.
			identifier: property.readOnlyByPhpDocDefaultValue
			count: 1
			path: src/Foo.php

Actual output (2.2.6 – 2.2.16)

 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   Foo.php                                                                                                                                                                                        
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
         Ignored error "@@readonly property cannot have a default value." (property.readOnlyByPhpDocDefaultValue) in path /home/andrew/web/phpstan-bug/src/Foo.php was not matched in reported errors.  
         🪪  ignore.unmatched (non-ignorable)                                                                                                                                                           
         at src/Foo.php:0                                                                                                                                                                               
  11     @readonly property cannot have a default value.                                                                                                                                                
         🪪  property.readOnlyByPhpDocDefaultValue                                                                                                                                                      
         at src/Foo.php:11                                                                                                                                                                              
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

Environment

  • PHPStan 2.2.16
  • PHP 8.4.24

Code snippet that reproduces the problem

No response

Expected output

[OK] No errors, as in 2.2.5.

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

PHPStan makes me happy every day!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions