Skip to content

Commit

Permalink
Merge pull request #46 from laminas/2.1.x-merge-up-into-2.2.x
Browse files Browse the repository at this point in the history
Merge release 2.1.1 into 2.2.x
  • Loading branch information
geerteltink committed Oct 24, 2020
2 parents ae429e1 + 24f1fb8 commit 5d4f38d
Show file tree
Hide file tree
Showing 22 changed files with 189 additions and 67 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Expand Up @@ -6,7 +6,7 @@ cache:

env:
global:
- COMPOSER_ARGS="--no-interaction"
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"

matrix:
fast_finish: true
Expand Down Expand Up @@ -35,6 +35,12 @@ matrix:
- php: 7.4
env:
- DEPS=latest
- php: nightly
env:
- DEPS=lowest
- php: nightly
env:
- DEPS=latest

addons:
apt:
Expand Down
27 changes: 16 additions & 11 deletions CHANGELOG.md
Expand Up @@ -2,27 +2,32 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.2.0 - TBD
## 2.1.1 - 2020-10-24

### Added
-----

- Nothing.
### Release Notes for [2.1.1](https://github.com/laminas/laminas-coding-standard/milestone/4)

### Changed
2.1.x bugfix release (patch)

- Nothing.
### 2.1.1

### Deprecated
- Total issues resolved: **3**
- Total pull requests resolved: **4**
- Total contributors: **3**

- Nothing.
#### Documentation

### Removed
- [45: docs: add example for type hinting in docblocks](https://github.com/laminas/laminas-coding-standard/pull/45) thanks to @geerteltink and @Xerkus

- Nothing.
#### Bug

### Fixed
- [44: fix: unused imports and generics](https://github.com/laminas/laminas-coding-standard/pull/44) thanks to @geerteltink
- [41: fix: update dependencies to ensure some fixes are included](https://github.com/laminas/laminas-coding-standard/pull/41) thanks to @geerteltink

- Nothing.
#### Enhancement

- [42: feat: php 8 support](https://github.com/laminas/laminas-coding-standard/pull/42) thanks to @geerteltink and @boesing

## 2.0.1 - 2020-07-02

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -20,12 +20,12 @@
"sort-packages": true
},
"require": {
"php": "^7.1",
"php": "^7.3 || ~8.0.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
"laminas/laminas-zendframework-bridge": "^1.0",
"slevomat/coding-standard": "^6.2.0",
"squizlabs/php_codesniffer": "^3.5.3",
"webimpress/coding-standard": "^1.1.5"
"slevomat/coding-standard": "^6.4.1",
"squizlabs/php_codesniffer": "^3.5.8",
"webimpress/coding-standard": "^1.1.6"
},
"autoload": {
"psr-4": {
Expand Down
27 changes: 24 additions & 3 deletions docs/book/v2/coding-style-guide.md
Expand Up @@ -1257,11 +1257,32 @@ $instance = new class extends \Foo implements

> ### Additional Laminas rules
>
> Code SHOULD be written so it explains itself. DocBlocks and comments
> SHOULD only be used if necessary. They MUST NOT start with `#` and MUST
> NOT be empty. They SHOULD NOT be used for already typehinted arguments,
> Code SHOULD be written so it explains itself.
>
> DocBlocks and comments SHOULD only be used if necessary. They MUST NOT start
> with `#` and MUST NOT be empty.
>
> DocBlocks and comments SHOULD NOT be used for already typehinted arguments,
> except arrays.
>
```php
/**
* Sets a single-line title
*
* The string `param` and `return` tags should be omitted as they are already
* type hinted.
*
* A `param` tag should be here to describe the array.
*
* @param array<string,string> $context
*/
public function setTitle(string $title, array $context): void
{
// ...
}
```

> The asterisks in a DocBlock should align, and there should be one
> space between the asterisk and tag.
>
Expand Down
43 changes: 30 additions & 13 deletions src/LaminasCodingStandard/ruleset.xml
Expand Up @@ -264,13 +264,17 @@
<!-- There MAY NOT be a space around a namespace separator. -->
<rule ref="WebimpressCodingStandard.WhiteSpace.NamespaceSeparator"/>
<!-- Import statements MUST be alphabetically sorted. -->
<rule ref="WebimpressCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Functions and const keywords MUST be lowercase in import statements. -->
<rule ref="WebimpressCodingStandard.Namespaces.ConstAndFunctionKeywords"/>
<!-- Unused import statements MUST be removed.-->
<rule ref="WebimpressCodingStandard.Namespaces.UnusedUseStatement"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Superfluous leading backslash in import statements MUST be removed. -->
<rule ref="WebimpressCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Fancy group import statements MUST NOT be used. -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Each import statement MUST be on its own line. -->
Expand All @@ -280,13 +284,23 @@
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Import statements aliases for classes, traits, functions and constants
MUST be useful. -->
<rule ref="WebimpressCodingStandard.Namespaces.RedundantAlias"/>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Classes, traits, interfaces, constants and functions MUST be imported. -->
<rule ref="WebimpressCodingStandard.PHP.DisallowFqn"/>
<!-- Internal functions MUST be imported. -->
<rule ref="WebimpressCodingStandard.PHP.ImportInternalFunction"/>
<!-- Internal constants MUST be imported. -->
<rule ref="WebimpressCodingStandard.PHP.ImportInternalConstant"/>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFullyQualifiedGlobalClasses" value="false"/>
<!-- Internal functions MUST be imported. -->
<property name="allowFallbackGlobalFunctions" value="false"/>
<property name="allowFullyQualifiedGlobalFunctions" value="false"/>
<!-- Internal constants MUST be imported. -->
<property name="allowFallbackGlobalConstants" value="false"/>
<property name="allowFullyQualifiedGlobalConstants" value="false"/>
<property name="allowFullyQualifiedNameForCollidingClasses" value="true"/>
<property name="allowFullyQualifiedNameForCollidingConstants" value="true"/>
<property name="allowFullyQualifiedNameForCollidingFunctions" value="true"/>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>

<!-- 4. Classes, Properties, and Methods -->

Expand Down Expand Up @@ -787,11 +801,14 @@

<!-- DocBlocks and comments SHOULD NOT be used for already typehinted arguments,
except arrays. -->
<rule ref="WebimpressCodingStandard.Functions.Param"/>
<rule ref="WebimpressCodingStandard.Functions.ReturnType"/>
<rule ref="WebimpressCodingStandard.Commenting.TagWithType">
<exclude name="WebimpressCodingStandard.Commenting.TagWithType.InvalidOrder"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>

<!-- The asterisks in a DocBlock should align, and there should be one
space between the asterisk and tag. -->
Expand Down
27 changes: 14 additions & 13 deletions test/expected-report.txt
Expand Up @@ -7,36 +7,37 @@ test/fixable/2.1.BasicCodingStandard.php 48 1
test/fixable/2.2.Files.php 6 0
test/fixable/2.3.Lines.php 35 0
test/fixable/2.4.IndentingAndSpacing.php 46 0
test/fixable/2.5.KeywordsAndTypes.php 13 0
test/fixable/2.5.KeywordsAndTypes.php 8 0
test/fixable/2.6.Variables.php 3 0
test/fixable/2.7.Arrays.php 9 0
test/fixable/3.DeclareNamespaceAndImport.php 11 0
test/fixable/3.DeclareNamespaceAndImport.php 12 0
test/fixable/4.1.ExtendsAndImplements.php 5 0
test/fixable/4.2.UsingTraits.php 4 0
test/fixable/4.3.PropertiesAndConstants.php 5 0
test/fixable/4.4.MethodsAndFunctions.php 26 0
test/fixable/4.2.UsingTraits.php 5 0
test/fixable/4.3.PropertiesAndConstants.php 7 0
test/fixable/4.4.MethodsAndFunctions.php 27 0
test/fixable/4.5.MethodAndFunctionArguments.php 66 0
test/fixable/4.6.AbstractFinalAndStatic.php 4 0
test/fixable/4.6.AbstractFinalAndStatic.php 5 0
test/fixable/4.7.MethodAndFunctionCalls.php 11 0
test/fixable/4.ClassesPropertiesAndMethods.php 32 0
test/fixable/5.1.IfElseifElse.php 15 1
test/fixable/4.ClassesPropertiesAndMethods.php 34 0
test/fixable/5.1.IfElseifElse.php 13 1
test/fixable/5.2.SwitchCase.php 11 0
test/fixable/5.3.WhileAndDoWhile.php 12 0
test/fixable/5.4.ForStructure.php 7 0
test/fixable/5.4.ForStructure.php 5 0
test/fixable/5.5.ForEachStructure.php 10 0
test/fixable/5.6.TryCatchFinally.php 9 0
test/fixable/5.ControlStructures.php 4 0
test/fixable/6.1.UnaryOperators.php 6 0
test/fixable/6.2.BinaryOperators.php 35 0
test/fixable/6.3.TernaryOperators.php 13 0
test/fixable/6.Operators.php 97 0
test/fixable/7.Closures.php 2 0
test/fixable/7.Closures.php 4 0
test/fixable/8.AnonymousClasses.php 1 0
test/fixable/9.CommentingAndDocBlocks.php 21 0
test/fixable/9.CommentingAndDocBlocks.php 17 0
test/fixable/9.GenericTypeHintSyntax.php 4 0
----------------------------------------------------------------------
A TOTAL OF 567 ERRORS AND 2 WARNINGS WERE FOUND IN 30 FILES
A TOTAL OF 568 ERRORS AND 2 WARNINGS WERE FOUND IN 31 FILES
----------------------------------------------------------------------
PHPCBF CAN FIX 487 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
PHPCBF CAN FIX 484 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


4 changes: 2 additions & 2 deletions test/fixable/2.3.Lines.php
Expand Up @@ -60,13 +60,13 @@ public function testThereMayNotBeAnyBlankLineFfterOpeningBracesAndBeforeClosingB
// There MAY NOT be any blank line after opening braces and before
// closing braces.

$noBlankLine = function () use ($noBlankLine) {
$noBlankLine = function () use ($noBlankLine): void {

$noBlankLine = 1;

};

$closure = function () {
$closure = function (): void {

$noBlankLine = 1;

Expand Down
2 changes: 1 addition & 1 deletion test/fixable/2.7.Arrays.php
Expand Up @@ -27,7 +27,7 @@ public function testArrayFormatting(): void
];

$array2 = [
'one' => function () {
'one' => function (): void {
$foo = [1, 2, 3];
$barBar = [
1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixable/4.1.ExtendsAndImplements.php
Expand Up @@ -16,7 +16,7 @@ class ExtendsAndImplements
ArrayAccess,
Countable,
Serializable {
public function testClassDeclaration()
public function testClassDeclaration(): void
{
// The extends and implements keywords MUST be declared on the same line
// as the class name.
Expand Down
4 changes: 2 additions & 2 deletions test/fixable/4.4.MethodsAndFunctions.php
Expand Up @@ -19,15 +19,15 @@ public function testMethodsAndFunctions ($arg1, &$arg2, $arg3 = []) {
// NOT be a space after the opening parenthesis, and there MUST NOT be a
// space before the closing parenthesis.

function fooBar ( $arg1, &$arg2, $arg3 = [] ) {
function fooBar ( $arg1, &$arg2, $arg3 = [] ): void {
// function body
}

}



public function testOneSingleLineBetweenMethods()
public function testOneSingleLineBetweenMethods(): void
{
// There MUST be a single empty line between methods in a class.
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixable/4.5.MethodAndFunctionArguments.php
Expand Up @@ -74,7 +74,7 @@ public function testVariadicThreeDotOperator(string $foo, & ... $baz): void
// When combining both the reference operator and the variadic three dot
// operator, there MUST NOT be any space between the two of them.

function method($a, $b, ... $c) {
function method($a, $b, ... $c): void {
if ($a < $b) {
method(... func_get_args());
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixable/6.Operators.php
Expand Up @@ -65,7 +65,7 @@ public function testOperatorSpacing(): void
$result*=4;
}

public function testObjectOperatorSpacing()
public function testObjectOperatorSpacing(): void
{
// There MAY NOT be any white space around the object operator unless
// multilines are used.
Expand Down
4 changes: 2 additions & 2 deletions test/fixable/7.Closures.php
Expand Up @@ -37,11 +37,11 @@ public function testClosures(): void
// MUST follow the use list closing parentheses with no spaces between
// the two characters.

$closureWithArgs = function ($arg1, $arg2) {
$closureWithArgs = function ($arg1, $arg2): void {
echo "$arg1, $arg2";
};

$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2) {
$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2): void {
echo "$arg1, $arg2, $var1, $var2";
};

Expand Down
36 changes: 36 additions & 0 deletions test/fixable/9.GenericTypeHintSyntax.php
@@ -0,0 +1,36 @@
<?php

/**
* @see https://github.com/laminas/laminas-coding-standard for the canonical source repository
* @copyright https://github.com/laminas/laminas-coding-standard/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-coding-standard/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

use IteratorAggregate;

class GenericTypeHintSyntax
{
/** @psalm-var IteratorAggregate */
private $config;

/** @var IteratorAggregate<string,string> */
private $bar;

/**
* @param IteratorAggregate<string,string> $bar
*/
public function __construct(ArrayObject $bar)
{
$this->bar = $bar;
}

/**
* @param array<string, mixed> $config
*/
public function doSomethingWithArray(array $config): void
{
$this->config = $config;
}
}
4 changes: 2 additions & 2 deletions test/fixed/2.3.Lines.php
Expand Up @@ -50,11 +50,11 @@ public function testThereMayNotBeAnyBlankLineFfterOpeningBracesAndBeforeClosingB
// There MAY NOT be any blank line after opening braces and before
// closing braces.

$noBlankLine = function () use ($noBlankLine) {
$noBlankLine = function () use ($noBlankLine): void {
$noBlankLine = 1;
};

$closure = function () {
$closure = function (): void {
$noBlankLine = 1;
};

Expand Down
2 changes: 1 addition & 1 deletion test/fixed/2.7.Arrays.php
Expand Up @@ -27,7 +27,7 @@ public function testArrayFormatting(): void
];

$array2 = [
'one' => function () {
'one' => function (): void {
$foo = [1, 2, 3];
$barBar = [
1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixed/4.1.ExtendsAndImplements.php
Expand Up @@ -14,7 +14,7 @@ class ExtendsAndImplements extends ParentClass implements
Countable,
Serializable
{
public function testClassDeclaration()
public function testClassDeclaration(): void
{
// The extends and implements keywords MUST be declared on the same line
// as the class name.
Expand Down

0 comments on commit 5d4f38d

Please sign in to comment.