Skip to content
Closed
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: 0 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\BooleanNot\NegatedAndsToPositiveOrsRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
Expand Down Expand Up @@ -176,7 +175,6 @@
],

// to be applied in separate PRs to ease review
NegatedAndsToPositiveOrsRector::class,
])
// auto import fully qualified class names
->withImportNames()
Expand Down
12 changes: 11 additions & 1 deletion system/DataCaster/Cast/DatetimeCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Exceptions\InvalidArgumentException;
use CodeIgniter\I18n\Time;
use DateTimeInterface;
use Exception;

/**
* Class DatetimeCast
Expand Down Expand Up @@ -51,7 +53,15 @@ public static function set(
array $params = [],
?object $helper = null,
): string {
if (! $value instanceof Time) {
if (is_string($value)) {
try {
$value = Time::parse($value);
} catch (Exception) {
self::invalidTypeValueError($value);
}
}

if (! $value instanceof DateTimeInterface) {
self::invalidTypeValueError($value);
}

Expand Down
6 changes: 2 additions & 4 deletions system/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,7 @@ public function toRawArray(bool $onlyChanged = false, bool $recursive = false):

// When returning everything
if (! $onlyChanged) {
return $recursive
? array_map($convert, $this->attributes)
: $this->attributes;
return array_map($convert, $this->attributes);
}

// When filtering by changed values only
Expand Down Expand Up @@ -335,7 +333,7 @@ public function toRawArray(bool $onlyChanged = false, bool $recursive = false):
}

// non-recursive changed value
$return[$key] = $value;
$return[$key] = $convert($value);
}

return $return;
Expand Down
127 changes: 126 additions & 1 deletion utils/phpstan-baseline/argument.type.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# total 68 errors
# total 228 errors

parameters:
ignoreErrors:
-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\RedirectResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../system/Config/Services.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 2
path: ../../system/Config/Services.php

-
message: '#^Parameter \#3 \.\.\.\$arrays of function array_map expects array, int\|string given\.$#'
count: 1
Expand All @@ -22,6 +32,26 @@ parameters:
count: 1
path: ../../system/Database/SQLite3/Builder.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../system/HTTP/CURLRequest.php

-
message: '#^Parameter \#1 \$config of method CodeIgniter\\HTTP\\Response\:\:__construct\(\) expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../system/HTTP/DownloadResponse.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\Test\\Mock\\MockResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 2
path: ../../tests/system/API/ResponseTraitTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 19
path: ../../tests/system/Cache/ResponseCacheTest.php

-
message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: CodeIgniter\\HTTP\\ResponseInterface given\.$#'
count: 1
Expand All @@ -42,6 +72,11 @@ parameters:
count: 1
path: ../../tests/system/CodeIgniterTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\RedirectResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 3
path: ../../tests/system/CommonFunctionsTest.php

-
message: '#^Parameter \#1 \$expected of method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) expects class\-string\<Config\\TestRegistrar\>, string given\.$#'
count: 1
Expand All @@ -52,6 +87,16 @@ parameters:
count: 2
path: ../../tests/system/Config/FactoriesTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\Test\\Mock\\MockResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 7
path: ../../tests/system/Config/ServicesTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../tests/system/ControllerTest.php

-
message: '#^Parameter \#1 \$from of method CodeIgniter\\Database\\BaseBuilder\:\:from\(\) expects array\|string, null given\.$#'
count: 1
Expand Down Expand Up @@ -97,16 +142,66 @@ parameters:
count: 1
path: ../../tests/system/Debug/TimerTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\RedirectResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../tests/system/Filters/PageCacheTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 10
path: ../../tests/system/Filters/PageCacheTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../tests/system/HTTP/CURLRequestShareOptionsTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../tests/system/HTTP/CURLRequestTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 6
path: ../../tests/system/HTTP/ContentSecurityPolicyTest.php

-
message: '#^Parameter \#1 \$array of method CodeIgniter\\Superglobals\:\:setServerArray\(\) expects array\<string, array\<mixed\>\|float\|int\|string\>, array\<string, string\|null\> given\.$#'
count: 1
path: ../../tests/system/HTTP/MessageTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\RedirectResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 15
path: ../../tests/system/HTTP/RedirectResponseTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 27
path: ../../tests/system/HTTP/ResponseCookieTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 5
path: ../../tests/system/HTTP/ResponseSendTest.php

-
message: '#^Parameter \#3 \$expire of method CodeIgniter\\HTTP\\Response\:\:setCookie\(\) expects int, string given\.$#'
count: 1
path: ../../tests/system/HTTP/ResponseSendTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 43
path: ../../tests/system/HTTP/ResponseTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\Test\\Mock\\MockResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 2
path: ../../tests/system/HTTP/ResponseTest.php

-
message: '#^Parameter \#1 \$data of method CodeIgniter\\HTTP\\Message\:\:setBody\(\) expects string, array\<string, list\<int\>\|string\> given\.$#'
count: 2
Expand All @@ -122,6 +217,11 @@ parameters:
count: 1
path: ../../tests/system/HTTP/SiteURITest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\Test\\Mock\\MockResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../tests/system/Helpers/CookieHelperTest.php

-
message: '#^Parameter \#2 \$value of function form_hidden expects array\|string, null given\.$#'
count: 1
Expand Down Expand Up @@ -152,11 +252,21 @@ parameters:
count: 2
path: ../../tests/system/Images/GDHandlerTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\Test\\Mock\\MockResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../tests/system/Log/Handlers/ChromeLoggerHandlerTest.php

-
message: '#^Parameter \#2 \$message of method CodeIgniter\\Log\\Handlers\\ChromeLoggerHandler\:\:handle\(\) expects string, stdClass given\.$#'
count: 1
path: ../../tests/system/Log/Handlers/ChromeLoggerHandlerTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 2
path: ../../tests/system/RESTful/ResourceControllerTest.php

-
message: '#^Parameter \#1 \$format of method CodeIgniter\\RESTful\\ResourceController\:\:setFormat\(\) expects ''json''\|''xml'', ''Nonsense'' given\.$#'
count: 1
Expand All @@ -172,6 +282,11 @@ parameters:
count: 1
path: ../../tests/system/Test/FeatureTestTraitTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 2
path: ../../tests/system/Test/TestCaseEmissionsTest.php

-
message: '#^Parameter \#1 \$body of method CodeIgniter\\HTTP\\Response\:\:setJSON\(\) expects array\|object\|string, false given\.$#'
count: 1
Expand All @@ -182,6 +297,16 @@ parameters:
count: 1
path: ../../tests/system/Test/TestResponseTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\RedirectResponse constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 5
path: ../../tests/system/Test/TestResponseTest.php

-
message: '#^Parameter \#1 \$config of class CodeIgniter\\HTTP\\Response constructor expects CodeIgniter\\HTTP\\App, Config\\App given\.$#'
count: 1
path: ../../tests/system/Test/TestResponseTest.php

-
message: '#^Parameter \#3 \$errors of method CodeIgniter\\Validation\\Validation\:\:check\(\) expects list\<string\>, array\{is_numeric\: ''Nope\. Not a number\.''\} given\.$#'
count: 1
Expand Down
2 changes: 1 addition & 1 deletion utils/phpstan-baseline/empty.notAllowed.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 212 errors
# total 205 errors

parameters:
ignoreErrors:
Expand Down
2 changes: 1 addition & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 1819 errors
# total 1972 errors

includes:
- argument.type.neon
Expand Down
Loading