Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add CompleteDynamicPropertiesRector #6187

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
Expand Down Expand Up @@ -160,4 +161,5 @@
'SQLite3',
]);
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
};
1 change: 1 addition & 0 deletions tests/system/CLI/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
final class ConsoleTest extends CIUnitTestCase
{
private DotEnv $env;
private $stream_filter;

protected function setUp(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/system/CommonFunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace CodeIgniter;

use CodeIgniter\Config\BaseService;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\URI;
Expand Down Expand Up @@ -43,6 +44,9 @@
*/
final class CommonFunctionsTest extends CIUnitTestCase
{
private ?App $config = null;
private IncomingRequest $request;

protected function setUp(): void
{
unset($_ENV['foo'], $_SERVER['foo']);
Expand Down
3 changes: 3 additions & 0 deletions tests/system/Config/DotEnvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use CodeIgniter\Test\CIUnitTestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

/**
* @backupGlobals enabled
Expand All @@ -23,6 +24,8 @@
*/
final class DotEnvTest extends CIUnitTestCase
{
private ?vfsStreamDirectory $root;
private string $path;
private $fixturesFolder;

protected function setUp(): void
Expand Down
2 changes: 2 additions & 0 deletions tests/system/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
final class ControllerTest extends CIUnitTestCase
{
private App $config;

/**
* @var Controller
*/
Expand Down
6 changes: 4 additions & 2 deletions tests/system/Database/Live/MetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace CodeIgniter\Database\Live;

use CodeIgniter\Database\Forge;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use Config\Database;
Expand All @@ -25,8 +26,9 @@ final class MetadataTest extends CIUnitTestCase
{
use DatabaseTestTrait;

protected $refresh = true;
protected $seed = CITestSeeder::class;
private ?Forge $forge = null;
protected $refresh = true;
protected $seed = CITestSeeder::class;

/**
* Array of expected tables.
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Events/EventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class EventsTest extends CIUnitTestCase
/**
* Accessible event manager instance
*/
private MockEvents $manager;
private Events $manager;

protected function setUp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
final class CURLRequestDoNotShareOptionsTest extends CIUnitTestCase
{
private MockCURLRequest $request;
private CURLRequest $request;

protected function setUp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/system/HTTP/CURLRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
final class CURLRequestTest extends CIUnitTestCase
{
private MockCURLRequest $request;
private CURLRequest $request;

protected function setUp(): void
{
Expand Down
3 changes: 3 additions & 0 deletions tests/system/HTTP/ContentSecurityPolicyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
*/
final class ContentSecurityPolicyTest extends CIUnitTestCase
{
private ?Response $response = null;
private ?ContentSecurityPolicy $csp = null;

// Having this method as setUp() doesn't work - can't find Config\App !?
protected function prepare(bool $CSPEnabled = true)
{
Expand Down
6 changes: 6 additions & 0 deletions tests/system/HTTP/Files/FileMovingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
use CodeIgniter\HTTP\Exceptions\HTTPException;
use CodeIgniter\Test\CIUnitTestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

/**
* @internal
*/
final class FileMovingTest extends CIUnitTestCase
{
private ?vfsStreamDirectory $root;
private string $path;
private string $start;
private string $destination;

protected function setUp(): void
{
parent::setUp();
Expand Down
1 change: 1 addition & 0 deletions tests/system/Helpers/CookieHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/
final class CookieHelperTest extends CIUnitTestCase
{
private IncomingRequest $request;
private $name;
private string $value;
private int $expire;
Expand Down
5 changes: 5 additions & 0 deletions tests/system/Helpers/FilesystemHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
*/
final class FilesystemHelperTest extends CIUnitTestCase
{
/**
* @var array<string, array<string, mixed[]>>|array<string, array<string, string>>|array<string, mixed>|array<string, mixed[]>|array<string, string>|mixed
*/
private array $structure;

protected function setUp(): void
{
parent::setUp();
Expand Down
6 changes: 6 additions & 0 deletions tests/system/Images/BaseHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use CodeIgniter\Images\Handlers\BaseHandler;
use CodeIgniter\Test\CIUnitTestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

/**
* Test the common image processing functionality.
Expand All @@ -30,6 +31,11 @@
*/
final class BaseHandlerTest extends CIUnitTestCase
{
private vfsStreamDirectory $root;
private string $origin;
private string $start;
private string $path;

protected function setUp(): void
{
if (! extension_loaded('gd')) {
Expand Down
8 changes: 8 additions & 0 deletions tests/system/Images/GDHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

use CodeIgniter\Config\Services;
use CodeIgniter\Images\Exceptions\ImageException;
use CodeIgniter\Images\Handlers\BaseHandler;
use CodeIgniter\Test\CIUnitTestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

/**
* Unit testing for the GD image handler.
Expand All @@ -29,6 +31,12 @@
*/
final class GDHandlerTest extends CIUnitTestCase
{
private vfsStreamDirectory $root;
private string $origin;
private string $start;
private string $path;
private BaseHandler $handler;

protected function setUp(): void
{
if (! extension_loaded('gd')) {
Expand Down
6 changes: 6 additions & 0 deletions tests/system/Images/ImageMagickHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use CodeIgniter\Config\Services;
use CodeIgniter\Images\Exceptions\ImageException;
use CodeIgniter\Images\Handlers\BaseHandler;
use CodeIgniter\Test\CIUnitTestCase;
use Config\Images;
use Imagick;
Expand All @@ -30,6 +31,11 @@
*/
final class ImageMagickHandlerTest extends CIUnitTestCase
{
private string $root;
private string $origin;
private string $path;
private BaseHandler $handler;

protected function setUp(): void
{
if (! extension_loaded('imagick')) {
Expand Down
6 changes: 6 additions & 0 deletions tests/system/Images/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
use CodeIgniter\Images\Exceptions\ImageException;
use CodeIgniter\Test\CIUnitTestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

/**
* @internal
*/
final class ImageTest extends CIUnitTestCase
{
private vfsStreamDirectory $root;
private string $origin;
private string $start;
private Image $image;

protected function setUp(): void
{
// create virtual file system
Expand Down
4 changes: 4 additions & 0 deletions tests/system/Log/Handlers/FileHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
use CodeIgniter\Test\Mock\MockFileLogger;
use CodeIgniter\Test\Mock\MockLogger as LoggerConfig;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use Tests\Support\Log\Handlers\TestHandler;

/**
* @internal
*/
final class FileHandlerTest extends CIUnitTestCase
{
private vfsStreamDirectory $root;
private string $start;

protected function setUp(): void
{
parent::setUp();
Expand Down
1 change: 1 addition & 0 deletions tests/system/Pager/PagerRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
final class PagerRendererTest extends CIUnitTestCase
{
private string $expect;
private URI $uri;

protected function setUp(): void
Expand Down
5 changes: 5 additions & 0 deletions tests/system/Test/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
*/
final class TestCaseTest extends CIUnitTestCase
{
/**
* @var bool|resource
*/
private $stream_filter;

public function testGetPrivatePropertyWithObject()
{
$obj = new __TestForReflectionHelper();
Expand Down
3 changes: 3 additions & 0 deletions tests/system/Throttle/ThrottleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace CodeIgniter\Throttle;

use CodeIgniter\Cache\CacheInterface;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\Mock\MockCache;

Expand All @@ -19,6 +20,8 @@
*/
final class ThrottleTest extends CIUnitTestCase
{
private CacheInterface $cache;

protected function setUp(): void
{
parent::setUp();
Expand Down
2 changes: 2 additions & 0 deletions tests/system/View/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
final class TableTest extends CIUnitTestCase
{
private Table $table;

protected function setUp(): void
{
$this->table = new MockTable();
Expand Down