Changeset View
Changeset View
Standalone View
Standalone View
src/parser/PhutilTypeSpec.php
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | switch ($this->type) { | ||||
} | } | ||||
break; | break; | ||||
case 'string': | case 'string': | ||||
if (!is_string($value)) { | if (!is_string($value)) { | ||||
throw new PhutilTypeCheckException($this, $value, $name); | throw new PhutilTypeCheckException($this, $value, $name); | ||||
} | } | ||||
break; | break; | ||||
case 'regex': | case 'regex': | ||||
if (!is_string($value)) { | |||||
throw new PhutilTypeCheckException($this, $value, $name); | |||||
} | |||||
$trap = new PhutilErrorTrap(); | $trap = new PhutilErrorTrap(); | ||||
$ok = @preg_match($value, ''); | $ok = @preg_match($value, ''); | ||||
$err = $trap->getErrorsAsString(); | $err = $trap->getErrorsAsString(); | ||||
$trap->destroy(); | $trap->destroy(); | ||||
if ($ok === false) { | if ($ok === false) { | ||||
throw new PhutilTypeCheckException($this, $value, $name, $err); | throw new PhutilTypeCheckException($this, $value, $name, $err); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,836 Lines • Show Last 20 Lines |