Skip to content

Commit b6c3977

Browse files
authored
Merge pull request #7794 from ya861220/230808-phpstan-View
Fix: Remove the ignore errors of `View` in phpstan.
2 parents d59f674 + 7d04deb commit b6c3977

7 files changed

Lines changed: 41 additions & 97 deletions

File tree

phpstan-baseline.php

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,66 +2111,11 @@
21112111
'count' => 1,
21122112
'path' => __DIR__ . '/system/View/Cell.php',
21132113
];
2114-
$ignoreErrors[] = [
2115-
'message' => '#^Method CodeIgniter\\\\View\\\\Cell\\:\\:getMethodParams\\(\\) has no return type specified\\.$#',
2116-
'count' => 1,
2117-
'path' => __DIR__ . '/system/View/Cell.php',
2118-
];
21192114
$ignoreErrors[] = [
21202115
'message' => '#^Property CodeIgniter\\\\View\\\\Cell\\:\\:\\$cache \\(CodeIgniter\\\\Cache\\\\CacheInterface\\) in empty\\(\\) is not falsy\\.$#',
21212116
'count' => 2,
21222117
'path' => __DIR__ . '/system/View/Cell.php',
21232118
];
2124-
$ignoreErrors[] = [
2125-
'message' => '#^Method CodeIgniter\\\\View\\\\Cells\\\\Cell\\:\\:setView\\(\\) has no return type specified\\.$#',
2126-
'count' => 1,
2127-
'path' => __DIR__ . '/system/View/Cells/Cell.php',
2128-
];
2129-
$ignoreErrors[] = [
2130-
'message' => '#^Method class@anonymous/system/Traits/PropertiesTrait\\.php\\:47\\:\\:getProperties\\(\\) has no return type specified\\.$#',
2131-
'count' => 1,
2132-
'path' => __DIR__ . '/system/View/Cells/Cell.php',
2133-
];
2134-
$ignoreErrors[] = [
2135-
'message' => '#^Method class@anonymous/system/Traits/PropertiesTrait\\.php\\:47\\:\\:getProperties\\(\\) has parameter \\$obj with no type specified\\.$#',
2136-
'count' => 1,
2137-
'path' => __DIR__ . '/system/View/Cells/Cell.php',
2138-
];
2139-
$ignoreErrors[] = [
2140-
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forInvalidCellClass\\(\\) has no return type specified\\.$#',
2141-
'count' => 1,
2142-
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
2143-
];
2144-
$ignoreErrors[] = [
2145-
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forInvalidCellMethod\\(\\) has no return type specified\\.$#',
2146-
'count' => 1,
2147-
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
2148-
];
2149-
$ignoreErrors[] = [
2150-
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forInvalidCellParameter\\(\\) has no return type specified\\.$#',
2151-
'count' => 1,
2152-
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
2153-
];
2154-
$ignoreErrors[] = [
2155-
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forInvalidDecorator\\(\\) has no return type specified\\.$#',
2156-
'count' => 1,
2157-
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
2158-
];
2159-
$ignoreErrors[] = [
2160-
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forMissingCellParameters\\(\\) has no return type specified\\.$#',
2161-
'count' => 1,
2162-
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
2163-
];
2164-
$ignoreErrors[] = [
2165-
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forNoCellClass\\(\\) has no return type specified\\.$#',
2166-
'count' => 1,
2167-
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
2168-
];
2169-
$ignoreErrors[] = [
2170-
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forTagSyntaxError\\(\\) has no return type specified\\.$#',
2171-
'count' => 1,
2172-
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
2173-
];
21742119
$ignoreErrors[] = [
21752120
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:addPlugin\\(\\) has parameter \\$callback with no signature specified for callable\\.$#',
21762121
'count' => 1,
@@ -2181,50 +2126,10 @@
21812126
'count' => 1,
21822127
'path' => __DIR__ . '/system/View/Parser.php',
21832128
];
2184-
$ignoreErrors[] = [
2185-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_compileTemplate\\(\\) has no return type specified\\.$#',
2186-
'count' => 1,
2187-
'path' => __DIR__ . '/system/View/Table.php',
2188-
];
2189-
$ignoreErrors[] = [
2190-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_setFromArray\\(\\) has no return type specified\\.$#',
2191-
'count' => 1,
2192-
'path' => __DIR__ . '/system/View/Table.php',
2193-
];
2194-
$ignoreErrors[] = [
2195-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_setFromDBResult\\(\\) has no return type specified\\.$#',
2196-
'count' => 1,
2197-
'path' => __DIR__ . '/system/View/Table.php',
2198-
];
21992129
$ignoreErrors[] = [
22002130
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$function type has no signature specified for callable\\.$#',
22012131
'count' => 1,
22022132
'path' => __DIR__ . '/system/View/Table.php',
22032133
];
2204-
$ignoreErrors[] = [
2205-
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:endSection\\(\\) has no return type specified\\.$#',
2206-
'count' => 1,
2207-
'path' => __DIR__ . '/system/View/View.php',
2208-
];
2209-
$ignoreErrors[] = [
2210-
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:extend\\(\\) has no return type specified\\.$#',
2211-
'count' => 1,
2212-
'path' => __DIR__ . '/system/View/View.php',
2213-
];
2214-
$ignoreErrors[] = [
2215-
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:logPerformance\\(\\) has no return type specified\\.$#',
2216-
'count' => 1,
2217-
'path' => __DIR__ . '/system/View/View.php',
2218-
];
2219-
$ignoreErrors[] = [
2220-
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:renderSection\\(\\) has no return type specified\\.$#',
2221-
'count' => 1,
2222-
'path' => __DIR__ . '/system/View/View.php',
2223-
];
2224-
$ignoreErrors[] = [
2225-
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:section\\(\\) has no return type specified\\.$#',
2226-
'count' => 1,
2227-
'path' => __DIR__ . '/system/View/View.php',
2228-
];
22292134

22302135
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

system/Traits/PropertiesTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final public function fill(array $params): self
4545
final public function getPublicProperties(): array
4646
{
4747
$worker = new class () {
48-
public function getProperties($obj)
48+
public function getProperties(object $obj): array
4949
{
5050
return get_object_vars($obj);
5151
}

system/View/Cell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ final protected function renderCell(BaseCell $instance, string $method, array $p
234234
* for a method, in the order they are defined. This allows
235235
* them to be passed directly into the method.
236236
*/
237-
private function getMethodParams(BaseCell $instance, string $method, array $params)
237+
private function getMethodParams(BaseCell $instance, string $method, array $params): array
238238
{
239239
$mountParams = [];
240240

system/View/Cells/Cell.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public function render(): string
5151

5252
/**
5353
* Sets the view to use when rendered.
54+
*
55+
* @return $this
5456
*/
5557
public function setView(string $view)
5658
{

system/View/Exceptions/ViewException.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,57 @@
1515

1616
class ViewException extends FrameworkException
1717
{
18+
/**
19+
* @return static
20+
*/
1821
public static function forInvalidCellMethod(string $class, string $method)
1922
{
2023
return new static(lang('View.invalidCellMethod', ['class' => $class, 'method' => $method]));
2124
}
2225

26+
/**
27+
* @return static
28+
*/
2329
public static function forMissingCellParameters(string $class, string $method)
2430
{
2531
return new static(lang('View.missingCellParameters', ['class' => $class, 'method' => $method]));
2632
}
2733

34+
/**
35+
* @return static
36+
*/
2837
public static function forInvalidCellParameter(string $key)
2938
{
3039
return new static(lang('View.invalidCellParameter', [$key]));
3140
}
3241

42+
/**
43+
* @return static
44+
*/
3345
public static function forNoCellClass()
3446
{
3547
return new static(lang('View.noCellClass'));
3648
}
3749

50+
/**
51+
* @return static
52+
*/
3853
public static function forInvalidCellClass(?string $class = null)
3954
{
4055
return new static(lang('View.invalidCellClass', [$class]));
4156
}
4257

58+
/**
59+
* @return static
60+
*/
4361
public static function forTagSyntaxError(string $output)
4462
{
4563
return new static(lang('View.tagSyntaxError', [$output]));
4664
}
4765

66+
/**
67+
* @return static
68+
*/
4869
public static function forInvalidDecorator(string $className)
4970
{
5071
return new static(lang('View.invalidDecoratorClass', [$className]));

system/View/Table.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ public function clear()
411411
* Set table data from a database result object
412412
*
413413
* @param BaseResult $object Database result object
414+
*
415+
* @return void
414416
*/
415417
protected function _setFromDBResult($object)
416418
{
@@ -428,6 +430,8 @@ protected function _setFromDBResult($object)
428430
* Set table data from an array
429431
*
430432
* @param array $data
433+
*
434+
* @return void
431435
*/
432436
protected function _setFromArray($data)
433437
{
@@ -442,6 +446,8 @@ protected function _setFromArray($data)
442446

443447
/**
444448
* Compile Template
449+
*
450+
* @return void
445451
*/
446452
protected function _compileTemplate()
447453
{

system/View/View.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ public function getData(): array
384384

385385
/**
386386
* Specifies that the current view should extend an existing layout.
387+
*
388+
* @return void
387389
*/
388390
public function extend(string $layout)
389391
{
@@ -394,6 +396,8 @@ public function extend(string $layout)
394396
* Starts holds content for a section within the layout.
395397
*
396398
* @param string $name Section name
399+
*
400+
* @return void
397401
*/
398402
public function section(string $name)
399403
{
@@ -407,6 +411,8 @@ public function section(string $name)
407411
/**
408412
* Captures the last section
409413
*
414+
* @return void
415+
*
410416
* @throws RuntimeException
411417
*/
412418
public function endSection()
@@ -429,6 +435,8 @@ public function endSection()
429435

430436
/**
431437
* Renders a section's contents.
438+
*
439+
* @return void
432440
*/
433441
public function renderSection(string $sectionName)
434442
{
@@ -465,6 +473,8 @@ public function getPerformanceData(): array
465473

466474
/**
467475
* Logs performance data for rendering a view.
476+
*
477+
* @return void
468478
*/
469479
protected function logPerformance(float $start, float $end, string $view)
470480
{

0 commit comments

Comments
 (0)