validate() public method

Validate annotation tree, and log notices & warnings.
public validate ( array $parents = [], array $skip = [] ) : boolean
$parents array The path of annotations above this annotation in the tree.
$skip array (prevent stack overflow, when traversing an infinite dependency graph)
return boolean
示例#1
0
 public function validate($skip = [])
 {
     if (in_array($this, $skip, true)) {
         return true;
     }
     $valid = parent::validate($skip);
     if (!$this->ref && $this->type === 'array' && $this->items === null) {
         Logger::notice('@SWG\\Items() is required when ' . $this->identity() . ' has type "array" in ' . $this->_context);
         $valid = false;
     }
     return $valid;
 }
示例#2
0
 /** @inheritdoc */
 public function validate($parents = [], $skip = [])
 {
     if (in_array($this, $skip, true)) {
         return true;
     }
     $valid = parent::validate($parents, $skip);
     if (empty($this->ref)) {
         if ($this->in === 'body') {
             if ($this->schema === null) {
                 Logger::notice('Field "schema" is required when ' . $this->identity() . ' is in "' . $this->in . '" in ' . $this->_context);
                 $valid = false;
             }
         } else {
             $validTypes = ['string', 'number', 'integer', 'boolean', 'array', 'file'];
             if ($this->type === null) {
                 Logger::notice($this->identity() . '->type is required when ' . $this->_identity([]) . '->in == "' . $this->in . '" in ' . $this->_context);
                 $valid = false;
             } elseif ($this->type === 'array' && $this->items === null) {
                 Logger::notice($this->identity() . '->items required when ' . $this->_identity([]) . '->type == "array" in ' . $this->_context);
                 $valid = false;
             } elseif (in_array($this->type, $validTypes) === false) {
                 $valid = false;
                 Logger::notice($this->identity() . '->type must be "' . implode('", "', $validTypes) . '" when ' . $this->_identity([]) . '->in != "body" in ' . $this->_context);
             }
         }
     }
     return $valid;
 }
示例#3
0
 public function validate($parents = [], $skip = [])
 {
     if (in_array($this, $skip, true)) {
         return true;
     }
     $valid = parent::validate($parents, $skip);
     if ($this->responses !== null) {
         foreach ($this->responses as $response) {
             if ($response->response !== 'default' && preg_match('/^[12345]{1}[0-9]{2}$/', $response->response) === 0) {
                 Logger::notice('Invalid value "' . $response->response . '" for ' . $response->_identity([]) . '->response, expecting "default" or a HTTP Status Code in ' . $response->_context);
             }
         }
     }
     return $valid;
 }