-
-
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.
- Loading branch information
smoench
committed
Jul 17, 2020
1 parent
e878a14
commit bac872b
Showing
7 changed files
with
181 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,34 @@ | ||
<?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\Types; | ||
|
||
/** | ||
* Value Object representing a array-key Type. | ||
* | ||
* A array-key Type is the supertype (but not a union) of int and string. | ||
* | ||
* @psalm-immutable | ||
*/ | ||
final class ArrayKey extends AggregatedType | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct([new String_(), new Integer()], '|'); | ||
} | ||
|
||
public function __toString() : string | ||
{ | ||
return 'array-key'; | ||
} | ||
} |
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,32 @@ | ||
<?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\Types; | ||
|
||
use phpDocumentor\Reflection\Type; | ||
|
||
/** | ||
* Value Object representing the type 'string'. | ||
* | ||
* @psalm-immutable | ||
*/ | ||
final class CallableString implements Type | ||
{ | ||
/** | ||
* Returns a rendered output of the Type as it would be used in a DocBlock. | ||
*/ | ||
public function __toString() : string | ||
{ | ||
return 'callable-string'; | ||
} | ||
} |
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,32 @@ | ||
<?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\Types; | ||
|
||
use phpDocumentor\Reflection\Type; | ||
|
||
/** | ||
* Value Object representing the type 'string'. | ||
* | ||
* @psalm-immutable | ||
*/ | ||
final class NumericString implements Type | ||
{ | ||
/** | ||
* Returns a rendered output of the Type as it would be used in a DocBlock. | ||
*/ | ||
public function __toString() : string | ||
{ | ||
return 'numeric-string'; | ||
} | ||
} |
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,32 @@ | ||
<?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\Types; | ||
|
||
use phpDocumentor\Reflection\Type; | ||
|
||
/** | ||
* Value Object representing the type 'string'. | ||
* | ||
* @psalm-immutable | ||
*/ | ||
final class TraitString implements Type | ||
{ | ||
/** | ||
* Returns a rendered output of the Type as it would be used in a DocBlock. | ||
*/ | ||
public function __toString() : string | ||
{ | ||
return 'trait-string'; | ||
} | ||
} |
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,45 @@ | ||
<?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\Types; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass \phpDocumentor\Reflection\Types\ArrayKey | ||
*/ | ||
final class ArrayKeyTest extends TestCase | ||
{ | ||
/** | ||
* @covers ::__construct | ||
* @covers ::__toString | ||
*/ | ||
public function testArrayKeyCanBeConstructedAndStringifiedCorrectly() : void | ||
{ | ||
$this->assertSame('array-key', (string) (new ArrayKey())); | ||
} | ||
|
||
/** | ||
* @uses ::__construct | ||
* | ||
* @covers ::getIterator | ||
*/ | ||
public function testArrayKeyCanBeIterated() : void | ||
{ | ||
$types = [String_::class, Integer::class]; | ||
|
||
foreach (new ArrayKey() as $index => $type) { | ||
$this->assertInstanceOf($types[$index], $type); | ||
} | ||
} | ||
} |