Skip to content

Commit

Permalink
PHPDoc types (#5960)
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Feb 28, 2024
1 parent db77f21 commit c677470
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 353 deletions.
Binary file modified .github/tests-visual/cronjob_cronjobs_add--dark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/tests-visual/cronjob_cronjobs_add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
290 changes: 0 additions & 290 deletions .tools/phpstan/baseline.neon

Large diffs are not rendered by default.

38 changes: 4 additions & 34 deletions .tools/psalm/baseline.xml
Expand Up @@ -1299,6 +1299,9 @@
<code><![CDATA[$params['id']]]></code>
<code><![CDATA[$params['id']]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$params]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$params['activeItem']]]></code>
</MixedAssignment>
Expand Down Expand Up @@ -3451,7 +3454,6 @@
</file>
<file src="redaxo/src/core/lib/autoload.php">
<MixedArgument>
<code><![CDATA[$class]]></code>
<code><![CDATA[$path]]></code>
<code><![CDATA[$path]]></code>
<code><![CDATA[$path]]></code>
Expand All @@ -3462,7 +3464,6 @@
<code><![CDATA[self::$dirs]]></code>
</MixedArrayAccess>
<MixedAssignment>
<code><![CDATA[$class]]></code>
<code><![CDATA[$file]]></code>
<code><![CDATA[$path]]></code>
<code><![CDATA[[self::$classes, self::$dirs]]]></code>
Expand Down Expand Up @@ -4079,8 +4080,6 @@
<code><![CDATA[$column['span'] ?? null]]></code>
<code><![CDATA[$column['width'] ?? null]]></code>
<code><![CDATA[$format[0]]]></code>
<code><![CDATA[$layout[0]]]></code>
<code><![CDATA[$layout[1]]]></code>
<code><![CDATA[$params]]></code>
<code><![CDATA[$string]]></code>
<code><![CDATA[$v]]></code>
Expand All @@ -4094,8 +4093,6 @@
</MixedArrayAssignment>
<MixedArrayOffset>
<code><![CDATA[$this->customColumns[$column]]]></code>
<code><![CDATA[$this->linkAttributes[$columnName]]]></code>
<code><![CDATA[$this->linkAttributes[$columnName][$attrName]]]></code>
<code><![CDATA[$this->linkAttributes[$column]]]></code>
</MixedArrayOffset>
<MixedAssignment>
Expand Down Expand Up @@ -4129,7 +4126,6 @@
</MixedOperand>
<MixedPropertyTypeCoercion>
<code><![CDATA[$attr]]></code>
<code><![CDATA[$this->linkAttributes]]></code>
</MixedPropertyTypeCoercion>
<MixedReturnStatement>
<code><![CDATA[$this->columnNames[$columnIndex] ?? $default]]></code>
Expand All @@ -4138,12 +4134,6 @@
<code><![CDATA[$this->linkAttributes[$column] ?? $default]]></code>
<code><![CDATA[json_decode($this->getValue($column), true)]]></code>
</MixedReturnStatement>
<PossiblyInvalidArgument>
<code><![CDATA[$columnValue]]></code>
</PossiblyInvalidArgument>
<PossiblyInvalidOperand>
<code><![CDATA[str_replace('###VALUE###', $columnHead, $layout[0])]]></code>
</PossiblyInvalidOperand>
<PossiblyNullArgument>
<code><![CDATA[$columnLayout]]></code>
<code><![CDATA[$column['width'] ?? null]]></code>
Expand Down Expand Up @@ -4263,24 +4253,6 @@
<code><![CDATA[$this->getDescription()]]></code>
</PossiblyNullArgument>
</file>
<file src="redaxo/src/core/lib/login/perm.php">
<MixedArgument>
<code><![CDATA[$perms]]></code>
</MixedArgument>
<MixedArrayAssignment>
<code><![CDATA[self::$perms[$group][$perm]]]></code>
</MixedArrayAssignment>
<MixedAssignment>
<code><![CDATA[$perms]]></code>
<code><![CDATA[$perms]]></code>
</MixedAssignment>
<MixedInferredReturnType>
<code><![CDATA[array]]></code>
</MixedInferredReturnType>
<MixedReturnStatement>
<code><![CDATA[$perms]]></code>
</MixedReturnStatement>
</file>
<file src="redaxo/src/core/lib/login/user.php">
<ArgumentTypeCoercion>
<code><![CDATA[$role]]></code>
Expand Down Expand Up @@ -4803,7 +4775,7 @@
</file>
<file src="redaxo/src/core/lib/util/file.php">
<MixedInferredReturnType>
<code><![CDATA[array|T]]></code>
<code><![CDATA[array<mixed>|T]]></code>
</MixedInferredReturnType>
<MixedReturnStatement>
<code><![CDATA[null === $content ? $default : json_decode($content, true)]]></code>
Expand Down Expand Up @@ -5180,7 +5152,6 @@
<file src="redaxo/src/core/pages/setup.php">
<MixedArgument>
<code><![CDATA[$config['timezone']]]></code>
<code><![CDATA[$error]]></code>
<code><![CDATA[$message]]></code>
<code><![CDATA[$messages]]></code>
<code><![CDATA[$value]]></code>
Expand All @@ -5200,7 +5171,6 @@
<code><![CDATA[$config['db'][1]['password']]]></code>
</MixedArrayAssignment>
<MixedAssignment>
<code><![CDATA[$error]]></code>
<code><![CDATA[$message]]></code>
<code><![CDATA[$messages]]></code>
<code><![CDATA[$value]]></code>
Expand Down
Expand Up @@ -15,6 +15,7 @@ class rex_extension_point_art_content_updated extends rex_extension_point
/** @var string */
private $action;

/** @param array<string, mixed> $params */
public function __construct(rex_article $article, string $action, string $subject = '', array $params = [], bool $readonly = false)
{
// for BC 'simple' attach params
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/api_function.php
Expand Up @@ -103,7 +103,7 @@ public static function factory()
*
* The method must be called on sub classes.
*
* @return array
* @return array<string, string>
*/
public static function getUrlParams()
{
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/autoload.php
Expand Up @@ -314,7 +314,7 @@ private static function _addDirectory($dir)
*
* @throws RuntimeException
*
* @return array The found classes
* @return list<string> The found classes
*/
private static function findClasses($path)
{
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/base/factory_trait.php
Expand Up @@ -90,7 +90,7 @@ public static function hasFactoryClass()
* Calls the factory class with the given method and arguments.
*
* @param string $method Method name
* @param array $arguments Array of arguments
* @param array<mixed> $arguments Array of arguments
*
* @return mixed Result of the callback
*
Expand Down
4 changes: 2 additions & 2 deletions redaxo/src/core/lib/base/instance_list_pool_trait.php
Expand Up @@ -9,14 +9,14 @@
*/
trait rex_instance_list_pool_trait
{
/** @var array<string, array> */
/** @var array<string, array<mixed>> */
private static $instanceLists = [];

/**
* Adds an instance list.
*
* @param mixed $key Key
* @param array $instanceKeyList Array of instance keys
* @param array<mixed> $instanceKeyList Array of instance keys
* @return void
*/
protected static function addInstanceList($key, array $instanceKeyList)
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/base/singleton_trait.php
Expand Up @@ -12,7 +12,7 @@ trait rex_singleton_trait
/**
* Singleton instances.
*
* @var static[]
* @var array<class-string<static>, static>
*/
private static $instances = [];

Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/csrf_token.php
Expand Up @@ -70,7 +70,7 @@ public function getHiddenField()
/**
* Returns an array containing the `_csrf_token` param.
*
* @return array
* @return array<self::PARAM, string>
*/
public function getUrlParams()
{
Expand Down
4 changes: 2 additions & 2 deletions redaxo/src/core/lib/extension.php
Expand Up @@ -18,7 +18,7 @@ abstract class rex_extension
/**
* Array of registered extensions.
*
* @var array<string, array<self::*, list<array{callable, array}>>>
* @var array<string, array<self::*, list<array{callable, array<string, mixed>}>>>
*/
private static $extensions = [];

Expand Down Expand Up @@ -72,7 +72,7 @@ public static function registerPoint(rex_extension_point $extensionPoint)
* @param string|string[] $extensionPoint Name(s) of extension point(s)
* @param callable(T):mixed $extension Callback extension
* @param self::* $level Runlevel (`rex_extension::EARLY`, `rex_extension::NORMAL` or `rex_extension::LATE`)
* @param array $params Additional params
* @param array<string, mixed> $params Additional params
* @return void
*/
public static function register($extensionPoint, callable $extension, $level = self::NORMAL, array $params = [])
Expand Down
8 changes: 5 additions & 3 deletions redaxo/src/core/lib/extension_point.php
Expand Up @@ -17,16 +17,17 @@ class rex_extension_point
private $name;
/** @var T */
private $subject;
/** @var array */
/** @var array<string, mixed> */
private $params = [];
/** @var array */
/** @var array<string, mixed> */
private $extensionParams = [];
/** @var bool */
private $readonly = false;

/**
* @param string $name
* @param T $subject
* @param array<string, mixed> $params
* @param bool $readonly
*/
public function __construct($name, $subject = null, array $params = [], $readonly = false)
Expand Down Expand Up @@ -91,6 +92,7 @@ public function setParam($key, $value)

/**
* Sets the specific params for the next extension.
* @param array<string, mixed> $params
* @return void
*/
public function setExtensionParams(array $params)
Expand Down Expand Up @@ -126,7 +128,7 @@ public function getParam($key, $default = null)
/**
* Returns all params.
*
* @return array
* @return array<string, mixed>
*/
public function getParams()
{
Expand Down
5 changes: 4 additions & 1 deletion redaxo/src/core/lib/list.php
Expand Up @@ -363,6 +363,9 @@ public function getFormAttributes()
}

/**
* @param string $columnName
* @param string $attrName
* @param string|int $attrValue
* @return void
*/
public function addLinkAttribute($columnName, $attrName, $attrValue)
Expand Down Expand Up @@ -457,7 +460,7 @@ public function setColumnLayout($columnHead, $columnLayout)
*
* @param string $columnName Name der Spalte
*
* @return array
* @return array{string, string}
*/
public function getColumnLayout($columnName)
{
Expand Down
10 changes: 5 additions & 5 deletions redaxo/src/core/lib/login/perm.php
Expand Up @@ -16,16 +16,16 @@ abstract class rex_perm
/**
* Array of permissions.
*
* @var array
* @var array<self::*, array<string, string>>
*/
private static $perms = [];

/**
* Registers a new permission.
*
* @param string $perm Perm key
* @param string $name Perm name
* @param string $group Perm group, possible values are rex_perm::GENERAL, rex_perm::OPTIONS and rex_perm::EXTRAS
* @param string|null $name Perm name
* @param self::* $group Perm group, possible values are rex_perm::GENERAL, rex_perm::OPTIONS and rex_perm::EXTRAS
* @return void
*/
public static function register($perm, $name = null, $group = self::GENERAL)
Expand Down Expand Up @@ -59,9 +59,9 @@ public static function has($perm)
/**
* Returns all permissions for the given group.
*
* @param string $group Perm group
* @param self::* $group Perm group
*
* @return array Permissions
* @return array<string, string> Permissions
*/
public static function getAll($group = self::GENERAL)
{
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/setup/setup.php
Expand Up @@ -61,7 +61,7 @@ public static function init($skinAddon = 'be_style', $skinPlugin = 'redaxo')
/**
* checks environment related conditions.
*
* @return array An array of error messages
* @return list<string> An array of error messages
*/
public static function checkEnvironment()
{
Expand Down
8 changes: 4 additions & 4 deletions redaxo/src/core/lib/sql/sql.php
Expand Up @@ -301,7 +301,7 @@ public static function datetime($timestamp = null)
*
* @param string $query The sql-query
* @param array $params An optional array of statement parameter
* @param array $options For possible option keys view `rex_sql::OPT_*` constants
* @param array<self::OPT_*, bool> $options For possible option keys view `rex_sql::OPT_*` constants
*
* @throws rex_sql_exception on errors
*
Expand Down Expand Up @@ -371,7 +371,7 @@ public function prepareQuery($query)
* Executes the prepared statement with the given input parameters.
*
* @param array $params Array of input parameters
* @param array $options For possible option keys view `rex_sql::OPT_*` constants
* @param array<self::OPT_*, bool> $options For possible option keys view `rex_sql::OPT_*` constants
*
* @throws rex_sql_exception
*
Expand Down Expand Up @@ -436,7 +436,7 @@ public function execute(array $params = [], array $options = [])
*
* @param string $query The sql-query
* @param array $params An optional array of statement parameter
* @param array $options For possible option keys view `rex_sql::OPT_*` constants
* @param array<self::OPT_*, bool> $options For possible option keys view `rex_sql::OPT_*` constants
*
* @throws rex_sql_exception on errors
*
Expand Down Expand Up @@ -747,7 +747,7 @@ public function getValue($column)
*
* @throws rex_sql_exception
*
* @return array
* @return array<mixed>
*/
public function getArrayValue($column)
{
Expand Down
8 changes: 4 additions & 4 deletions redaxo/src/core/lib/util/file.php
Expand Up @@ -53,7 +53,7 @@ public static function get($file, $default = null)
* @template T
* @param string $file Path to the file
* @param T $default Default value
* @return array|T Content of the file or default value if the file isn't readable
* @return array<mixed>|T Content of the file or default value if the file isn't readable
*/
public static function getConfig($file, $default = [])
{
Expand All @@ -67,7 +67,7 @@ public static function getConfig($file, $default = [])
* @template T
* @param string $file Path to the file
* @param T $default Default value
* @return array|T Content of the file or default value if the file isn't readable
* @return array<mixed>|T Content of the file or default value if the file isn't readable
*/
public static function getCache($file, $default = [])
{
Expand Down Expand Up @@ -144,7 +144,7 @@ public static function append(string $file, string $content, string $delimiter =
* Puts content in a config file.
*
* @param string $file Path to the file
* @param array $content Content for the file
* @param array<mixed> $content Content for the file
* @param int $inline The level where you switch to inline YAML
*
* @return bool TRUE on success, FALSE on failure
Expand All @@ -160,7 +160,7 @@ public static function putConfig($file, $content, $inline = 3)
* Puts content in a cache file.
*
* @param string $file Path to the file
* @param array $content Content for the file
* @param array<mixed> $content Content for the file
*
* @return bool TRUE on success, FALSE on failure
*
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/util/markdown.php
Expand Up @@ -53,7 +53,7 @@ public function parse($code, $options = [])
* @param int $bottomLevel Bottom included headline level for TOC, e.g. `6` for `<h6>`
* @param array<self::*, bool>|bool $options
*
* @return array tupel of table-of-content and content
* @return list{string, string} tupel of table-of-content and content
*/
public function parseWithToc($code, $topLevel = 2, $bottomLevel = 3, $options = [])
{
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/util/string.php
Expand Up @@ -149,7 +149,7 @@ public static function yamlEncode(array $value, $inline = 3)
*
* @throws rex_yaml_parse_exception
*
* @return array
* @return array<mixed>
*/
public static function yamlDecode($value)
{
Expand Down

0 comments on commit c677470

Please sign in to comment.