Skip to content

Commit 7b2ad9c

Browse files
authored
Merge pull request #6471 from paulbalandan/cs-fixer
Bump `friendsofphp/php-cs-fixer` to `~3.11.0`
2 parents 9cbe0a2 + 4369d20 commit 7b2ad9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+227
-102
lines changed

.php-cs-fixer.dist.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use CodeIgniter\CodingStandard\CodeIgniter4;
1515
use Nexus\CsConfig\Factory;
1616
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
17-
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
1817
use Nexus\CsConfig\FixerGenerator;
1918
use PhpCsFixer\Finder;
2019

@@ -39,15 +38,28 @@
3938
__DIR__ . '/spark',
4039
]);
4140

42-
$overrides = [];
41+
$overrides = [
42+
'phpdoc_separation' => [
43+
'groups' => [
44+
['immutable', 'psalm-immutable'],
45+
['param', 'phpstan-param', 'psalm-param'],
46+
['phpstan-pure', 'psalm-pure'],
47+
['readonly', 'psalm-readonly'],
48+
['return', 'phpstan-return', 'psalm-return'],
49+
['template', 'phpstan-template', 'psalm-template'],
50+
['template-covariant', 'phpstan-template-covariant', 'psalm-template-covariant'],
51+
['phpstan-type', 'psalm-type'],
52+
['var', 'phpstan-var', 'psalm-var'],
53+
],
54+
],
55+
];
4356

4457
$options = [
4558
'cacheFile' => 'build/.php-cs-fixer.cache',
4659
'finder' => $finder,
4760
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
4861
'customRules' => [
4962
NoCodeSeparatorCommentFixer::name() => true,
50-
SpaceAfterCommentStartFixer::name() => true,
5163
],
5264
];
5365

.php-cs-fixer.no-header.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use CodeIgniter\CodingStandard\CodeIgniter4;
1515
use Nexus\CsConfig\Factory;
1616
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
17-
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
1817
use Nexus\CsConfig\FixerGenerator;
1918
use PhpCsFixer\Finder;
2019

@@ -31,15 +30,28 @@
3130
__DIR__ . '/admin/starter/builds',
3231
]);
3332

34-
$overrides = [];
33+
$overrides = [
34+
'phpdoc_separation' => [
35+
'groups' => [
36+
['immutable', 'psalm-immutable'],
37+
['param', 'phpstan-param', 'psalm-param'],
38+
['phpstan-pure', 'psalm-pure'],
39+
['readonly', 'psalm-readonly'],
40+
['return', 'phpstan-return', 'psalm-return'],
41+
['template', 'phpstan-template', 'psalm-template'],
42+
['template-covariant', 'phpstan-template-covariant', 'psalm-template-covariant'],
43+
['phpstan-type', 'psalm-type'],
44+
['var', 'phpstan-var', 'psalm-var'],
45+
],
46+
],
47+
];
3548

3649
$options = [
3750
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',
3851
'finder' => $finder,
3952
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
4053
'customRules' => [
4154
NoCodeSeparatorCommentFixer::name() => true,
42-
SpaceAfterCommentStartFixer::name() => true,
4355
],
4456
];
4557

.php-cs-fixer.user-guide.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use CodeIgniter\CodingStandard\CodeIgniter4;
1515
use Nexus\CsConfig\Factory;
1616
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
17-
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
1817
use Nexus\CsConfig\FixerGenerator;
1918
use PhpCsFixer\Finder;
2019

@@ -34,6 +33,19 @@
3433
'php_unit_internal_class' => false,
3534
'no_unused_imports' => false,
3635
'class_attributes_separation' => false,
36+
'phpdoc_separation' => [
37+
'groups' => [
38+
['immutable', 'psalm-immutable'],
39+
['param', 'phpstan-param', 'psalm-param'],
40+
['phpstan-pure', 'psalm-pure'],
41+
['readonly', 'psalm-readonly'],
42+
['return', 'phpstan-return', 'psalm-return'],
43+
['template', 'phpstan-template', 'psalm-template'],
44+
['template-covariant', 'phpstan-template-covariant', 'psalm-template-covariant'],
45+
['phpstan-type', 'psalm-type'],
46+
['var', 'phpstan-var', 'psalm-var'],
47+
],
48+
],
3749
];
3850

3951
$options = [
@@ -42,7 +54,6 @@
4254
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
4355
'customRules' => [
4456
NoCodeSeparatorCommentFixer::name() => true,
45-
SpaceAfterCommentStartFixer::name() => true,
4657
],
4758
];
4859

admin/framework/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"require-dev": {
1818
"codeigniter/coding-standard": "^1.1",
1919
"fakerphp/faker": "^1.9",
20-
"friendsofphp/php-cs-fixer": "3.6.*",
20+
"friendsofphp/php-cs-fixer": "~3.11.0",
2121
"mikey179/vfsstream": "^1.6",
2222
"nexusphp/cs-config": "^3.3",
2323
"phpunit/phpunit": "^9.1",

app/Config/App.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ class App extends BaseConfig
437437
* Defaults to `Lax` as recommended in this link:
438438
*
439439
* @see https://portswigger.net/web-security/csrf/samesite-cookies
440+
*
440441
* @deprecated `Config\Cookie` $samesite property is used.
441442
*
442443
* @var string

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"require-dev": {
1818
"codeigniter/coding-standard": "^1.1",
1919
"fakerphp/faker": "^1.9",
20-
"friendsofphp/php-cs-fixer": "3.6.*",
20+
"friendsofphp/php-cs-fixer": "~3.11.0",
2121
"mikey179/vfsstream": "^1.6",
2222
"nexusphp/cs-config": "^3.3",
2323
"nexusphp/tachycardia": "^1.0",

system/CodeIgniter.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,11 +945,9 @@ protected function display404errors(PageNotFoundException $e)
945945
$this->response->setStatusCode($e->getCode());
946946

947947
if (ENVIRONMENT !== 'testing') {
948-
// @codeCoverageIgnoreStart
949948
if (ob_get_level() > 0) {
950-
ob_end_flush();
949+
ob_end_flush(); // @codeCoverageIgnore
951950
}
952-
// @codeCoverageIgnoreEnd
953951
}
954952
// When testing, one is for phpunit, another is for test case.
955953
elseif (ob_get_level() > 2) {

system/Config/BaseService.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -92,43 +92,43 @@
9292
* @see http://blog.ircmaxell.com/2015/11/simple-easy-risk-and-change.html
9393
* @see http://www.infoq.com/presentations/Simple-Made-Easy
9494
*
95-
* @method static CacheInterface cache(Cache $config = null, $getShared = true)
96-
* @method static CLIRequest clirequest(App $config = null, $getShared = true)
97-
* @method static CodeIgniter codeigniter(App $config = null, $getShared = true)
98-
* @method static Commands commands($getShared = true)
99-
* @method static void createRequest(App $config, bool $isCli = false)
100-
* @method static ContentSecurityPolicy csp(CSPConfig $config = null, $getShared = true)
101-
* @method static CURLRequest curlrequest($options = [], ResponseInterface $response = null, App $config = null, $getShared = true)
102-
* @method static Email email($config = null, $getShared = true)
103-
* @method static EncrypterInterface encrypter(Encryption $config = null, $getShared = false)
104-
* @method static Exceptions exceptions(ConfigExceptions $config = null, IncomingRequest $request = null, Response $response = null, $getShared = true)
105-
* @method static Filters filters(ConfigFilters $config = null, $getShared = true)
106-
* @method static Format format(ConfigFormat $config = null, $getShared = true)
107-
* @method static Honeypot honeypot(ConfigHoneyPot $config = null, $getShared = true)
108-
* @method static BaseHandler image($handler = null, Images $config = null, $getShared = true)
109-
* @method static IncomingRequest incomingrequest(?App $config = null, bool $getShared = true)
110-
* @method static Iterator iterator($getShared = true)
111-
* @method static Language language($locale = null, $getShared = true)
112-
* @method static Logger logger($getShared = true)
113-
* @method static MigrationRunner migrations(Migrations $config = null, ConnectionInterface $db = null, $getShared = true)
114-
* @method static Negotiate negotiator(RequestInterface $request = null, $getShared = true)
115-
* @method static Pager pager(ConfigPager $config = null, RendererInterface $view = null, $getShared = true)
116-
* @method static Parser parser($viewPath = null, ConfigView $config = null, $getShared = true)
117-
* @method static RedirectResponse redirectresponse(App $config = null, $getShared = true)
118-
* @method static View renderer($viewPath = null, ConfigView $config = null, $getShared = true)
95+
* @method static CacheInterface cache(Cache $config = null, $getShared = true)
96+
* @method static CLIRequest clirequest(App $config = null, $getShared = true)
97+
* @method static CodeIgniter codeigniter(App $config = null, $getShared = true)
98+
* @method static Commands commands($getShared = true)
99+
* @method static void createRequest(App $config, bool $isCli = false)
100+
* @method static ContentSecurityPolicy csp(CSPConfig $config = null, $getShared = true)
101+
* @method static CURLRequest curlrequest($options = [], ResponseInterface $response = null, App $config = null, $getShared = true)
102+
* @method static Email email($config = null, $getShared = true)
103+
* @method static EncrypterInterface encrypter(Encryption $config = null, $getShared = false)
104+
* @method static Exceptions exceptions(ConfigExceptions $config = null, IncomingRequest $request = null, Response $response = null, $getShared = true)
105+
* @method static Filters filters(ConfigFilters $config = null, $getShared = true)
106+
* @method static Format format(ConfigFormat $config = null, $getShared = true)
107+
* @method static Honeypot honeypot(ConfigHoneyPot $config = null, $getShared = true)
108+
* @method static BaseHandler image($handler = null, Images $config = null, $getShared = true)
109+
* @method static IncomingRequest incomingrequest(?App $config = null, bool $getShared = true)
110+
* @method static Iterator iterator($getShared = true)
111+
* @method static Language language($locale = null, $getShared = true)
112+
* @method static Logger logger($getShared = true)
113+
* @method static MigrationRunner migrations(Migrations $config = null, ConnectionInterface $db = null, $getShared = true)
114+
* @method static Negotiate negotiator(RequestInterface $request = null, $getShared = true)
115+
* @method static Pager pager(ConfigPager $config = null, RendererInterface $view = null, $getShared = true)
116+
* @method static Parser parser($viewPath = null, ConfigView $config = null, $getShared = true)
117+
* @method static RedirectResponse redirectresponse(App $config = null, $getShared = true)
118+
* @method static View renderer($viewPath = null, ConfigView $config = null, $getShared = true)
119119
* @method static IncomingRequest|CLIRequest request(App $config = null, $getShared = true)
120-
* @method static Response response(App $config = null, $getShared = true)
121-
* @method static Router router(RouteCollectionInterface $routes = null, Request $request = null, $getShared = true)
122-
* @method static RouteCollection routes($getShared = true)
123-
* @method static Security security(App $config = null, $getShared = true)
124-
* @method static Session session(App $config = null, $getShared = true)
125-
* @method static Throttler throttler($getShared = true)
126-
* @method static Timer timer($getShared = true)
127-
* @method static Toolbar toolbar(ConfigToolbar $config = null, $getShared = true)
128-
* @method static Typography typography($getShared = true)
129-
* @method static URI uri($uri = null, $getShared = true)
130-
* @method static Validation validation(ConfigValidation $config = null, $getShared = true)
131-
* @method static Cell viewcell($getShared = true)
120+
* @method static Response response(App $config = null, $getShared = true)
121+
* @method static Router router(RouteCollectionInterface $routes = null, Request $request = null, $getShared = true)
122+
* @method static RouteCollection routes($getShared = true)
123+
* @method static Security security(App $config = null, $getShared = true)
124+
* @method static Session session(App $config = null, $getShared = true)
125+
* @method static Throttler throttler($getShared = true)
126+
* @method static Timer timer($getShared = true)
127+
* @method static Toolbar toolbar(ConfigToolbar $config = null, $getShared = true)
128+
* @method static Typography typography($getShared = true)
129+
* @method static URI uri($uri = null, $getShared = true)
130+
* @method static Validation validation(ConfigValidation $config = null, $getShared = true)
131+
* @method static Cell viewcell($getShared = true)
132132
*/
133133
class BaseService
134134
{

system/Database/BaseBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ public function insert($set = null, ?bool $escape = null)
19281928
* @internal This is a temporary solution.
19291929
*
19301930
* @see https://github.com/codeigniter4/CodeIgniter4/pull/5376
1931+
*
19311932
* @TODO Fix a root cause, and this method should be removed.
19321933
*/
19331934
protected function removeAlias(string $from): string

system/Database/SQLSRV/Forge.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ protected function _createTableAttributes(array $attributes): string
125125
*/
126126
protected function _alterTable(string $alterType, string $table, $field)
127127
{
128-
129128
// Handle DROP here
130129
if ($alterType === 'DROP') {
131130
// check if fields are part of any indexes

system/Entity/Entity.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ public function __set(string $key, $value = null)
471471
* $p = $this->getMyProperty()
472472
*
473473
* @throws Exception
474+
*
474475
* @params string $key class property
475476
*
476477
* @return array|bool|float|int|object|string|null

system/HTTP/Response.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public function getStatusCode(): int
222222
*
223223
* @see http://tools.ietf.org/html/rfc7231#section-6
224224
* @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
225+
*
225226
* @deprecated Use getReasonPhrase()
226227
*
227228
* @codeCoverageIgnore

system/HTTP/ResponseInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public function setStatusCode(int $code, string $reason = '');
141141
*
142142
* @see http://tools.ietf.org/html/rfc7231#section-6
143143
* @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
144+
*
144145
* @deprecated Use getReasonPhrase()
145146
*/
146147
public function getReason(): string;

system/I18n/Time.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ public static function createFromInstance(DateTimeInterface $dateTime, ?string $
285285
* @return Time
286286
*
287287
* @deprecated Use createFromInstance() instead
288+
*
288289
* @codeCoverageIgnore
289290
*/
290291
public static function instance(DateTime $dateTime, ?string $locale = null)

system/Router/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ protected function checkRoutes(string $uri): bool
459459
return true;
460460
}
461461

462-
[$controller, ] = explode('::', $handler);
462+
[$controller] = explode('::', $handler);
463463

464464
// Checks `/` in controller name
465465
if (strpos($controller, '/') !== false) {

tests/AutoReview/ComposerJsonTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @internal
2121
*
2222
* @coversNothing
23+
*
2324
* @group auto-review
2425
*/
2526
final class ComposerJsonTest extends TestCase

tests/system/API/ResponseTraitTest.php

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ protected function makeController(array $userConfig = [], string $uri = 'http://
4343
$config = new App();
4444

4545
foreach ([
46-
'baseURL' => 'http://example.com/',
47-
'uriProtocol' => 'REQUEST_URI',
48-
'defaultLocale' => 'en',
49-
'negotiateLocale' => false,
46+
'baseURL' => 'http://example.com/',
47+
'uriProtocol' => 'REQUEST_URI',
48+
'defaultLocale' => 'en',
49+
'negotiateLocale' => false,
5050
'supportedLocales' => ['en'],
51-
'CSPEnabled' => false,
52-
'cookiePrefix' => '',
53-
'cookieDomain' => '',
54-
'cookiePath' => '/',
55-
'cookieSecure' => false,
56-
'cookieHTTPOnly' => false,
57-
'proxyIPs' => [],
58-
'cookieSameSite' => 'Lax',
51+
'CSPEnabled' => false,
52+
'cookiePrefix' => '',
53+
'cookieDomain' => '',
54+
'cookiePath' => '/',
55+
'cookieSecure' => false,
56+
'cookieHTTPOnly' => false,
57+
'proxyIPs' => [],
58+
'cookieSameSite' => 'Lax',
5959
] as $key => $value) {
6060
$config->{$key} = $value;
6161
}
@@ -79,7 +79,7 @@ protected function makeController(array $userConfig = [], string $uri = 'http://
7979
}
8080

8181
// Create the controller class finally.
82-
$controller = new class ($this->request, $this->response, $this->formatter) {
82+
return new class ($this->request, $this->response, $this->formatter) {
8383
use ResponseTrait;
8484

8585
protected $request;
@@ -98,8 +98,6 @@ public function resetFormatter()
9898
$this->formatter = null;
9999
}
100100
};
101-
102-
return $controller;
103101
}
104102

105103
public function testNoFormatterJSON()
@@ -518,19 +516,19 @@ public function testFormatByRequestNegotiateIfFormatIsNotJsonOrXML()
518516
$config = new App();
519517

520518
foreach ([
521-
'baseURL' => 'http://example.com/',
522-
'uriProtocol' => 'REQUEST_URI',
523-
'defaultLocale' => 'en',
524-
'negotiateLocale' => false,
519+
'baseURL' => 'http://example.com/',
520+
'uriProtocol' => 'REQUEST_URI',
521+
'defaultLocale' => 'en',
522+
'negotiateLocale' => false,
525523
'supportedLocales' => ['en'],
526-
'CSPEnabled' => false,
527-
'cookiePrefix' => '',
528-
'cookieDomain' => '',
529-
'cookiePath' => '/',
530-
'cookieSecure' => false,
531-
'cookieHTTPOnly' => false,
532-
'proxyIPs' => [],
533-
'cookieSameSite' => 'Lax',
524+
'CSPEnabled' => false,
525+
'cookiePrefix' => '',
526+
'cookieDomain' => '',
527+
'cookiePath' => '/',
528+
'cookieSecure' => false,
529+
'cookieHTTPOnly' => false,
530+
'proxyIPs' => [],
531+
'cookieSameSite' => 'Lax',
534532
] as $key => $value) {
535533
$config->{$key} = $value;
536534
}

tests/system/CodeIgniterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function testControllersCanReturnResponseObject()
177177
$routes = Services::routes();
178178
$routes->add('pages/(:segment)', static function ($segment) {
179179
$response = Services::response();
180-
$string = "You want to see 'about' page.";
180+
$string = "You want to see 'about' page.";
181181

182182
return $response->setBody($string);
183183
});
@@ -583,7 +583,7 @@ public function testPageCacheSendSecureHeaders()
583583
CodeIgniter::cache(3600);
584584

585585
$response = Services::response();
586-
$string = 'This is a test page. Elapsed time: {elapsed_time}';
586+
$string = 'This is a test page. Elapsed time: {elapsed_time}';
587587

588588
return $response->setBody($string);
589589
});

0 commit comments

Comments
 (0)