spryker/code-sniffer
Spryker Code Sniffer is a PHP_CodeSniffer ruleset for Spryker projects. Enforces Spryker coding standards and best practices, supports automated code style checks in CI, and helps keep code consistent across teams and modules.
Included commits: https://github.com/spryker/code-sniffer/compare/0.17.33...0.17.34
CommentingTrait::hasInheritDoc() so now it recognizes the inline {[@inheritDoc](https://github.com/inheritDoc)} form as doc-block inheritance.Included commits: https://github.com/spryker/code-sniffer/compare/0.17.32...0.17.33
CommentingTrait::hasInheritDoc() so now it recognizes the inline {[@inheritDoc](https://github.com/inheritDoc)} form as doc-block inheritance.Included commits: https://github.com/spryker/code-sniffer/compare/0.17.30...0.17.31
Included commits: https://github.com/spryker/code-sniffer/compare/0.17.29...0.17.30
PHP 8.4 support.Full Changelog: https://github.com/spryker/code-sniffer/compare/0.17.28...0.17.29
Included commits: https://github.com/spryker/code-sniffer/compare/0.17.27...0.17.28
phpstan/phpdoc-parser used in the tool.Included commits: https://github.com/spryker/code-sniffer/compare/0.17.26...0.17.27
Included commits: https://github.com/spryker/code-sniffer/compare/0.17.25...0.17.26
SprykerFeature module types to supported namespaces.Included commits: https://github.com/spryker/code-sniffer/compare/0.17.24...0.17.25
8.3 support.Included commits: https://github.com/spryker/code-sniffer/compare/0.17.23...0.17.24
DocBlockApiAnnotationSniff to fix the false negative errors when declaring the Specification annotation.Included commits: https://github.com/spryker/code-sniffer/compare/0.17.22...0.17.23
Included commits: https://github.com/spryker/code-sniffer/compare/0.17.21...0.17.22
Included commits: https://github.com/spryker/code-sniffer/compare/0.17.20...0.17.21
Included commits: https://github.com/spryker/code-sniffer/compare/0.17.19...0.17.20
SprykerStrict/ruleset.xml to fix ERROR: Ruleset invalid. Property "enableNeverTypeHint" does not exist on sniff SprykerStrict.TypeHints.ParameterTypeHint error.Included commits: https://github.com/spryker/code-sniffer/compare/0.17.18...0.17.19
Spryker.Namespaces.SprykerNamespace to be used in a more generic context. <rule ref="Spryker.Namespaces.SprykerNamespace">
<properties>
<property name="namespace" value="App"/>
<property name="isRoot" value="true"/>
</properties>
</rule>
It would then validate your class files within src/:
src/Some/Sub/MyClass.php would then have to match FQCN App\\Some\\Sub\\MyClass insideNote: If not further specific, it will still only check Spryker core files here for now and skip all other class files.
Fix up DocBlockParamAllowDefaultValueSniff to not error on nullable annotation for mixed type.
The previous fix didn't fix all issues around the PHP anti-pattern of mixed type including null.
Now DocBlockReturnNullableTypeSniff does not prematurely add null for a mixed return type annotation, as well.
DocBlockReturnNullableTypeSniff does not falsely remove null for a mixed return type annotation.
?-> and have improved diff output for changes now: <rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowNullSafeObjectOperator">
<severity>0</severity>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration">
<severity>0</severity>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse">
<severity>0</severity>
</rule>
Fixed false positive on usage of list<\Type>
Now PHP 7.4+ and tested on PHP 8.2.
Fixed sniffs around param type parsing and errors with new PHPStan versions.
The else if to elseif sniff and fixer so far was always just a warning, which usually didn't show the issue.
This has been fixed with a Spryker sniff that now enforces this on an error level.
It will auto-fix itself for code that doesn't yet follow the coding guidelines.
Projects as well as libraries can now enable strict_types for PHP files.
<rule ref="Spryker.PHP.DeclareStrictTypesAfterFileDoc">
<properties>
<property name="strictTypesMandatory" value="true"/>
</properties>
</rule>
Please note: This can have side effects as type casting is now not happening anymore in some cases.
Also: declare(strict_types=1); is now consistently placed within a PHP file, after the file doc block as per PSR-12 specification.
class-string to pass as string type in docblocks, including class-string<\Some\Class\Name>.SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse sniffFixed DocBlockVar sniff to handle and allow list<type> documentation for array collections.
Adjusted the SprykerStrict sniffers as per our minimum PHP version to ensure that no accidents happen in regards to signature changes that are not PHP version compatible.
Allow for new slevomat/coding-standard 8.x. This is to allow for all new fixes of that series to be used by everyone.
Please note You need to add the php_version config in your root phpcs.xml file before upgrading.
E.g. if you are using >= 7.4 in composer as PHP min requirement:
<config name="php_version" value="70400"/>
The reason is that it would otherwise execute your local PHP version (e.g. 8.1) and modify the code according to "too new language features".
slevomat/coding-standard:^8.0.1 by @localheinz in https://github.com/spryker/code-sniffer/pull/345Full Changelog: https://github.com/spryker/code-sniffer/compare/0.17.7...0.17.8
For generics please make sure:
\SomeObject|some-type[] that is actually a true "object or array" case must be noted as \SomeObject|array<some-type>. If you do not do this before this update, it will change it as per expectation regarding legacy syntax.checkGenericClassInNonGenericObjectType: false or to adjust your docblocks to specify the type of generic class/object.For project annotations:
Pyz namespace, you need to add a few configs to let the sniffer know about this and make the correct class usage assessment: https://github.com/spryker/code-sniffer#configure-custom-namespacesAdded Spryker.PHP.DisallowTrailingCommaInSingleLine to avoid side effects with other sniffs.
Added Spryker.ControlStructures.DisallowCloakingCheck to remove unnecessary anti-pattern of cloaking (silencing of non-existence), regarding variables and properties. This is also in sync with stricter 8.2+ in the future, but already now can spot a few typos and no-ops.
Make sure to always declare local variables or class properties before using. Using isset()/empty() is only useful when the key of an array is possibly undefined. This is never the case on local variables or normal class properties.
It has a strict mode (default off) which would also disallow some edge cases and silencing for dynamic property access.
We don't want to go quite as far as this article and say never, but there are some use cases where more appropriate solutions are possible:
$x = !empty($this->property) !== false;
// should be
$x = (bool)$this->property;
if (isset($this->property)) {}
// should be
if ($this->property !== null) {}
if (empty($myTransfer->getFoo()) {}
// should be
if (!$myTransfer->getFoo()) {}
For further reference see guidelines.
Fixed InlineDocBlock sniff to handle annotations with a comments above.
[@throws](https://github.com/throws) annotation fixing using full FQCN string.How can I help you explore Laravel packages today?