Skip to content

chore: adopt Nextcloud's coding standard, .editorconfig and NC 34 - #1229

Merged
rubenvdlinde merged 11 commits into
developmentfrom
chore/nextcloud-coding-standard
Aug 12, 2026
Merged

rubenvdlinde merged 11 commits into
developmentfrom
chore/nextcloud-coding-standard

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Part of the fleet-wide move to Nextcloud's coding standard. Recipe proven on nextcloud-app-template#142; enforced from ConductionNL/.github@main by gate-65 coding-standard-adoption, which this app fails today and passes with this PR.

Policy: Conduction code must pass Nextcloud's own checks unchanged. We may be stricter, never different.

Three commits, deliberately separated

chore: config the whole review
style: reformat 712 files, whitespace only — not worth reading line by line
chore: blame-ignore .git-blame-ignore-revs naming the reformat

What changed

  • .php-cs-fixer.dist.php + conduction/coding-standard, which extends nextcloud/coding-standard and can only add to it — enforced by that package's invariant test, not by review.
  • cs:check / cs:fix now actually run php-cs-fixer. They were aliases for phpcs/phpcbf, so the documented Nextcloud command reformatted code away from Nextcloud's standard.
  • nextcloud/coding-standard dropped as a direct dependency — it arrives transitively at a tested version. Declared directly it was a dead dependency with no config file and no invocation anywhere.
  • phpcs.xml is a stub over the shared semantics-only ruleset; the local phpcs-custom-sniffs/ copy is gone. The fleet was carrying six divergent versions of NamedParametersSniff.php — a custom rule, not a setting.
  • .editorconfig, verbatim from nextcloud/server. No fleet app had one.
  • NC 34: nextcloud/ocp → ^34.0, PHPUnit → stable34. This app declared support for NC 34 while being analysed against 31, so a symbol removed in 32/33/34 was invisible to the type checker — which is why the NC 34 removal of \OC::$server needed a hand-written sniff.
  • stylelint glob quoted, so stylelint expands it rather than the shell. Unquoted, src/**/ matches exactly one directory level and nested components go unlinted.

Verification

Reformatted with a shared php-cs-fixer across all 18 apps: 9,656 files, 0 remaining findings anywhere. Every changed PHP file re-linted with php -l.

Expect red

This app's base branch already fails several quality jobs, and moving to NC 34 will surface more. That is intended — the point is to align with Nextcloud, not to keep the board green.


One thing to look at, surfaced rather than caused

SynchronizationService::synchronizeContract() now emits a PHP deprecation:

Optional parameter $synchronization declared before required parameter $flowToken

The signature was array $synchronization=null — implicitly nullable. Nextcloud's nullable_type_declaration_for_default_null_value made it ?array $synchronization = null, and once explicit, PHP notices what was always true: an optional parameter sits before a required one, and has been "implicitly treated as required" all along.

The fixer did not create this. It made PHP report it. The real fix is reordering the parameters, which is a behaviour change (it breaks named arguments) and does not belong in a formatting PR — so it is flagged here rather than smuggled in.

Configuration only. The reformat is the next commit on purpose, so
.git-blame-ignore-revs can name a revision containing nothing but whitespace.

- .php-cs-fixer.dist.php + conduction/coding-standard, which extends
  nextcloud/coding-standard and can only ADD to it — enforced by that package's
  invariant test, not by review.
- cs:check / cs:fix now run php-cs-fixer. They were aliases for phpcs/phpcbf,
  so the documented Nextcloud command reformatted code AWAY from Nextcloud's
  standard.
- nextcloud/coding-standard dropped as a direct dependency. It arrives
  transitively at a version conduction/coding-standard has tested against;
  declared directly it was a dead dependency with no config and no invocation.
- phpcs.xml is now a stub over the shared semantics-only ruleset, and the local
  phpcs-custom-sniffs/ copy is gone. The fleet was carrying six divergent
  versions of NamedParametersSniff.php — a custom RULE, not a setting.
- .editorconfig, verbatim from nextcloud/server. No fleet app had one, so an
  editor configured by someone's previous Nextcloud work defaulted to tabs,
  which the old ruleset then rejected.
- nextcloud/ocp -> ^34.0 and PHPUnit -> stable34. This app declared support for
  NC 34 while being analysed against 31, so a symbol REMOVED in 32/33/34 was
  invisible to the type checker. That is why the NC 34 removal of \OC::$server
  needed a hand-written PHPCS sniff.
- the stylelint glob is quoted, so stylelint expands it rather than the shell.
  Unquoted, src/**/ matches exactly one directory level and nested components
  are silently unlinted.

gate-65 (coding-standard-adoption) enforces all of the above from
ConductionNL/.github@main. This app failed it; with this commit it passes.
Applied by php-cs-fixer with conduction/coding-standard. Tabs, same-line braces,
(int)$x, single-space concatenation, ordered imports — Nextcloud's dialect, which
this app now passes unchanged. 712 file(s), no behaviour change.

Isolated from the configuration change so .git-blame-ignore-revs can name a
revision that touches nothing but formatting. Reviewing it line by line is not a
useful activity; the previous commit is the review.
0a5295c touches 712 files and changes no behaviour. Without this, every line it
reflowed attributes to it and the real author is one --skip away.

GitHub honours the file automatically; locally it needs
`git config blame.ignoreRevsFile .git-blame-ignore-revs` once.
The previous commit changed composer.json without touching the lock, so
`composer install` refused with exit 4 and EVERY PHP job failed:

    Required (in require-dev) package "conduction/coding-standard" is not
    present in the lock file.
    Required (in require-dev) package "conduction/hydra-gates" is not present
    in the lock file.
    Required (in require-dev) package "nextcloud/ocp" is in the lock file as
    "v31.0.9" but that does not satisfy your constraint "^34.0".

Nothing was wrong with the reformat or the ruleset — the jobs never got as far
as running a tool. Measured on larpingapp#313 before this fix: phpcs, psalm,
phpstan and both PHPUnit legs red, all of them at `composer install`. Hydra
Gates passed in the same run, because it does not install composer
dependencies.

Now locked at conduction/coding-standard v1.0.0, conduction/hydra-gates v1.7.0,
nextcloud/ocp v34.0.2 — the last of which is the point of the exercise: this app
declares support for NC 34 and is now analysed against it.
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openconnector @ 2765e7d

Check PHP Vue Security License Tests
lint ❌
phpcs ❌
phpmd ❌
psalm ❌
phpstan ❌
phpmetrics ❌
eslint ✅
stylelint ✅
build ✅
build ✅
check-specs ✅
test-l10n ✅
composer ❌ ❌
npm ✅ ✅ 551/551
PHPUnit ❌
Newman ❌
Playwright ❌
Hydra gates ❌

Quality workflow — 2026-08-12 10:13 UTC

Download the full PDF report from the workflow artifacts.

The App Store's info.xsd declares <info> and its children as xs:sequence, so
element ORDER is significant. This file was rejected by
`xmllint --noout --schema info.xsd appinfo/info.xml`. Nextcloud's
lint-info-xml workflow validates against exactly that schema, and
ConductionNL/.github#383 adds the same check to the shared pipeline.

Elements were moved into the schema's order. <version> and the <nextcloud>
min/max-version declaration are unchanged.

<category> was moved after <namespace> (the sequence is version, licence,
author, namespace, types, documentation, category), and the <dependencies>
children were put in php, database, lib, owncloud, nextcloud order.

Ordering alone was not sufficient here. The <dependencies><app> entry is not
an ordering problem: the App Store schema has no <app> child under
<dependencies> at any position, so it can never validate. It was also inert -
OC\App\DependencyAnalyzer::analyze() handles only architecture, php, database,
command, lib, os and the server version, and never looks at "app" - so it
enforced nothing at install time. The dependency is now recorded as a comment
in the same place.

Verified: `xmllint --noout --schema info.xsd appinfo/info.xml` reports
"validates" (libxml2 2.12.10). The pre-change file failed the same command.
Conflicts and how they were resolved:

- .editorconfig: both sides added one. Kept the Nextcloud core file the
  coding-standard migration ships (it is the fleet-wide artefact) and folded
  in the two stanzas development's version had that it did not cover:
  [*.{yml,yaml,json,jsonc}] instead of the narrower [*.yml], and [Makefile].
  No setting differs between the two — only coverage.

- package.json: both sides quoted the stylelint glob. Took development's
  three-glob form (#1230); the brace form on this branch is equivalent, and
  keeping the base's spelling leaves this PR with no diff on the line.

- appinfo/info.xml: development (#1224) added an <install> repair-steps hook
  and MigrateLegacyStorage; this branch had moved <repair-steps> and
  <settings> to their App Store xs:sequence positions. Applied development's
  content at this branch's element positions, so the fresh-install fix and
  the ordering fix both survive. Parsed back to confirm the XML is valid.

- lib/Migration/Version2Date20260520000099.php and
  lib/Service/Migration/LegacyToRegisterMigrator.php: the reformat rewrote
  every brace in both files while development (#1224) swapped
  fetchAssociative()/fetchAllAssociative() for fetchOne()/fetch()/fetchAll()
  because the Associative variants only reached OCP\DB\IResult in NC 33 and
  this app advertises min-version 32. Took the reformatted files and
  re-applied all seven of development's call-site changes, including the
  guarded `$count === false` branch, by hand.

lib/Repair/MigrateLegacyStorage.php and its test arrived from development in
the old Allman style, so php-cs-fixer was re-run over the whole tree: it
reformatted exactly those two files, and the re-check reports
"Found 0 of 713 files that can be fixed".

composer.lock did not conflict — development has not touched it since the
merge base — and still resolves nextcloud/ocp to v34.0.2. composer validate
passes, so the lock's content-hash still matches composer.json.
development moved to #1233 while the previous merge was being pushed.

One conflict, lib/Service/CallService.php: the reformat rewrote every brace
in the file while #1233 added `dispatchesThroughBroker()` and the
FulfilledPromise short-circuit at the top of `callAsync()`. Took the
reformatted file and re-applied both hunks by hand, then re-ran
php-cs-fixer, which reformatted CallService.php and the new
CallServiceBrokeredAsyncTest.php. Re-check: "Found 0 of 714 files that can
be fixed".

Verified the resolution kept #1233's code rather than just its comments:
`php -w` (comments and whitespace stripped) over each conflicted file
against origin/development leaves only coding-standard differences —
removed unused imports, double to single quotes, trailing commas in
multi-line parameter lists — and no difference in any statement.
…wing

The comment above `nextcloud-test-refs` explained a choice of
`["stable32", "stable33"]` while the value directly below it read
`["stable34"]` — the config commit changed the value and left the reasoning
describing the old one. A comment that contradicts the line it sits on is
worse than no comment: the next reader trusts it.

Records the actual reason (ocp ^34 stubs and the tested server should be the
same server) and, more importantly, records what the change COSTS: info.xml
still declares `min-version="32" max-version="34"`, so the app claims three
server versions and CI now exercises one. NC32 and NC33 are unmeasured from
here, not known-good. Names both ways the gap can be closed so it is a
tracked trade rather than an accident.

No behaviour change — comment only.
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openconnector @ 274b796

Check PHP Vue Security License Tests
lint ❌
phpcs ❌
phpmd ❌
psalm ❌
phpstan ❌
phpmetrics ❌
eslint ✅
stylelint ✅
build ✅
build ✅
check-specs ✅
test-l10n ✅
composer ❌ ❌
npm ✅ ✅ 551/551
app:check-code ⏭️
info.xml ❌
REUSE ❌
PHPUnit ❌
Newman ❌
Playwright ❌
Hydra gates ❌

Quality workflow — 2026-08-12 12:52 UTC

Download the full PDF report from the workflow artifacts.

TWO DEFECTS, both of which made a job red rather than a finding.

1. composer.lock locked packages this app's own platform cannot run.

`config.platform.php` is pinned to "8.3", and the lock carried
symfony/string v8.1.2, symfony/finder v8.1.1 and symfony/process v8.1.0 —
all three require php >=8.4.1. That is the signature of a regeneration run
with a blanket `--ignore-platform-reqs`: the flag suppresses the PHP version
constraint as well as the extension ones, so composer resolves against a
platform that does not exist here and writes the result down as if it did.

`composer validate` passes on such a lock — the content-hash still matches
composer.json — so the defect is invisible to the check most likely to be
run, and only surfaces at install time. In CI it took out NINE jobs, all
with the same line and none of them naming a package this app requires
directly:

  Your lock file does not contain a compatible set of packages.

  PHP Quality (lint / phpcs / phpmd / phpstan / psalm / phpmetrics)
  Security (composer), License (composer)
  PHPUnit (8.3 and 8.4), Integration Tests (Newman), E2E (Playwright)

and it cascaded one gate further: gate-33 axe-core reported SKIPPED
(structural) because the Playwright job that produces its report never ran.

Re-resolved with the three packages named explicitly and `--ignore-platform-
req=ext-*` — extension constraints only, so the PHP version stays enforced.
They downgrade to the 7.4 line, which is where the rest of the symfony
packages here already are:

  symfony/finder   v8.1.1 -> v7.4.14
  symfony/process  v8.1.0 -> v7.4.13
  symfony/string   v8.1.2 -> v7.4.15

`nextcloud/ocp` is unaffected and still resolves to v34.0.2, which is the
point of this PR. `composer install --dry-run` under the pinned 8.3 platform
now completes, and a sweep of every locked package's `require.php` finds
zero above 8.3 — the same sweep over the previous lock finds exactly those
three, so it is a measurement and not a hopeful assertion.

2. appinfo/info.xml did not validate against the App Store schema.

`info.xml lint` landed in the shared workflow today
(ConductionNL/.github#383) and this is the first run that had it. The App
Store's info.xsd declares repair-steps as an xs:sequence — pre-migration,
post-migration, live-migration, install, uninstall — so `<install>` must
come AFTER `<post-migration>`, which is the opposite of the order they run
in and the opposite of how #1224 wrote them:

  appinfo/info.xml:115: element post-migration: Schemas validity error :
  Element 'post-migration': This element is not expected.
  Expected is ( uninstall ).

Swapped, with the constraint written down next to it so the intuitive order
does not come back. Nothing about which hooks run, or when, changes.

⚠️ THE BASE BRANCH FAILS THIS CHECK TOO, and earlier: `origin/development`'s
info.xml is rejected at line 28 with `Element 'category': This element is
not expected. Expected is one of ( licence, author )`. This branch already
fixed that half in d960a2f. Verified by running xmllint against the real
appstore info.xsd over both files — head validates, base does not.
…ed red

phpstan — ONE error, and the reformat is what created it.

  Deprecated in PHP 8.1: Required parameter $flowToken follows optional
  parameter $synchronization.  lib/Service/SynchronizationService.php

`synchronizeContract()` reads the same on both branches, but not to PHP. On
`development` the parameter is written `array $synchronization=null`, which
PHP treats as IMPLICITLY NULLABLE and therefore exempt from the 8.1
"required after optional" deprecation. php-cs-fixer's
`nullable_type_declaration_for_default_null_value` rewrites that to
`?array $synchronization = null` — now genuinely optional, and the required
`FlowToken &$flowToken` behind it becomes a deprecation. The signature did
not change meaning; it changed CATEGORY.

Fixed by moving `$flowToken` ahead of the optional parameters rather than by
undoing the rule, because the rule is the standard this PR adopts and
`cs:fix` would rewrite it back. All four call sites pass every argument by
NAME, and the test suite only ever mocks the method with `willReturn` — no
`->with()` positional assertion anywhere — so the position is free to move.
A scan of every signature in lib/ for a required parameter after an optional
one now returns nothing; the same scan over the previous commit returns
exactly this one, so it is a measurement.

phpcs — 21 errors, all from the ruleset switch, all now zero.

phpcs.xml moved to the shared semantics-only ruleset in this PR, so the tree
is being read by a different set of sniffs than the one `development` passes
under. It is a different question, not a regression, and the answer was 21:

  1  missing docblock  #1233 inserted `dispatchesThroughBroker()`'s docblock
                       BETWEEN `resolveBrokeredDispatch()`'s docblock and its
                       signature, orphaning the first and leaving the second
                       undocumented. Moved the docblock back onto its own
                       function; no code moved.
  11 param alignment   one BankfeedSyncService docblock indented its
                       continuation lines to a column no @PARAM sits at.
  9  line length       over 150 characters.

⚠️ THE OBVIOUS FIX FOR THE LONG LINES DOES NOT HOLD, and this is the part
worth knowing before the next app in the migration hits it. Five of them are
`@return <very wide array shape>  <description>`, and php-cs-fixer's
`phpdoc_align` re-indents the continuation under the type column. Manually
re-wrapping them at a sane indent makes `cs:fix` put them straight back —
the two tools genuinely disagree, and phpcs is the one that fails the build.
Moved the prose OUT of the tag and into the docblock body instead, which
leaves no continuation line for either tool to have an opinion about. Two
more were over-long signatures, wrapped one parameter per line.

Verified in the same container CI uses (php:8.3-cli, this repo's own vendor):

  php-cs-fixer  Fixed 0 of 714 files          (stable — cs:fix is a fixpoint)
  phpcs         0 ERRORS AND 277 WARNINGS     (the job passes on warnings)
  phpstan       [OK] No errors
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openconnector @ 50c4b7a

Check PHP Vue Security License Tests
lint ✅
phpcs ❌
phpmd ✅
psalm ✅
phpstan ❌
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
build ✅
check-specs ✅
test-l10n ✅
composer ✅ ✅ 154/154
npm ✅ ✅ 551/551
app:check-code ⏭️
info.xml ✅
REUSE ❌
PHPUnit ✅
Newman ✅
Playwright ✅
Hydra gates ❌

Quality workflow — 2026-08-12 13:16 UTC

Download the full PDF report from the workflow artifacts.

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openconnector @ ced2542

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ✅
psalm ✅
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
build ✅
check-specs ✅
test-l10n ✅
composer ✅ ✅ 154/154
npm ✅ ✅ 551/551
app:check-code ⏭️
info.xml ✅
REUSE ❌
PHPUnit ✅
Newman ✅
Playwright ✅
Hydra gates ❌

Quality workflow — 2026-08-12 13:35 UTC

Download the full PDF report from the workflow artifacts.

appinfo/info.xml declares <nextcloud min-version="32" max-version="34"/>, but
nextcloud-test-refs was '["stable34"]' — so the declared floor and the middle
major were advertised to the App Store with no job touching either.

This is the coding-standard migration's own defect: its rollout REPLACED the
ref list instead of extending it. The programme opened by reporting that
nothing was tested on NC 34 and, in fixing that, made 32 and 33 the untested
end. Same drift, other direction.

stable34 stays first because newman, playwright and journeydoc-capture all read
fromJSON(inputs.nextcloud-test-refs)[0] as their single server.

Verified green on all three refs against nextcloud/ocp ^34 on portaliq
(run 31599055849, six PHPUnit legs: 32/33/34 x PHP 8.3/8.4).
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openconnector @ b696bdc

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ✅
psalm ✅
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
build ✅
check-specs ✅
test-l10n ✅
composer ✅ ✅ 154/154
npm ✅ ✅ 551/551
app:check-code ⏭️
info.xml ✅
REUSE ❌
PHPUnit ✅
Newman ✅
Playwright ✅
Hydra gates ❌

Quality workflow — 2026-08-12 18:21 UTC

Download the full PDF report from the workflow artifacts.

@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openconnector @ b696bdc

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ✅
psalm ✅
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
build ✅
check-specs ✅
test-l10n ✅
composer ✅ ✅ 154/154
npm ✅ ✅ 551/551
app:check-code ⏭️
info.xml ✅
REUSE ❌
PHPUnit ✅
Newman ✅
Playwright ✅
Hydra gates ❌

Quality workflow — 2026-08-12 19:28 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde
rubenvdlinde merged commit 6d5f9cc into development Aug 12, 2026
70 of 74 checks passed
@rubenvdlinde
rubenvdlinde deleted the chore/nextcloud-coding-standard branch August 12, 2026 20:17
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