Skip to content
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

fix: Remove the ignore errors of View in phpstan. #7793

Closed
wants to merge 3 commits into from
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
115 changes: 0 additions & 115 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,26 +806,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Email/Email.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Encryption\\\\Handlers\\\\SodiumHandler\\:\\:parseParams\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Encryption/Handlers/SodiumHandler.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$casts has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Entity/Entity.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$datamap has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Entity/Entity.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$dates has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Entity/Entity.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Events\\\\Events\\:\\:on\\(\\) has parameter \\$callback with no signature specified for callable\\.$#',
'count' => 1,
Expand Down Expand Up @@ -2436,66 +2416,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 @@ -2506,50 +2431,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: 2 additions & 0 deletions system/Encryption/Handlers/SodiumHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public function decrypt($data, $params = null)
*
* @param array|string|null $params
*
* @return void
*
* @throws EncryptionException If key is empty
*/
protected function parseParams($params)
Expand Down
10 changes: 10 additions & 0 deletions system/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,17 @@ class Entity implements JsonSerializable
* $datamap = [
* 'class_property_name' => 'db_column_name'
* ];
*
* @var array<string, string>
*/
protected $datamap = [];

/**
* The date fields.
*
* @var array<int, string>
* @phpstan-var list<string>
*/
protected $dates = [
'created_at',
'updated_at',
Expand All @@ -57,6 +65,8 @@ class Entity implements JsonSerializable
/**
* Array of field names and the type of value to cast them as when
* they are accessed.
*
* @var array<string, string>
*/
protected $casts = [];

Expand Down
5 changes: 5 additions & 0 deletions system/Traits/PropertiesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ final public function fill(array $params): self
final public function getPublicProperties(): array
{
$worker = new class () {
/**
* @param object $obj
*
* @return array
*/
public function getProperties($obj)
{
return get_object_vars($obj);
Expand Down
2 changes: 2 additions & 0 deletions system/View/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ final protected function renderCell(BaseCell $instance, string $method, array $p
* Returns the values from $params that match the parameters
* for a method, in the order they are defined. This allows
* them to be passed directly into the method.
*
* @return array
*/
private function getMethodParams(BaseCell $instance, string $method, array $params)
{
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 ViewException
*/
public static function forInvalidCellMethod(string $class, string $method)
{
return new static(lang('View.invalidCellMethod', ['class' => $class, 'method' => $method]));
}

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

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

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

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

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

/**
* @return ViewException
*/
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