v1.0 Initial commit of project
This commit is contained in:
33
vendor/myclabs/php-enum/static-analysis/EnumIsPure.php
vendored
Normal file
33
vendor/myclabs/php-enum/static-analysis/EnumIsPure.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MyCLabs\Tests\Enum\StaticAnalysis;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/**
|
||||
* @method static PureEnum A()
|
||||
* @method static PureEnum C()
|
||||
*
|
||||
* @psalm-immutable
|
||||
* @psalm-template T of 'A'|'B'
|
||||
* @template-extends Enum<T>
|
||||
*/
|
||||
final class PureEnum extends Enum
|
||||
{
|
||||
const A = 'A';
|
||||
const C = 'C';
|
||||
}
|
||||
|
||||
/** @psalm-pure */
|
||||
function enumFetchViaMagicMethodIsPure(): PureEnum
|
||||
{
|
||||
return PureEnum::A();
|
||||
}
|
||||
|
||||
/** @psalm-pure */
|
||||
function enumFetchViaExplicitMagicCallIsPure(): PureEnum
|
||||
{
|
||||
return PureEnum::__callStatic('A', []);
|
||||
}
|
||||
Reference in New Issue
Block a user