Skip to content

Bump friendsofphp/php-cs-fixer to ~3.11.0 #6471

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

Merged
merged 5 commits into from
Sep 3, 2022
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
18 changes: 15 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use CodeIgniter\CodingStandard\CodeIgniter4;
use Nexus\CsConfig\Factory;
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
use Nexus\CsConfig\FixerGenerator;
use PhpCsFixer\Finder;

Expand All @@ -39,15 +38,28 @@
__DIR__ . '/spark',
]);

$overrides = [];
$overrides = [
'phpdoc_separation' => [
'groups' => [
['immutable', 'psalm-immutable'],
['param', 'phpstan-param', 'psalm-param'],
['phpstan-pure', 'psalm-pure'],
['readonly', 'psalm-readonly'],
['return', 'phpstan-return', 'psalm-return'],
['template', 'phpstan-template', 'psalm-template'],
['template-covariant', 'phpstan-template-covariant', 'psalm-template-covariant'],
['phpstan-type', 'psalm-type'],
['var', 'phpstan-var', 'psalm-var'],
],
],
];

$options = [
'cacheFile' => 'build/.php-cs-fixer.cache',
'finder' => $finder,
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
'customRules' => [
NoCodeSeparatorCommentFixer::name() => true,
SpaceAfterCommentStartFixer::name() => true,
],
];

Expand Down
18 changes: 15 additions & 3 deletions .php-cs-fixer.no-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use CodeIgniter\CodingStandard\CodeIgniter4;
use Nexus\CsConfig\Factory;
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
use Nexus\CsConfig\FixerGenerator;
use PhpCsFixer\Finder;

Expand All @@ -31,15 +30,28 @@
__DIR__ . '/admin/starter/builds',
]);

$overrides = [];
$overrides = [
'phpdoc_separation' => [
'groups' => [
['immutable', 'psalm-immutable'],
['param', 'phpstan-param', 'psalm-param'],
['phpstan-pure', 'psalm-pure'],
['readonly', 'psalm-readonly'],
['return', 'phpstan-return', 'psalm-return'],
['template', 'phpstan-template', 'psalm-template'],
['template-covariant', 'phpstan-template-covariant', 'psalm-template-covariant'],
['phpstan-type', 'psalm-type'],
['var', 'phpstan-var', 'psalm-var'],
],
],
];

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

Expand Down
15 changes: 13 additions & 2 deletions .php-cs-fixer.user-guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use CodeIgniter\CodingStandard\CodeIgniter4;
use Nexus\CsConfig\Factory;
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
use Nexus\CsConfig\FixerGenerator;
use PhpCsFixer\Finder;

Expand All @@ -34,6 +33,19 @@
'php_unit_internal_class' => false,
'no_unused_imports' => false,
'class_attributes_separation' => false,
'phpdoc_separation' => [
'groups' => [
['immutable', 'psalm-immutable'],
['param', 'phpstan-param', 'psalm-param'],
['phpstan-pure', 'psalm-pure'],
['readonly', 'psalm-readonly'],
['return', 'phpstan-return', 'psalm-return'],
['template', 'phpstan-template', 'psalm-template'],
['template-covariant', 'phpstan-template-covariant', 'psalm-template-covariant'],
['phpstan-type', 'psalm-type'],
['var', 'phpstan-var', 'psalm-var'],
],
],
];

$options = [
Expand All @@ -42,7 +54,6 @@
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
'customRules' => [
NoCodeSeparatorCommentFixer::name() => true,
SpaceAfterCommentStartFixer::name() => true,
],
];

Expand Down
2 changes: 1 addition & 1 deletion admin/framework/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require-dev": {
"codeigniter/coding-standard": "^1.1",
"fakerphp/faker": "^1.9",
"friendsofphp/php-cs-fixer": "3.6.*",
"friendsofphp/php-cs-fixer": "~3.11.0",
"mikey179/vfsstream": "^1.6",
"nexusphp/cs-config": "^3.3",
"phpunit/phpunit": "^9.1",
Expand Down
1 change: 1 addition & 0 deletions app/Config/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ class App extends BaseConfig
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
*
* @deprecated `Config\Cookie` $samesite property is used.
*
* @var string
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require-dev": {
"codeigniter/coding-standard": "^1.1",
"fakerphp/faker": "^1.9",
"friendsofphp/php-cs-fixer": "3.6.*",
"friendsofphp/php-cs-fixer": "~3.11.0",
"mikey179/vfsstream": "^1.6",
"nexusphp/cs-config": "^3.3",
"nexusphp/tachycardia": "^1.0",
Expand Down
4 changes: 1 addition & 3 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,9 @@ protected function display404errors(PageNotFoundException $e)
$this->response->setStatusCode($e->getCode());

if (ENVIRONMENT !== 'testing') {
// @codeCoverageIgnoreStart
if (ob_get_level() > 0) {
ob_end_flush();
ob_end_flush(); // @codeCoverageIgnore
}
// @codeCoverageIgnoreEnd
}
// When testing, one is for phpunit, another is for test case.
elseif (ob_get_level() > 2) {
Expand Down
72 changes: 36 additions & 36 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,43 +92,43 @@
* @see http://blog.ircmaxell.com/2015/11/simple-easy-risk-and-change.html
* @see http://www.infoq.com/presentations/Simple-Made-Easy
*
* @method static CacheInterface cache(Cache $config = null, $getShared = true)
* @method static CLIRequest clirequest(App $config = null, $getShared = true)
* @method static CodeIgniter codeigniter(App $config = null, $getShared = true)
* @method static Commands commands($getShared = true)
* @method static void createRequest(App $config, bool $isCli = false)
* @method static ContentSecurityPolicy csp(CSPConfig $config = null, $getShared = true)
* @method static CURLRequest curlrequest($options = [], ResponseInterface $response = null, App $config = null, $getShared = true)
* @method static Email email($config = null, $getShared = true)
* @method static EncrypterInterface encrypter(Encryption $config = null, $getShared = false)
* @method static Exceptions exceptions(ConfigExceptions $config = null, IncomingRequest $request = null, Response $response = null, $getShared = true)
* @method static Filters filters(ConfigFilters $config = null, $getShared = true)
* @method static Format format(ConfigFormat $config = null, $getShared = true)
* @method static Honeypot honeypot(ConfigHoneyPot $config = null, $getShared = true)
* @method static BaseHandler image($handler = null, Images $config = null, $getShared = true)
* @method static IncomingRequest incomingrequest(?App $config = null, bool $getShared = true)
* @method static Iterator iterator($getShared = true)
* @method static Language language($locale = null, $getShared = true)
* @method static Logger logger($getShared = true)
* @method static MigrationRunner migrations(Migrations $config = null, ConnectionInterface $db = null, $getShared = true)
* @method static Negotiate negotiator(RequestInterface $request = null, $getShared = true)
* @method static Pager pager(ConfigPager $config = null, RendererInterface $view = null, $getShared = true)
* @method static Parser parser($viewPath = null, ConfigView $config = null, $getShared = true)
* @method static RedirectResponse redirectresponse(App $config = null, $getShared = true)
* @method static View renderer($viewPath = null, ConfigView $config = null, $getShared = true)
* @method static CacheInterface cache(Cache $config = null, $getShared = true)
* @method static CLIRequest clirequest(App $config = null, $getShared = true)
* @method static CodeIgniter codeigniter(App $config = null, $getShared = true)
* @method static Commands commands($getShared = true)
* @method static void createRequest(App $config, bool $isCli = false)
* @method static ContentSecurityPolicy csp(CSPConfig $config = null, $getShared = true)
* @method static CURLRequest curlrequest($options = [], ResponseInterface $response = null, App $config = null, $getShared = true)
* @method static Email email($config = null, $getShared = true)
* @method static EncrypterInterface encrypter(Encryption $config = null, $getShared = false)
* @method static Exceptions exceptions(ConfigExceptions $config = null, IncomingRequest $request = null, Response $response = null, $getShared = true)
* @method static Filters filters(ConfigFilters $config = null, $getShared = true)
* @method static Format format(ConfigFormat $config = null, $getShared = true)
* @method static Honeypot honeypot(ConfigHoneyPot $config = null, $getShared = true)
* @method static BaseHandler image($handler = null, Images $config = null, $getShared = true)
* @method static IncomingRequest incomingrequest(?App $config = null, bool $getShared = true)
* @method static Iterator iterator($getShared = true)
* @method static Language language($locale = null, $getShared = true)
* @method static Logger logger($getShared = true)
* @method static MigrationRunner migrations(Migrations $config = null, ConnectionInterface $db = null, $getShared = true)
* @method static Negotiate negotiator(RequestInterface $request = null, $getShared = true)
* @method static Pager pager(ConfigPager $config = null, RendererInterface $view = null, $getShared = true)
* @method static Parser parser($viewPath = null, ConfigView $config = null, $getShared = true)
* @method static RedirectResponse redirectresponse(App $config = null, $getShared = true)
* @method static View renderer($viewPath = null, ConfigView $config = null, $getShared = true)
* @method static IncomingRequest|CLIRequest request(App $config = null, $getShared = true)
* @method static Response response(App $config = null, $getShared = true)
* @method static Router router(RouteCollectionInterface $routes = null, Request $request = null, $getShared = true)
* @method static RouteCollection routes($getShared = true)
* @method static Security security(App $config = null, $getShared = true)
* @method static Session session(App $config = null, $getShared = true)
* @method static Throttler throttler($getShared = true)
* @method static Timer timer($getShared = true)
* @method static Toolbar toolbar(ConfigToolbar $config = null, $getShared = true)
* @method static Typography typography($getShared = true)
* @method static URI uri($uri = null, $getShared = true)
* @method static Validation validation(ConfigValidation $config = null, $getShared = true)
* @method static Cell viewcell($getShared = true)
* @method static Response response(App $config = null, $getShared = true)
* @method static Router router(RouteCollectionInterface $routes = null, Request $request = null, $getShared = true)
* @method static RouteCollection routes($getShared = true)
* @method static Security security(App $config = null, $getShared = true)
* @method static Session session(App $config = null, $getShared = true)
* @method static Throttler throttler($getShared = true)
* @method static Timer timer($getShared = true)
* @method static Toolbar toolbar(ConfigToolbar $config = null, $getShared = true)
* @method static Typography typography($getShared = true)
* @method static URI uri($uri = null, $getShared = true)
* @method static Validation validation(ConfigValidation $config = null, $getShared = true)
* @method static Cell viewcell($getShared = true)
*/
class BaseService
{
Expand Down
1 change: 1 addition & 0 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,7 @@ public function insert($set = null, ?bool $escape = null)
* @internal This is a temporary solution.
*
* @see https://github.com/codeigniter4/CodeIgniter4/pull/5376
*
* @TODO Fix a root cause, and this method should be removed.
*/
protected function removeAlias(string $from): string
Expand Down
1 change: 0 additions & 1 deletion system/Database/SQLSRV/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ protected function _createTableAttributes(array $attributes): string
*/
protected function _alterTable(string $alterType, string $table, $field)
{

// Handle DROP here
if ($alterType === 'DROP') {
// check if fields are part of any indexes
Expand Down
1 change: 1 addition & 0 deletions system/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ public function __set(string $key, $value = null)
* $p = $this->getMyProperty()
*
* @throws Exception
*
* @params string $key class property
*
* @return array|bool|float|int|object|string|null
Expand Down
1 change: 1 addition & 0 deletions system/HTTP/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public function getStatusCode(): int
*
* @see http://tools.ietf.org/html/rfc7231#section-6
* @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
*
* @deprecated Use getReasonPhrase()
*
* @codeCoverageIgnore
Expand Down
1 change: 1 addition & 0 deletions system/HTTP/ResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function setStatusCode(int $code, string $reason = '');
*
* @see http://tools.ietf.org/html/rfc7231#section-6
* @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
*
* @deprecated Use getReasonPhrase()
*/
public function getReason(): string;
Expand Down
1 change: 1 addition & 0 deletions system/I18n/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public static function createFromInstance(DateTimeInterface $dateTime, ?string $
* @return Time
*
* @deprecated Use createFromInstance() instead
*
* @codeCoverageIgnore
*/
public static function instance(DateTime $dateTime, ?string $locale = null)
Expand Down
2 changes: 1 addition & 1 deletion system/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ protected function checkRoutes(string $uri): bool
return true;
}

[$controller, ] = explode('::', $handler);
[$controller] = explode('::', $handler);

// Checks `/` in controller name
if (strpos($controller, '/') !== false) {
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/ComposerJsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* @internal
*
* @coversNothing
*
* @group auto-review
*/
final class ComposerJsonTest extends TestCase
Expand Down
52 changes: 25 additions & 27 deletions tests/system/API/ResponseTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ protected function makeController(array $userConfig = [], string $uri = 'http://
$config = new App();

foreach ([
'baseURL' => 'http://example.com/',
'uriProtocol' => 'REQUEST_URI',
'defaultLocale' => 'en',
'negotiateLocale' => false,
'baseURL' => 'http://example.com/',
'uriProtocol' => 'REQUEST_URI',
'defaultLocale' => 'en',
'negotiateLocale' => false,
'supportedLocales' => ['en'],
'CSPEnabled' => false,
'cookiePrefix' => '',
'cookieDomain' => '',
'cookiePath' => '/',
'cookieSecure' => false,
'cookieHTTPOnly' => false,
'proxyIPs' => [],
'cookieSameSite' => 'Lax',
'CSPEnabled' => false,
'cookiePrefix' => '',
'cookieDomain' => '',
'cookiePath' => '/',
'cookieSecure' => false,
'cookieHTTPOnly' => false,
'proxyIPs' => [],
'cookieSameSite' => 'Lax',
] as $key => $value) {
$config->{$key} = $value;
}
Expand All @@ -79,7 +79,7 @@ protected function makeController(array $userConfig = [], string $uri = 'http://
}

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

protected $request;
Expand All @@ -98,8 +98,6 @@ public function resetFormatter()
$this->formatter = null;
}
};

return $controller;
}

public function testNoFormatterJSON()
Expand Down Expand Up @@ -518,19 +516,19 @@ public function testFormatByRequestNegotiateIfFormatIsNotJsonOrXML()
$config = new App();

foreach ([
'baseURL' => 'http://example.com/',
'uriProtocol' => 'REQUEST_URI',
'defaultLocale' => 'en',
'negotiateLocale' => false,
'baseURL' => 'http://example.com/',
'uriProtocol' => 'REQUEST_URI',
'defaultLocale' => 'en',
'negotiateLocale' => false,
'supportedLocales' => ['en'],
'CSPEnabled' => false,
'cookiePrefix' => '',
'cookieDomain' => '',
'cookiePath' => '/',
'cookieSecure' => false,
'cookieHTTPOnly' => false,
'proxyIPs' => [],
'cookieSameSite' => 'Lax',
'CSPEnabled' => false,
'cookiePrefix' => '',
'cookieDomain' => '',
'cookiePath' => '/',
'cookieSecure' => false,
'cookieHTTPOnly' => false,
'proxyIPs' => [],
'cookieSameSite' => 'Lax',
] as $key => $value) {
$config->{$key} = $value;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/system/CodeIgniterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function testControllersCanReturnResponseObject()
$routes = Services::routes();
$routes->add('pages/(:segment)', static function ($segment) {
$response = Services::response();
$string = "You want to see 'about' page.";
$string = "You want to see 'about' page.";

return $response->setBody($string);
});
Expand Down Expand Up @@ -583,7 +583,7 @@ public function testPageCacheSendSecureHeaders()
CodeIgniter::cache(3600);

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

return $response->setBody($string);
});
Expand Down
Loading