Skip to content

Commit

Permalink
Bump Symplify and PHPStan rules version (#2218)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
TomasVotruba and actions-user committed May 3, 2022
1 parent c4e1ee2 commit 0052951
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"phpstan/phpstan-strict-rules": "^1.1",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^9.5",
"rector/phpstan-rules": "^0.4.24",
"rector/phpstan-rules": "^0.5.0",
"spatie/enum": "^3.13",
"symplify/coding-standard": "^10.2",
"symplify/easy-ci": "^10.2",
Expand Down
4 changes: 2 additions & 2 deletions config/phpstan/static-reflection.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ parameters:
disableRuntimeReflectionProvider: false

conditionalTags:
PhpParser\NodeVisitor\NodeConnectingVisitor:
phpstan.parser.richParserNodeVisitor: true
PhpParser\NodeVisitor\NodeConnectingVisitor:
phpstan.parser.richParserNodeVisitor: true

services:
- Rector\NodeTypeResolver\Reflection\BetterReflection\RectorBetterReflectionSourceLocatorFactory
Expand Down
2 changes: 1 addition & 1 deletion rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function refactor(Node $node): ?Node
/** @var Arg $secondArg */
$secondArg = $node->args[1];
$typeNode = $this->valueResolver->getValue($secondArg->value);
if ($typeNode === null) {
if (! is_string($typeNode)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function refactor(Node $node): ?Node
function (array $matches): string {
$output = '';

$output .= isset($matches[1]) ? strtolower($matches[1]) : '';
$output .= isset($matches[1]) ? strtolower((string) $matches[1]) : '';
$output .= $matches[2] ?? '';

return $output . ($matches[3] ?? '');
Expand Down
28 changes: 14 additions & 14 deletions rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ final class NullToStrictStringFuncCallArgRector extends AbstractRector implement
* @var array<string, string[]>
*/
private const ARG_POSITION_NAME_NULL_TO_STRICT_STRING = [
'preg_split' => ['subject'],
'preg_match' => ['subject'],
'preg_match_all' => ['subject'],
'explode' => ['string'],
'strlen' => ['string'],
'str_contains' => ['haystack', 'needle'],
'strtotime' => ['datetime'],
'str_replace' => ['subject'],
'substr' => ['string'],
'str_starts_with' => ['haystack', 'needle'],
'strtoupper' => ['string'],
'strtolower' => ['string'],
'strpos' => ['haystack', 'needle'],
'stripos' => ['haystack', 'needle'],
'preg_split' => ['subject'],
'preg_match' => ['subject'],
'preg_match_all' => ['subject'],
'explode' => ['string'],
'strlen' => ['string'],
'str_contains' => ['haystack', 'needle'],
'strtotime' => ['datetime'],
'str_replace' => ['subject'],
'substr' => ['string'],
'str_starts_with' => ['haystack', 'needle'],
'strtoupper' => ['string'],
'strtolower' => ['string'],
'strpos' => ['haystack', 'needle'],
'stripos' => ['haystack', 'needle'],
];

public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function create(Expr $expr, string $classWithConstants, bool $caseInsensi
$constantNamesToValues = $this->classConstantsResolver->getClassConstantNamesToValues($classWithConstants);
foreach ($constantNamesToValues as $constantName => $constantValue) {
if ($caseInsensitive) {
$constantValue = strtolower($constantValue);
$value = strtolower($value);
$constantValue = strtolower((string) $constantValue);
$value = strtolower((string) $value);
}

if ($constantValue !== $value) {
Expand Down
4 changes: 3 additions & 1 deletion src/Util/StaticRectorStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public static function camelCaseToUnderscore(string $input): string
$matches = Strings::matchAll($input, self::CAMEL_CASE_SPLIT_REGEX);
$parts = [];
foreach ($matches as $match) {
$parts[] = $match[0] === strtoupper($match[0]) ? strtolower($match[0]) : lcfirst($match[0]);
$matchedPart = (string) $match[0];

$parts[] = $matchedPart === strtoupper($matchedPart) ? strtolower($matchedPart) : lcfirst($matchedPart);
}

return implode('_', $parts);
Expand Down

0 comments on commit 0052951

Please sign in to comment.