本文整理汇总了PHP中PHP_CodeSniffer_File::getmethodproperties方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeSniffer_File::getmethodproperties方法的具体用法?PHP PHP_CodeSniffer_File::getmethodproperties怎么用?PHP PHP_CodeSniffer_File::getmethodproperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeSniffer_File
的用法示例。
在下文中一共展示了PHP_CodeSniffer_File::getmethodproperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processtokenwithinscope
/**
* Processes the tokens within the scope.
*
* @param PHP_CodeSniffer_File $phpcsfile The file being processed.
* @param int $stackptr The position where this token was
* found.
* @param int $currscope The position of the current scope.
*
* @return void
*/
protected function processtokenwithinscope(PHP_CodeSniffer_File $phpcsfile, $stackptr, $currscope)
{
$classname = $phpcsfile->getdeclarationname($currscope);
$methodname = $phpcsfile->getdeclarationname($stackptr);
// Is this a magic method. IE. is prefixed with "__".
if (preg_match('|^__|', $methodname) !== 0) {
$magicpart = substr($methodname, 2);
if (in_array($magicpart, $this->_magicmethods) === false) {
$error = "method name \"{$classname}::{$methodname}\" is invalid; " . 'only PHP magic methods should be prefixed with a double underscore';
$phpcsfile->adderror($error, $stackptr);
}
return;
}
// PHP4 constructors are allowed to break our rules.
if ($methodname === $classname) {
return;
}
// PHP4 destructors are allowed to break our rules.
if ($methodname === '_' . $classname) {
return;
}
$methodprops = $phpcsfile->getmethodproperties($stackptr);
$ispublic = $methodprops['scope'] === 'private' ? false : true;
$scope = $methodprops['scope'];
$scopespecified = $methodprops['scope_specified'];
// Only lower-case accepted
if (preg_match('/[A-Z]+/', $methodname)) {
if ($scopespecified === true) {
$error = ucfirst($scope) . " method name \"{$classname}::{$methodname}\" must be in lower-case letters only";
} else {
$error = "method name \"{$classname}::{$methodname}\" must be in lower-case letters only";
}
$phpcsfile->adderror($error, $stackptr);
return;
}
// No numbers accepted
if (preg_match('/[0-9]+/', $methodname)) {
if ($scopespecified === true) {
$error = ucfirst($scope) . " method name \"{$classname}::{$methodname}\" must only contain letters";
} else {
$error = "Method name \"{$classname}::{$methodname}\" must only contain letters";
}
$phpcsfile->adderror($error, $stackptr);
return;
}
}