Skip to content

Commit

Permalink
Apply formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Sep 3, 2022
1 parent ec2dc1b commit eb44074
Show file tree
Hide file tree
Showing 55 changed files with 188 additions and 90 deletions.
2 changes: 1 addition & 1 deletion system/CodeIgniter.php
Expand Up @@ -949,7 +949,7 @@ protected function display404errors(PageNotFoundException $e)
if (ob_get_level() > 0) {
ob_end_flush();
}
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
}
// When testing, one is for phpunit, another is for test case.
elseif (ob_get_level() > 2) {
Expand Down
1 change: 1 addition & 0 deletions system/Commands/Utilities/Routes/AutoRouteCollector.php
Expand Up @@ -36,6 +36,7 @@ public function __construct(string $namespace, string $defaultController, string

/**
* @return array<int, array<int, string>>
*
* @phpstan-return list<list<string>>
*/
public function get(): array
Expand Down
Expand Up @@ -54,6 +54,7 @@ public function __construct(

/**
* @return array<int, array<int, string>>
*
* @phpstan-return list<list<string>>
*/
public function get(): array
Expand Down
Expand Up @@ -41,6 +41,7 @@ public function __construct(string $namespace, array $httpMethods)
* @phpstan-param class-string $class
*
* @return array<int, array<string, array|string>>
*
* @phpstan-return list<array<string, string|array>>
*/
public function read(string $class, string $defaultController = 'Home', string $defaultMethod = 'index'): array
Expand Down
1 change: 1 addition & 0 deletions system/Commands/Utilities/Routes/ControllerFinder.php
Expand Up @@ -37,6 +37,7 @@ public function __construct(string $namespace)

/**
* @return string[]
*
* @phpstan-return class-string[]
*/
public function find(): array
Expand Down
Expand Up @@ -36,6 +36,7 @@ public function __construct(string $namespace)
* @phpstan-param class-string $class
*
* @return array<int, array{route: string, handler: string}>
*
* @phpstan-return list<array{route: string, handler: string}>
*/
public function read(string $class, string $defaultController = 'Home', string $defaultMethod = 'index'): array
Expand Down
72 changes: 36 additions & 36 deletions system/Config/BaseService.php
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
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
2 changes: 2 additions & 0 deletions system/Database/BaseConnection.php
Expand Up @@ -995,6 +995,7 @@ public function getConnectDuration(int $decimals = 6): string
* @param bool $fieldExists Supplied $item contains a column name?
*
* @return array|string
*
* @phpstan-return ($item is array ? array : string)
*/
public function protectIdentifiers($item, bool $prefixSingle = false, ?bool $protectIdentifiers = null, bool $fieldExists = true)
Expand Down Expand Up @@ -1597,6 +1598,7 @@ public function isWriteType($sql): bool
* Must return an array with keys 'code' and 'message':
*
* @return array<string, int|string|null>
*
* @phpstan-return array{code: int|string|null, message: string|null}
*/
abstract public function error(): array;
Expand Down
1 change: 0 additions & 1 deletion system/Database/SQLSRV/Forge.php
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
2 changes: 2 additions & 0 deletions system/Database/SQLite3/Table.php
Expand Up @@ -28,6 +28,7 @@ class Table
* All of the fields this table represents.
*
* @var array
*
* @phpstan-var array<string, array<string, bool|int|string|null>>
*/
protected $fields = [];
Expand Down Expand Up @@ -305,6 +306,7 @@ protected function copyData()
* @param array|bool $fields
*
* @return mixed
*
* @phpstan-return ($fields is array ? array : mixed)
*/
protected function formatFields($fields)
Expand Down
1 change: 1 addition & 0 deletions system/Entity/Entity.php
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/I18n/Time.php
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
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
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
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
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
1 change: 1 addition & 0 deletions tests/system/Commands/GenerateKeyTest.php
Expand Up @@ -86,6 +86,7 @@ public function testGenerateKeyShowsEncodedKey()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testGenerateKeyCreatesNewKey()
Expand Down
1 change: 1 addition & 0 deletions tests/system/CommonFunctionsSendTest.php
Expand Up @@ -32,6 +32,7 @@ protected function setUp(): void
* See https://github.com/codeigniter4/CodeIgniter4/issues/1393
*
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testRedirectResponseCookiesSent()
Expand Down
10 changes: 10 additions & 0 deletions tests/system/CommonFunctionsTest.php
Expand Up @@ -179,6 +179,7 @@ public function testEscapeBadContext()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testSessionInstance()
Expand All @@ -190,6 +191,7 @@ public function testSessionInstance()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testSessionVariable()
Expand All @@ -203,6 +205,7 @@ public function testSessionVariable()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testSessionVariableNotThere()
Expand Down Expand Up @@ -286,6 +289,7 @@ public function testModelExistsAbsoluteClassname()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testOldInput()
Expand Down Expand Up @@ -321,6 +325,7 @@ public function testOldInput()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testOldInputSerializeData()
Expand Down Expand Up @@ -354,7 +359,9 @@ public function testOldInputSerializeData()

/**
* @see https://github.com/codeigniter4/CodeIgniter4/issues/1492
*
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testOldInputArray()
Expand Down Expand Up @@ -468,6 +475,7 @@ public function testRedirectResponseCookies1()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testTrace()
Expand All @@ -491,6 +499,7 @@ public function testViewNotSaveData()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testForceHttpsNullRequestAndResponse()
Expand Down Expand Up @@ -571,6 +580,7 @@ public function testDWithCSP()

/**
* @runInSeparateProcess
*
* @preserveGlobalState disabled
*/
public function testTraceWithCSP()
Expand Down

0 comments on commit eb44074

Please sign in to comment.