for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Deltatag\Enum;
/**
* Trait ConstantsTrait
*
* Provides constant features.
* @package Deltatag\Enum
*/
trait ConstantsTrait
{
* Fetch all constants of enum class
* @return array
array<string,integer|double|string|boolean>
This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.
array
public static function getConstants()
return (new \ReflectionClass(static::class))->getConstants();
}
* Helper for getConstants()
public static function toArray()
return self::getConstants();
* Check if given value is valid value
* @param mixed $value
* @return bool
public static function isValid($value)
return in_array($value, static::getConstants());
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.