mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
EnumTrait: fixed regex not accepting member names with 1 character
this also fixes EnumTrait accepting invalid non-numeric characters for the first character, such as @.
This commit is contained in:
parent
fdd42fd15f
commit
f4f5c3128f
@ -70,7 +70,7 @@ trait EnumTrait{
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function __construct(string $enumName){
|
||||
if(preg_match('/^\D[A-Za-z\d_]+$/u', $enumName, $matches) === 0){
|
||||
if(preg_match('/^(?!\d)[A-Za-z\d_]+$/u', $enumName, $matches) === 0){
|
||||
throw new \InvalidArgumentException("Invalid enum member name \"$enumName\", should only contain letters, numbers and underscores, and must not start with a number");
|
||||
}
|
||||
$this->enumName = $enumName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user