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

PHPDoc: Array-Types optimiert #5977

Merged
merged 1 commit into from
Mar 3, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions .tools/phpstan/baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2265,11 +2265,6 @@ parameters:
count: 1
path: ../../redaxo/src/core/lib/sql/util.php

-
message: "#^Method rex_system_report\\:\\:get\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../redaxo/src/core/lib/system_report.php

-
message: "#^Method rex_file\\:\\:formattedSize\\(\\) has parameter \\$format with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
85 changes: 27 additions & 58 deletions .tools/psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,13 @@
</PossiblyNullOperand>
</file>
<file src="redaxo/src/addons/cronjob/plugins/article_status/lib/cronjob.php">
<ArgumentTypeCoercion>
<code><![CDATA[$from['before']]]></code>
<code><![CDATA[$to['before']]]></code>
</ArgumentTypeCoercion>
<MixedArgument>
<code><![CDATA[$status]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$from['before']]]></code>
<code><![CDATA[$to['before']]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$status]]></code>
<code><![CDATA[$status]]></code>
Expand Down Expand Up @@ -1016,7 +1016,7 @@
})]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[rex_media[]]]></code>
<code><![CDATA[list<rex_media>]]></code>
</InvalidReturnType>
<MixedArgument>
<code><![CDATA[$id]]></code>
Expand Down Expand Up @@ -1475,7 +1475,7 @@
<code><![CDATA[$warning]]></code>
</MixedAssignment>
<MixedInferredReturnType>
<code><![CDATA[string[]]]></code>
<code><![CDATA[list<string>]]></code>
</MixedInferredReturnType>
<MixedMethodCall>
<code><![CDATA[getValue]]></code>
Expand Down Expand Up @@ -2041,10 +2041,10 @@
</MixedArgument>
</file>
<file src="redaxo/src/addons/structure/pages/index.php">
<MixedArgumentTypeCoercion>
<ArgumentTypeCoercion>
<code><![CDATA[$structureContext->getMountpoints()]]></code>
<code><![CDATA[$structureContext->getMountpoints()]]></code>
</MixedArgumentTypeCoercion>
</ArgumentTypeCoercion>
<MixedArrayAccess>
<code><![CDATA[$tEMPLATENAME[$sql->getValue('template_id')]]]></code>
<code><![CDATA[$tEMPLATENAME[(int) $sql->getValue('template_id')]]]></code>
Expand Down Expand Up @@ -2311,6 +2311,13 @@
<MixedAssignment>
<code><![CDATA[$templateName]]></code>
</MixedAssignment>
<MixedPropertyTypeCoercion>
<code><![CDATA[$this->templates]]></code>
</MixedPropertyTypeCoercion>
<MixedReturnTypeCoercion>
<code><![CDATA[$this->templates]]></code>
<code><![CDATA[array<int, string>]]></code>
</MixedReturnTypeCoercion>
</file>
<file src="redaxo/src/addons/structure/plugins/content/lib/var_template.php">
<PossiblyFalseArgument>
Expand Down Expand Up @@ -3468,10 +3475,6 @@
<MixedMethodCall>
<code><![CDATA[unregister]]></code>
</MixedMethodCall>
<MixedReturnTypeCoercion>
<code><![CDATA[array_keys(self::$classes)]]></code>
<code><![CDATA[string[]]]></code>
</MixedReturnTypeCoercion>
<PossiblyNullArgument>
<code><![CDATA[self::$cacheFile]]></code>
<code><![CDATA[self::$cacheFile]]></code>
Expand Down Expand Up @@ -3579,12 +3582,9 @@
<code><![CDATA[$key]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<MixedReturnTypeCoercion>
<code><![CDATA[$id]]></code>
<code><![CDATA[array_keys(self::getAll($ignoreOfflines))]]></code>
<code><![CDATA[int]]></code>
<code><![CDATA[int[]]]></code>
</MixedReturnTypeCoercion>
<MixedPropertyTypeCoercion>
<code><![CDATA[self::$clangs]]></code>
</MixedPropertyTypeCoercion>
</file>
<file src="redaxo/src/core/lib/clang/service.php">
<PossiblyNullReference>
Expand Down Expand Up @@ -3803,14 +3803,6 @@
<code><![CDATA[$charset]]></code>
</MixedReturnStatement>
</file>
<file src="redaxo/src/core/lib/console/system/report.php">
<MixedArgumentTypeCoercion>
<code><![CDATA[$label]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$value]]></code>
</MixedAssignment>
</file>
<file src="redaxo/src/core/lib/console/user/create.php">
<MixedArgument>
<code><![CDATA[$password]]></code>
Expand Down Expand Up @@ -4393,7 +4385,7 @@
<code><![CDATA[$successMessage]]></code>
</MixedOperand>
<MoreSpecificReturnType>
<code><![CDATA[non-empty-string[]]]></code>
<code><![CDATA[list<non-empty-string>]]></code>
</MoreSpecificReturnType>
<PossiblyNullArrayAccess>
<code><![CDATA[$config[$addonName]['plugins'][$pluginName]]]></code>
Expand Down Expand Up @@ -4750,21 +4742,12 @@
<ArgumentTypeCoercion>
<code><![CDATA[$dbId]]></code>
</ArgumentTypeCoercion>
<MixedArgument>
<code><![CDATA[$value]]></code>
<code><![CDATA[$value]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$groupLabel]]></code>
<code><![CDATA[$groupLabel]]></code>
<code><![CDATA[$label]]></code>
<code><![CDATA[$label]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$rows[$label]]]></code>
<code><![CDATA[$value]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<InvalidReturnStatement>
<code><![CDATA[$data]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[array<string, array<string, string|bool>>]]></code>
</InvalidReturnType>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$_SERVER['SERVER_PROTOCOL']]]></code>
</PossiblyUndefinedArrayOffset>
Expand Down Expand Up @@ -4830,7 +4813,6 @@
<code><![CDATA[$text]]></code>
<code><![CDATA[call_user_func($i18nFunction, substr($text, $transKeyLen))]]></code>
<code><![CDATA[rex_escape($text)]]></code>
<code><![CDATA[self::$locales]]></code>
</LessSpecificReturnStatement>
<MixedArgumentTypeCoercion>
<code><![CDATA[$i18nFunction]]></code>
Expand All @@ -4843,7 +4825,6 @@
<code><![CDATA[$value]]></code>
</MixedAssignment>
<MoreSpecificReturnType>
<code><![CDATA[list<string>]]></code>
<code><![CDATA[non-empty-string]]></code>
<code><![CDATA[non-empty-string]]></code>
<code><![CDATA[non-empty-string]]></code>
Expand Down Expand Up @@ -5101,11 +5082,6 @@
<MixedArgument>
<code><![CDATA[$pageObj]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$id]]></code>
<code><![CDATA[$id]]></code>
<code><![CDATA[$id]]></code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess>
<code><![CDATA[$navigation['navigation']]]></code>
</MixedArrayAccess>
Expand Down Expand Up @@ -5263,16 +5239,9 @@
</TypeDoesNotContainNull>
</file>
<file src="redaxo/src/core/pages/system.report.html.php">
<MixedArgument>
<code><![CDATA[$value]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$value]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<MixedOperand>
<InvalidScalarArgument>
<code><![CDATA[$value]]></code>
</MixedOperand>
</InvalidScalarArgument>
</file>
<file src="redaxo/src/core/pages/system.settings.php">
<MixedAssignment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function isConflicting(PropertyRename $propertyRename): bool
}

/**
* @return string[]
* @return array<string>
*/
public function resolve(ClassLike $classLike): array
{
Expand Down
8 changes: 4 additions & 4 deletions redaxo/src/addons/backup/lib/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function isFilenameValid(int $importType, string $filename): bool
/**
* @param self::IMPORT_*|string $fileType
*
* @return string[]
* @return list<string>
*/
public static function getBackupFiles($fileType)
{
Expand Down Expand Up @@ -253,7 +253,7 @@ public static function importFiles($filename)
* Dieser wird in der Datei $filename gespeichert.
*
* @param string $filename
* @param string[] $tables
* @param array<string>|null $tables
*
* @return bool TRUE wenn ein Dump erstellt wurde, sonst FALSE
*/
Expand Down Expand Up @@ -370,7 +370,7 @@ public static function exportDb($filename, ?array $tables = null)
* Exportiert alle Ordner $folders aus dem Verzeichnis /files.
* Wenn $archivePath übergeben wird, wird das Achive mittels Streaming gebaut, sodass sehr große Exporte möglich sind.
*
* @param string[] $folders Array von Ordnernamen, die exportiert werden sollen
* @param array<string> $folders Array von Ordnernamen, die exportiert werden sollen
* @param string|null $archivePath Pfad, wo das archiv angelegt werden soll
*
* @return string|null Inhalt des Tar-Archives als string, wenn $archivePath nicht uebergeben wurde - sonst null
Expand All @@ -396,7 +396,7 @@ public static function exportFiles($folders, $archivePath = null)
}

/**
* @param string[] $folders
* @param array<string> $folders
* @param string $archivePath
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/addons/cronjob/lib/cronjob.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ final public function getType()
}

/**
* @return string[]
* @return list<'frontend'|'backend'|'script'>
*/
public function getEnvironments()
{
Expand Down
4 changes: 2 additions & 2 deletions redaxo/src/addons/debug/lib/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
class rex_debug
{
/** @var class-string[] */
/** @var list<class-string> */
private static $ignoreClasses = [
rex_extension_debug::class,
rex_api_function_debug::class,
Expand All @@ -21,7 +21,7 @@ class rex_debug
];

/**
* @param class-string[] $ignoredClasses
* @param list<class-string> $ignoredClasses
*/
public static function getTrace(array $ignoredClasses = []): array
{
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/addons/install/lib/api/api_package_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function execute()
if ($upload['ignore_tests']) {
$exclude[] = 'tests';
}
/** @var string[]|null $packageExclude */
/** @var list<string>|null $packageExclude */
$packageExclude = rex_addon::get($addonkey)->getProperty('installer_ignore');
if (is_array($packageExclude)) {
foreach ($packageExclude as $excludeItem) {
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/addons/install/lib/archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function extract(string $archive, string $dir, string $basename =
}

/**
* @param string|string[]|null $exclude
* @param string|list<string>|null $exclude
* @return void
*/
public static function copyDirToArchive(string $dir, string $archive, ?string $basename = null, $exclude = null)
Expand Down
4 changes: 2 additions & 2 deletions redaxo/src/addons/media_manager/lib/media_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ private static function getEffectClass(string $effectFile): string

/**
* Checks if media is used by this addon.
* @return string[] Warning message as array
* @return list<string> Warning message as array
*/
public static function mediaIsInUse(rex_extension_point $ep)
{
/** @var string[] $warning */
/** @var list<string> $warning */
$warning = $ep->getSubject();
$filename = $ep->getParam('filename');
assert(is_string($filename));
Expand Down
1 change: 0 additions & 1 deletion redaxo/src/addons/media_manager/pages/effects.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
echo rex_view::warning($warning);
}

/** @var rex_effect_abstract[] $effects */
$effects = [];
foreach (rex_media_manager::getSupportedEffects() as $class => $shortName) {
$effects[$shortName] = new $class();
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/addons/mediapool/lib/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function forId(int $mediaId): ?self
}

/**
* @return static[]
* @return list<static>
*/
public static function getRootMedia()
{
Expand Down
10 changes: 5 additions & 5 deletions redaxo/src/addons/mediapool/lib/media_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function get($id)
}

/**
* @return self[]
* @return list<self>
*/
public static function getRootCategories()
{
Expand All @@ -85,7 +85,7 @@ public static function getRootCategories()
/**
* @param int $parentId
*
* @return self[]
* @return list<self>
*/
protected static function getChildCategories($parentId)
{
Expand Down Expand Up @@ -196,7 +196,7 @@ public function getParent()
* Get an array of all parentCategories.
* Returns an array of rex_media_category objects sorted by $priority.
*
* @return self[]
* @return list<self>
*/
public function getParentTree()
{
Expand Down Expand Up @@ -234,15 +234,15 @@ public function inParentTree($anObj)
}

/**
* @return self[]
* @return list<self>
*/
public function getChildren()
{
return self::getChildCategories($this->getId());
}

/**
* @return rex_media[]
* @return list<rex_media>
*/
public function getMedia()
{
Expand Down
4 changes: 2 additions & 2 deletions redaxo/src/addons/mediapool/lib/media_category_select.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class rex_media_category_select extends rex_select
/** @var bool */
private $checkPerms;

/** @var int|int[]|null */
/** @var int|list<int>|null */
private $rootId;

/** @var bool */
Expand All @@ -26,7 +26,7 @@ public function __construct($checkPerms = true)
/**
* Kategorie-Id oder ein Array von Kategorie-Ids als Wurzelelemente der Select-Box.
*
* @param int|int[]|null $rootId Kategorie-Id oder Array von Kategorie-Ids zur Identifikation der Wurzelelemente
* @param int|list<int>|null $rootId Kategorie-Id oder Array von Kategorie-Ids zur Identifikation der Wurzelelemente
* @return void
*/
public function setRootId($rootId)
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/addons/mediapool/lib/service_media.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public static function deleteMedia(string $filename): void
}

/**
* @param array{category_id?: int, category_id_path?: int, types?: string[], term?: string} $filter
* @param array{category_id?: int, category_id_path?: int, types?: list<string>, term?: string} $filter
* @param list<array{string, 'ASC'|'DESC'}> $orderBy
* @throws rex_sql_exception
* @return list<rex_media>
Expand Down