-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from voku/int_range
add support for "int<min,max>", "negative-int" and "numeric"
- Loading branch information
Showing
10 changed files
with
489 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of phpDocumentor. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @link http://phpdoc.org | ||
*/ | ||
|
||
namespace phpDocumentor\Reflection\PseudoTypes; | ||
|
||
use phpDocumentor\Reflection\PseudoType; | ||
use phpDocumentor\Reflection\Type; | ||
use phpDocumentor\Reflection\Types\Integer; | ||
|
||
/** | ||
* Value Object representing the type 'int'. | ||
* | ||
* @psalm-immutable | ||
*/ | ||
final class IntegerRange extends Integer implements PseudoType | ||
{ | ||
/** @var string */ | ||
private $minValue; | ||
|
||
/** @var string */ | ||
private $maxValue; | ||
|
||
public function __construct(string $minValue, string $maxValue) | ||
{ | ||
$this->minValue = $minValue; | ||
$this->maxValue = $maxValue; | ||
} | ||
|
||
public function underlyingType(): Type | ||
{ | ||
return new Integer(); | ||
} | ||
|
||
public function getMinValue(): string | ||
{ | ||
return $this->minValue; | ||
} | ||
|
||
public function getMaxValue(): string | ||
{ | ||
return $this->maxValue; | ||
} | ||
|
||
/** | ||
* Returns a rendered output of the Type as it would be used in a DocBlock. | ||
*/ | ||
public function __toString(): string | ||
{ | ||
return 'int<' . $this->minValue . ', ' . $this->maxValue . '>'; | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of phpDocumentor. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @link http://phpdoc.org | ||
*/ | ||
|
||
namespace phpDocumentor\Reflection\PseudoTypes; | ||
|
||
use phpDocumentor\Reflection\PseudoType; | ||
use phpDocumentor\Reflection\Type; | ||
use phpDocumentor\Reflection\Types\Integer; | ||
|
||
/** | ||
* Value Object representing the type 'int'. | ||
* | ||
* @psalm-immutable | ||
*/ | ||
final class NegativeInteger extends Integer implements PseudoType | ||
{ | ||
public function underlyingType(): Type | ||
{ | ||
return new Integer(); | ||
} | ||
|
||
/** | ||
* Returns a rendered output of the Type as it would be used in a DocBlock. | ||
*/ | ||
public function __toString(): string | ||
{ | ||
return 'negative-int'; | ||
} | ||
} |
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of phpDocumentor. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @link http://phpdoc.org | ||
*/ | ||
|
||
namespace phpDocumentor\Reflection\PseudoTypes; | ||
|
||
use phpDocumentor\Reflection\PseudoType; | ||
use phpDocumentor\Reflection\Type; | ||
use phpDocumentor\Reflection\Types\AggregatedType; | ||
use phpDocumentor\Reflection\Types\Compound; | ||
use phpDocumentor\Reflection\Types\Float_; | ||
use phpDocumentor\Reflection\Types\Integer; | ||
|
||
/** | ||
* Value Object representing the 'numeric' pseudo-type, which is either a numeric-string, integer or float. | ||
* | ||
* @psalm-immutable | ||
*/ | ||
final class Numeric_ extends AggregatedType implements PseudoType | ||
{ | ||
public function __construct() | ||
{ | ||
AggregatedType::__construct([new NumericString(), new Integer(), new Float_()], '|'); | ||
} | ||
|
||
public function underlyingType(): Type | ||
{ | ||
return new Compound([new NumericString(), new Integer(), new Float_()]); | ||
} | ||
|
||
/** | ||
* Returns a rendered output of the Type as it would be used in a DocBlock. | ||
*/ | ||
public function __toString(): string | ||
{ | ||
return 'numeric'; | ||
} | ||
} |
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
Oops, something went wrong.