Zend\Code\Scanner\ClassScanner::hasConstant PHP Method

hasConstant() public method

Verify if class has constant
public hasConstant ( string $name ) : boolean
$name string
return boolean
    public function hasConstant($name)
    {
        $this->scan();
        foreach ($this->infos as $info) {
            if ($info['type'] === 'constant' && $info['name'] === $name) {
                return true;
            }
        }
        return false;
    }

Usage Example

 /**
  * Verify if class or parent class has constant
  *
  * @param  string $name
  * @return bool
  */
 public function hasConstant($name)
 {
     if ($this->classScanner->hasConstant($name)) {
         return true;
     }
     foreach ($this->parentClassScanners as $pClassScanner) {
         if ($pClassScanner->hasConstant($name)) {
             return true;
         }
     }
     return false;
 }