Skip to content

Fix phpcs violations + add phpcs to CI#2

Merged
oojacoboo merged 5 commits into
masterfrom
chore/fix-phpcs-violations
Apr 30, 2026
Merged

Fix phpcs violations + add phpcs to CI#2
oojacoboo merged 5 commits into
masterfrom
chore/fix-phpcs-violations

Conversation

@oojacoboo

@oojacoboo oojacoboo commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Brings src/ and test/ into compliance with our shared coding standard, and gates that compliance in CI going forward.

Code style fixes

  • 36 violations auto-fixed via phpcbf (mostly blank-line spacing on enums + the integration test class)
  • src/Client.php: split a 125-char URL into a $renterId variable
  • src/ClientException.php: add a marker comment so the empty class body satisfies both empty-lines-around-braces rules
  • src/Model/Address.php: extract the repeated regex pattern and message into class constants; line-wrap the message under 120 chars
  • test/Unit/Model/AddressTest.php: extract long fixture strings into local variables and the shared error message into a constant; reformat the data provider so every row fits on one line

CI

  • New phpcs job in .github/workflows/ci.yml runs against vendor/rentpost/coding-standard-php/phpcs.xml
  • Uses --warning-severity=0 so only errors fail. The 30 remaining warnings are unavoidable: 28 are TU API field names that contain digits (addressLine1–4), and 2 are PHPUnit #[Depends] parameter chains where the params are intentionally unused

Test plan

  • vendor/bin/phpcs --standard=vendor/rentpost/coding-standard-php/phpcs.xml --warning-severity=0 src/ test/ exits 0
  • vendor/bin/phpunit --testsuite unit — 66/66 pass
  • Run integration tests via gh workflow run ci.yml --ref chore/fix-phpcs-violations to confirm nothing in the touched code broke real TU API calls

phpcbf auto-fixed 36 violations (blank-line spacing on enums and similar).
Manual fixes:
- src/Client.php: split long URL string into a renterId variable
- src/ClientException.php: add a marker comment so the empty class body
  doesn't trip the empty-lines-around-braces rules
- src/Model/Address.php: extract repeated regex/message into class
  constants, line-wrap the message to stay under 120 chars
- test/Unit/Model/AddressTest.php: extract long fixture strings into local
  variables and the shared message into a constant; reformat the data
  provider rows so each fits on one line

Add a phpcs CI job that runs against vendor/rentpost/coding-standard-php
with --warning-severity=0, so warnings (TU API field names that include
digits, intentional unused PHPUnit @Depends params) are visible but only
errors fail the build.

All 66 unit tests pass.
The just-merged coding-standard-php master tightens
SlevomatCodingStandard.Classes.ClassStructure so 'public static methods'
must come before 'public methods'.  phpcbf moved the static methods
(fromArray, validationProvider, etc.) above the instance methods across
the model and test classes.  Pure reorder: every file has equal additions
and removals, no logic touched.
… in CI

- src/Model/Address.php: addressLine1..4 are TU API field names; renaming
  them would break the wire contract.  Disable the
  Zend.NamingConventions.ContainsNumbers sniff for this file with a
  documented phpcs:disable directive.
- test/Integration/IntegrationTest.php: testValidateRenterForScreeningRequest
  and testCreateReport must accept return values from PHPUnit #[Depends]
  chains, which means some parameters are unavoidably unused.  Suppress the
  Generic.CodeAnalysis.UnusedFunctionParameter sniff for those two methods
  with explanatory comments on the parameters themselves.
- .github/workflows/ci.yml: drop --warning-severity=0 from the phpcs job so
  CI now fails on either an error or a warning, since neither type should
  ever reappear.
PHPUnit runs tests in source order, and cancelling the screening request
before testCreateExam puts it in a terminal state in the TU sandbox.  TU
then rejects createExam with "IDV not possible as the reports were
already generated" because cancelled is treated as a final report state.

Move cancel to the very end and add a #[Depends('testGetReportsForRenter')]
so it can never run before the report chain even if PHPUnit ever changes
its default ordering.
Cancelling the main screening request after the report chain fails with
ScreeningRequestCannotCancel because TU treats a completed SR as terminal.
Cancelling before the report chain fails because IDV requires a non-
terminal SR.  There's no order that makes both flows happy on the same SR.

Have testCancelScreeningRequestForRenter create a dedicated, never-
completed screening request for the existing renter and cancel that one,
so the API endpoint is still exercised without disturbing the report flow.
@oojacoboo
oojacoboo merged commit fe6c3d5 into master Apr 30, 2026
6 checks passed
@oojacoboo
oojacoboo deleted the chore/fix-phpcs-violations branch April 30, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant