![]() You can turn on/off reporting unused ignores explicitly for each entry in ignoredErrors. You can turn off this behaviour by setting reportUnmatchedIgnoredErrors to false in the configuration: parameters : reportUnmatchedIgnoredErrors : false ![]() If some of the ignored errors (both from configuration and PHPDocs) do not occur in the result anymore, PHPStan will let you know and you will have to remove the pattern from the configuration. If you want to ignore all the current errors and only focus on new and changed code from now on, go and learn about the baseline feature. It deals with the complexity of writing a matching regular expression from a plain string and encoding that regular expression into the neon format.Īn error occurred. Using the fields below, you can generate an entry that you can put in the parameters.ignoreErrors section of your configuration file. You can also use only the identifier key to ignore all errors of the same type: parameters : ignoreErrors : - identifier : property.notFound Generate an ignoreErrors entry # The reported error has to match both the message pattern and the identifier in order to be ignored. If you want to ignore only a specific error, you can take advantage of error identifiers in the identifier key: parameters : ignoreErrors : - message : '#Access to an undefined property +::\$foo#' identifier : property.notFound So if your phpstan.neon is in the root directory of the project, and you want to ignore an error in src/Foo/Bar.php, your path key can simply be src/Foo/Bar.php. Relative paths in the path and paths keys are resolved based on the directory of the config file is in. message : '#Call to an undefined method +::doFoo\(\)#' path : other/dir/DifferentFile.phpĬount : 2 # optional - '#Other error to ignore everywhere#' messages : - '#Call to an undefined method +::doFooFoo\(\)#' - '#Call to an undefined method +::doFooBar\(\)#' paths : - some/foo/dir/* messages : - '#Call to an undefined method +::doFooFoo\(\)#' - '#Call to an undefined method +::doFooBar\(\)#' path : other/dir/AnotherFile.php message : '#Call to an undefined method +::doBar\(\)#' paths : - some/dir/* parameters : ignoreErrors : - message : '#Access to an undefined property +::\$foo#' path : some/dir/SomeFile.php You can specify how many times the error is expected by using count (optional, applies only to message not messages and path, not paths). Wildcard patterns compatible with the PHP fnmatch() are also supported. To ignore errors by a regular expression only in a specific file, add an entry with message or messages and path or paths keys. To ignore an error by a regular expression in the whole project, add a string entry: parameters : ignoreErrors : - '#Call to an undefined method +::doFoo\(\)#' - '#Call to an undefined method +::doBar\(\)#' The reason why a certain error is ignored using can be put into parentheses after the identifier: echo $foo // variable.undefined (Because we are lazy) Ignoring in configuration file #Įrrors can be ignored by adding a regular expression to the configuration file under the ignoreErrors key. Custom error formatters also have the error identifiers at their disposal in order to output them.It will output the identifier next to the error message. By reproducing your error in the playground.It will output your errors along with their identifiers in a beautiful web UI. The default table error formatter will output the error identifier below the error message. You can find out the error identifier for the error you’re trying to ignore: Multiple errors with the same identifier can also be ignored the same way: echo $foo, $bar // variable.undefined, variable.undefined ![]() Multiple errors can be ignored with comma-separated identifiers. It requires an error identifier to only ignore a specific error instead of all errors.įunction ( ).If there’s no code on the line with the comment, it ignores the next line. It figures out automatically if you want to ignore an error on the current line or the next line. ![]() If you want to ignore only a specific error, you can take advantage of error identifiers and use the new tag that comes with two features:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |