Closed (fixed)
Project:
Coder
Version:
8.3.x-dev
Component:
Coder Sniffer
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Jun 2023 at 23:36 UTC
Updated:
3 Nov 2025 at 11:59 UTC
Jump to comment: Most recent
Comments
Comment #2
dpi@cmlara I'd recommend using normal @var blocks in Drupal code, I dont think theres a legitimate reason for our ecosystem to use @phpstan-var for inlines.
PHPStan/Psalm advanced types work in @var inlines perfectly fine, as far as I'm aware.
I think I've only used phpstan-var on class properties.
My opinion is it's not worth the exception, however if maintainer decides otherwise I'd suggest also adding the Psalm equivalent also.
Comment #3
cmlaraRealistically the Drupal sniffs should not interfere with any other external systems that have a defined standard, so I would contend that is an argument on its own to do these changes. If were going to have sniffs they need to work in all situations otherwise developers will just not use them.
Even if they can be done with @var its always possible other software in a developers stack does not handle these enhanced types, this is part of the reason the @phpstan-* tags exist.
Looks like our support has become a lot better in the latest release, I'm not 100% sure what version I was on a few weeks back, but phpcs was throwing a fit left and right over a number of the enriched formats so I was taking advantage of the @phpstan-* tags extensively. Looks like most (maybe all) are now handled in 8.3.20 so that I can roll back to the non phpstan specific version.
Comment #4
dpiWe'll I think its reasonable for the Drupal standard to reject all /**/ comments, with a single whitelisted @var. It doesnt make sense to continuously add exceptions, unless for example we allow /** @anythingUntilEndOfLine */
Happy to continue to provide advice and anecdotes in dslack#phpstan.
Comment #5
klausiI think your idea that we allow /** @anythingUntilEndOfLine */ for any doc comment tag is good. There is a trend in PHP to annotate types and variables inline in code, I think Coder can ignore that and let developers use any tag they want. I agree that @var is probably the best choice in most cases, but I'm not sure that we should enforce that as standard (at least not yet).
Pull requests welcome to relax this check for any doc tag!
Marking this as feature request.
Comment #8
twiesing commentedI've created a merge request to relax the check based on the above.
In the MR I decided to allow doc comments that start with a doc tag (preceding whitespace is fine).
To illustrate, I've also added a couple of test cases:
Comment #9
klausiThanks! Can you open a PR at https://github.com/pfrenssen/coder/pulls ? We are still doing the pull requests there for now.
Comment #10
twiesing commentedDone: https://github.com/pfrenssen/coder/pull/269
Should I close the MR on GitLab?
Comment #12
twiesing commentedIs there any estimate on how long it takes from a GitHub PR until the code appears in a release?
Comment #14
klausiThanks, merged!
Usually I try to make releases every 3 months if changes were merged in that period.
I think I can make a new release at Drupalcon on contribution day next Friday.
Comment #16
klausiCoder 8.3.31 released with this fix!