Neos\Kickstarter\Utility\Validation::isReservedKeyword PHP Метод

isReservedKeyword() публичный статический Метод

Check the given keyword to be not one of the reserved words of PHP.
См. также: http://www.php.net/manual/en/reserved.keywords.php
public static isReservedKeyword ( string $keyword ) : boolean
$keyword string
Результат boolean
    public static function isReservedKeyword($keyword)
    {
        $reservedKeywords = array('__halt_compiler', 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor');
        return in_array(strtolower($keyword), $reservedKeywords);
    }

Usage Example

 /**
  * Check the given model name to be not one of the reserved words of PHP.
  *
  * @param string $modelName
  * @return boolean
  * @see http://www.php.net/manual/en/reserved.keywords.php
  */
 protected function validateModelName($modelName)
 {
     if (Validation::isReservedKeyword($modelName)) {
         $this->outputLine('The name of the model cannot be one of the reserved words of PHP!');
         $this->outputLine('Have a look at: http://www.php.net/manual/en/reserved.keywords.php');
         exit(3);
     }
 }