我有一个名为BaseSniff
的基类,并从中派生了几个类。
BaseSniff
包含名为PHP_CodeSniffer_File
的{{1}}类型的成员。
编辑$phpcsFile
使用BaseSniff
时,PhpStorm将自动完成,但在派生类中,这不起作用。
有没有办法实现这个目标?
以下是基类的声明方式
$this->phpcsFile
这是派生类
/**
* Base class for all Cardstream code sniffs.
*
* The class is constructed from a
* list of tokens to register
* list of code violations to check
* This class implements the 'process' method of the PHP_CodeSniffer_Sniff
* class.
* Derived classes are able to execute code before the actual processing of
* the token via the 'preProcess' method.
* The code violations are then processed and errors and warnings are reported.
*
* A code violation can stop the processing of the remaining
* violations for the file.
*
* @author Graham Labdon <graham.labdon@cardstream.com>
*/
abstract class BaseSniff implements \PHP_CodeSniffer_Sniff {
public function process(\PHP_CodeSniffer_File $phpcs_file, $stack_ptr) {
$this->phpcsFile = $phpcs_file;
}
/**
* Creates the sniff.
*
* Initialises the sniff
*
* @param array $register Array of tokens to register
* @param array $code_violations List of code violations to check
* @param string $sniff_name Name of sniff
* @return void
*/
public function __construct(
array $register,
array $code_violations,
$sniff_name
) {
$this->firstCall = true;
$this->registeredTokens = $register;
$this->codeViolations = $code_violations;
$this->sniffName = $sniff_name;
}
}
答案 0 :(得分:0)
答案是在基类的doc块中添加@property标记