Hi
I am just starting to write my own coding standard and have followed the tutorial
However when I run phpcs against the standard no error is detected
What would be the best way debug this?
This is my ruleset.xml and sniff
<?xml version="1.0"?>
<ruleset name="CardstreamCodingStandard">
<description>>Rule set to implement the Cardstream coding standard</description>
</ruleset>
<?php
/**
This sniff prohibits the use of Perl style hash comments.
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;
class DisallowHashCommentsSniff implements Sniff
{
/**
* Returns the token types that this sniff is interested in.
*
* @return array(int)
*/
public function register()
{
echo ("register")
return array(T_COMMENT);
}//end register()
/**
* Processes this sniff, when one of its tokens is encountered.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being checked.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
*
* @return void
*/
public function process(File $phpcsFile, $stackPtr)
{
echo ("process")
$tokens = $phpcsFile->getTokens();
/ if ($tokens[$stackPtr]['content']{0} === '#') {/
$error = 'Hash comments are prohibited; found %s';
$data = array(trim($tokens[$stackPtr]['content']));
$phpcsFile->addError($error, $stackPtr, 'Found', $data);
/ }/
Hi I am just starting to write my own coding standard and have followed the tutorial However when I run phpcs against the standard no error is detected What would be the best way debug this? This is my ruleset.xml and sniff
<?php /**
namespace PHP_CodeSniffer\Standards\MyStandard\Sniffs\Commenting;
use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File;
class DisallowHashCommentsSniff implements Sniff {
/ if ($tokens[$stackPtr]['content']{0} === '#') {/ $error = 'Hash comments are prohibited; found %s'; $data = array(trim($tokens[$stackPtr]['content'])); $phpcsFile->addError($error, $stackPtr, 'Found', $data); / }/
}//end class
?>