Skip to content

1.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 03 Oct 02:54
· 1 commit to main since this release
bac6e84

What's new since 1.0.0

Breaking changes

  • [#30] 'ParameterNaming' no longer skips parameters in classes whose ancestors live in Drupal modules, profiles and themes. @AlexSkrypnyk (#32)
    Drupal registers module, profile and theme namespaces at runtime, so Composer can't find their classes; ParameterNaming now reads them straight from the Drupal root, which it detects from the drupal/core install path. Their subclasses are now checked like any other class, so Drupal projects can see new ParameterNaming errors after upgrading: render(ResultRow $resultRow) in a FieldPluginBase subclass is reported because the parent names that parameter $values. Setting the new drupalRoot property to false turns discovery off and goes back to skipping those parameters, and setting it to a path covers a Drupal root that detection can't find.

  • [#29] Arrow function parameters are now reported by 'ParameterNaming' instead of 'LocalVariableNaming'. @AlexSkrypnyk (#31)
    In 1.0.0 the sniffs didn't recognise fn($param) => ... parameters as parameters, so LocalVariableNaming reported the signature and every use in the body; now each parameter gets 1 ParameterNaming error on its signature, and closure and anonymous class method parameters stop getting a second LocalVariableNaming error in the body. A suppression that names LocalVariableNaming no longer silences arrow function parameters, so replace LocalVariableNaming with ParameterNaming in its code, as the migration notes below show. If you set different format values for the 2 sniffs, arrow function parameters now follow the ParameterNaming one.

  • [#22] 'ParameterNaming' now exempts only parameter names that an ancestor declares for the same method. @AlexSkrypnyk (#28)
    1.0.0 decided from keywords alone: it skipped every parameter in interface and abstract method declarations and in any class with an extends or implements clause, so in codebases where most classes extend or implement something, the sniff was close to inert. It now looks up the extended class, interfaces and traits, so it checks renamed and extra parameters, private methods, and interface and abstract methods that declare a signature for the first time; on the vendored PHPCS, PHPUnit, Symfony and Slevomat sources, that took the sniff from 1469 violations to 2906. There's no switch to restore the old exemption, so rename or suppress the new errors; a method still has all its parameters skipped when an ancestor can't be found and none of the found ones declares it.

  • Dropped PHP 8.2 support and raised dev dependency floors to the latest PHP 8.3-compatible releases. @AlexSkrypnyk (#27)
    require.php is now >=8.3, so Composer won't install 1.1.0 on PHP 8.2, and projects there stay on 1.0.0 until they move to PHP 8.3. The runtime requirements don't change (squizlabs/php_codesniffer ^3.10 || ^4 and dealerdirect/phpcodesniffer-composer-installer ^1), and the raised floors only touch this package's own dev tooling. CI now covers PHP 8.3, 8.4 and 8.5 against PHPCS 3 and 4.

Migration notes

Only the sniff name changes: wherever a suppression covers an arrow function parameter, LocalVariableNaming becomes ParameterNaming. Ignores that name only DrevOps or DrevOps.NamingConventions cover both sniffs and keep working.

In an inline ignore, swap the sniff name:

-// phpcs:ignore DrevOps.NamingConventions.LocalVariableNaming.NotSnakeCase
+// phpcs:ignore DrevOps.NamingConventions.ParameterNaming.NotSnakeCase
 $doubled = array_map(fn($itemValue) => $itemValue * 2, $items);

The shorter DrevOps.NamingConventions.ParameterNaming works too, and with format="camelCase" the suffix is NotCamelCase, as before.

When the same line also has a camelCase local variable, 2 sniffs now report it, so list both codes, comma-separated:

-// phpcs:ignore DrevOps.NamingConventions.LocalVariableNaming.NotSnakeCase
+// phpcs:ignore DrevOps.NamingConventions.LocalVariableNaming.NotSnakeCase,DrevOps.NamingConventions.ParameterNaming.NotSnakeCase
 $runningTotal = array_sum(array_map(fn($itemValue) => $itemValue * 2, $items));

In phpcs:disable and phpcs:enable comments, list both sniffs the same way. A block that only covers arrow functions needs ParameterNaming alone.

In a ruleset, keep the LocalVariableNaming exclusion and add a matching one:

 <rule ref="DrevOps.NamingConventions.LocalVariableNaming">
     <exclude-pattern>*/src/Legacy/*</exclude-pattern>
 </rule>
+<rule ref="DrevOps.NamingConventions.ParameterNaming">
+    <exclude-pattern>*/src/Legacy/*</exclude-pattern>
+</rule>

No error code targets arrow function parameters alone, so this stops checking every parameter in those paths, method and closure parameters included. To skip only specific arrow functions, use an inline ignore.

Other changes

  • Pinned all GitHub Actions to commit SHAs and replaced 'codecov/test-results-action'. @AlexSkrypnyk (#26)
    Every uses: line in the repository's workflows now names a full commit SHA, with the release tag as a trailing comment, so a re-pointed upstream tag can't change what CI runs, and Renovate keeps the pins current. Test results now upload through codecov/codecov-action, because codecov/test-results-action is archived upstream. None of this changes the installed package.

Full Changelog: 1.0.0...1.1.0