Skip to content

Commit

Permalink
rector
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Dec 16, 2024
1 parent 9d65963 commit bd91142
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
12 changes: 11 additions & 1 deletion .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

declare(strict_types=1);

use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
#__DIR__ . '/tests',
])
->withSkip([
MakeInheritedMethodVisibilitySameAsParentRector::class => [
__DIR__ . '/src/N98/Magento/Application.php',
],
RemoveAlwaysTrueIfConditionRector::class => [
__DIR__ . '/src/N98/Magento/Initializer.php',
],
])
->withPreparedSets(
true,
Expand Down
2 changes: 1 addition & 1 deletion src/N98/Magento/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ private function setRootDir(string $path): void
protected function _initMagento1(bool $soft = false): void
{
// Load Mage class definition
Initialiser::bootstrap($this->_magentoRootFolder);
Initializer::bootstrap($this->_magentoRootFolder);

// skip Mage::app init routine and return
if ($soft) {
Expand Down
2 changes: 1 addition & 1 deletion src/N98/Magento/Command/Database/Compressor/Gzip.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getDecompressingCommand(string $command, string $fileName, bool

public function getFileName(string $fileName, bool $pipe = true): string
{
if ((string) $fileName === '') {
if ($fileName === '') {
return $fileName;
}

Expand Down
9 changes: 1 addition & 8 deletions src/N98/Magento/Command/Database/Compressor/Uncompressed.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,9 @@ public function getDecompressingCommand(string $command, string $fileName, bool
return $command . ' < ' . $fileName;
}

/**
* Returns the file name for the compressed dump file.
*
* @param string $fileName
* @param bool $pipe
* @return string
*/
public function getFileName(string $fileName, bool $pipe = true): string
{
if ((string) $fileName === '') {
if ($fileName === '') {
return $fileName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function checkSettings(Result $result, ?Mage_Core_Model_Store $mageCor
$host = parse_url($baseUrl, PHP_URL_HOST);
$isValid = (bool) strstr($host, '.');

$storeCode = $mageCoreModelStore ? $mageCoreModelStore->getCode() : 'n/a';
$storeCode = $mageCoreModelStore instanceof Mage_Core_Model_Store ? $mageCoreModelStore->getCode() : 'n/a';

$result->setStatus($isValid);
if ($isValid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function initConfigPaths(): void
protected function checkSettings(Result $result, ?Mage_Core_Model_Store $mageCoreModelStore, string $baseUrl, ?string $cookieDomain): void
{
$errorMessage = 'cookie-domain and ' . $this->class . ' base-URL do not match';
$websiteCode = $mageCoreModelStore ? $mageCoreModelStore->getCode() : '';
$websiteCode = $mageCoreModelStore instanceof Mage_Core_Model_Store ? $mageCoreModelStore->getCode() : '';

if ($cookieDomain && strlen($cookieDomain) !== 0) {
$isValid = $this->validateCookieDomainAgainstUrl($cookieDomain, $baseUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

declare(strict_types=1);

/**
* this file is part of magerun
*
* @author Tom Klingenberg <https://github.com/ktomk>
*/

namespace N98\Magento;

use N98\Util\AutoloadRestorer;
Expand All @@ -20,7 +14,7 @@
*
* @author Tom Klingenberg (https://github.com/ktomk)
*/
class Initialiser
class Initializer
{
/**
* Mage filename
Expand Down Expand Up @@ -50,8 +44,8 @@ public function __construct(string $magentoPath)
*/
public static function bootstrap(string $magentoPath): void
{
$initialiser = new Initialiser($magentoPath);
$initialiser->requireMage();
$initializer = new Initializer($magentoPath);
$initializer->requireMage();
}

/**
Expand All @@ -67,7 +61,7 @@ public function requireMage(): void

$this->requireOnce();

# @phpstan-ignore booleanNot.alwaysTrue
// @phpstan-ignore booleanNot.alwaysTrue
if (!class_exists(self::CLASS_MAGE, false)) {
throw new RuntimeException(sprintf('Failed to load definition of "%s" class', self::CLASS_MAGE));
}
Expand Down
2 changes: 1 addition & 1 deletion src/N98/Util/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ public static function humanFileSize(int $bytes, int $decimals = 2): string
$units = ['B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
$factor = floor((strlen((string) $bytes) - 1) / 3);

return sprintf("%.{$decimals}f%s", $bytes / 1024 ** $factor, $units[$factor]);
return sprintf('%.' . $decimals . 'f%s', $bytes / 1024 ** $factor, $units[$factor]);
}
}

0 comments on commit bd91142

Please sign in to comment.