Skip to content

Commit

Permalink
[Rector] Apply Full PHP 7.3 Rector Set List (Skip JsonThrowOnErrorRec…
Browse files Browse the repository at this point in the history
…tor)
  • Loading branch information
samsonasik committed Apr 23, 2021
1 parent 35fc1d0 commit 39a6a06
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
9 changes: 7 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Utils\Rector\PassStrictParameterToFunctionParameterRector;
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;
Expand All @@ -37,6 +38,10 @@
__DIR__ . '/system/Test/bootstrap.php',
]);

$parameters->set(Option::SETS, [
SetList::PHP_73,
]);

// is there a file you need to skip?
$parameters->set(Option::SKIP, [
__DIR__ . '/app/Views',
Expand All @@ -45,6 +50,7 @@
__DIR__ . '/tests/system/Config/fixtures',
__DIR__ . '/tests/_support',
PassStrictParameterToFunctionParameterRector::class => [__DIR__ . '/tests/system/Database/Live/SelectTest.php'],
JsonThrowOnErrorRector::class,
]);

// auto import fully qualified class names
Expand All @@ -61,7 +67,6 @@
$services->set(ForToForeachRector::class);
$services->set(ChangeNestedForeachIfsToEarlyContinueRector::class);
$services->set(ChangeIfElseValueAssignToEarlyReturnRector::class);
$services->set(ArrayKeyFirstLastRector::class);
$services->set(SimplifyStrposLowerRector::class);
$services->set(CombineIfRector::class);
$services->set(SimplifyIfReturnBoolRector::class);
Expand Down
2 changes: 1 addition & 1 deletion system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ protected function loadInNamespace(string $class)
{
$directory = rtrim($directory, '\\/');

if (strpos($class, $namespace) === 0)
if (strpos($class, (string) $namespace) === 0)
{
$filePath = $directory . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, strlen($namespace))) . '.php';
$filename = $this->includeFile($filePath);
Expand Down
2 changes: 1 addition & 1 deletion system/CLI/GeneratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected function qualifyClassName(): string
$class = $matches[1] . ucfirst($matches[2]);
}

if ($this->enabledSuffixing && $this->getOption('suffix') && ! strripos($class, $component))
if ($this->enabledSuffixing && $this->getOption('suffix') && ! strripos($class, (string) $component))
{
$class .= ucfirst($component);
}
Expand Down
2 changes: 1 addition & 1 deletion system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ protected function getEncoding()

foreach ($this->baseCharsets as $charset)
{
if (strpos($this->charset, $charset) === 0)
if (strpos($this->charset, (string) $charset) === 0)
{
$this->encoding = '7bit';

Expand Down
6 changes: 3 additions & 3 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,14 @@ protected function parseRequestURI(): string
if (isset($_SERVER['SCRIPT_NAME'][0]) && pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_EXTENSION) === 'php')
{
// strip the script name from the beginning of the URI
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0 && strpos($uri, '/index.php') === 0)
if (strpos($uri, (string) $_SERVER['SCRIPT_NAME']) === 0 && strpos($uri, '/index.php') === 0)
{
$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
// if the script is nested, strip the parent folder & script from the URI
elseif (strpos($uri, $_SERVER['SCRIPT_NAME']) > 0)
elseif (strpos($uri, (string) $_SERVER['SCRIPT_NAME']) > 0)
{
$uri = (string) substr($uri, strpos($uri, $_SERVER['SCRIPT_NAME']) + strlen($_SERVER['SCRIPT_NAME']));
$uri = (string) substr($uri, strpos($uri, (string) $_SERVER['SCRIPT_NAME']) + strlen($_SERVER['SCRIPT_NAME']));
}
// or if index.php is implied
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function getIPAddress(): string
}

// If the proxy entry doesn't match the IP protocol - skip it
if (strpos($proxyIP, $separator) === false)
if (strpos($proxyIP, (string) $separator) === false)
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ protected function fillRouteParams(string $from, array $params = null): string

// Ensure that the param we're inserting matches
// the expected param type.
$pos = strpos($from, $pattern);
$pos = strpos($from, (string) $pattern);
$from = substr_replace($from, $params[$index], $pos, strlen($pattern));
}

Expand Down

0 comments on commit 39a6a06

Please sign in to comment.