Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS 3.6.0 + Slevomat CS 7.0 #3

Merged
merged 3 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private function checkThatExceptionIsChainable(PhpCsFile $phpcsFile, int $classP

if (
$lastArgument->getTypeHint() !== '\Throwable'
&& $lastArgument->getTypeHint() !== '?\Throwable'
&& !StringHelper::endsWith($lastArgument->getTypeHint(), 'Exception')
&& !StringHelper::endsWith($lastArgument->getTypeHint(), 'Error')
) {
Expand Down
16 changes: 2 additions & 14 deletions Consistence/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces"/>
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/>
Expand All @@ -106,15 +105,6 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword">
<properties>
<property name="keywordsToCheck" type="array">
<element value="T_EXTENDS"/>
<element value="T_IMPLEMENTS"/>
<element value="T_USE"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
Expand All @@ -124,10 +114,8 @@
<properties>
<property name="allowFullyQualifiedExceptions" value="true"/>
<property name="allowPartialUses" value="false"/>
<property name="fullyQualifiedKeywords" type="array">
<element value="T_EXTENDS"/>
<element value="T_IMPLEMENTS"/>
<element value="T_USE"/>
<property name="namespacesRequiredToUse" type="array">
<!-- to make sniff disable only partial uses -->
</property>
</properties>
</rule>
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
],
"require": {
"php": ">=7.4",
"squizlabs/php_codesniffer": "~3.5.8",
"slevomat/coding-standard": "~6.4"
"squizlabs/php_codesniffer": "~3.6.0",
"slevomat/coding-standard": "~7.0"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "1.2.0",
"php-parallel-lint/php-parallel-lint": "1.3.0",
"phing/phing": "2.16.4",
"phpunit/phpunit": "9.5.2"
"phpunit/phpunit": "9.5.4"
},
"replace": {
"consistence/coding-standard": "3.10.*"
Expand Down
9 changes: 9 additions & 0 deletions tests/Sniffs/Exceptions/ExceptionDeclarationSniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ public function testExceptionWithChainableConstructorIsChainable(): void
$this->assertNoSniffErrorInFile($resultFile);
}

public function testExceptionWithNullablePreviousInConstructorIsChainable(): void
{
$resultFile = $this->checkFile(__DIR__ . '/data/ChainableConstructorWithNullablePreviousException.php', [
'exceptionsDirectoryName' => 'data',
]);

$this->assertNoSniffErrorInFile($resultFile);
}

public function testExceptionWithCustomExceptionArgumentIsChainable(): void
{
$resultFile = $this->checkFile(__DIR__ . '/data/CustomExceptionArgumentChainableConstructorException.php', [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types = 1);

namespace Consistence\Sniffs\Exceptions;

class ChainableConstructorWithNullablePreviousException extends \Exception
{

public function __construct(string $foo, ?\Throwable $e = null)
{
parent::__construct($foo, 0, $e);
}

}