Skip to content

Commit

Permalink
Merge pull request #7794 from ya861220/230808-phpstan-View
Browse files Browse the repository at this point in the history
Fix: Remove the ignore errors of `View` in phpstan.
  • Loading branch information
kenjis authored Aug 10, 2023
2 parents d59f674 + 7d04deb commit b6c3977
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 97 deletions.
95 changes: 0 additions & 95 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2111,66 +2111,11 @@
'count' => 1,
'path' => __DIR__ . '/system/View/Cell.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Cell\\:\\:getMethodParams\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Cell.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Cell\\:\\:\\$cache \\(CodeIgniter\\\\Cache\\\\CacheInterface\\) in empty\\(\\) is not falsy\\.$#',
'count' => 2,
'path' => __DIR__ . '/system/View/Cell.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Cells\\\\Cell\\:\\:setView\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Cells/Cell.php',
];
$ignoreErrors[] = [
'message' => '#^Method class@anonymous/system/Traits/PropertiesTrait\\.php\\:47\\:\\:getProperties\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Cells/Cell.php',
];
$ignoreErrors[] = [
'message' => '#^Method class@anonymous/system/Traits/PropertiesTrait\\.php\\:47\\:\\:getProperties\\(\\) has parameter \\$obj with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Cells/Cell.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forInvalidCellClass\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forInvalidCellMethod\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forInvalidCellParameter\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forInvalidDecorator\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forMissingCellParameters\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forNoCellClass\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Exceptions\\\\ViewException\\:\\:forTagSyntaxError\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Exceptions/ViewException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:addPlugin\\(\\) has parameter \\$callback with no signature specified for callable\\.$#',
'count' => 1,
Expand All @@ -2181,50 +2126,10 @@
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_compileTemplate\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_setFromArray\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_setFromDBResult\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$function type has no signature specified for callable\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:endSection\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:extend\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:logPerformance\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:renderSection\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:section\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
2 changes: 1 addition & 1 deletion system/Traits/PropertiesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final public function fill(array $params): self
final public function getPublicProperties(): array
{
$worker = new class () {
public function getProperties($obj)
public function getProperties(object $obj): array
{
return get_object_vars($obj);
}
Expand Down
2 changes: 1 addition & 1 deletion system/View/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ final protected function renderCell(BaseCell $instance, string $method, array $p
* for a method, in the order they are defined. This allows
* them to be passed directly into the method.
*/
private function getMethodParams(BaseCell $instance, string $method, array $params)
private function getMethodParams(BaseCell $instance, string $method, array $params): array
{
$mountParams = [];

Expand Down
2 changes: 2 additions & 0 deletions system/View/Cells/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function render(): string

/**
* Sets the view to use when rendered.
*
* @return $this
*/
public function setView(string $view)
{
Expand Down
21 changes: 21 additions & 0 deletions system/View/Exceptions/ViewException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,57 @@

class ViewException extends FrameworkException
{
/**
* @return static
*/
public static function forInvalidCellMethod(string $class, string $method)
{
return new static(lang('View.invalidCellMethod', ['class' => $class, 'method' => $method]));
}

/**
* @return static
*/
public static function forMissingCellParameters(string $class, string $method)
{
return new static(lang('View.missingCellParameters', ['class' => $class, 'method' => $method]));
}

/**
* @return static
*/
public static function forInvalidCellParameter(string $key)
{
return new static(lang('View.invalidCellParameter', [$key]));
}

/**
* @return static
*/
public static function forNoCellClass()
{
return new static(lang('View.noCellClass'));
}

/**
* @return static
*/
public static function forInvalidCellClass(?string $class = null)
{
return new static(lang('View.invalidCellClass', [$class]));
}

/**
* @return static
*/
public static function forTagSyntaxError(string $output)
{
return new static(lang('View.tagSyntaxError', [$output]));
}

/**
* @return static
*/
public static function forInvalidDecorator(string $className)
{
return new static(lang('View.invalidDecoratorClass', [$className]));
Expand Down
6 changes: 6 additions & 0 deletions system/View/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ public function clear()
* Set table data from a database result object
*
* @param BaseResult $object Database result object
*
* @return void
*/
protected function _setFromDBResult($object)
{
Expand All @@ -428,6 +430,8 @@ protected function _setFromDBResult($object)
* Set table data from an array
*
* @param array $data
*
* @return void
*/
protected function _setFromArray($data)
{
Expand All @@ -442,6 +446,8 @@ protected function _setFromArray($data)

/**
* Compile Template
*
* @return void
*/
protected function _compileTemplate()
{
Expand Down
10 changes: 10 additions & 0 deletions system/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ public function getData(): array

/**
* Specifies that the current view should extend an existing layout.
*
* @return void
*/
public function extend(string $layout)
{
Expand All @@ -394,6 +396,8 @@ public function extend(string $layout)
* Starts holds content for a section within the layout.
*
* @param string $name Section name
*
* @return void
*/
public function section(string $name)
{
Expand All @@ -407,6 +411,8 @@ public function section(string $name)
/**
* Captures the last section
*
* @return void
*
* @throws RuntimeException
*/
public function endSection()
Expand All @@ -429,6 +435,8 @@ public function endSection()

/**
* Renders a section's contents.
*
* @return void
*/
public function renderSection(string $sectionName)
{
Expand Down Expand Up @@ -465,6 +473,8 @@ public function getPerformanceData(): array

/**
* Logs performance data for rendering a view.
*
* @return void
*/
protected function logPerformance(float $start, float $end, string $view)
{
Expand Down

0 comments on commit b6c3977

Please sign in to comment.