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

Dev: Remove the config ignore errors. #7764

Merged
merged 4 commits into from
Aug 4, 2023
Merged
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
67 changes: 16 additions & 51 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
'message' => '#^PHPDoc type array of property Config\\\\View\\:\\:\\$filters is not covariant with PHPDoc type array\\<string, callable\\-string\\> of overridden property CodeIgniter\\\\Config\\\\View\\:\\:\\$filters\\.$#',
'count' => 1,
'path' => __DIR__ . '/app/Config/View.php',
];
$ignoreErrors[] = [
'message' => '#^PHPDoc type array of property Config\\\\View\\:\\:\\$plugins is not covariant with PHPDoc type array\\<string, callable\\-string\\> of overridden property CodeIgniter\\\\Config\\\\View\\:\\:\\$plugins\\.$#',
'count' => 1,
'path' => __DIR__ . '/app/Config/View.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$callback of function spl_autoload_register expects \\(callable\\(string\\)\\: void\\)\\|null, array\\{\\$this\\(CodeIgniter\\\\Autoloader\\\\Autoloader\\), \'loadClass\'\\} given\\.$#',
'count' => 1,
Expand Down Expand Up @@ -317,67 +327,22 @@
'path' => __DIR__ . '/system/ComposerScripts.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\BaseConfig\\:\\:registerProperties\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/BaseConfig.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\BaseService\\:\\:injectMock\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/BaseService.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\BaseService\\:\\:reset\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/BaseService.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\BaseService\\:\\:resetSingle\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/BaseService.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\Config\\:\\:injectMock\\(\\) has no return type specified\\.$#',
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$coreFilters type has no signature specified for callable\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/Config.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\Config\\:\\:reset\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/Config.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\DotEnv\\:\\:setVariable\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/DotEnv.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\Factories\\:\\:injectMock\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/Factories.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\Factories\\:\\:reset\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/Factories.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Config\\\\ForeignCharacters\\:\\:\\$characterList has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/ForeignCharacters.php',
'path' => __DIR__ . '/system/Config/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\Publisher\\:\\:registerProperties\\(\\) has no return type specified\\.$#',
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$corePlugins type has no signature specified for callable\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/Publisher.php',
'path' => __DIR__ . '/system/Config/View.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$filters has no type specified\\.$#',
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$filters type has no signature specified for callable\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/View.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$plugins has no type specified\\.$#',
'message' => '#^Property CodeIgniter\\\\Config\\\\View\\:\\:\\$plugins type has no signature specified for callable\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Config/View.php',
];
Expand Down
2 changes: 2 additions & 0 deletions system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ protected function getEnvValue(string $property, string $prefix, string $shortPr
* Provides external libraries a simple way to register one or more
* options into a config file.
*
* @return void
*
* @throws ReflectionException
*/
protected function registerProperties()
Expand Down
6 changes: 6 additions & 0 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ public static function serviceExists(string $name): ?string

/**
* Reset shared instances and mocks for testing.
*
* @return void
*/
public static function reset(bool $initAutoloader = true)
{
Expand All @@ -286,6 +288,8 @@ public static function reset(bool $initAutoloader = true)

/**
* Resets any mock and shared instances for a single service.
*
* @return void
*/
public static function resetSingle(string $name)
{
Expand All @@ -297,6 +301,8 @@ public static function resetSingle(string $name)
* Inject mock object for testing.
*
* @param object $mock
*
* @return void
*/
public static function injectMock(string $name, $mock)
{
Expand Down
4 changes: 4 additions & 0 deletions system/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static function get(string $name, bool $getShared = true)
* Helper method for injecting mock instances while testing.
*
* @param object $instance
*
* @return void
*/
public static function injectMock(string $name, $instance)
{
Expand All @@ -42,6 +44,8 @@ public static function injectMock(string $name, $instance)

/**
* Resets the static arrays
*
* @return void
*/
public static function reset()
{
Expand Down
2 changes: 2 additions & 0 deletions system/Config/DotEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public function parse(): ?array
* Sets the variable into the environment. Will parse the string
* first to look for {name}={value} pattern, ensure that nested
* variables are handled, and strip it of single and double quotes.
*
* @return void
*/
protected function setVariable(string $name, string $value = '')
{
Expand Down
4 changes: 4 additions & 0 deletions system/Config/Factories.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ public static function setOptions(string $component, array $values): array
* Resets the static arrays, optionally just for one component
*
* @param string|null $component Lowercase, plural component name
*
* @return void
*/
public static function reset(?string $component = null)
{
Expand All @@ -290,6 +292,8 @@ public static function reset(?string $component = null)
*
* @param string $component Lowercase, plural component name
* @param string $name The name of the instance
*
* @return void
*/
public static function injectMock(string $component, string $name, object $instance)
{
Expand Down
4 changes: 3 additions & 1 deletion system/Config/ForeignCharacters.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
class ForeignCharacters
{
/**
* Without further ado, the list of foreign characters.
* The list of foreign characters.
*
* @var array<string, string>
*/
public $characterList = [
'/ä|æ|ǽ/' => 'ae',
Expand Down
2 changes: 1 addition & 1 deletion system/Config/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Publisher extends BaseConfig
/**
* Disables Registrars to prevent modules from altering the restrictions.
*/
final protected function registerProperties()
final protected function registerProperties(): void
{
}
}
12 changes: 10 additions & 2 deletions system/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,27 @@ class View extends BaseConfig
*
* To prevent potential abuse, all filters MUST be defined here
* in order for them to be available for use within the Parser.
*
* @var array<string, string>
* @phpstan-var array<string, callable-string>
*/
public $filters = [];

/**
* Parser Plugins provide a way to extend the functionality provided
* by the core Parser by creating aliases that will be replaced with
* any callable. Can be single or tag pair.
*
* @var array<string, string>
* @phpstan-var array<string, callable-string>
*/
paulbalandan marked this conversation as resolved.
Show resolved Hide resolved
public $plugins = [];

/**
* Built-in View filters.
*
* @var array
* @var array<string, string>
* @phpstan-var array<string, callable-string>
*/
protected $coreFilters = [
'abs' => '\abs',
Expand Down Expand Up @@ -75,7 +82,8 @@ class View extends BaseConfig
/**
* Built-in View plugins.
*
* @var array
* @var array<string, string>
* @phpstan-var array<string, callable-string>
*/
protected $corePlugins = [
'csp_script_nonce' => '\CodeIgniter\View\Plugins::cspScriptNonce',
Expand Down