Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade PHPCompatibility to 9.3.5+ (9fb3244) #69

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
31 changes: 23 additions & 8 deletions PHPCompatibility/AbstractComplexVersionSniff.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?php
/**
* \PHPCompatibility\AbstractComplexVersionSniff.
* PHPCompatibility, an external standard for PHP_CodeSniffer.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
* @package PHPCompatibility
* @copyright 2012-2019 PHPCompatibility Contributors
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
* @link https://github.com/PHPCompatibility/PHPCompatibility
*/

namespace PHPCompatibility;

use PHP_CodeSniffer_File as File;

/**
* \PHPCompatibility\AbstractComplexVersionSniff.
* Abstract base class for sniffs based on complex arrays with PHP version information.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
* @since 7.1.0
*/
abstract class AbstractComplexVersionSniff extends Sniff implements ComplexVersionInterface
{
Expand All @@ -26,6 +25,8 @@ abstract class AbstractComplexVersionSniff extends Sniff implements ComplexVersi
* Handle the retrieval of relevant information and - if necessary - throwing of an
* error/warning for an item.
*
* @since 7.1.0
*
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the relevant token in
* the stack.
Expand All @@ -47,6 +48,8 @@ public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo)
/**
* Determine whether an error/warning should be thrown for an item based on collected information.
*
* @since 7.1.0
*
* @param array $errorInfo Detail information about an item.
*
* @return bool
Expand All @@ -57,6 +60,8 @@ abstract protected function shouldThrowError(array $errorInfo);
/**
* Get an array of the non-PHP-version array keys used in a sub-array.
*
* @since 7.1.0
*
* @return array
*/
protected function getNonVersionArrayKeys()
Expand All @@ -69,6 +74,8 @@ protected function getNonVersionArrayKeys()
* Retrieve a subset of an item array containing only the array keys which
* contain PHP version information.
*
* @since 7.1.0
*
* @param array $itemArray Version and other information about an item.
*
* @return array Array with only the version information.
Expand All @@ -82,6 +89,8 @@ protected function getVersionArray(array $itemArray)
/**
* Get the item name to be used for the creation of the error code and in the error message.
*
* @since 7.1.0
*
* @param array $itemInfo Base information about the item.
* @param array $errorInfo Detail information about an item.
*
Expand All @@ -96,6 +105,8 @@ protected function getItemName(array $itemInfo, array $errorInfo)
/**
* Get the error message template for a specific sniff.
*
* @since 7.1.0
*
* @return string
*/
abstract protected function getErrorMsgTemplate();
Expand All @@ -104,6 +115,8 @@ abstract protected function getErrorMsgTemplate();
/**
* Allow for concrete child classes to filter the error message before it's passed to PHPCS.
*
* @since 7.1.0
*
* @param string $error The error message which was created.
* @param array $itemInfo Base information about the item this error message applies to.
* @param array $errorInfo Detail information about an item this error message applies to.
Expand All @@ -119,6 +132,8 @@ protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
/**
* Allow for concrete child classes to filter the error data before it's passed to PHPCS.
*
* @since 7.1.0
*
* @param array $data The error data array which was created.
* @param array $itemInfo Base information about the item this error message applies to.
* @param array $errorInfo Detail information about an item this error message applies to.
Expand Down
34 changes: 24 additions & 10 deletions PHPCompatibility/AbstractFunctionCallParameterSniff.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
/**
* \PHPCompatibility\AbstractFunctionCallParameterSniff.
* PHPCompatibility, an external standard for PHP_CodeSniffer.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
* @package PHPCompatibility
* @copyright 2012-2019 PHPCompatibility Contributors
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
* @link https://github.com/PHPCompatibility/PHPCompatibility
*/

namespace PHPCompatibility;
Expand All @@ -14,13 +15,9 @@
use PHP_CodeSniffer_Tokens as Tokens;

/**
* \PHPCompatibility\AbstractFunctionCallParameterSniff.
*
* Abstract class to use as a base for examining the parameter values passed to function calls.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
* @since 8.2.0
*/
abstract class AbstractFunctionCallParameterSniff extends Sniff
{
Expand All @@ -31,6 +28,8 @@ abstract class AbstractFunctionCallParameterSniff extends Sniff
* the method called is of the right class/object.
* Checking that is outside of the scope of this abstract sniff.
*
* @since 8.2.0
*
* @var bool False (default) if the sniff is looking for function calls.
* True if the sniff is looking for method calls.
*/
Expand All @@ -39,6 +38,8 @@ abstract class AbstractFunctionCallParameterSniff extends Sniff
/**
* Functions the sniff is looking for. Should be defined in the child class.
*
* @since 8.2.0
*
* @var array The only requirement for this array is that the top level
* array keys are the names of the functions you're looking for.
* Other than that, the array can have arbitrary content
Expand All @@ -50,6 +51,8 @@ abstract class AbstractFunctionCallParameterSniff extends Sniff
* List of tokens which when they preceed the $stackPtr indicate that this
* is not a function call.
*
* @since 8.2.0
*
* @var array
*/
private $ignoreTokens = array(
Expand All @@ -65,6 +68,8 @@ abstract class AbstractFunctionCallParameterSniff extends Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @since 8.2.0
*
* @return array
*/
public function register()
Expand All @@ -79,11 +84,14 @@ public function register()
/**
* Processes this test, when one of its tokens is encountered.
*
* @since 8.2.0
*
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in
* the stack passed in $tokens.
*
* @return void
* @return int|void Integer stack pointer to skip forward or void to continue
* normal file processing.
*/
public function process(File $phpcsFile, $stackPtr)
{
Expand Down Expand Up @@ -135,6 +143,8 @@ public function process(File $phpcsFile, $stackPtr)
/**
* Do a version check to determine if this sniff needs to run at all.
*
* @since 8.2.0
*
* If the check done in a child class is not specific to one PHP version,
* this function should return `false`.
*
Expand All @@ -148,6 +158,8 @@ abstract protected function bowOutEarly();
*
* This method has to be made concrete in child classes.
*
* @since 8.2.0
*
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the stack.
* @param string $functionName The token content (function name) which was matched.
Expand All @@ -165,6 +177,8 @@ abstract public function processParameters(File $phpcsFile, $stackPtr, $function
* Defaults to doing nothing. Can be overloaded in child classes to handle functions
* were parameters are expected, but none found.
*
* @since 8.2.0
*
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the stack.
* @param string $functionName The token content (function name) which was matched.
Expand Down
23 changes: 15 additions & 8 deletions PHPCompatibility/AbstractNewFeatureSniff.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?php
/**
* \PHPCompatibility\AbstractNewFeatureSniff.
* PHPCompatibility, an external standard for PHP_CodeSniffer.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
* @package PHPCompatibility
* @copyright 2012-2019 PHPCompatibility Contributors
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
* @link https://github.com/PHPCompatibility/PHPCompatibility
*/

namespace PHPCompatibility;

use PHP_CodeSniffer_File as File;

/**
* \PHPCompatibility\AbstractNewFeatureSniff.
* Base class for new feature sniffs.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
* @since 7.1.0
*/
abstract class AbstractNewFeatureSniff extends AbstractComplexVersionSniff
{
Expand All @@ -25,6 +24,8 @@ abstract class AbstractNewFeatureSniff extends AbstractComplexVersionSniff
/**
* Determine whether an error/warning should be thrown for an item based on collected information.
*
* @since 7.1.0
*
* @param array $errorInfo Detail information about an item.
*
* @return bool
Expand All @@ -38,6 +39,8 @@ protected function shouldThrowError(array $errorInfo)
/**
* Retrieve the relevant detail (version) information for use in an error message.
*
* @since 7.1.0
*
* @param array $itemArray Version and other information about the item.
* @param array $itemInfo Base information about the item.
*
Expand Down Expand Up @@ -69,6 +72,8 @@ public function getErrorInfo(array $itemArray, array $itemInfo)
/**
* Get the error message template for this sniff.
*
* @since 7.1.0
*
* @return string
*/
protected function getErrorMsgTemplate()
Expand All @@ -80,6 +85,8 @@ protected function getErrorMsgTemplate()
/**
* Generates the error or warning for this item.
*
* @since 7.1.0
*
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the relevant token in
* the stack.
Expand Down
27 changes: 18 additions & 9 deletions PHPCompatibility/AbstractRemovedFeatureSniff.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?php
/**
* \PHPCompatibility\AbstractRemovedFeatureSniff.
* PHPCompatibility, an external standard for PHP_CodeSniffer.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
* @package PHPCompatibility
* @copyright 2012-2019 PHPCompatibility Contributors
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
* @link https://github.com/PHPCompatibility/PHPCompatibility
*/

namespace PHPCompatibility;

use PHP_CodeSniffer_File as File;

/**
* \PHPCompatibility\AbstractRemovedFeatureSniff.
* Base class for removed feature sniffs.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
* @since 7.1.0
*/
abstract class AbstractRemovedFeatureSniff extends AbstractComplexVersionSniff
{
Expand All @@ -25,6 +24,8 @@ abstract class AbstractRemovedFeatureSniff extends AbstractComplexVersionSniff
/**
* Determine whether an error/warning should be thrown for an item based on collected information.
*
* @since 7.1.0
*
* @param array $errorInfo Detail information about an item.
*
* @return bool
Expand All @@ -40,6 +41,8 @@ protected function shouldThrowError(array $errorInfo)
*
* By default, removed feature version arrays, contain an additional 'alternative' array key.
*
* @since 7.1.0
*
* @return array
*/
protected function getNonVersionArrayKeys()
Expand All @@ -51,6 +54,8 @@ protected function getNonVersionArrayKeys()
/**
* Retrieve the relevant detail (version) information for use in an error message.
*
* @since 7.1.0
*
* @param array $itemArray Version and other information about the item.
* @param array $itemInfo Base information about the item.
*
Expand Down Expand Up @@ -91,6 +96,8 @@ public function getErrorInfo(array $itemArray, array $itemInfo)
/**
* Get the error message template for suggesting an alternative for a specific sniff.
*
* @since 7.1.0
*
* @return string
*/
protected function getAlternativeOptionTemplate()
Expand All @@ -102,6 +109,8 @@ protected function getAlternativeOptionTemplate()
/**
* Generates the error or warning for this item.
*
* @since 7.1.0
*
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the relevant token in
* the stack.
Expand Down Expand Up @@ -132,7 +141,7 @@ public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $err
}

// Remove the last 'and' from the message.
$error = substr($error, 0, (strlen($error) - 5));
$error = substr($error, 0, (\strlen($error) - 5));

if ($errorInfo['alternative'] !== '') {
$error .= $this->getAlternativeOptionTemplate();
Expand Down
Loading