Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

camel caps format

I have to pass the gitlab codequality test:

I get this error message:

52 | ERROR | [ ] Public method name 38 | | "TimeSlotController::addAWeekTimeSlot" is not in 39 | | camel caps format

I don't know why it is not in camel caps format I thought I already fixed it?

I can't really find a good reference in google:

ref: https://en.wikipedia.org/wiki/Camel_case

0 likes
16 replies
ChristophHarms's avatar

I never heard of a "camel caps" format, and neither did google, as you already wrote. The only thing I can think of is that "camel caps" could mean "camel case where the first letter is also a capital letter", which would mean your method should be named TimeSlotController::AddAWeekTimeSlot with a capital 'A' in the word "Add". That's just a guess, though.

Could also be that the one letter word "A" is messing with the algorithm, because it leads to two capitalized letters following each other in "addAWeekTimeSlot". Maybe try "addWeekTimeSlot" or "AddWeekTimeSlot".

davy_yg's avatar
Level 27

Another message:

$this->store8($date);
        }
        return back()->withSuccess('1 minggu sudah ditambahkan');
    } else {

60 | ERROR | [ ] Double space found line 60: return back()->withSuccess('1 minggu sudah ditambahkan');

What's wrong with line 60 ?

Sinnbeck's avatar

As we cannot actually inspect the real code that is very hard to say. Maybe your project expects tabs and you have spaces, or maybe you have extra spaces. This one you need to check yourself. Might be an idea to install phpcs locally to test it there instead of relying on gitlab.

https://github.com/squizlabs/PHP_CodeSniffer

davy_yg's avatar
Level 27

ok, I would like a testing system on local that could help me pass the gitlab code quality test. Is PHP_CodeSniffer the right test for that?

  1. composer global require "squizlabs/php_codesniffer=*"
  2. add this in composer.json:

{ "require-dev": { "squizlabs/php_codesniffer": "3.*" } }

3

D:\xampp2\htdocs\sesa_final\sesa-e-commerce\vendor\bin>phpcs -h

Usage: phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors] [--stdin-path=] [--report=] [--report-file=] [--report-=] ... [--report-width=] [--generator=] [--tab-width=] [--severity=] [--error-severity=] [--warning-severity=] [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show] [--standard=] [--sniffs=] [--exclude=] [--encoding=] [--extensions=] [--ignore=] [--bootstrap=] [--file-list=] ... Set runtime value (see --config-set) -n Do not print warnings (shortcut for --warning-severity=0) -w Print both warnings and errors (this is the default) -l Local directory only, no recursion

...

number 3 instead of showing the test result, it shows all these info.

I also try :

D:\xampp2\htdocs\sesa_final\sesa-e-commerce\vendor\bin>phpcs -n

but it takes forever.. any clue how to test the error message?

Sinnbeck's avatar

It takes time as it is running through all files But just define the file you want to test

phpcs path/to/the/file.php
davy_yg's avatar
Level 27

Hey the syntax different:

D:\xampp2\htdocs\sesa_final\sesa-e-commerce\vendor\bin>phpcs D:\xampp2\htdocs\sesa_final\sesa-e-commerce\modules\TimeSlot\Http\Controllers\TimeSlotController.php

FILE: ...ommerce\modules\TimeSlot\Http\Controllers\TimeSlotController.php

FOUND 16 ERRORS AND 7 WARNINGS AFFECTING 23 LINES

 1 | ERROR   | [x] End of line character is invalid; expected "\n"|         |     but found "\r\n"
 2 | ERROR   | [ ] Missing file doc comment
 14 | ERROR   | [ ] Missing class doc comment
 18 | ERROR   | [ ] Missing function doc comment
 23 | ERROR   | [ ] Missing function doc comment
 25 | WARNING | [ ] Line exceeds 85 characters; contains 87
     |         |     characters
 30 | ERROR   | [ ] Missing function doc comment
 38 | ERROR   | [ ] Missing function doc comment
 42 | WARNING | [ ] Line exceeds 85 characters; contains 86
     |         |     characters
 48 | WARNING | [ ] Line exceeds 85 characters; contains 86
     |         |     characters
 52 | ERROR   | [ ] Missing function doc comment
 66 | ERROR   | [ ] Missing function doc comment
 77 | ERROR   | [ ] Missing function doc comment
 148 | ERROR   | [ ] Missing function doc comment
 153 | ERROR   | [ ] Missing function doc comment
 162 | WARNING | [ ] Line exceeds 85 characters; contains 115
     |         |     characters
 166 | ERROR   | [ ] Missing function doc comment
 170 | WARNING | [ ] Line exceeds 85 characters; contains 86
     |         |     characters
 177 | ERROR   | [ ] Missing function doc comment
 190 | ERROR   | [ ] Missing function doc comment
 213 | ERROR   | [ ] Missing function doc comment
 215 | WARNING | [ ] Line exceeds 85 characters; contains 94
      |         |     characters
 217 | WARNING | [ ] Line exceeds 85 characters; contains 93
     |         |     characters
 ----------------------------------------------------------------------
 PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
      ----------------------------------------------------------------------

Time: 91ms; Memory: 12Mb

I already pass the gitlab test when these errors does not exist in gitlab. My point is I would like an equal test just like gitlab test.

Sinnbeck's avatar

Did you setup gitlab or did someone else? I have never used it so I dont know if it runs phpcs automatically or you manually have to set it up. If it is the latter you should be able to see where it reads the config from (it migh also just be set to a specific standard. I think it ships with the following: Squiz, PSR1, PEAR, Zend, MySource, PHPCS and PSR2)

You can also simply try running the standards one by one and see if the output matches

D:\xampp2\htdocs\sesa_final\sesa-e-commerce\vendor\bin>phpcs D:\xampp2\htdocs\sesa_final\sesa-e-commerce\modules\TimeSlot\Http\Controllers\TimeSlotController.php --standard=psr2
davy_yg's avatar
Level 27

composer.json

 "check-quality": [
        "! find app -type f -name \"*.php\" -exec php -l {} \; |  grep -v 'No syntax errors'",
        "vendor/bin/phpcs --colors --standard=vendor/suitmedia/php-code-standards/Suitmedia/ app/",
        "vendor/bin/phpcs --colors --ignore=views,TableView --standard=vendor/suitmedia/php-code-standards/Suitmedia/ modules/",
        "vendor/bin/phpcs --colors --ignore=views,TableView --standard=vendor/suitmedia/php-code-standards/Suitmedia/ LivingModules/"
    ],

Doe it mean using PHPCS codestandard?

Sinnbeck's avatar

Correct. While you are in the root of your project run

phpcs --colors --standard=vendor\suitmedia\php-code-standards\Suitmedia\ modules\TimeSlot\Http\Controllers\TimeSlotController.php
davy_yg's avatar
Level 27

D:\xampp2\htdocs\sesa_final\sesa-e-commerce>phpcs --colors --standard=vendor/suitmedia/php-code-standards/Suitmedia/modules\TimeSlot\Http\Controllers\TimeSlotController.php ERROR: the "vendor/suitmedia/php-code-standards/Suitmedia/modules\TimeSlot\Http\Controllers\TimeSlotController.php" coding standard is not installed. The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz and Zend

I don't understand what it means?

Sinnbeck's avatar

Missed a space .. sorry. Changed my post. You might need absolute paths on windows.. You can try without :)

davy_yg's avatar
Level 27

D:\xampp2\htdocs\sesa_final\sesa-e-commerce>phpcs --colors --standard=vendor\suitmedia\php-code-standards\Suitmedia\modules\TimeSlot\Http\Controllers\TimeSlotController.php ERROR: the "vendor\suitmedia\php-code-standards\Suitmedia\modules\TimeSlot\Http\Controllers\TimeSlotController.php" coding standard is not installed. The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz and Zend

Any space between Suitmedia\ and modules ?

What is "scripts": { in composer json for? How to call it ?

Sinnbeck's avatar

You can try running the script using

composer run check-quality
davy_yg's avatar
Level 27

D:\xampp2\htdocs\sesa_final\sesa-e-commerce>composer run check-quality

! find app -type f -name ".php" -exec php -l {} ; | grep -v 'No syntax errors' '!' is not recognized as an internal or external command, operable program or batch file. Script ! find app -type f -name ".php" -exec php -l {} ; | grep -v 'No syntax errors' handling the check-quality event returned with error code 255

Any clue why?

Sinnbeck's avatar

Can you run these commands from your shell (not need to be able to)

grep 'test'
find -name 'test'

Please or to participate in this conversation.