Skip to content

Commit f658272

Browse files
committed
update rector config and re-run rector
1 parent 5c17f47 commit f658272

10 files changed

Lines changed: 34 additions & 41 deletions

File tree

rector.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
3030
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
3131
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
32-
use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector;
3332
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
3433
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
3534
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
@@ -43,7 +42,6 @@
4342
use Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
4443
use Rector\PHPUnit\Set\PHPUnitSetList;
4544
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
46-
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
4745
use Rector\Set\ValueObject\LevelSetList;
4846
use Rector\Set\ValueObject\SetList;
4947
use Utils\Rector\PassStrictParameterToFunctionParameterRector;
@@ -94,11 +92,6 @@
9492
__DIR__ . '/system/Router/AutoRouterImproved.php',
9593
],
9694

97-
// call on purpose for nothing happen check
98-
RemoveEmptyMethodCallRector::class => [
99-
__DIR__ . '/tests',
100-
],
101-
10295
// check on constant compare
10396
UnwrapFutureCompatibleIfPhpVersionRector::class => [
10497
__DIR__ . '/system/Autoloader/Autoloader.php',
@@ -147,7 +140,6 @@
147140
$rectorConfig->rule(FuncGetArgsToVariadicParamRector::class);
148141
$rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class);
149142
$rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
150-
$rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
151143
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
152144
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
153145
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);

system/Database/OCI8/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Connection extends BaseConnection
5353
protected $validDSNs = [
5454
'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // TNS
5555
// Easy Connect string (Oracle 10g+)
56-
'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^\/])?(\/[a-z0-9$_]+)?$/i',
56+
'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9]\d{0,4})?(\/[a-z0-9$_]+)?(:[^\/])?(\/[a-z0-9$_]+)?$/i',
5757
'in' => '/^[a-z0-9$_]+$/i', // Instance name (defined in tnsnames.ora)
5858
];
5959

system/Helpers/text_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ function _from_random(int $length, string $pool): string
662662
*/
663663
function increment_string(string $str, string $separator = '_', int $first = 1): string
664664
{
665-
preg_match('/(.+)' . preg_quote($separator, '/') . '([0-9]+)$/', $str, $match);
665+
preg_match('/(.+)' . preg_quote($separator, '/') . '(\d+)$/', $str, $match);
666666

667667
return isset($match[2]) ? $match[1] . $separator . ((int) $match[2] + 1) : $str . $separator . $first;
668668
}

system/Router/RouteCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class RouteCollection implements RouteCollectionInterface
9898
'any' => '.*',
9999
'segment' => '[^/]+',
100100
'alphanum' => '[a-zA-Z0-9]+',
101-
'num' => '[0-9]+',
101+
'num' => '\d+',
102102
'alpha' => '[a-zA-Z]+',
103103
'hash' => '[^/]+',
104104
];

tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function routeKeyProvider(): Generator
3838
{
3939
yield from [
4040
'root' => ['/', '/'],
41-
'placeholder num' => ['shop/product/([0-9]+)', 'shop/product/123'],
41+
'placeholder num' => ['shop/product/(\d+)', 'shop/product/123'],
4242
'placeholder segment' => ['shop/product/([^/]+)', 'shop/product/abc_123'],
4343
'placeholder any' => ['shop/product/(.*)', 'shop/product/123/abc'],
4444
'auto route' => ['home/index[/...]', 'home/index/1/2/3/4/5'],

tests/system/Database/Builder/SelectTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testSelectWorksWithRawSql()
105105
{
106106
$builder = new BaseBuilder('users', $this->db);
107107

108-
$sql = 'REGEXP_SUBSTR(ral_anno,"[0-9]{1,2}([,.][0-9]{1,3})([,.][0-9]{1,3})") AS ral';
108+
$sql = 'REGEXP_SUBSTR(ral_anno,"\d{1,2}([,.]\d{1,3})([,.]\d{1,3})") AS ral';
109109
$builder->select(new RawSql($sql));
110110

111111
$expected = 'SELECT ' . $sql . ' FROM "users"';
@@ -134,12 +134,12 @@ public function testSelectRegularExpressionWorksWithEscpaeFalse()
134134
$builder = new BaseBuilder('ob_human_resources', $this->db);
135135

136136
$builder->select(
137-
'REGEXP_SUBSTR(ral_anno,"[0-9]{1,2}([,.][0-9]{1,3})([,.][0-9]{1,3})") AS ral',
137+
'REGEXP_SUBSTR(ral_anno,"\d{1,2}([,.]\d{1,3})([,.]\d{1,3})") AS ral',
138138
false
139139
);
140140

141141
$expected = <<<'SQL'
142-
SELECT REGEXP_SUBSTR(ral_anno,"[0-9]{1,2}([,.][0-9]{1,3})([,.][0-9]{1,3})") AS ral
142+
SELECT REGEXP_SUBSTR(ral_anno,"\d{1,2}([,.]\d{1,3})([,.]\d{1,3})") AS ral
143143
FROM "ob_human_resources"
144144
SQL;
145145
$this->assertSame($expected, $builder->getCompiledSelect());

tests/system/Database/RawSqlTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class RawSqlTest extends CIUnitTestCase
2222
{
2323
public function testCanConvertToString()
2424
{
25-
$expected = 'REGEXP_SUBSTR(ral_anno,"[0-9]{1,2}([,.][0-9]{1,3})([,.][0-9]{1,3})") AS ral';
25+
$expected = 'REGEXP_SUBSTR(ral_anno,"\d{1,2}([,.]\d{1,3})([,.]\d{1,3})") AS ral';
2626
$rawSql = new RawSql($expected);
2727

2828
$this->assertSame($expected, (string) $rawSql);
@@ -47,6 +47,6 @@ public function testGetBindingKey()
4747

4848
$key = $rawSql->getBindingKey();
4949

50-
$this->assertMatchesRegularExpression('/\ARawSql[0-9]+\z/', $key);
50+
$this->assertMatchesRegularExpression('/\ARawSql\d+\z/', $key);
5151
}
5252
}

tests/system/Router/RouteCollectionTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\Router;
1313

1414
use CodeIgniter\Config\Services;
15+
use CodeIgniter\controller;
1516
use CodeIgniter\Exceptions\PageNotFoundException;
1617
use CodeIgniter\Test\CIUnitTestCase;
1718
use Config\Modules;
@@ -88,7 +89,7 @@ public function testBasicAddCallableWithParamsString()
8889

8990
$routes = $routes->getRoutes();
9091
$expects = [
91-
'product/([0-9]+)/([0-9]+)' => '\Tests\Support\Controllers\Hello::index/$2/$1',
92+
'product/(\d+)/(\d+)' => '\Tests\Support\Controllers\Hello::index/$2/$1',
9293
];
9394
$this->assertSame($expects, $routes);
9495
}
@@ -101,7 +102,7 @@ public function testBasicAddCallableWithParamsWithoutString()
101102

102103
$routes = $routes->getRoutes();
103104
$expects = [
104-
'product/([0-9]+)/([0-9]+)' => '\Tests\Support\Controllers\Hello::index/$1/$2',
105+
'product/(\d+)/(\d+)' => '\Tests\Support\Controllers\Hello::index/$1/$2',
105106
];
106107
$this->assertSame($expects, $routes);
107108
}
@@ -237,7 +238,7 @@ public function testAddRecognizesCustomNamespaces()
237238
$routes->add('home', 'controller');
238239

239240
$expects = [
240-
'home' => '\CodeIgniter\controller',
241+
'home' => '\\' . controller::class,
241242
];
242243

243244
$routes = $routes->getRoutes();
@@ -615,10 +616,10 @@ public function testResourcesWithCustomPlaceholder()
615616
$routes->resource('photos', ['placeholder' => ':num']);
616617

617618
$expected = [
618-
'photos' => '\Photos::index',
619-
'photos/new' => '\Photos::new',
620-
'photos/([0-9]+)/edit' => '\Photos::edit/$1',
621-
'photos/([0-9]+)' => '\Photos::show/$1',
619+
'photos' => '\Photos::index',
620+
'photos/new' => '\Photos::new',
621+
'photos/(\d+)/edit' => '\Photos::edit/$1',
622+
'photos/(\d+)' => '\Photos::show/$1',
622623
];
623624

624625
$this->assertSame($expected, $routes->getRoutes());
@@ -633,10 +634,10 @@ public function testResourcesWithDefaultPlaceholder()
633634
$routes->resource('photos');
634635

635636
$expected = [
636-
'photos' => '\Photos::index',
637-
'photos/new' => '\Photos::new',
638-
'photos/([0-9]+)/edit' => '\Photos::edit/$1',
639-
'photos/([0-9]+)' => '\Photos::show/$1',
637+
'photos' => '\Photos::index',
638+
'photos/new' => '\Photos::new',
639+
'photos/(\d+)/edit' => '\Photos::edit/$1',
640+
'photos/(\d+)' => '\Photos::show/$1',
640641
];
641642

642643
$this->assertSame($expected, $routes->getRoutes());
@@ -1399,7 +1400,7 @@ public function testOffsetParameters()
13991400
$routes = $this->getCollector();
14001401

14011402
$routes->get('users/(:num)', 'users/show/$1', ['offset' => 1]);
1402-
$expected = ['users/([0-9]+)' => '\users/show/$2'];
1403+
$expected = ['users/(\d+)' => '\users/show/$2'];
14031404
$this->assertSame($expected, $routes->getRoutes());
14041405
}
14051406

tests/system/Validation/FormatRulesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testRegexMatch(): void
6363

6464
$this->validation->setRules([
6565
'foo' => 'regex_match[/[a-z]/]',
66-
'phone' => 'regex_match[/^(01[2689]|09)[0-9]{8}$/]',
66+
'phone' => 'regex_match[/^(01[2689]|09)\d{8}$/]',
6767
]);
6868

6969
$this->assertTrue($this->validation->run($data));
@@ -78,7 +78,7 @@ public function testRegexMatchFalse(): void
7878

7979
$this->validation->setRules([
8080
'foo' => 'regex_match[\d]',
81-
'phone' => 'regex_match[/^(01[2689]|09)[0-9]{8}$/]',
81+
'phone' => 'regex_match[/^(01[2689]|09)\d{8}$/]',
8282
]);
8383

8484
$this->assertFalse($this->validation->run($data));

tests/system/Validation/ValidationTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -883,15 +883,15 @@ public function testHasError(): void
883883
public function testSplitRulesTrue(): void
884884
{
885885
$this->validation->setRules([
886-
'phone' => 'required|regex_match[/^(01[2689]|09)[0-9]{8}$/]|numeric',
886+
'phone' => 'required|regex_match[/^(01[2689]|09)\d{8}$/]|numeric',
887887
]);
888888
$this->assertTrue($this->validation->run(['phone' => '0987654321']));
889889
}
890890

891891
public function testSplitRulesFalse(): void
892892
{
893893
$this->validation->setRules([
894-
'phone' => 'required|regex_match[/^(01[2689]|09)[0-9]{8}$/]|numeric',
894+
'phone' => 'required|regex_match[/^(01[2689]|09)\d{8}$/]|numeric',
895895
]);
896896
$this->assertFalse($this->validation->run(['phone' => '09876543214']));
897897
}
@@ -909,8 +909,8 @@ public function testSplitNotRegex(): void
909909
public function testSplitRegex(): void
910910
{
911911
$method = $this->getPrivateMethodInvoker($this->validation, 'splitRules');
912-
$result = $method('required|regex_match[/^[0-9]{4}[\-\.\[\/][0-9]{2}[\-\.\[\/][0-9]{2}/]|max_length[10]');
913-
$this->assertSame('regex_match[/^[0-9]{4}[\-\.\[\/][0-9]{2}[\-\.\[\/][0-9]{2}/]', $result[1]);
912+
$result = $method('required|regex_match[/^\d{4}[\-\.\[\/]\d{2}[\-\.\[\/]\d{2}/]|max_length[10]');
913+
$this->assertSame('regex_match[/^\d{4}[\-\.\[\/]\d{2}[\-\.\[\/]\d{2}/]', $result[1]);
914914
}
915915

916916
public function testTagReplacement(): void
@@ -1365,18 +1365,18 @@ public function provideStringRulesCases(): iterable
13651365
];
13661366

13671367
yield [
1368-
'required|regex_match[/^(01[2689]|09)[0-9]{8}$/]|numeric',
1369-
['required', 'regex_match[/^(01[2689]|09)[0-9]{8}$/]', 'numeric'],
1368+
'required|regex_match[/^(01[2689]|09)\d{8}$/]|numeric',
1369+
['required', 'regex_match[/^(01[2689]|09)\d{8}$/]', 'numeric'],
13701370
];
13711371

13721372
yield [
1373-
'required|regex_match[/^[0-9]{4}[\-\.\[\/][0-9]{2}[\-\.\[\/][0-9]{2}/]|max_length[10]',
1374-
['required', 'regex_match[/^[0-9]{4}[\-\.\[\/][0-9]{2}[\-\.\[\/][0-9]{2}/]', 'max_length[10]'],
1373+
'required|regex_match[/^\d{4}[\-\.\[\/]\d{2}[\-\.\[\/]\d{2}/]|max_length[10]',
1374+
['required', 'regex_match[/^\d{4}[\-\.\[\/]\d{2}[\-\.\[\/]\d{2}/]', 'max_length[10]'],
13751375
];
13761376

13771377
yield [
1378-
'required|regex_match[/^(01|2689|09)[0-9]{8}$/]|numeric',
1379-
['required', 'regex_match[/^(01|2689|09)[0-9]{8}$/]', 'numeric'],
1378+
'required|regex_match[/^(01|2689|09)\d{8}$/]|numeric',
1379+
['required', 'regex_match[/^(01|2689|09)\d{8}$/]', 'numeric'],
13801380
];
13811381
}
13821382

0 commit comments

Comments
 (0)