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

Added slevomat coding standard #85

Merged
merged 38 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ade14ef
Added slevomat coding standard
marekdedic Dec 23, 2023
1f9709f
Temporarily disabled slevomat rules
marekdedic Dec 23, 2023
9fe647f
Enabled SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.Inco…
marekdedic Dec 23, 2023
3e5d15f
Enabled SlevomatCodingStandard.Attributes.AttributesOrder
marekdedic Dec 23, 2023
17fa7aa
Enabled SlevomatCodingStandard.Classes.ClassStructure.IncorrectGroupO…
marekdedic Dec 23, 2023
cdafdc8
Enabled SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces.No…
marekdedic Dec 23, 2023
57da89d
Permanently disabled SlevomatCodingStandard.Classes.EmptyLinesAroundC…
marekdedic Dec 23, 2023
bc8d46b
Permanently disabled SlevomatCodingStandard.Classes.ForbiddenPublicPr…
marekdedic Dec 23, 2023
3b0b4a9
Enabled SlevomatCodingStandard.Classes.MethodSpacing.IncorrectLinesCo…
marekdedic Dec 23, 2023
41adf94
Permanently disabled SlevomatCodingStandard.Classes.RequireAbstractOr…
marekdedic Dec 23, 2023
f7fc640
Permanently disabled SlevomatCodingStandard.Classes.SuperfluousErrorN…
marekdedic Dec 23, 2023
a246d24
Permanently disabled SlevomatCodingStandard.Classes.SuperfluousExcept…
marekdedic Dec 23, 2023
20daa66
Enabled SlevomatCodingStandard.Commenting.DisallowCommentAfterCode.Di…
marekdedic Dec 23, 2023
b79ddb4
Permanently disabled SlevomatCodingStandard.Commenting.DocCommentSpac…
marekdedic Dec 23, 2023
d28ea32
Postponed a rule
marekdedic Dec 23, 2023
e802c31
Permanently disabled SlevomatCodingStandard.Commenting.RequireOneLine…
marekdedic Dec 23, 2023
9a33820
Permanently disabled SlevomatCodingStandard.Commenting.RequireOneLine…
marekdedic Dec 23, 2023
bb1be34
Permanently disabled SlevomatCodingStandard.Files.FileLength.FileTooLong
marekdedic Dec 23, 2023
15816ce
Enabled SlevomatCodingStandard.Files.LineLength.LineTooLong
marekdedic Dec 23, 2023
d74139e
Permanently disabled SlevomatCodingStandard.Files.TypeNameMatchesFile…
marekdedic Dec 23, 2023
540b9b7
Permanently disabled SlevomatCodingStandard.Functions.DisallowEmptyFu…
marekdedic Dec 23, 2023
15f568f
Permanently disabled SlevomatCodingStandard.Functions.UnusedParameter…
marekdedic Dec 23, 2023
c82a7ee
Permanently disabled SlevomatCodingStandard.Namespaces.FullyQualified…
marekdedic Dec 23, 2023
2ca9354
Permanently disabled SlevomatCodingStandard.Namespaces.FullyQualified…
marekdedic Dec 23, 2023
16d94ed
Enabled SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.Refe…
marekdedic Dec 23, 2023
2491fe8
Enabled SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.Refe…
marekdedic Dec 23, 2023
01d05b1
Permanently disabled SlevomatCodingStandard.Namespaces.UseOnlyWhiteli…
marekdedic Dec 23, 2023
f5d1e47
Enabled SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareSt…
marekdedic Dec 23, 2023
97fbff0
Permanently disabled SlevomatCodingStandard.TypeHints.DisallowMixedTy…
marekdedic Dec 23, 2023
e3fafca
Enabled SlevomatCodingStandard.TypeHints.LongTypeHints.UsedLongTypeHint
marekdedic Dec 23, 2023
7fb767d
Enabled SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition.N…
marekdedic Dec 23, 2023
27fb756
Permanently disabled SlevomatCodingStandard.TypeHints.ParameterTypeHi…
marekdedic Dec 23, 2023
8e9aab6
Permanently disabled SlevomatCodingStandard.TypeHints.PropertyTypeHin…
marekdedic Dec 23, 2023
768aeae
Permanently disabled SlevomatCodingStandard.TypeHints.ReturnTypeHint.…
marekdedic Dec 23, 2023
59b3045
Permanently disabled SlevomatCodingStandard.TypeHints.UselessConstant…
marekdedic Dec 23, 2023
10892a1
Permanently disabled SlevomatCodingStandard.Whitespaces.DuplicateSpac…
marekdedic Dec 23, 2023
9324b10
Enabled SlevomatCodingStandard.Commenting.EmptyComment.EmptyComment
marekdedic Dec 23, 2023
b63957b
Cleaned up PHPCS config
marekdedic Dec 23, 2023
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
15 changes: 9 additions & 6 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@
* @package wordpress-stubs
*/

declare(strict_types = 1);

return array(
'target_php_version' => '7.3',
'backward_compatibility_checks' => false, // Covered by PHPCS.
'warn_about_redundant_use_namespaced_class' => true,
// Covered by PHPCS.
'backward_compatibility_checks' => false,
'directory_list' => array(
'stubs',
'.phan',
),
'suppress_issue_types' => array(
'PhanTypeMissingReturn',
),
'plugins' => array(
'PreferNamespaceUsePlugin',
'SuspiciousParamOrderPlugin',
'UnusedSuppressionPlugin',
),
'suppress_issue_types' => array(
'PhanTypeMissingReturn',
),
'target_php_version' => '7.3',
'warn_about_redundant_use_namespaced_class' => true,
);
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"squizlabs/php_codesniffer": "^3.0",
"wp-coding-standards/wpcs": "^3.0",
"phan/phan": "^5.0",
"phpstan/phpstan": "^1.4"
"phpstan/phpstan": "^1.4",
"slevomat/coding-standard": "^8.14"
},
"scripts": {
"phpcs": "phpcs",
Expand Down
67 changes: 66 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,52 @@
<property name="blank_line_check" value="true"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard">
<!-- Incompatible with PHP version requirements -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>

<!-- Conflicts with WPCS -->
<exclude name="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces.NoEmptyLineBeforeClosingBrace"/>
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName"/>
<exclude name="SlevomatCodingStandard.Whitespaces.DuplicateSpaces.DuplicateSpaces"/>

<!-- Covered by PHPMD -->
<exclude name="SlevomatCodingStandard.Files.FunctionLength.FunctionLength"/>
<exclude name="SlevomatCodingStandard.Functions.FunctionLength.FunctionLength"/>

<!-- Not applicable to stubs -->
<exclude name="SlevomatCodingStandard.Classes.ForbiddenPublicProperty.ForbiddenPublicProperty"/>
<exclude name="SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousErrorNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Functions.DisallowEmptyFunction.EmptyFunction"/>
<exclude name="SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter"/>
<exclude name="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint.UselessDocComment"/>

<!-- Disabled due to style preferences -->
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectLinesCountBetweenDifferentAnnotationsTypes"/>
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment"/>
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment.MultiLinePropertyComment"/>
<exclude name="SlevomatCodingStandard.Files.FileLength.FileTooLong"/>
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation.NonFullyQualifiedClassName"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions.NonFullyQualifiedException"/>
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces.NonFullyQualified"/>
<exclude name="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint"/>
</rule>

<rule ref="SlevomatCodingStandard.Attributes.AttributesOrder">
<properties>
<property name="orderAlphabetically" value="true" />
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Files.LineLength">
<properties>
<property name="ignoreComments" value="true"/>
</properties>
</rule>
</ruleset>
3 changes: 3 additions & 0 deletions stubs/PHPUnit/Framework/class-assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
* @package wordpress-stubs
*/

declare(strict_types = 1);

namespace PHPUnit\Framework;

class Assert {

/**
* @param string $expected
* @param mixed $actual
Expand Down
3 changes: 3 additions & 0 deletions stubs/PHPUnit/Framework/class-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
* @package wordpress-stubs
*/

declare(strict_types = 1);

namespace PHPUnit\Framework;

class TestCase extends Assert {

}
9 changes: 6 additions & 3 deletions stubs/WordPress-test/class-wp-unittestcase-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
* @package wordpress-stubs
*/

/**
*/
class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
declare(strict_types = 1);

use PHPUnit\Framework\TestCase;

class WP_UnitTestCase_Base extends TestCase {

}
5 changes: 3 additions & 2 deletions stubs/WordPress-test/class-wp-unittestcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* @package wordpress-stubs
*/

/**
*/
declare(strict_types = 1);

class WP_UnitTestCase extends WP_UnitTestCase_Base {

}
2 changes: 2 additions & 0 deletions stubs/WordPress-test/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* @package wordpress-stubs
*/

declare(strict_types = 1);

/**
* @param string $tag
* @param callable $function_to_add
Expand Down
13 changes: 8 additions & 5 deletions stubs/WordPress/class-requests-cookie-jar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
* @package wordpress-stubs
*/

declare(strict_types = 1);

/**
* @implements ArrayAccess<string, string>
* @implements IteratorAggregate<string, string>
*/
class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate {

/**
* @param string $key
*
* @return bool
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function offsetExists( $key ) {
}

Expand All @@ -22,7 +25,7 @@ public function offsetExists( $key ) {
*
* @return string|null
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function offsetGet( $key ) {
}

Expand All @@ -32,7 +35,7 @@ public function offsetGet( $key ) {
*
* @return void
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function offsetSet( $key, $value ) {
}

Expand All @@ -41,14 +44,14 @@ public function offsetSet( $key, $value ) {
*
* @return void
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function offsetUnset( $key ) {
}

/**
* @return ArrayIterator<string, string>
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function getIterator() {
}
}
5 changes: 3 additions & 2 deletions stubs/WordPress/class-requests-exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* @package wordpress-stubs
*/

/**
*/
declare(strict_types = 1);

class Requests_Exception extends Exception {

}
5 changes: 3 additions & 2 deletions stubs/WordPress/class-requests-response.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* @package wordpress-stubs
*/

/**
*/
declare(strict_types = 1);

class Requests_Response {

/**
* @var string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
* @package wordpress-stubs
*/

declare(strict_types = 1);

/**
* @implements ArrayAccess<string, string>
* @implements IteratorAggregate<string, string>
*/
class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate {

/**
* @param string $key
*
* @return bool
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function offsetExists( $key ) {
}

Expand All @@ -22,7 +25,7 @@ public function offsetExists( $key ) {
*
* @return string|null
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function offsetGet( $key ) {
}

Expand All @@ -32,7 +35,7 @@ public function offsetGet( $key ) {
*
* @return void
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function offsetSet( $key, $value ) {
}

Expand All @@ -41,14 +44,14 @@ public function offsetSet( $key, $value ) {
*
* @return void
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function offsetUnset( $key ) {
}

/**
* @return ArrayIterator<string, string>
*/
#[\ReturnTypeWillChange]
#[ReturnTypeWillChange]
public function getIterator() {
}
}
5 changes: 3 additions & 2 deletions stubs/WordPress/class-requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* @package wordpress-stubs
*/

/**
*/
declare(strict_types = 1);

class Requests {

/**
* @param array<int|string, array{url: string, headers?: array<string, string>, data?: array<int|string, string>|string, type?: string, cookies?: array<string, string>|Requests_Cookie_Jar}> $requests
* @param array{timeout?: float, connect_timeout?: float, useragent?: string, follow_redirects?: bool, redirects?: int, blocking?: bool, filename?: string|bool, auth?: Requests_Auth|array<string>|bool, proxy?: Requests_Proxy|array<string>|string|bool, max_bytes?: int|bool, idn?: bool, transport?: string|Requests_Transport, hooks?: Requests_Hooker, verify?: string|bool, verifyname?: bool, data_format?: string, complete?: callable} $options {
Expand Down
5 changes: 3 additions & 2 deletions stubs/WordPress/class-wp-admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* @package wordpress-stubs
*/

/**
*/
declare(strict_types = 1);

class WP_Admin_Bar {

/**
* @param array{id: string, title?: string, parent?: string, href?: string, group?: bool, meta?: array{html?: string, class?: string, rel?: string, onclick?: string, target?: string, title?: string, tabindex?: string}} $node {
* @type string $id
Expand Down
Loading
Loading