Skip to content

Commit

Permalink
Merge pull request #27 from webimpress/hotfix/sorting-types
Browse files Browse the repository at this point in the history
Fixes sorting types in doc-block tags
  • Loading branch information
michalbundyra committed May 19, 2019
2 parents 1f6b0b7 + cf4d622 commit 6064834
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/WebimpressCodingStandard/Helper/MethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ trait MethodsTrait
'?callable',
'float',
'?float',
'iterable',
'?iterable',
'int',
'?int',
'iterable',
'?iterable',
'object',
'?object',
'resource',
Expand Down Expand Up @@ -164,10 +164,13 @@ public function sortTypes(string $a, string $b) : int
return 1;
}

$aIsSimple = array_filter($this->simpleReturnTypes, function ($v) use ($a) {
$types = $this->simpleReturnTypes
+ ['parent' => 'parent', 'self' => 'self', 'static' => 'static'];

$aIsSimple = array_filter($types, static function (string $v) use ($a) {
return $v === $a || strpos($a, $v . '[') === 0;
});
$bIsSimple = array_filter($this->simpleReturnTypes, function ($v) use ($b) {
$bIsSimple = array_filter($types, static function (string $v) use ($b) {
return $v === $b || strpos($b, $v . '[') === 0;
});

Expand Down
5 changes: 5 additions & 0 deletions test/Sniffs/Commenting/TagWithTypeUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ namespace MyNamespace\Test;

class TagWithType
{
/**
* @var array|bool|callable|float|int|iterable|object|parent|resource|self|static|string|MyClass
*/
public $typesOrder;

/** @var \Property_Type */
public $className;

Expand Down

0 comments on commit 6064834

Please sign in to comment.