Closed (fixed)
Project:
Coder
Version:
8.3.x-dev
Component:
Coder Sniffer
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Jan 2025 at 05:43 UTC
Updated:
25 Feb 2025 at 21:59 UTC
Jump to comment: Most recent
I was working on MR 10884 and accidentally use
#[Hook('hook_node_view')]
instead of
#[Hook('node_view')]
I think this can be catched with static code analysis.
I am not sure if what is best tool for that? phpcs, or phpstan?
PR https://github.com/pfrenssen/coder/pull/260
Comments
Comment #2
nikolay shapovalov commentedPR created https://github.com/pfrenssen/coder/pull/260
Comment #3
nicxvan commentedThe problem is hooks like hook_hook_info.
Now that one won't ever be oop, but we can't guarantee contrib or custom code hasn't done something similar.
Comment #4
klausiThanks, approach makes sense, I think we can do this. Left some comments on the PR.
Please add special handling for hook_hook_info(). There are not other hooks in core that would be falsely flagged, I don't think we need to care about other special cases in contrib or custom code (people can make PHPCS ignore directives).
Comment #5
nicxvan commentedWe don't need to worry about hook_hook_info, it cannot be oop anyways.
My point was we shouldn't make assumptions about contrib and custom code.
If you think the ignore rule is enough then it's ok with me, this covers the vast majority of the cases.
Comment #6
nikolay shapovalov commented@klausi thanks for your review, I update PR and it's ready for review.
@nicxvan, I add special handling for hook_hook_info(). But still not sure about it.
Comment #7
nicxvan commentedWe don't need to handle hook_hook_info it will never be oop.
Comment #8
nikolay shapovalov commentedThanks @nicxvan, I remove special handling for "hook_hook_info()".
Comment #9
nikolay shapovalov commentedDecide to improve Hook attribute tests #3501237: Improve HookCollectorPass test.
Comment #10
klausiThanks, I think the sniff is almost ready!
Comment #11
nikolay shapovalov commentedThanks for review, PR updated and ready for the review.
Comment #13
klausiMerged, thanks!
Comment #14
nicxvan commented