-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
6 changed files
with
132 additions
and
45 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
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,13 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Spaze\PHPStan\Rules\Disallowed\Params; | ||
|
||
use PHPStan\Type\ConstantScalarType; | ||
|
||
interface DisallowedCallParam | ||
{ | ||
|
||
public function matches(ConstantScalarType $type): bool; | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/Params/DisallowedCallParamWithCaseInsensitiveValue.php
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,41 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Spaze\PHPStan\Rules\Disallowed\Params; | ||
|
||
use PHPStan\Type\Constant\ConstantStringType; | ||
use PHPStan\Type\ConstantScalarType; | ||
|
||
class DisallowedCallParamWithCaseInsensitiveValue implements DisallowedCallParam | ||
{ | ||
|
||
/** @var integer|boolean|string */ | ||
private $value; | ||
|
||
|
||
/** | ||
* @param integer|boolean|string $value | ||
*/ | ||
public function __construct($value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
|
||
public function matches(ConstantScalarType $type): bool | ||
{ | ||
$a = is_string($this->value) ? strtolower($this->value) : $this->value; | ||
$b = $type instanceof ConstantStringType ? strtolower($type->getValue()) : $type->getValue(); | ||
return $a === $b; | ||
} | ||
|
||
|
||
/** | ||
* @return integer|boolean|string | ||
*/ | ||
public function getValue() | ||
{ | ||
return $this->value; | ||
} | ||
|
||
} |
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,38 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Spaze\PHPStan\Rules\Disallowed\Params; | ||
|
||
use PHPStan\Type\ConstantScalarType; | ||
|
||
class DisallowedCallParamWithValue implements DisallowedCallParam | ||
{ | ||
|
||
/** @var integer|boolean|string */ | ||
private $value; | ||
|
||
|
||
/** | ||
* @param integer|boolean|string $value | ||
*/ | ||
public function __construct($value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
|
||
public function matches(ConstantScalarType $type): bool | ||
{ | ||
return $this->value === $type->getValue(); | ||
} | ||
|
||
|
||
/** | ||
* @return integer|boolean|string | ||
*/ | ||
public function getValue() | ||
{ | ||
return $this->value; | ||
} | ||
|
||
} |