Skip to content

Commit

Permalink
chore(deps): update phpstan packages to v2 (major) (#149)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
renovate[bot] authored Nov 11, 2024
1 parent e98b1e6 commit f35911f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
},
"require-dev": {
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpstan/phpstan": "^2.0.0",
"phpstan/phpstan-phpunit": "^2.0.0",
"phpstan/phpstan-strict-rules": "^2.0.0",
"phpunit/phpunit": "^11.0"
},
"config": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function register(): array
*/
public function process(File $phpcsFile, $stackPtr): void
{
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();

if ($tokens[$stackPtr]['code'] === T_CONST) {
Expand Down
3 changes: 3 additions & 0 deletions src/Cdn77/Sniffs/NamingConventions/ValidVariableNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ValidVariableNameSniff extends AbstractVariableSniff
*/
protected function processVariable(File $phpcsFile, $stackPtr): void
{
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();
$varName = ltrim($tokens[$stackPtr]['content'], '$');

Expand Down Expand Up @@ -105,6 +106,7 @@ protected function processVariable(File $phpcsFile, $stackPtr): void
*/
protected function processMemberVar(File $phpcsFile, $stackPtr): void
{
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();

$varName = ltrim($tokens[$stackPtr]['content'], '$');
Expand Down Expand Up @@ -137,6 +139,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr): void
*/
protected function processVariableInString(File $phpcsFile, $stackPtr): void
{
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private function fix(File $file, array $namesWithValues): void
private function findConstantNamesWithValuesByVisibility(File $phpcsFile): array
{
$constantNamesWithValues = [];
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();

foreach ($tokens as $stackPtr => $token) {
Expand Down Expand Up @@ -177,6 +178,7 @@ private function findConstantNamesWithValuesByVisibility(File $phpcsFile): array

private function getVisibility(File $phpcsFile, int $constStackPtr): string
{
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();
$visibilityTokenPointer = $phpcsFile->findPrevious(
types: Tokens::$emptyTokens,
Expand All @@ -186,13 +188,14 @@ private function getVisibility(File $phpcsFile, int $constStackPtr): string
);

return in_array($tokens[$visibilityTokenPointer]['code'], [T_PUBLIC, T_PROTECTED, T_PRIVATE], true)
? (string) $tokens[$visibilityTokenPointer]['content']
? $tokens[$visibilityTokenPointer]['content']
: 'public';
}

/** @phpstan-return TypeNameShape|null */
private function findTypeAndConstantName(File $phpcsFile, int $constStackPtr): array|null
{
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();
$assignmentOperatorTokenPtr = $phpcsFile->findNext(
types: [T_EQUAL, T_SEMICOLON],
Expand Down Expand Up @@ -241,6 +244,7 @@ private function findTypeAndConstantName(File $phpcsFile, int $constStackPtr): a

private function findEqualsPointer(File $phpcsFile, int $constNameStackPtr): int|null
{
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();
$equalsTokenPointer = $phpcsFile->findNext(
types: Tokens::$emptyTokens,
Expand All @@ -259,6 +263,7 @@ private function findEqualsPointer(File $phpcsFile, int $constNameStackPtr): int
/** @phpstan-return ValueShape|null */
private function findValue(File $phpcsFile, int $equalsTokenPointer): array|null
{
/** @var array<int, array{code: int|string, content: string}> $tokens */
$tokens = $phpcsFile->getTokens();
$startValueTokenPointer = $phpcsFile->findNext(
types: Tokens::$emptyTokens,
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected static function checkFile(string $filePath, array $sniffProperties = [

private static function getSniffClassReflection(): ReflectionClass
{
/** @var array<string, ReflectionClass<object>> $reflections */
static $reflections = [];

$className = static::getSniffClassName();
Expand Down

0 comments on commit f35911f

Please sign in to comment.