-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Ptscs\Tests\Sniffs\Slevomat\TypeHints; | ||
|
||
use Iterator; | ||
use Ptscs\Tests\SniffTestCase; | ||
use Ptscs\Tests\Utils\ErrorData; | ||
|
||
final class PropertyTypeHintTest extends SniffTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->appendExclude('Squiz.Classes.ClassFileName.NoMatch'); | ||
} | ||
|
||
public static function provideTestData(): Iterator | ||
{ | ||
yield [ | ||
[ | ||
new ErrorData(10, 'SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation'), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Ptscs\Tests\Sniffs\Slevomat\TypeHints; | ||
|
||
use Iterator; | ||
use Ptscs\Tests\SniffTestCase; | ||
|
||
final class UselessDocblockTest extends SniffTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->appendExclude('Squiz.Classes.ClassFileName.NoMatch'); | ||
} | ||
|
||
public static function provideTestData(): Iterator | ||
{ | ||
yield []; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/Sniffs/Slevomat/TypeHints/_data/PropertyTypeHint.php.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App; | ||
|
||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
final class Foobar | ||
{ | ||
private string $useless; | ||
|
||
/** | ||
* @Assert\NotBlank | ||
*/ | ||
private $missing; | ||
|
||
/** | ||
* Description | ||
* | ||
*/ | ||
private string $value1; | ||
|
||
private ?int $value2 = null; | ||
|
||
private string|int|float $value3; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
private array $value4; | ||
|
||
/** | ||
* @var string The hashed password | ||
*/ | ||
private string $password; | ||
|
||
private $inferMissing; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $inferUseless; | ||
|
||
public function __construct(string $inferMissing, int $inferUseless) | ||
{ | ||
$this->inferMissing = $inferMissing; | ||
$this->inferUseless = $inferUseless; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/Sniffs/Slevomat/TypeHints/_data/PropertyTypeHint.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App; | ||
|
||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
final class Foobar | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private string $useless; | ||
|
||
/** | ||
* @Assert\NotBlank | ||
*/ | ||
private $missing; | ||
|
||
/** | ||
* Description | ||
* | ||
*/ | ||
private string $value1; | ||
|
||
private ?int $value2 = null; | ||
|
||
private string|int|float $value3; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
private array $value4; | ||
|
||
/** | ||
* @var string The hashed password | ||
*/ | ||
private string $password; | ||
|
||
private $inferMissing; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $inferUseless; | ||
|
||
public function __construct(string $inferMissing, int $inferUseless) | ||
{ | ||
$this->inferMissing = $inferMissing; | ||
$this->inferUseless = $inferUseless; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/Sniffs/Slevomat/TypeHints/_data/UselessDocblock.php.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App; | ||
|
||
final class Foobar | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $value; | ||
|
||
/** | ||
* Class constructor. | ||
* @param string $value | ||
*/ | ||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getValue(): string | ||
{ | ||
return $this->value; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/Sniffs/Slevomat/TypeHints/_data/UselessDocblock.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App; | ||
|
||
final class Foobar | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $value; | ||
|
||
/** | ||
* Class constructor. | ||
* @param string $value | ||
*/ | ||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getValue(): string | ||
{ | ||
return $this->value; | ||
} | ||
} |