Skip to content

Commit

Permalink
Fix rector changes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Dec 14, 2024
1 parent d59cf6e commit e8e2c9f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 21 deletions.
2 changes: 0 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
Expand Down Expand Up @@ -152,7 +151,6 @@
__DIR__ . '/system/Security/Security.php',
__DIR__ . '/system/Session/Session.php',
],
MixedTypeRector::class,

ReturnNeverTypeRector::class => [
__DIR__ . '/system/Cache/Handlers/BaseHandler.php',
Expand Down
2 changes: 1 addition & 1 deletion system/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function start()
if (! isset($_SESSION['__ci_last_regenerate'])) {
$_SESSION['__ci_last_regenerate'] = Time::now()->getTimestamp();
} elseif ($_SESSION['__ci_last_regenerate'] < (Time::now()->getTimestamp() - $regenerateTime)) {
$this->regenerate((bool) $this->config->regenerateDestroy);
$this->regenerate($this->config->regenerateDestroy);
}
}
// Another work-around ... PHP doesn't seem to send the session cookie
Expand Down
10 changes: 3 additions & 7 deletions tests/system/Debug/ExceptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,10 @@ public function testDeprecationsOnPhp81DoNotThrow(): void
$this->exception = new Exceptions($config);
$this->exception->initialize();

// this is only needed for IDEs not to complain that strlen does not accept explicit null
$maybeNull = PHP_VERSION_ID >= 80100 ? null : 'random string';

try {
// We test DEPRECATED error, so cannot set `declare(strict_types=1)` in this file.
strlen($maybeNull);
$this->assertLogContains('error', '[DEPRECATED] strlen(): ');
} catch (ErrorException $e) {
$result = str_contains('foobar', null); // @phpstan-ignore argument.type (Needed for testing)
$this->assertLogContains('error', '[DEPRECATED] str_contains(): ');
} catch (ErrorException) {
$this->fail('The catch block should not be reached.');
} finally {
restore_error_handler();
Expand Down
8 changes: 0 additions & 8 deletions utils/phpstan-baseline/function.resultUnused.neon

This file was deleted.

1 change: 0 additions & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ includes:
- function.alreadyNarrowedType.neon
- function.inner.neon
- function.notFound.neon
- function.resultUnused.neon
- generator.returnType.neon
- generator.valueType.neon
- greaterOrEqual.invalid.neon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Utils\Rector;

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ErrorSuppress;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Function_;
Expand Down Expand Up @@ -60,7 +61,7 @@ public function refactor(Node $node): ?Node

$this->traverseNodesWithCallable(
$node->stmts,
static function (Node $subNode) use (&$hasChanged) {
static function (Node $subNode) use (&$hasChanged): int|Expr|null {
if ($subNode instanceof Class_ || $subNode instanceof Function_) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private function updateDocblock(string $variableName, string $camelCaseName, ?Fu
}

$docComment = $functionLike->getDocComment();
if ($docComment === null) {
if (! $docComment instanceof Doc) {
return;
}

Expand Down

0 comments on commit e8e2c9f

Please sign in to comment.