public function testTypeCheckFailures()
 {
     $map = array('int' => 'string', 'string' => 32, 'null' => true, 'bool' => null, 'map<wild, wild>' => 16, 'list<string>' => array('y' => 'z'), 'int|null' => 'ducks', 'stdClass' => new Exception(), 'list<RuntimeException>' => array(new Exception()));
     foreach ($map as $type => $value) {
         $caught = null;
         try {
             PhutilTypeSpec::newFromString($type)->check($value);
         } catch (PhutilTypeCheckException $ex) {
             $caught = $ex;
         }
         $this->assertTrue($ex instanceof PhutilTypeCheckException);
     }
 }
 public function getValueForStorage($value)
 {
     PhutilTypeSpec::newFromString('list<string>')->check($value);
     return array_values($value);
 }
Example #3
0
 public function setBugtraqSelectExpression($regex)
 {
     PhutilTypeSpec::newFromString('regex')->check($regex);
     $this->bugtraqSelectExpression = $regex;
     return $this;
 }