Closed (fixed)
Project:
Chosen
Version:
5.0.1
Component:
Code
Priority:
Minor
Category:
Task
Assigned:
Reporter:
Created:
19 Mar 2025 at 05:44 UTC
Updated:
9 Oct 2025 at 12:49 UTC
Jump to comment: Most recent
Running PHPCS shows the warnings/errors in attached file, which should be fixed.
| Comment | File | Size | Author |
|---|---|---|---|
| chosen.txt | 9.2 KB | ggh |
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
ggh commentedMR Raised
Comment #4
bhupesh_upadhyay commentedIt looks like there are few issues that needs to be fixed.
FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/src/ChosenFormRender.php
---------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------
38 | ERROR | Type hint "array" missing for $element
125 | ERROR | Type hint "array" missing for $element
143 | ERROR | Type hint "array" missing for $element
---------------------------------------------------------------------------------------
FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/modules/chosen_field/src/Plugin/Field/FieldWidget/ChosenFieldWidget.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
25 | ERROR | [x] Missing class doc comment
--------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/modules/chosen_field/tests/src/Functional/ChosenFieldWidgetsTest.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------------------------------
40 | ERROR | Class property $card_1 should use lowerCamel naming without underscores
47 | ERROR | Class property $card_2 should use lowerCamel naming without underscores
94 | ERROR | The array declaration extends to column 101 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/modules/chosen_lib/src/Commands/ChosenLibCommands.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
151 | ERROR | The array declaration extends to column 91 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/drupal10_contro/web/modules/contrib/chosen/chosen.module
-------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------------------------
19 | WARNING | Global constants should not be used, move it to a class or interface
20 | WARNING | Global constants should not be used, move it to a class or interface
21 | WARNING | Global constants should not be used, move it to a class or interface
22 | WARNING | Global constants should not be used, move it to a class or interface
-------------------------------------------------------------------------------------
Comment #5
bhupesh_upadhyay commentedComment #7
schillerm commentedHi, I reviewed !MR18 and got some warnings and errors.. see below..
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/contrib/chosen
FILE: ...-11-3513892/web/modules/contrib/chosen/modules/chosen_field/tests/src/Functional/ChosenFieldWidgetsTest.php
-----------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------
40 | ERROR | Class property $card_1 should use lowerCamel naming without underscores
47 | ERROR | Class property $card_2 should use lowerCamel naming without underscores
-----------------------------------------------------------------------------------------------------------------
FILE: /home/laptopuser/Documents/Test2/Dev-11-3513892/web/modules/contrib/chosen/chosen.module
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------
19 | WARNING | Global constants should not be used, move it to a class or interface
20 | WARNING | Global constants should not be used, move it to a class or interface
21 | WARNING | Global constants should not be used, move it to a class or interface
22 | WARNING | Global constants should not be used, move it to a class or interface
----------------------------------------------------------------------------------------------
So I fixed these errors locally and retested, no phpcs issues.
To fix these errors I created a new simple class for the constants called ChosenConstants.php and moved the constants in there. Also renamed the $card_1 and $card_2 variables.
It looked like The source branch (3513892-fix-issues-reported) was 4 commits behind the target branch (5.0.x). So I did a git rebase 5.0.x on my local branch to bring those commits in.
I then retested and also ran the phpunit tests. The phpunit test ChosenFieldWidgetsTest.php was failing due to me changing the $card_1 and $card_2 variables. I fixed this but it is also failing due to other things, like when it gets to these lines ..
What is the etiquette with this .. should I fix phpunit tests as well?
Comment #8
nagy.balint commentedHi!
If you can fix phpunit in a separate issue that would be awesome!
I can commit it quickly and then we can return to this.
Comment #9
nagy.balint commentedSeems like phpcs is still failing.
Comment #10
mdranove commentedyeah looks like there was an error that phpcs was not catching locally? Weird. Anyway, fixed it.
Comment #11
schillerm commentedHi, I just retested and phpcs is now passing all tests. +1 for RTBC from me.
Comment #13
nagy.balint commentedThanks!