Skip to content

Commit

Permalink
Merge pull request #632 from Automattic/fix/various-minor-documentati…
Browse files Browse the repository at this point in the history
…on-fixes

Documentation: various minor improvements
  • Loading branch information
rebeccahum authored Mar 2, 2021
2 parents d199359 + d66899c commit dfa99fd
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function findNonCheckedVariables( $stackPtr ) {
* Function used as as callback for the array_reduce call.
*
* @param string $carry The final string.
* @param array $item Processed item.
* @param array $item Processed item.
*
* @return string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public function is_targetted_token( $stackPtr ) {
if ( isset( $skipped[ $this->tokens[ $prev ]['code'] ] ) ) {
return false;
}
// Skip namespaced functions, ie: \foo\bar() not \bar().
// Skip namespaced functions, ie: `\foo\bar()` not `\bar()`.
if ( $this->tokens[ $prev ]['code'] === \T_NS_SEPARATOR ) {
$pprev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, $prev - 1, null, true );
if ( $pprev !== false && $this->tokens[ $pprev ]['code'] === \T_STRING ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ private function processArray( $stackPtr ) {
* Process string.
*
* @param int $stackPtr The position in the stack where the token was found.
* @param int $start The start of the token.
* @param int $end The end of the token.
* @param int $start The start of the token.
* @param int $end The end of the token.
*/
private function processString( $stackPtr, $start = 0, $end = null ) {

Expand All @@ -149,8 +149,8 @@ private function processString( $stackPtr, $start = 0, $end = null ) {
* Process function.
*
* @param int $stackPtr The position in the stack where the token was found.
* @param int $start The start of the token.
* @param int $end The end of the token.
* @param int $start The start of the token.
* @param int $end The end of the token.
*/
private function processFunction( $stackPtr, $start = 0, $end = null ) {

Expand Down
4 changes: 2 additions & 2 deletions WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private function processClosure( $stackPtr ) {
/**
* Process function's body
*
* @param int $stackPtr The position in the stack where the token was found.
* @param int $stackPtr The position in the stack where the token was found.
* @param string $variableName Variable name.
*/
private function processFunctionBody( $stackPtr, $variableName ) {
Expand Down Expand Up @@ -363,7 +363,7 @@ private function isEarlyMainQueryCheck( $stackPtr ) {
* Is the current code a WP_Query call?
*
* @param int $stackPtr The position in the stack where the token was found.
* @param null $method Method.
* @param null $method Method.
*
* @return bool
*/
Expand Down
4 changes: 2 additions & 2 deletions WordPressVIPMinimum/Sniffs/JS/StringConcatSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public function process_token( $stackPtr ) {
/**
* Consolidated violation.
*
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
* @param array $data Replacements for the error message.
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
* @param array $data Replacements for the error message.
*/
private function addFoundError( $stackPtr, array $data ) {
$message = 'HTML string concatenation detected, this is a security risk, use DOM node construction or a templating language instead: %s.';
Expand Down
14 changes: 6 additions & 8 deletions WordPressVIPMinimum/Sniffs/Performance/RegexpCompareSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ class RegexpCompareSniff extends AbstractArrayAssignmentRestrictionsSniff {

/**
* Groups of variables to restrict.
* This should be overridden in extending classes.
*
* Example: groups => array(
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* 'groupname' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'keys' => array( 'key1', 'another_key' ),
* 'callback' => array( 'class', 'method' ), // Optional.
* )
* )
*
* @return array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ class RemoteRequestTimeoutSniff extends AbstractArrayAssignmentRestrictionsSniff

/**
* Groups of variables to restrict.
* This should be overridden in extending classes.
*
* Example: groups => array(
* 'wpdb' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'variables' => array( '$val', '$var' ),
* 'object_vars' => array( '$foo->bar', .. ),
* 'array_members' => array( '$foo['bar']', .. ),
* )
* 'groupname' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Dont use this one please!',
* 'keys' => array( 'key1', 'another_key' ),
* 'callback' => array( 'class', 'method' ), // Optional.
* )
* )
*
* @return array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function is_html_attr( $content ) {
* A helper function which tests whether string ends with some other.
*
* @param string $haystack String which is being tested.
* @param string $needle The substring, which we try to locate on the end of the $haystack.
* @param string $needle The substring, which we try to locate on the end of the $haystack.
*
* @return bool True if haystack ends with needle.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function process_text_for_style( $stackPtr, $file_name ) {
/**
* Processes this test for T_STYLE tokens in CSS files.
*
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
*
* @return void
*/
Expand Down Expand Up @@ -370,7 +370,7 @@ protected function process_css_style( $stackPtr ) {
/**
* Consolidated violation.
*
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
*/
private function addHidingDetectedError( $stackPtr ) {
$message = 'Hiding of the admin bar is not allowed.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use PHP_CodeSniffer\Files\File;

/**
* Checks the for undefined function variables.
* Checks for undefined function variables.
*
* This sniff checks that all function variables
* are defined in the function body.
Expand Down
8 changes: 4 additions & 4 deletions tests/RulesetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private function collect_phpcs_result() {
/**
* Process the Decoded JSON output from PHP_CodeSniffer.
*
* @param stdClass $output Deconded JSON output from PHP_CodeSniffer.
* @param \stdClass $output Decoded JSON output from PHP_CodeSniffer.
*/
private function process_output( $output ) {
foreach ( $output->files as $file ) {
Expand Down Expand Up @@ -310,9 +310,9 @@ private function check_messages() {
* Print out the message reporting found issues.
*
* @param int $expected Expected number of issues.
* @param string $type The type of the issue.
* @param int $number Real number of issues.
* @param int $line Line number.
* @param string $type The type of the issue.
* @param int $number Real number of issues.
* @param int $line Line number.
*/
private function error_warning_message( $expected, $type, $number, $line ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
Expand Down

0 comments on commit dfa99fd

Please sign in to comment.