mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
[Rector] Re-run InlineIfToExplicitIfRector on Latest Rector 0.11.36
This commit is contained in:
parent
02ac2de62d
commit
ac19c85ed0
@ -20,10 +20,10 @@
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"nexusphp/cs-config": "^3.1",
|
||||
"nexusphp/tachycardia": "^1.0",
|
||||
"phpstan/phpstan": "0.12.90",
|
||||
"phpstan/phpstan": "0.12.91",
|
||||
"phpunit/phpunit": "^9.1",
|
||||
"predis/predis": "^1.1",
|
||||
"rector/rector": "0.11.35",
|
||||
"rector/rector": "0.11.36",
|
||||
"symplify/package-builder": "^9.3"
|
||||
},
|
||||
"suggest": {
|
||||
|
@ -61,6 +61,10 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
PassStrictParameterToFunctionParameterRector::class => [__DIR__ . '/tests/system/Database/Live/SelectTest.php'],
|
||||
JsonThrowOnErrorRector::class,
|
||||
StringifyStrNeedlesRector::class,
|
||||
InlineIfToExplicitIfRector::class => [
|
||||
__DIR__ . '/app/Config',
|
||||
__DIR__ . '/system/Test/bootstrap.php',
|
||||
],
|
||||
]);
|
||||
|
||||
// auto import fully qualified class names
|
||||
|
@ -239,7 +239,9 @@ class CodeIgniter
|
||||
|
||||
$file = SYSTEMPATH . 'ThirdParty/Kint/' . implode('/', $class) . '.php';
|
||||
|
||||
file_exists($file) && require_once $file;
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
}
|
||||
});
|
||||
|
||||
require_once SYSTEMPATH . 'ThirdParty/Kint/init.php';
|
||||
@ -476,7 +478,9 @@ class CodeIgniter
|
||||
protected function detectEnvironment()
|
||||
{
|
||||
// Make sure ENVIRONMENT isn't already set by other means.
|
||||
defined('ENVIRONMENT') || define('ENVIRONMENT', $_SERVER['CI_ENVIRONMENT'] ?? 'production'); // @codeCoverageIgnore
|
||||
if (!defined('ENVIRONMENT')) {
|
||||
define('ENVIRONMENT', $_SERVER['CI_ENVIRONMENT'] ?? 'production');
|
||||
} // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -151,7 +151,9 @@ abstract class BaseResult implements ResultInterface
|
||||
return $this->customResultObject[$className];
|
||||
}
|
||||
|
||||
$this->rowData === null || $this->dataSeek();
|
||||
if ($this->rowData !== null) {
|
||||
$this->dataSeek();
|
||||
}
|
||||
$this->customResultObject[$className] = [];
|
||||
|
||||
while ($row = $this->fetchObject($className)) {
|
||||
@ -196,7 +198,9 @@ abstract class BaseResult implements ResultInterface
|
||||
return $this->resultArray;
|
||||
}
|
||||
|
||||
$this->rowData === null || $this->dataSeek();
|
||||
if ($this->rowData !== null) {
|
||||
$this->dataSeek();
|
||||
}
|
||||
|
||||
while ($row = $this->fetchAssoc()) {
|
||||
$this->resultArray[] = $row;
|
||||
@ -235,7 +239,9 @@ abstract class BaseResult implements ResultInterface
|
||||
return $this->resultObject;
|
||||
}
|
||||
|
||||
$this->rowData === null || $this->dataSeek();
|
||||
if ($this->rowData !== null) {
|
||||
$this->dataSeek();
|
||||
}
|
||||
|
||||
while ($row = $this->fetchObject()) {
|
||||
if (! is_subclass_of($row, Entity::class) && method_exists($row, 'syncOriginal')) {
|
||||
@ -303,7 +309,9 @@ abstract class BaseResult implements ResultInterface
|
||||
*/
|
||||
public function getCustomRowObject(int $n, string $className)
|
||||
{
|
||||
isset($this->customResultObject[$className]) || $this->getCustomResultObject($className);
|
||||
if (!isset($this->customResultObject[$className])) {
|
||||
$this->getCustomResultObject($className);
|
||||
}
|
||||
|
||||
if (empty($this->customResultObject[$className])) {
|
||||
return null;
|
||||
|
@ -905,8 +905,9 @@ class Forge
|
||||
continue;
|
||||
}
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
isset($attributes['TYPE']) && $this->_attributeType($attributes);
|
||||
if (isset($attributes['TYPE'])) {
|
||||
$this->_attributeType($attributes);
|
||||
}
|
||||
|
||||
$field = [
|
||||
'name' => $key,
|
||||
@ -921,8 +922,9 @@ class Forge
|
||||
'_literal' => false,
|
||||
];
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
isset($attributes['TYPE']) && $this->_attributeUnsigned($attributes, $field);
|
||||
if (isset($attributes['TYPE'])) {
|
||||
$this->_attributeUnsigned($attributes, $field);
|
||||
}
|
||||
|
||||
if ($createTable === false) {
|
||||
if (isset($attributes['AFTER'])) {
|
||||
|
@ -136,8 +136,9 @@ class Connection extends BaseConnection
|
||||
if (! empty($ssl)) {
|
||||
if (isset($this->encrypt['ssl_verify'])) {
|
||||
if ($this->encrypt['ssl_verify']) {
|
||||
defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT')
|
||||
&& $this->mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, 1);
|
||||
if (defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT')) {
|
||||
$this->mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, 1);
|
||||
}
|
||||
}
|
||||
// Apparently (when it exists), setting MYSQLI_OPT_SSL_VERIFY_SERVER_CERT
|
||||
// to FALSE didn't do anything, so PHP 5.6.16 introduced yet another
|
||||
|
@ -75,7 +75,9 @@ class Connection extends BaseConnection
|
||||
return false;
|
||||
}
|
||||
|
||||
empty($this->schema) || $this->simpleQuery("SET search_path TO {$this->schema},public");
|
||||
if (!empty($this->schema)) {
|
||||
$this->simpleQuery("SET search_path TO {$this->schema},public");
|
||||
}
|
||||
|
||||
if ($this->setClientEncoding($this->charset) === false) {
|
||||
return false;
|
||||
|
@ -2256,7 +2256,9 @@ class Email
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
is_resource($this->SMTPConnect) && $this->sendCommand('quit');
|
||||
if (is_resource($this->SMTPConnect)) {
|
||||
$this->sendCommand('quit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,7 +219,9 @@ class MemcachedHandler extends BaseHandler
|
||||
public function close(): bool
|
||||
{
|
||||
if (isset($this->memcached)) {
|
||||
isset($this->lockKey) && $this->memcached->delete($this->lockKey);
|
||||
if (isset($this->lockKey)) {
|
||||
$this->memcached->delete($this->lockKey);
|
||||
}
|
||||
|
||||
if (! $this->memcached->quit()) {
|
||||
return false;
|
||||
|
@ -231,7 +231,9 @@ class RedisHandler extends BaseHandler
|
||||
$pingReply = $this->redis->ping();
|
||||
// @phpstan-ignore-next-line
|
||||
if (($pingReply === true) || ($pingReply === '+PONG')) {
|
||||
isset($this->lockKey) && $this->redis->del($this->lockKey);
|
||||
if (isset($this->lockKey)) {
|
||||
$this->redis->del($this->lockKey);
|
||||
}
|
||||
|
||||
if (! $this->redis->close()) {
|
||||
return false;
|
||||
|
@ -28,8 +28,12 @@ final class CommandGeneratorTest extends CIUnitTestCase
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
$dir = dirname($file);
|
||||
|
||||
is_file($file) && unlink($file);
|
||||
is_dir($dir) && strpos($dir, 'Commands') !== false && rmdir($dir);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
if (is_dir($dir) && strpos($dir, 'Commands') !== false) {
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFileContents(string $filepath): string
|
||||
|
@ -26,7 +26,9 @@ final class ConfigGeneratorTest extends CIUnitTestCase
|
||||
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateConfig()
|
||||
|
@ -35,7 +35,9 @@ final class ConfigurableSortImportsTest extends CIUnitTestCase
|
||||
$this->assertStringContainsString('File created: ', CITestStreamFilter::$buffer);
|
||||
$this->assertFileExists($file);
|
||||
$this->assertNotSame(sha1_file(SUPPORTPATH . 'Commands/Foobar.php'), sha1_file($file));
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testEnabledSortImportsWillDisruptLanguageFilePublish()
|
||||
@ -46,9 +48,13 @@ final class ConfigurableSortImportsTest extends CIUnitTestCase
|
||||
$this->assertStringContainsString('File created: ', CITestStreamFilter::$buffer);
|
||||
$this->assertFileExists($file);
|
||||
$this->assertNotSame(sha1_file(SUPPORTPATH . 'Commands/Foobar.php'), sha1_file($file));
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
$dir = dirname($file);
|
||||
is_dir($dir) && rmdir($dir);
|
||||
if (is_dir($dir)) {
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
public function testDisabledSortImportsWillNotAffectLanguageFilesPublish()
|
||||
@ -59,8 +65,12 @@ final class ConfigurableSortImportsTest extends CIUnitTestCase
|
||||
$this->assertStringContainsString('File created: ', CITestStreamFilter::$buffer);
|
||||
$this->assertFileExists($file);
|
||||
$this->assertSame(sha1_file(SUPPORTPATH . 'Commands/Foobar.php'), sha1_file($file));
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
$dir = dirname($file);
|
||||
is_dir($dir) && rmdir($dir);
|
||||
if (is_dir($dir)) {
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,9 @@ final class ControllerGeneratorTest extends CIUnitTestCase
|
||||
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFileContents(string $filepath): string
|
||||
|
@ -27,8 +27,12 @@ final class EntityGeneratorTest extends CIUnitTestCase
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
$dir = dirname($file);
|
||||
is_file($file) && unlink($file);
|
||||
is_dir($dir) && rmdir($dir);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
if (is_dir($dir)) {
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateEntity()
|
||||
|
@ -26,7 +26,9 @@ final class FilterGeneratorTest extends CIUnitTestCase
|
||||
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateFilter()
|
||||
|
@ -30,7 +30,9 @@ final class GeneratorsTest extends CIUnitTestCase
|
||||
command('make:seeder categories');
|
||||
$this->assertStringContainsString('File created: ', CITestStreamFilter::$buffer);
|
||||
$file = APPPATH . 'Database/Seeds/Categories.php';
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateFileExists()
|
||||
@ -41,7 +43,9 @@ final class GeneratorsTest extends CIUnitTestCase
|
||||
command('make:filter items');
|
||||
$this->assertStringContainsString('File exists: ', CITestStreamFilter::$buffer);
|
||||
$file = APPPATH . 'Filters/Items.php';
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateFileOverwritten()
|
||||
@ -52,7 +56,9 @@ final class GeneratorsTest extends CIUnitTestCase
|
||||
command('make:controller products -force');
|
||||
$this->assertStringContainsString('File overwritten: ', CITestStreamFilter::$buffer);
|
||||
$file = APPPATH . 'Controllers/Products.php';
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateFileFailsOnUnwritableDirectory()
|
||||
@ -82,8 +88,12 @@ final class GeneratorsTest extends CIUnitTestCase
|
||||
$dir = dirname($file);
|
||||
$this->assertFileExists($file);
|
||||
$this->assertDirectoryExists($dir);
|
||||
is_file($file) && unlink($file);
|
||||
is_dir($dir) && rmdir($dir);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
if (is_dir($dir)) {
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSuffixingHasNoEffect(): void
|
||||
@ -96,8 +106,14 @@ final class GeneratorsTest extends CIUnitTestCase
|
||||
$this->assertFileExists($file1);
|
||||
$this->assertFileDoesNotExist($file2);
|
||||
|
||||
is_file($file1) && unlink($file1);
|
||||
is_file($file2) && unlink($file2);
|
||||
is_dir($dir) && rmdir($dir);
|
||||
if (is_file($file1)) {
|
||||
unlink($file1);
|
||||
}
|
||||
if (is_file($file2)) {
|
||||
unlink($file2);
|
||||
}
|
||||
if (is_dir($dir)) {
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,9 @@ final class MigrationGeneratorTest extends CIUnitTestCase
|
||||
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
file_exists($file) && unlink($file);
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateMigration()
|
||||
|
@ -26,7 +26,9 @@ final class ModelGeneratorTest extends CIUnitTestCase
|
||||
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFileContent(string $filepath): string
|
||||
@ -93,12 +95,18 @@ final class ModelGeneratorTest extends CIUnitTestCase
|
||||
$file = APPPATH . 'Models/User.php';
|
||||
$this->assertFileExists($file);
|
||||
$this->assertStringContainsString('protected $returnType = \'App\Entities\User\';', $this->getFileContent($file));
|
||||
is_file($file) && unlink($file);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
$file = APPPATH . 'Entities/User.php';
|
||||
$this->assertFileExists($file);
|
||||
$dir = dirname($file);
|
||||
is_file($file) && unlink($file);
|
||||
is_dir($dir) && rmdir($dir);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
if (is_dir($dir)) {
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateModelWithOptionSuffix()
|
||||
|
@ -26,7 +26,9 @@ final class SeederGeneratorTest extends CIUnitTestCase
|
||||
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
file_exists($file) && unlink($file);
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateSeeder()
|
||||
|
@ -28,7 +28,9 @@ final class SessionsCommandsTest extends CIUnitTestCase
|
||||
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
file_exists($file) && unlink($file);
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCreateMigrationCommand()
|
||||
|
@ -27,8 +27,12 @@ final class ValidationGeneratorTest extends CIUnitTestCase
|
||||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
|
||||
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
|
||||
$dir = dirname($file);
|
||||
is_file($file) && unlink($file);
|
||||
is_dir($dir) && rmdir($dir);
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
if (is_dir($dir)) {
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGenerateValidation()
|
||||
|
@ -71,7 +71,9 @@ final class FileMovingTest extends CIUnitTestCase
|
||||
$destination = $this->destination;
|
||||
|
||||
// Create the destination if not exists
|
||||
is_dir($destination) || mkdir($destination, 0777, true);
|
||||
if (!is_dir($destination)) {
|
||||
mkdir($destination, 0777, true);
|
||||
}
|
||||
|
||||
foreach ($collection->all() as $file) {
|
||||
$this->assertInstanceOf(UploadedFile::class, $file);
|
||||
@ -121,7 +123,9 @@ final class FileMovingTest extends CIUnitTestCase
|
||||
$destination = $this->destination;
|
||||
|
||||
// Create the destination if not exists
|
||||
is_dir($destination) || mkdir($destination, 0777, true);
|
||||
if (!is_dir($destination)) {
|
||||
mkdir($destination, 0777, true);
|
||||
}
|
||||
|
||||
foreach ($collection->all() as $file) {
|
||||
$this->assertInstanceOf(UploadedFile::class, $file);
|
||||
@ -157,7 +161,9 @@ final class FileMovingTest extends CIUnitTestCase
|
||||
$destination = $this->destination;
|
||||
|
||||
// Create the destination if not exists
|
||||
is_dir($destination) || mkdir($destination, 0777, true);
|
||||
if (!is_dir($destination)) {
|
||||
mkdir($destination, 0777, true);
|
||||
}
|
||||
|
||||
$file = $collection->getFile('userfile1');
|
||||
|
||||
@ -190,7 +196,9 @@ final class FileMovingTest extends CIUnitTestCase
|
||||
$destination = $this->destination;
|
||||
|
||||
// Create the destination if not exists
|
||||
is_dir($destination) || mkdir($destination, 0777, true);
|
||||
if (!is_dir($destination)) {
|
||||
mkdir($destination, 0777, true);
|
||||
}
|
||||
|
||||
$file = $collection->getFile('userfile1');
|
||||
|
||||
@ -222,7 +230,9 @@ final class FileMovingTest extends CIUnitTestCase
|
||||
$destination = $this->destination;
|
||||
|
||||
// Create the destination if not exists
|
||||
is_dir($destination) || mkdir($destination, 0777, true);
|
||||
if (!is_dir($destination)) {
|
||||
mkdir($destination, 0777, true);
|
||||
}
|
||||
|
||||
$this->expectException(HTTPException::class);
|
||||
|
||||
@ -272,7 +282,9 @@ final class FileMovingTest extends CIUnitTestCase
|
||||
$destination = $this->destination;
|
||||
|
||||
// Create the destination and make it read only
|
||||
is_dir($destination) || mkdir($destination, 0400, true);
|
||||
if (!is_dir($destination)) {
|
||||
mkdir($destination, 0400, true);
|
||||
}
|
||||
|
||||
$collection = new FileCollection();
|
||||
$file = $collection->getFile('userfile');
|
||||
|
Loading…
x
Reference in New Issue
Block a user