Closed maxcohn closed 1 year ago
I actually like the idea of making it entirely userconfigurable instead of hardcoded so I've implemented it. Should be in the next release :)
I can't get over how fast you are! I'm very grateful for your work :)
Just an idea: maybe it could support substrings so one could just specify Warning:
and have all errors caught. PHP likes to throw line numbers and absolute paths in some of these errors, so small changes to the file's location or just line number the errors was on will prevent the error from being caught. Since a string is also a substring of itself, the current functionality would just be altered slightly.
For example, this
PHP Warning: Optional parameter $numFields declared before required parameter $condensedField is implicitly treated as a required parameter
becomes this:
PHP Optional parameter $numFields declared before required parameter $condensedField is implicitly treated as a required parameter
since there's only a find and replace happening. I believe this can be updated right here (https://github.com/SanderRonde/phpstan-vscode/commit/9a53527fe9d6e4e8b10eab802e49b2955de0a0bf#diff-cb9065f770e90db317f3d505d67589dc098bab45986df0aaaa32d2f192cc558eR185) to ignore the entire error instead of just removing a bit of it. Not sure if the current implementation bases the output on lines, but that would probably be necessary given this case, or you could jerryrig regex to work per line instead.
All of this is assuming this is the path you want to take here - I don't want to impose, this just something I thought would be beneficial for myself and other users of this extension.
Thanks for the suggestion. After thinking about it I've gone for something that is pretty close to this namely regexes. That way you can just do PHP Warning: .*
and be done (or in the Xdebug case Xdebug: .*
). This way it also doesn't happen that errors are ignored while they shouldn't be (which will get me a lot of "the extension doesn't work" issues). It also allows for more flexibility by just making stuff like the line number a \d
.
Great call, just allowing regular expressions really gives as much (or as little) power as anyone could want.
I saw #16 and figured that maybe a configuration setting where you can specify an array of "ignore strings" that a user can supply themselves so that way it's not hard coding something like 'XDebug' or 'Warning:'. I'm running into a similar situation because my execution environment is different than my development environment.
If you're open to the idea but don't want to work on it, I can give it a go.