diff --git a/src/Glpi/Api/API.php b/src/Glpi/Api/API.php index d9e570537b8..af6ce1b6899 100644 --- a/src/Glpi/Api/API.php +++ b/src/Glpi/Api/API.php @@ -93,21 +93,35 @@ abstract class API { // permit writing to $_SESSION + /** @var bool */ protected $session_write = false; + /** @var string */ public static $api_url = ""; + /** @var string */ public static $content_type = "application/json"; + /** @var string */ protected $format = "json"; + /** @var string */ protected $iptxt = ""; + /** @var string */ protected $ipnum = ""; + /** @var array */ protected $app_tokens = []; + /** @var int */ protected $apiclients_id = 0; + /** @var ?DeprecatedInterface */ protected $deprecated_item = null; + /** @var string */ protected $request_uri; + /** @var array */ protected $url_elements; + /** @var string */ protected $verb; + /** @var array */ protected $parameters; - protected $debug = 0; + /** @var bool */ + protected $debug = false; /** * @param integer $nb Unused value diff --git a/src/Glpi/Api/APIRest.php b/src/Glpi/Api/APIRest.php index c860d6efa12..f8e137608ed 100644 --- a/src/Glpi/Api/APIRest.php +++ b/src/Glpi/Api/APIRest.php @@ -150,7 +150,7 @@ public function call() if (isset($this->parameters['debug'])) { $this->debug = $this->parameters['debug']; if (empty($this->debug)) { - $this->debug = 1; + $this->debug = true; } } diff --git a/src/Glpi/Api/HL/Controller/AssetController.php b/src/Glpi/Api/HL/Controller/AssetController.php index 323e9bfc747..baf36be9373 100644 --- a/src/Glpi/Api/HL/Controller/AssetController.php +++ b/src/Glpi/Api/HL/Controller/AssetController.php @@ -1528,7 +1528,7 @@ public function index(Request $request): Response return new JSONResponse($asset_paths); } - private static function getGlobalAssetSchema($asset_schemas) + private static function getGlobalAssetSchema(array $asset_schemas): array { $asset_types = self::getAssetTypes(); $asset_schemas = array_filter($asset_schemas, static fn($key) => !str_starts_with($key, '_') && in_array($key, $asset_types, true), ARRAY_FILTER_USE_KEY); diff --git a/src/Glpi/Api/HL/GraphQLGenerator.php b/src/Glpi/Api/HL/GraphQLGenerator.php index 3b495705425..a92bedb2813 100644 --- a/src/Glpi/Api/HL/GraphQLGenerator.php +++ b/src/Glpi/Api/HL/GraphQLGenerator.php @@ -35,9 +35,12 @@ namespace Glpi\Api\HL; +use Closure; use Glpi\Api\HL\Doc as Doc; use Glpi\Debug\Profiler; +use GraphQL\Type\Definition\ListOfType; use GraphQL\Type\Definition\ObjectType; +use GraphQL\Type\Definition\ScalarType; use GraphQL\Type\Definition\Type; use Throwable; @@ -57,6 +60,9 @@ private function normalizeTypeName(string $type_name): string return str_replace([' ', '-'], ['', '_'], $type_name); } + /** + * @return string + */ public function getSchema() { Profiler::getInstance()->start('GraphQLGenerator::loadTypes', Profiler::CATEGORY_HLAPI); @@ -87,7 +93,7 @@ public function getSchema() return $schema_str; } - private function writeType($type_name, ObjectType|callable $type): string + private function writeType(string $type_name, ObjectType|callable $type): string { $type_name = $this->normalizeTypeName($type_name); $type_str = "type $type_name {\n"; @@ -118,7 +124,7 @@ private function writeType($type_name, ObjectType|callable $type): string return $type_str; } - private function loadTypes() + private function loadTypes(): void { $component_schemas = OpenAPIGenerator::getComponentSchemas($this->api_version); foreach ($component_schemas as $schema_name => $schema) { @@ -173,6 +179,13 @@ private function convertRESTSchemaToGraphQLSchema(string $schema_name, array $sc ]); } + /** + * @param array $property + * @param string|null $name + * @param string $prefix + * + * @return Closure|ListOfType|ObjectType|ScalarType|void + */ private function convertRESTPropertyToGraphQLType(array $property, ?string $name = null, string $prefix = '') { $type = $property['type'] ?? 'string'; diff --git a/src/Glpi/Api/HL/RoutePath.php b/src/Glpi/Api/HL/RoutePath.php index abf3b368848..1f232fee27d 100644 --- a/src/Glpi/Api/HL/RoutePath.php +++ b/src/Glpi/Api/HL/RoutePath.php @@ -224,6 +224,11 @@ public function getAttributesFromPath(string $path): array return $attributes; } + /** + * @param string $path + * + * @return bool + */ public function isValidPath($path): bool { // Ensure no placeholders are left @@ -368,13 +373,13 @@ public function matchesAPIVersion(string $api_version): bool ); } - private function setPath(string $path) + private function setPath(string $path): void { $this->path = $path; $this->route->path = $path; } - private function setPriority(int $priority) + private function setPriority(int $priority): void { $this->priority = $priority; $this->route->priority = $priority; diff --git a/src/Glpi/Application/Environment.php b/src/Glpi/Application/Environment.php index fef52baa001..98b593b142a 100644 --- a/src/Glpi/Application/Environment.php +++ b/src/Glpi/Application/Environment.php @@ -69,6 +69,9 @@ public static function isSet(): bool return defined('GLPI_ENVIRONMENT_TYPE'); } + /** + * @return array + */ public static function getValues() { $values = []; diff --git a/src/Glpi/Application/View/Extension/DocumentExtension.php b/src/Glpi/Application/View/Extension/DocumentExtension.php index 45c33fb0c2b..eceb488e91b 100644 --- a/src/Glpi/Application/View/Extension/DocumentExtension.php +++ b/src/Glpi/Application/View/Extension/DocumentExtension.php @@ -49,7 +49,7 @@ class DocumentExtension extends AbstractExtension /** * Static cache for user defined files extensions icons. */ - private static $extensionIcon = null; + private static ?array $extensionIcon = null; public function getFilters(): array { diff --git a/src/Glpi/Application/View/Extension/PluginExtension.php b/src/Glpi/Application/View/Extension/PluginExtension.php index cccade87050..1926ed11054 100644 --- a/src/Glpi/Application/View/Extension/PluginExtension.php +++ b/src/Glpi/Application/View/Extension/PluginExtension.php @@ -96,6 +96,14 @@ public function callPluginHookFunction(string $name, $params = null, bool $retur } } + /** + * @param string $plugin + * @param string $name + * @param array $params + * @param bool $return_result + * + * @return ($return_result is true ? mixed : void) + */ public function callPluginOneHook(string $plugin, string $name, $params = null, bool $return_result = false) { $result = Plugin::doOneHook($plugin, $name, $params); diff --git a/src/Glpi/Application/View/Extension/TeamExtension.php b/src/Glpi/Application/View/Extension/TeamExtension.php index 58b19c1ef8e..7a15c8ce017 100644 --- a/src/Glpi/Application/View/Extension/TeamExtension.php +++ b/src/Glpi/Application/View/Extension/TeamExtension.php @@ -35,6 +35,7 @@ namespace Glpi\Application\View\Extension; +use CommonDBTM; use Glpi\Features\TeamworkInterface; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; @@ -51,6 +52,13 @@ public function getFilters(): array ]; } + /** + * @param class-string $itemtype + * @param int $role + * @param int $nb + * + * @return string + */ public function getTeamRoleName($itemtype, int $role, int $nb = 1): string { if (is_a($itemtype, TeamworkInterface::class, true)) { diff --git a/src/Glpi/Cache/I18nCache.php b/src/Glpi/Cache/I18nCache.php index bcf32a0d487..f73fa1f6bcf 100644 --- a/src/Glpi/Cache/I18nCache.php +++ b/src/Glpi/Cache/I18nCache.php @@ -44,23 +44,39 @@ */ class I18nCache { - private $cache; + private CacheInterface $cache; public function __construct(CacheInterface $cache) { $this->cache = $cache; } + /** + * @param string $key + * + * @return mixed + */ public function getItem($key) { return $this->cache->get($key); } + /** + * @param string $key + * @param mixed $value + * + * @return bool + */ public function setItem($key, $value) { return $this->cache->set($key, $value); } + /** + * @param string $key + * + * @return bool + */ public function removeItem($key) { return $this->cache->delete($key); diff --git a/src/Glpi/CalDAV/Backend/Calendar.php b/src/Glpi/CalDAV/Backend/Calendar.php index d98cacaeb4c..a6d07ac3cd7 100644 --- a/src/Glpi/CalDAV/Backend/Calendar.php +++ b/src/Glpi/CalDAV/Backend/Calendar.php @@ -170,6 +170,11 @@ public function createCalendar($principalPath, $calendarPath, array $properties) throw new NotImplemented('Calendar creation is not implemented'); } + /** + * @param string $calendarId + * + * @return void + */ public function deleteCalendar($calendarId) { throw new NotImplemented('Calendar deletion is not implemented'); @@ -257,6 +262,12 @@ public function updateCalendarObject($calendarId, $objectPath, $calendarData) return null; } + /** + * @param string $calendarId + * @param string $objectPath + * + * @return void + */ public function deleteCalendarObject($calendarId, $objectPath) { diff --git a/src/Glpi/CalDAV/Backend/Principal.php b/src/Glpi/CalDAV/Backend/Principal.php index 29ff307211f..802d4b99ad4 100644 --- a/src/Glpi/CalDAV/Backend/Principal.php +++ b/src/Glpi/CalDAV/Backend/Principal.php @@ -104,6 +104,12 @@ public function getPrincipalByPath($path) return $this->getPrincipalFromItem($item); } + /** + * @param string $path + * @param PropPatch $propPatch + * + * @return void + */ public function updatePrincipal($path, PropPatch $propPatch) { throw new NotImplemented('Principal update is not implemented'); @@ -232,6 +238,12 @@ public function getGroupMembership($path) return $groups_uris; } + /** + * @param string $path + * @param array $members + * + * @return void + */ public function setGroupMemberSet($path, array $members) { throw new NotImplemented('Group member set update is not implemented'); diff --git a/src/Glpi/CalDAV/Plugin/CalDAV.php b/src/Glpi/CalDAV/Plugin/CalDAV.php index cc684016ac8..26e5270f40f 100644 --- a/src/Glpi/CalDAV/Plugin/CalDAV.php +++ b/src/Glpi/CalDAV/Plugin/CalDAV.php @@ -71,6 +71,12 @@ public function getCalendarHomeForPrincipal($principalUrl) return $calendar_uri; } + /** + * @param PropFind $propFind + * @param INode $node + * + * @return void + */ public function propFind(PropFind $propFind, INode $node) { diff --git a/src/Glpi/CalDAV/Server.php b/src/Glpi/CalDAV/Server.php index f6fe51ed616..d6c70a1c108 100644 --- a/src/Glpi/CalDAV/Server.php +++ b/src/Glpi/CalDAV/Server.php @@ -90,8 +90,9 @@ public function __construct() } /** - * * @param Throwable $exception + * + * @return void */ public function logException(Throwable $exception) { diff --git a/src/Glpi/Console/Assets/CleanSoftwareCommand.php b/src/Glpi/Console/Assets/CleanSoftwareCommand.php index 1d4e7be91e5..f92ee8b590a 100644 --- a/src/Glpi/Console/Assets/CleanSoftwareCommand.php +++ b/src/Glpi/Console/Assets/CleanSoftwareCommand.php @@ -77,6 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output) * * @param InputInterface $input * + * @return void * @throws InvalidArgumentException */ private function validateInput(InputInterface $input) diff --git a/src/Glpi/Console/Assets/PurgeSoftwareCommand.php b/src/Glpi/Console/Assets/PurgeSoftwareCommand.php index 559451f05b4..ea4b01dcaf9 100644 --- a/src/Glpi/Console/Assets/PurgeSoftwareCommand.php +++ b/src/Glpi/Console/Assets/PurgeSoftwareCommand.php @@ -77,6 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output) * * @param InputInterface $input * + * @return void * @throws InvalidArgumentException */ private function validateInput(InputInterface $input) diff --git a/src/Glpi/Console/Cache/ClearCommand.php b/src/Glpi/Console/Cache/ClearCommand.php index 9914ea9903e..194e47dd4e0 100644 --- a/src/Glpi/Console/Cache/ClearCommand.php +++ b/src/Glpi/Console/Cache/ClearCommand.php @@ -51,6 +51,7 @@ class ClearCommand extends Command */ public const ERROR_CACHE_CLEAR_FAILURE = 1; + /** @var bool */ protected $requires_db_up_to_date = false; protected function configure() diff --git a/src/Glpi/Console/Cache/DebugCommand.php b/src/Glpi/Console/Cache/DebugCommand.php index 128db9074af..832191a7483 100644 --- a/src/Glpi/Console/Cache/DebugCommand.php +++ b/src/Glpi/Console/Cache/DebugCommand.php @@ -46,6 +46,7 @@ class DebugCommand extends Command { + /** @var bool */ protected $requires_db_up_to_date = false; protected function configure() diff --git a/src/Glpi/Console/CommandLoader.php b/src/Glpi/Console/CommandLoader.php index 04dfff95b29..60e695ac8dc 100644 --- a/src/Glpi/Console/CommandLoader.php +++ b/src/Glpi/Console/CommandLoader.php @@ -160,7 +160,7 @@ private function getCommands() * * return void */ - private function findCoreCommands() + private function findCoreCommands(): void { $basedir = $this->rootdir . DIRECTORY_SEPARATOR . 'src'; @@ -293,7 +293,7 @@ private function findPluginCommands() * * return void */ - private function findToolsCommands() + private function findToolsCommands(): void { $basedir = $this->rootdir . DIRECTORY_SEPARATOR . 'tools'; diff --git a/src/Glpi/Console/Database/AbstractConfigureCommand.php b/src/Glpi/Console/Database/AbstractConfigureCommand.php index c49773089ed..7887e47af69 100644 --- a/src/Glpi/Console/Database/AbstractConfigureCommand.php +++ b/src/Glpi/Console/Database/AbstractConfigureCommand.php @@ -265,6 +265,12 @@ protected function configureDatabase( } else { // Instanciate DB to be able to compute boolean properties flags. $db = new class ($db_hostport, $db_user, $db_pass, $db_name) extends DBmysql { + /** + * @param string $dbhost + * @param string $dbuser + * @param string $dbpassword + * @param string $dbdefault + */ public function __construct($dbhost, $dbuser, $dbpassword, $dbdefault) { $this->dbhost = $dbhost; @@ -326,6 +332,17 @@ public function __construct($dbhost, $dbuser, $dbpassword, $dbdefault) $allow_datetime, $allow_signed_keys ) extends DBmysql { + /** + * @param string $dbhost + * @param string $dbuser + * @param string $dbpassword + * @param string $dbdefault + * @param bool $use_timezones + * @param bool $log_deprecation_warnings + * @param bool $use_utf8mb4 + * @param bool $allow_datetime + * @param bool $allow_signed_keys + */ public function __construct( $dbhost, $dbuser, @@ -370,6 +387,7 @@ protected function isDbAlreadyConfigured() * * @param InputInterface $input * + * @return void * @throws InvalidArgumentException */ protected function validateConfigInput(InputInterface $input) @@ -438,6 +456,9 @@ private function checkTimezonesAvailability(mysqli $mysqli): bool { $db = new class ($mysqli) extends DBmysql { + /** + * @param mysqli $dbh + */ public function __construct($dbh) { $this->dbh = $dbh; diff --git a/src/Glpi/Console/Database/InstallCommand.php b/src/Glpi/Console/Database/InstallCommand.php index fa97a70831a..d5d45ad6a4d 100644 --- a/src/Glpi/Console/Database/InstallCommand.php +++ b/src/Glpi/Console/Database/InstallCommand.php @@ -264,6 +264,9 @@ protected function execute(InputInterface $input, OutputInterface $output) // Check for compatibility with utf8mb4 usage. $db = new class ($mysqli) extends DBmysql { + /** + * @param mysqli $dbh + */ public function __construct($dbh) { $this->dbh = $dbh; diff --git a/src/Glpi/Console/Migration/AppliancesPluginToCoreCommand.php b/src/Glpi/Console/Migration/AppliancesPluginToCoreCommand.php index 7083b7737fa..ef53556acea 100644 --- a/src/Glpi/Console/Migration/AppliancesPluginToCoreCommand.php +++ b/src/Glpi/Console/Migration/AppliancesPluginToCoreCommand.php @@ -218,7 +218,7 @@ private function checkPlugin(): bool * * @throws RuntimeException */ - private function cleanCoreTables() + private function cleanCoreTables(): void { $core_tables = [ Appliance::getTable(), diff --git a/src/Glpi/Console/Migration/RacksPluginToCoreCommand.php b/src/Glpi/Console/Migration/RacksPluginToCoreCommand.php index 18a20df9a59..74040bc0070 100644 --- a/src/Glpi/Console/Migration/RacksPluginToCoreCommand.php +++ b/src/Glpi/Console/Migration/RacksPluginToCoreCommand.php @@ -389,7 +389,7 @@ private function checkPlugin() * * @throws RuntimeException */ - private function cleanCoreTables() + private function cleanCoreTables(): void { $core_tables = [ @@ -417,7 +417,7 @@ private function cleanCoreTables() } - private function migratePlugin() + private function migratePlugin(): bool { $no_interaction = $this->input->getOption('no-interaction'); diff --git a/src/Glpi/ContentTemplates/TemplateDocumentation.php b/src/Glpi/ContentTemplates/TemplateDocumentation.php index f68df134cc2..f5d9a79ea4b 100644 --- a/src/Glpi/ContentTemplates/TemplateDocumentation.php +++ b/src/Glpi/ContentTemplates/TemplateDocumentation.php @@ -102,6 +102,8 @@ public function build(): string * @param string $title Section's title * @param array $parameters Parameters to be displayed in this section * @param string|null $fields_prefix Prefix to happen to the parameters fields name + * + * @return void */ public function addSection( string $title, diff --git a/src/Glpi/Controller/Form/QuestionActorsDropdownController.php b/src/Glpi/Controller/Form/QuestionActorsDropdownController.php index 98fd5ab768c..e852cfa2827 100644 --- a/src/Glpi/Controller/Form/QuestionActorsDropdownController.php +++ b/src/Glpi/Controller/Form/QuestionActorsDropdownController.php @@ -93,7 +93,7 @@ private function loadTargetForm(Request $request): Form return $form; } - private function checkFormAccessPolicies(Request $request) + private function checkFormAccessPolicies(Request $request): void { $form_access_manager = FormAccessControlManager::getInstance(); diff --git a/src/Glpi/Controller/RequestException.php b/src/Glpi/Controller/RequestException.php index ce7dd3636d7..647447d732a 100644 --- a/src/Glpi/Controller/RequestException.php +++ b/src/Glpi/Controller/RequestException.php @@ -41,6 +41,12 @@ final class RequestException extends Exception { protected int $http_code; + /** + * @param int $http_code + * @param string $message + * @param int $code + * @param Exception $previous + */ public function __construct($http_code, $message, $code = 0, $previous = null) { $this->http_code = $http_code; diff --git a/src/Glpi/Csv/PlanningCsv.php b/src/Glpi/Csv/PlanningCsv.php index 6e5835fe543..fcd19016363 100644 --- a/src/Glpi/Csv/PlanningCsv.php +++ b/src/Glpi/Csv/PlanningCsv.php @@ -44,9 +44,9 @@ **/ class PlanningCsv implements ExportToCsvInterface { - private $users_id; - private $groups_id; - private $limititemtype; + private int $users_id; + private ?int $groups_id; + private string $limititemtype; /** * @param int $who user ID diff --git a/src/Glpi/DBAL/QueryFunction.php b/src/Glpi/DBAL/QueryFunction.php index d3fab416156..74853498c1c 100644 --- a/src/Glpi/DBAL/QueryFunction.php +++ b/src/Glpi/DBAL/QueryFunction.php @@ -82,6 +82,12 @@ private static function getExpression(string $func_name, array $params, ?string return new QueryExpression($func_name . '(' . implode(', ', $params) . ')', $alias); } + /** + * @param string $name + * @param array $arguments + * + * @return QueryExpression + */ public static function __callStatic(string $name, array $arguments) { $args = array_values($arguments); diff --git a/src/Glpi/DBAL/QuerySubQuery.php b/src/Glpi/DBAL/QuerySubQuery.php index eb740a027aa..bdccfc79eb3 100644 --- a/src/Glpi/DBAL/QuerySubQuery.php +++ b/src/Glpi/DBAL/QuerySubQuery.php @@ -44,7 +44,7 @@ **/ class QuerySubQuery extends AbstractQuery { - private $dbiterator; + private DBmysqlIterator $dbiterator; /** * Create a sub query diff --git a/src/Glpi/DBAL/QueryUnion.php b/src/Glpi/DBAL/QueryUnion.php index 2beacfe9403..60d9244759a 100644 --- a/src/Glpi/DBAL/QueryUnion.php +++ b/src/Glpi/DBAL/QueryUnion.php @@ -44,23 +44,21 @@ **/ class QueryUnion extends AbstractQuery { - private $queries = []; - private $distinct = false; + private array $queries = []; /** * Create a sub query * * @param array $queries An array of queries to union. Either SubQuery objects * or an array of criteria to build them. - * You can also add later using @param boolean $distinct Include duplicates or not. Turning on may has + * @param boolean $distinct Include duplicates or not. Turning on may has * huge cost on queries performances. * @param string $alias Union ALIAS. Defaults to null. * @see addQuery */ - public function __construct(array $queries = [], $distinct = false, $alias = null) + public function __construct(array $queries = [], private $distinct = false, $alias = null) { parent::__construct($alias); - $this->distinct = $distinct; foreach ($queries as $query) { $this->addQuery($query); @@ -72,6 +70,8 @@ public function __construct(array $queries = [], $distinct = false, $alias = nul * * @param QuerySubQuery|array $query Either a SubQuery object * or an array of criteria to build it. + * + * @return void */ public function addQuery($query) { diff --git a/src/Glpi/Dashboard/Dashboard.php b/src/Glpi/Dashboard/Dashboard.php index e5b6f3606f7..2bf7c15ac11 100644 --- a/src/Glpi/Dashboard/Dashboard.php +++ b/src/Glpi/Dashboard/Dashboard.php @@ -46,14 +46,22 @@ class Dashboard extends CommonDBTM { + /** @var int */ protected $id = 0; + /** @var string */ protected $key = ""; + /** @var string */ protected $title = ""; + /** @var bool */ protected $embed = false; + /** @var ?array */ protected $items = null; + /** @var ?array */ protected $rights = null; + /** @var string */ protected $filters = ""; + /** @var array */ public static $all_dashboards = []; public static $rightname = 'dashboard'; @@ -621,6 +629,11 @@ public static function importFromJson($import = null) return true; } + /** + * @param bool $is_private + * + * @return bool + */ public function setPrivate($is_private) { $this->load(); @@ -632,6 +645,9 @@ public function setPrivate($is_private) ]); } + /** + * @return string (int as string... should be a boolean.) + */ public function getPrivate() { $this->load(); diff --git a/src/Glpi/Dashboard/Grid.php b/src/Glpi/Dashboard/Grid.php index cee28f79612..aac846c8734 100644 --- a/src/Glpi/Dashboard/Grid.php +++ b/src/Glpi/Dashboard/Grid.php @@ -61,16 +61,24 @@ class Grid { + /** @var int */ protected $cell_margin = 3; + /** @var int */ protected $grid_cols = 26; + /** @var int */ protected $grid_rows = 24; + /** @var string */ protected $current = ""; /** @var Dashboard|null */ protected $dashboard = null; + /** @var array */ protected $items = []; + /** @var string */ protected $context = ''; + /** @var bool */ public static $embed = false; + /** @var array */ public static $all_dashboards = []; public function __construct(string $dashboard_key = "central", int $grid_cols = 26, int $grid_rows = 24, string $context = 'core') @@ -194,6 +202,9 @@ public function canViewCurrent(): bool * Do we have the right to view at least one dashboard? * * This can be optionally restricted to a specific context. + * + * @param ?string $context + * * @return bool */ public static function canViewOneDashboard($context = null): bool @@ -486,6 +497,9 @@ public function show(bool $mini = false, ?string $token = null) } + /** + * @return void + */ public function showDefault() { echo "
"; @@ -496,6 +510,10 @@ public function showDefault() /** * Init embed session + * + * @param array $params + * + * @return void */ public function initEmbedSession(array $params = []) { @@ -1464,6 +1482,11 @@ public function getAllDasboardCards($force = false): array } + /** + * @param string $interface + * + * @return array + */ public function getRights($interface = 'central') { return [ diff --git a/src/Glpi/Dashboard/Palette.php b/src/Glpi/Dashboard/Palette.php index c34dbd73927..b5e7b045fb7 100644 --- a/src/Glpi/Dashboard/Palette.php +++ b/src/Glpi/Dashboard/Palette.php @@ -40,6 +40,7 @@ final class Palette { + /** @var string[] */ private $colors = []; private const DEFAULT = "tab10"; diff --git a/src/Glpi/Dashboard/Provider.php b/src/Glpi/Dashboard/Provider.php index 045b426c495..b90a3dce3a7 100644 --- a/src/Glpi/Dashboard/Provider.php +++ b/src/Glpi/Dashboard/Provider.php @@ -167,6 +167,9 @@ public static function bigNumberItem(?CommonDBTM $item = null, array $params = [ /** * @method array bigNumberItem(CommonDBTM $item, array $params = []) * @method array nbItemByFk(CommonDBTM $item, array $params = []) + * @method array articleListItem(CommonDBTM $item, array $params = []) + * + * @return array|void */ public static function __callStatic(string $name = "", array $arguments = []) { @@ -1750,6 +1753,12 @@ final public static function getSearchFiltersCriteria(string $table = "", array return ['criteria' => $s_criteria]; } + /** + * @param string $table + * @param array $apply_filters + * + * @return array + */ public static function getFiltersCriteria(string $table = "", array $apply_filters = []) { $where = []; diff --git a/src/Glpi/Dashboard/Widget.php b/src/Glpi/Dashboard/Widget.php index d27f0b40b7a..7f705d2dc6f 100644 --- a/src/Glpi/Dashboard/Widget.php +++ b/src/Glpi/Dashboard/Widget.php @@ -57,6 +57,7 @@ **/ class Widget { + /** @var int */ public static $animation_duration = 1000; // in millseconds diff --git a/src/Glpi/Debug/Profile.php b/src/Glpi/Debug/Profile.php index 69897e5666d..ceac7b20019 100644 --- a/src/Glpi/Debug/Profile.php +++ b/src/Glpi/Debug/Profile.php @@ -64,6 +64,7 @@ final class Profile private static ?self $current = null; + /** @var bool */ private $disabled = false; public function __construct(string $id, ?string $parent_id) @@ -137,6 +138,12 @@ public function getParentID(): ?string return $this->parent_id; } + /** + * @param string $widget + * @param mixed $data + * + * @return void + */ public function setData(string $widget, $data) { if ($this->disabled) { @@ -148,6 +155,15 @@ public function setData(string $widget, $data) $this->additional_info[$widget][] = $data; } + /** + * @param string $query + * @param float $time + * @param int $rows + * @param string $errors + * @param string $warnings + * + * @return void + */ public function addSQLQueryData(string $query, float $time, int $rows = 0, string $errors = '', string $warnings = '') { if ($this->disabled) { diff --git a/src/Glpi/Debug/Profiler.php b/src/Glpi/Debug/Profiler.php index f43114e9b05..167ac38dbe9 100644 --- a/src/Glpi/Debug/Profiler.php +++ b/src/Glpi/Debug/Profiler.php @@ -46,6 +46,7 @@ final class Profiler /** @var ProfilerSection[] */ private $current_sections = []; + /** @var bool */ private $disabled = false; public const CATEGORY_BOOT = 'boot'; @@ -57,6 +58,7 @@ final class Profiler public const CATEGORY_CUSTOMOBJECTS = 'customobjects'; public const CATEGORY_HLAPI = 'hlapi'; + /** @var ?self */ private static $instance; public static function getInstance(): self @@ -91,7 +93,7 @@ public function start(string $name, string $category = self::CATEGORY_CORE): voi $parent_id = array_key_last($this->current_sections); $parent_id = $this->current_sections[$parent_id]->getId(); } - $this->current_sections[] = new ProfilerSection($category, $name, microtime(true) * 1000, $parent_id); + $this->current_sections[] = new ProfilerSection($category, $name, (int) (microtime(true) * 1000), $parent_id); } /** @@ -137,7 +139,7 @@ public function stop(string $name, bool $auto_ended = false): int if (count($section)) { $k = array_key_last($section); $section = array_pop($section); - $section->end(microtime(true) * 1000); + $section->end((int) (microtime(true) * 1000)); $duration = $section->getDuration(); unset($this->current_sections[$k]); Profile::getCurrent()->setData('profiler', $section->toArray() + ['auto_ended' => $auto_ended]); diff --git a/src/Glpi/Debug/ProfilerSection.php b/src/Glpi/Debug/ProfilerSection.php index d70da71cb55..1d22eb74fb9 100644 --- a/src/Glpi/Debug/ProfilerSection.php +++ b/src/Glpi/Debug/ProfilerSection.php @@ -56,6 +56,13 @@ final class ProfilerSection */ private array $pauses = []; + /** + * @param string $category + * @param string $name + * @param int $start + * @param ?string $parent_id + * @param ?string $id + */ public function __construct(string $category, string $name, $start, ?string $parent_id = null, ?string $id = null) { $this->id = $id ?? Uuid::uuid4()->toString(); @@ -65,6 +72,11 @@ public function __construct(string $category, string $name, $start, ?string $par $this->start = (int) $start; } + /** + * @param int $time + * + * @return void + */ public function end($time): void { // Force resume to complete the last pause. diff --git a/src/Glpi/Event.php b/src/Glpi/Event.php index 3fae0e8feb7..0a63de6d3a2 100644 --- a/src/Glpi/Event.php +++ b/src/Glpi/Event.php @@ -108,12 +108,14 @@ public function delete(array $input, $force = false, $history = true) * Log the event $event on the glpi_event table with all the others args, if * $level is above or equal to setting from configuration. * - * @param $items_id - * @param $type - * @param $level - * @param $service - * @param $event - **/ + * @param string|int $items_id + * @param string $type + * @param int $level + * @param string $service + * @param string $event + * + * @return void + */ public static function log($items_id, $type, $level, $service, $event) { global $CFG_GLPI, $DB; @@ -154,7 +156,7 @@ public static function log($items_id, $type, $level, $service, $event) /** * Clean old event - Call by cron * - * @param $day integer + * @param int $day * * @return integer number of events deleted **/ @@ -175,7 +177,9 @@ public static function cleanOld($day) /** * Return arrays for function showEvent et lastEvent - **/ + * + * @return array + */ public static function logArray() { @@ -218,8 +222,10 @@ public static function logArray() } /** - * @param $type - * @param $items_id + * @param class-string $type + * @param int $items_id + * + * @return void **/ public static function displayItemLogID($type, $items_id) { @@ -281,7 +287,9 @@ public static function displayItemLogID($type, $items_id) * * @param string $user name user to search on message (default '') * @param bool $display if false, return html - **/ + * + * @return void|string + */ public static function showForUser(string $user = "", bool $display = true) { global $CFG_GLPI, $DB; diff --git a/src/Glpi/Exception/PasswordTooWeakException.php b/src/Glpi/Exception/PasswordTooWeakException.php index 38fd2e4a68c..ab5b92cb10d 100644 --- a/src/Glpi/Exception/PasswordTooWeakException.php +++ b/src/Glpi/Exception/PasswordTooWeakException.php @@ -39,13 +39,22 @@ class PasswordTooWeakException extends Exception { + /** @var array */ private $messages = []; + /** + * @param string $message + * + * @return void + */ public function addMessage($message) { $this->messages[] = $message; } + /** + * @return array + */ public function getMessages() { return $this->messages; diff --git a/src/Glpi/Features/AssignableItem.php b/src/Glpi/Features/AssignableItem.php index 6153019a319..b7d79ab4155 100644 --- a/src/Glpi/Features/AssignableItem.php +++ b/src/Glpi/Features/AssignableItem.php @@ -338,21 +338,35 @@ public function updateGroupFields() $this->loadGroupFields(); } - /** @see AssignableItemInterface::post_addItem() */ + /** + * @see AssignableItemInterface::post_addItem() + * + * @return void + */ public function post_addItem() { parent::post_addItem(); $this->updateGroupFields(); } - /** @see AssignableItemInterface::post_updateItem() */ + /** + * @see AssignableItemInterface::post_updateItem() + * + * @param bool $history + * + *@return void + */ public function post_updateItem($history = true) { parent::post_updateItem($history); $this->updateGroupFields(); } - /** @see AssignableItemInterface::getEmpty() */ + /** + * @see AssignableItemInterface::getEmpty() + * + * @return bool + */ public function getEmpty() { if (!parent::getEmpty()) { @@ -365,7 +379,7 @@ public function getEmpty() return true; } - private function loadGroupFields() + private function loadGroupFields(): void { global $DB; @@ -389,7 +403,11 @@ private function loadGroupFields() } } - /** @see AssignableItemInterface::post_getFromDB() */ + /** + * @see AssignableItemInterface::post_getFromDB() + * + * @return void + */ public function post_getFromDB() { $this->loadGroupFields(); diff --git a/src/Glpi/Features/AssignableItemInterface.php b/src/Glpi/Features/AssignableItemInterface.php index df575b6f9bd..6eb93449424 100644 --- a/src/Glpi/Features/AssignableItemInterface.php +++ b/src/Glpi/Features/AssignableItemInterface.php @@ -59,22 +59,53 @@ public static function getAssignableVisiblityCriteria(): array; */ public function getRights($interface = 'central'); + /** + * @param array $input + * + * @return false|array + */ public function prepareGroupFields(array $input); + /** + * @param array $input + * + * @return false|array + */ public function prepareInputForAdd($input); + /** + * @param array $input + * + * @return false|array + */ public function prepareInputForUpdate($input); + /** + * @return void + */ public function post_addItem(); + /** + * @param bool $history + * + * @return void + */ public function post_updateItem($history = true); + /** + * @return bool + */ public function getEmpty(); + /** + * @return void + */ public function post_getFromDB(); /** * Update the values in the 'glpi_groups_items' link table as needed based on the groups set in the 'groups_id' and 'groups_id_tech' fields. + * + * @return void */ public function updateGroupFields(); } diff --git a/src/Glpi/Features/Inventoriable.php b/src/Glpi/Features/Inventoriable.php index aea37d80462..ba069dae462 100644 --- a/src/Glpi/Features/Inventoriable.php +++ b/src/Glpi/Features/Inventoriable.php @@ -52,6 +52,9 @@ trait Inventoriable { protected ?Agent $agent = null; + /** + * @return bool + */ public function pre_purgeInventory() { $file_name = $this->getInventoryFileName(); @@ -182,6 +185,8 @@ protected function showInventoryInfo() /** * Display agent information + * + * @return void */ protected function displayAgentInformation() { diff --git a/src/Glpi/Features/KanbanInterface.php b/src/Glpi/Features/KanbanInterface.php index 9b233ac0416..8a245374232 100644 --- a/src/Glpi/Features/KanbanInterface.php +++ b/src/Glpi/Features/KanbanInterface.php @@ -125,9 +125,25 @@ public function prepareKanbanStateForUpdate($oldstate, $newstate, $users_id); */ public function canOrderKanbanCard($ID); + /** + * @param class-string<\CommonDBTM> $itemtype + * + * @return array + */ public static function getKanbanPluginFilters($itemtype); + /** + * @param bool $full + * + * @return string + */ public static function getGlobalKanbanUrl(bool $full = true); + /** + * @param int $items_id + * @param bool $full + * + * @return string + */ public function getKanbanUrlWithID(int $items_id, bool $full = true); } diff --git a/src/Glpi/Features/TreeBrowseInterface.php b/src/Glpi/Features/TreeBrowseInterface.php index 6d3362b8f7b..c391f717943 100644 --- a/src/Glpi/Features/TreeBrowseInterface.php +++ b/src/Glpi/Features/TreeBrowseInterface.php @@ -38,6 +38,13 @@ interface TreeBrowseInterface { + /** + * @param string $itemtype + * @param array $params + * @param bool $update + * + * @return void + */ public static function showBrowseView(string $itemtype, array $params, $update = false); /** diff --git a/src/Glpi/Form/Form.php b/src/Glpi/Form/Form.php index 900eea488a9..0156359f0f8 100644 --- a/src/Glpi/Form/Form.php +++ b/src/Glpi/Form/Form.php @@ -94,6 +94,7 @@ final class Form extends CommonDBTM implements ConditionableVisibilityInterface { use ConditionableVisibilityTrait; + /** @use Clonable */ use Clonable { Clonable::prepareInputForClone as parentPrepareInputForClone; Clonable::post_clone as parentPostClone; diff --git a/src/Glpi/ItemTranslation/ItemTranslation.php b/src/Glpi/ItemTranslation/ItemTranslation.php index 3848e9473ff..d3572a38664 100644 --- a/src/Glpi/ItemTranslation/ItemTranslation.php +++ b/src/Glpi/ItemTranslation/ItemTranslation.php @@ -67,6 +67,11 @@ public function prepareInputForUpdate($input): array return $this->prepapreInput($input); } + /** + * @param array $input + * + * @return array + */ public function prepapreInput($input): array { if (isset($input['translations'])) { diff --git a/src/Glpi/Mail/Protocol/ProtocolInterface.php b/src/Glpi/Mail/Protocol/ProtocolInterface.php index 2185f84e616..9629b32d661 100644 --- a/src/Glpi/Mail/Protocol/ProtocolInterface.php +++ b/src/Glpi/Mail/Protocol/ProtocolInterface.php @@ -52,6 +52,8 @@ public function setNoValidateCert(bool $novalidatecert); * @param string $host hostname or IP address of POP3 server * @param int|null $port server port, null value with fallback to default port * @param string|bool $ssl use 'SSL', 'TLS' or false + * + * @return void */ public function connect($host, $port = null, $ssl = false); diff --git a/src/Glpi/Mail/SMTP/OauthProvider/ProviderInterface.php b/src/Glpi/Mail/SMTP/OauthProvider/ProviderInterface.php index c35e0d3d643..b5de2fa79ca 100644 --- a/src/Glpi/Mail/SMTP/OauthProvider/ProviderInterface.php +++ b/src/Glpi/Mail/SMTP/OauthProvider/ProviderInterface.php @@ -50,6 +50,9 @@ public function __construct(array $options = []); public function getAuthorizationUrl(array $options = []); /** + * @param string $grant + * @param array $options + * * @return AccessTokenInterface * @see \League\OAuth2\Client\Provider\AbstractProvider::getAccessToken() */ diff --git a/src/Glpi/Marketplace/Api/Plugins.php b/src/Glpi/Marketplace/Api/Plugins.php index 111581a8efe..ccb6b5ab906 100644 --- a/src/Glpi/Marketplace/Api/Plugins.php +++ b/src/Glpi/Marketplace/Api/Plugins.php @@ -36,6 +36,7 @@ namespace Glpi\Marketplace\Api; use GLPINetwork; +use GuzzleHttp\Client; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\Message; @@ -50,13 +51,15 @@ class Plugins { + /** @var ?Client */ protected $httpClient = null; + /** @var ?array */ protected $last_error = null; public const COL_PAGE = 200; /** - * Max request attemps on READ operations. + * Max request attempts on READ operations. * * @var integer */ @@ -69,6 +72,7 @@ class Plugins */ protected $is_list_truncated = false; + /** @var ?array */ public static $plugins = null; public function __construct() diff --git a/src/Glpi/Marketplace/Controller.php b/src/Glpi/Marketplace/Controller.php index 8b12c488429..ad2cab221d0 100644 --- a/src/Glpi/Marketplace/Controller.php +++ b/src/Glpi/Marketplace/Controller.php @@ -63,9 +63,11 @@ */ class Controller extends CommonGLPI { + /** @var string */ protected $plugin_key = ""; public static $rightname = 'config'; + /** @var ?PluginsApi */ public static $api = null; /** @@ -425,6 +427,11 @@ public static function getAllUpdates() } + /** + * @param string $name + * + * @return array + */ public static function cronInfo($name) { return ['description' => __('Check all plugin updates')]; diff --git a/src/Glpi/Marketplace/NotificationTargetController.php b/src/Glpi/Marketplace/NotificationTargetController.php index 9912749ab88..b284cedfb30 100644 --- a/src/Glpi/Marketplace/NotificationTargetController.php +++ b/src/Glpi/Marketplace/NotificationTargetController.php @@ -92,6 +92,9 @@ public function addDataForTemplate($event, $options = []) } + /** + * @return void + */ public function getTags() { //Tags with just lang diff --git a/src/Glpi/Marketplace/View.php b/src/Glpi/Marketplace/View.php index 9c7f5abb073..aa763699c56 100644 --- a/src/Glpi/Marketplace/View.php +++ b/src/Glpi/Marketplace/View.php @@ -53,6 +53,7 @@ class View extends CommonGLPI { public static $rightname = 'config'; + /** @var ?PluginsApi */ public static $api = null; public $get_item_to_display_tab = true; @@ -85,6 +86,9 @@ public static function canCreate(): bool } + /** + * @return string + */ public static function getIcon() { return "ti ti-building-store"; diff --git a/src/Glpi/OAuth/AccessTokenRepository.php b/src/Glpi/OAuth/AccessTokenRepository.php index 3ef05c94bc4..7ab4143007f 100644 --- a/src/Glpi/OAuth/AccessTokenRepository.php +++ b/src/Glpi/OAuth/AccessTokenRepository.php @@ -42,6 +42,13 @@ class AccessTokenRepository implements AccessTokenRepositoryInterface { + /** + * @param ClientEntityInterface $clientEntity + * @param array $scopes + * @param ?string $userIdentifier + * + * @return AccessTokenEntityInterface + */ public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null): AccessTokenEntityInterface { $token = new AccessToken(); @@ -68,6 +75,11 @@ public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEnt ]); } + /** + * @param string $tokenId + * + * @return void + */ public function revokeAccessToken($tokenId): void { global $DB; @@ -75,6 +87,11 @@ public function revokeAccessToken($tokenId): void $DB->delete('glpi_oauth_access_tokens', ['identifier' => $tokenId]); } + /** + * @param string $tokenId + * + * @return bool + */ public function isAccessTokenRevoked($tokenId): bool { global $DB; diff --git a/src/Glpi/OAuth/AuthCodeRepository.php b/src/Glpi/OAuth/AuthCodeRepository.php index d98e9ee6c5d..a180cf31e9c 100644 --- a/src/Glpi/OAuth/AuthCodeRepository.php +++ b/src/Glpi/OAuth/AuthCodeRepository.php @@ -61,6 +61,11 @@ public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity): voi ]); } + /** + * @param string $codeId + * + * @return void + */ public function revokeAuthCode($codeId): void { global $DB; @@ -68,6 +73,11 @@ public function revokeAuthCode($codeId): void $DB->delete('glpi_oauth_auth_codes', ['identifier' => $codeId]); } + /** + * @param string $codeId + * + * @return bool + */ public function isAuthCodeRevoked($codeId): bool { global $DB; diff --git a/src/Glpi/OAuth/Client.php b/src/Glpi/OAuth/Client.php index 38e714348fe..0888ff067cf 100644 --- a/src/Glpi/OAuth/Client.php +++ b/src/Glpi/OAuth/Client.php @@ -50,6 +50,11 @@ public function __construct() $this->isConfidential = true; } + /** + * @param string $name + * + * @return void + */ public function setName(string $name) { $this->name = $name; diff --git a/src/Glpi/OAuth/ClientRepository.php b/src/Glpi/OAuth/ClientRepository.php index ccc90cb4d03..4400bcc3102 100644 --- a/src/Glpi/OAuth/ClientRepository.php +++ b/src/Glpi/OAuth/ClientRepository.php @@ -44,6 +44,11 @@ class ClientRepository implements ClientRepositoryInterface { + /** + * @param string $clientIdentifier + * + * @return ?ClientEntityInterface + */ public function getClientEntity($clientIdentifier): ?ClientEntityInterface { global $DB; @@ -67,6 +72,11 @@ public function getClientEntity($clientIdentifier): ?ClientEntityInterface } /** + * @param string $clientIdentifier + * @param string $clientSecret + * @param string $grantType + * + * @return bool * @throws OAuthServerException If the requested grant type is not allowed for the client */ public function validateClient($clientIdentifier, $clientSecret, $grantType): bool diff --git a/src/Glpi/OAuth/RefreshTokenRepository.php b/src/Glpi/OAuth/RefreshTokenRepository.php index 1a170dc7a90..ab89aa03387 100644 --- a/src/Glpi/OAuth/RefreshTokenRepository.php +++ b/src/Glpi/OAuth/RefreshTokenRepository.php @@ -59,6 +59,11 @@ public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshToken ]); } + /** + * @param string $tokenId + * + * @return void + */ public function revokeRefreshToken($tokenId): void { global $DB; @@ -68,6 +73,11 @@ public function revokeRefreshToken($tokenId): void ]); } + /** + * @param string $tokenId + * + * @return bool + */ public function isRefreshTokenRevoked($tokenId): bool { global $DB; diff --git a/src/Glpi/OAuth/ScopeRepository.php b/src/Glpi/OAuth/ScopeRepository.php index 7e1c73a4ce9..3ed796eb51a 100644 --- a/src/Glpi/OAuth/ScopeRepository.php +++ b/src/Glpi/OAuth/ScopeRepository.php @@ -50,6 +50,15 @@ public function getScopeEntityByIdentifier($identifier): ?ScopeEntityInterface return $scope; } + /** + * @param array $scopes + * @param string $grantType + * @param ClientEntityInterface $clientEntity + * @param ?string $userIdentifier + * @param ?string $authCodeId + * + * @return ScopeEntityInterface[] + */ public function finalizeScopes(array $scopes, $grantType, ClientEntityInterface $clientEntity, $userIdentifier = null, ?string $authCodeId = null): array { global $DB; diff --git a/src/Glpi/OAuth/UserRepository.php b/src/Glpi/OAuth/UserRepository.php index bd7b02bdafb..f938ff53de7 100644 --- a/src/Glpi/OAuth/UserRepository.php +++ b/src/Glpi/OAuth/UserRepository.php @@ -42,6 +42,14 @@ class UserRepository implements UserRepositoryInterface { + /** + * @param string $username + * @param string $password + * @param string $grantType + * @param ClientEntityInterface $clientEntity + * + * @return ?UserEntityInterface + */ public function getUserEntityByUserCredentials($username, $password, $grantType, ClientEntityInterface $clientEntity): ?UserEntityInterface { $auth = new Auth(); diff --git a/src/Glpi/Search/Output/HTMLSearchOutput.php b/src/Glpi/Search/Output/HTMLSearchOutput.php index c5a5178353d..994c3b0e639 100644 --- a/src/Glpi/Search/Output/HTMLSearchOutput.php +++ b/src/Glpi/Search/Output/HTMLSearchOutput.php @@ -275,6 +275,12 @@ public function displayData(array $data, array $params = []) $_SESSION['glpimassiveactionselected'] = []; } + /** + * @param bool $odd + * @param bool $is_deleted + * + * @return string + */ public static function showNewLine($odd = false, $is_deleted = false): string { $class = " class='tab_bg_2" . ($is_deleted ? '_2' : '') . "' "; @@ -294,7 +300,13 @@ public static function showBeginHeader(): string return ''; } - public static function showHeader($rows, $cols, $fixed = 0): string + /** + * @param int $rows + * @param int $cols + * @param bool $fixed + * @return string + */ + public static function showHeader($rows, $cols, $fixed = false): string { if ($fixed) { return "
"; @@ -303,7 +315,17 @@ public static function showHeader($rows, $cols, $fixed = 0): string return "
"; } - public static function showHeaderItem($value, &$num, $linkto = "", $issort = 0, $order = "", $options = ""): string + /** + * @param string $value + * @param int $num + * @param string $linkto + * @param bool $issort + * @param string $order + * @param string $options + * + * @return string + */ + public static function showHeaderItem($value, &$num, $linkto = "", $issort = false, $order = "", $options = ""): string { $class = ""; if ($issort) { @@ -327,6 +349,14 @@ public static function showEndHeader(): string return ''; } + /** + * @param string $value + * @param int $num + * @param int $row + * @param string $extraparam + * + * @return string + */ public static function showItem($value, &$num, $row, $extraparam = ''): string { global $CFG_GLPI; @@ -370,11 +400,22 @@ public static function showItem($value, &$num, $row, $extraparam = ''): string return $out; } + /** + * @param string $title + * @param ?int $count + * + * @return string + */ public static function showFooter($title = "", $count = null): string { return "
\n"; } + /** + * @param string $message + * + * @return string + */ public static function showError($message = ''): string { return "
" . \htmlescape($message) . "
"; diff --git a/src/Glpi/Search/Output/NamesListSearchOutput.php b/src/Glpi/Search/Output/NamesListSearchOutput.php index 98c1582056b..c8bd43727b8 100644 --- a/src/Glpi/Search/Output/NamesListSearchOutput.php +++ b/src/Glpi/Search/Output/NamesListSearchOutput.php @@ -124,7 +124,14 @@ public static function showEndLine(): string return "\n"; } - public static function showHeader($rows, $cols, $fixed = 0): string + /** + * @param int $rows + * @param int $cols + * @param bool $fixed + * + * @return string + */ + public static function showHeader($rows, $cols, $fixed = false): string { if (!headers_sent()) { header("Content-disposition: filename=glpi.txt"); @@ -133,6 +140,14 @@ public static function showHeader($rows, $cols, $fixed = 0): string return ''; } + /** + * @param string $value + * @param int $num + * @param int $row + * @param string $extraparam + * + * @return string + */ public static function showItem($value, &$num, $row, $extraparam = ''): string { // We only want to display one column (the name of the item). diff --git a/src/Glpi/Search/Output/Spreadsheet.php b/src/Glpi/Search/Output/Spreadsheet.php index 81668b811ac..d3bd9b04e8b 100644 --- a/src/Glpi/Search/Output/Spreadsheet.php +++ b/src/Glpi/Search/Output/Spreadsheet.php @@ -51,6 +51,10 @@ abstract class Spreadsheet extends ExportSearchOutput { protected \PhpOffice\PhpSpreadsheet\Spreadsheet $spread; protected BaseWriter|IWriter $writer; + /** + * FIXME: remove in GLPI 12, seems not used + * @var int + */ protected $count; public function __construct() diff --git a/src/Glpi/Search/Output/Tcpdf.php b/src/Glpi/Search/Output/Tcpdf.php index dc8e89807a2..63fb4eec1d3 100644 --- a/src/Glpi/Search/Output/Tcpdf.php +++ b/src/Glpi/Search/Output/Tcpdf.php @@ -56,6 +56,11 @@ protected function createExternalWriterInstance($orientation, $unit, $paperSize) null, false ) extends GLPIPDF { + /** + * @param bool $val + * + * @return void + */ public function setPrintFooter($val = true) { //override because \PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf::save() explicitly calls setPrintFooter(false) -_- diff --git a/src/Glpi/Search/Provider/SQLProvider.php b/src/Glpi/Search/Provider/SQLProvider.php index b142b35aaed..82356b6ab93 100644 --- a/src/Glpi/Search/Provider/SQLProvider.php +++ b/src/Glpi/Search/Provider/SQLProvider.php @@ -1142,7 +1142,17 @@ private static function getMainItemtypeSystemSQLCriteria(string $itemtype): stri return $dbi->analyseCrit($criteria); } - public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val, $meta = 0): ?array + /** + * @param bool $nott + * @param class-string $itemtype + * @param int $ID + * @param string $searchtype + * @param string|int $val + * @param bool $meta + * + * @return ?array + */ + public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val, $meta = false): ?array { global $DB; diff --git a/src/Glpi/Search/SearchEngine.php b/src/Glpi/Search/SearchEngine.php index aff73e4a18e..d3bc0612029 100644 --- a/src/Glpi/Search/SearchEngine.php +++ b/src/Glpi/Search/SearchEngine.php @@ -36,10 +36,12 @@ namespace Glpi\Search; use AllAssets; +use Change; use CommonDBTM; use CommonITILObject; use CommonITILTask; use CommonITILValidation; +use Computer; use DisplayPreference; use Dropdown; use Entity; @@ -65,10 +67,17 @@ use ITILFollowup; use ITILSolution; use KnowbaseItem; +use Monitor; +use Peripheral; +use Phone; use Plugin; +use Printer; +use Problem; use RuntimeException; use Search; use Session; +use Software; +use Ticket; use Toolbox; use function Safe\preg_match; @@ -246,10 +255,9 @@ public static function isPossibleMetaSubitemOf(string $parent_itemtype, string $ } /** - * - * @param $itemtype + * @param class-string $itemtype * @return class-string|false - **/ + */ public static function getMetaReferenceItemtype($itemtype) { @@ -259,15 +267,15 @@ public static function getMetaReferenceItemtype($itemtype) // Use reference type if given itemtype extends a reference type. $types = [ - 'Computer', - 'Problem', - 'Change', - 'Ticket', - 'Printer', - 'Monitor', - 'Peripheral', - 'Software', - 'Phone', + Computer::class, + Problem::class, + Change::class, + Ticket::class, + Printer::class, + Monitor::class, + Peripheral::class, + Software::class, + Phone::class, ]; foreach ($types as $type) { if (is_a($itemtype, $type, true)) { diff --git a/src/Glpi/Search/SearchOption.php b/src/Glpi/Search/SearchOption.php index a73097817bb..fab77ee7846 100644 --- a/src/Glpi/Search/SearchOption.php +++ b/src/Glpi/Search/SearchOption.php @@ -68,6 +68,7 @@ * This is a wrapper class for the array format search option. * * @internal Not for use outside {@link Search} class and the "Glpi\Search" namespace. + * @implements ArrayAccess */ final class SearchOption implements ArrayAccess { @@ -76,6 +77,7 @@ final class SearchOption implements ArrayAccess * @var array{id: int, name: string, field: string, table: string} */ private array $search_opt_array; + /** @var array */ private static $search_options_cache = []; public function __construct(array $search_opt_array) @@ -426,6 +428,8 @@ public static function isInfocomOption($itemtype, $searchID): bool /** * @param class-string $itemtype * @param integer $field_num + * + * @return array **/ public static function getActionsFor($itemtype, $field_num) { diff --git a/src/Glpi/Socket.php b/src/Glpi/Socket.php index cdb7d6aa035..abbf29108d4 100644 --- a/src/Glpi/Socket.php +++ b/src/Glpi/Socket.php @@ -62,6 +62,7 @@ class Socket extends CommonDBChild // From CommonDBTM public $dohistory = true; public static $rightname = 'cable_management'; + /** @var bool */ public $can_be_translated = false; public const REAR = 1; @@ -165,6 +166,11 @@ public function prepareInputForUpdate($input) return $input; } + /** + * @param array $input + * + * @return array + */ public function retrievedataFromNetworkPort($input) { // get position from networkport if needed @@ -315,8 +321,10 @@ public function post_getEmpty() * * @since 0.84 * - * @param integer $value status ID - **/ + * @param int $value status ID + * + * @return int + */ public static function getWiringSideName($value) { $tab = static::getSides(); @@ -401,6 +409,9 @@ public function rawSearchOptions() return $tab; } + /** + * @return array + */ public static function rawSearchOptionsToAdd() { $tab = []; @@ -561,6 +572,9 @@ public function post_updateItem($history = true) $this->cleanIfStealNetworkPort(); } + /** + * @return void + */ public function cleanIfStealNetworkPort() { global $DB; @@ -913,12 +927,12 @@ public static function showForLocation(Location $item): bool } /** - * @since 0.84 + * @param ?HTMLTableRow $row + * @param ?CommonDBTM $item + * @param ?HTMLTableCell $father + * @param array $options * - * @param $row HTMLTableRow object (default NULL) - * @param $item CommonDBTM object (default NULL) - * @param $father HTMLTableCell object (default NULL) - * @param $options array + * @return void **/ public static function getHTMLTableCellsForItem( ?HTMLTableRow $row = null, diff --git a/src/Glpi/Stat/StatData.php b/src/Glpi/Stat/StatData.php index 35fa88a137b..ad88add3e6c 100644 --- a/src/Glpi/Stat/StatData.php +++ b/src/Glpi/Stat/StatData.php @@ -42,11 +42,17 @@ */ abstract class StatData { + /** @var array */ protected $labels; + /** @var array */ protected $series; + /** @var int */ protected $total; + /** @var string */ protected $csv_link; + /** @var array */ protected $options; + /** @var array */ protected $params; public function __construct(array $params = []) @@ -67,6 +73,12 @@ public function __construct(array $params = []) $this->total = 0; } + /** + * @param array $params + * @param string $type + * + * @return ?array + */ public function getDataByType(array $params, string $type) { return Stat::constructEntryValues( diff --git a/src/Glpi/System/Log/LogViewer.php b/src/Glpi/System/Log/LogViewer.php index 823b666821c..51a4e172845 100644 --- a/src/Glpi/System/Log/LogViewer.php +++ b/src/Glpi/System/Log/LogViewer.php @@ -158,6 +158,9 @@ public function showLogFile(string $filepath, bool $only_content = false): void } + /** + * @return string + */ public static function getIcon() { return "ti ti-news"; diff --git a/src/Glpi/System/Requirement/SessionsSecurityConfiguration.php b/src/Glpi/System/Requirement/SessionsSecurityConfiguration.php index 6a2bff9a4c6..d42a9123014 100644 --- a/src/Glpi/System/Requirement/SessionsSecurityConfiguration.php +++ b/src/Glpi/System/Requirement/SessionsSecurityConfiguration.php @@ -93,16 +93,25 @@ protected function check() } } + /** + * @return string + */ protected function getCookiesSecure() { return ini_get('session.cookie_secure'); } + /** + * @return string + */ protected function getCookiesHttpOnly() { return ini_get('session.cookie_httponly'); } + /** + * @return string + */ protected function getCookiesSamesite(): string { return ini_get('session.cookie_samesite'); diff --git a/src/Glpi/System/RequirementsList.php b/src/Glpi/System/RequirementsList.php index e1cbe07acdd..4725f4baf79 100644 --- a/src/Glpi/System/RequirementsList.php +++ b/src/Glpi/System/RequirementsList.php @@ -42,6 +42,7 @@ /** * @since 9.5.0 + * @implements IteratorAggregate */ class RequirementsList implements IteratorAggregate { diff --git a/src/Glpi/Toolbox/MarkdownBuilder.php b/src/Glpi/Toolbox/MarkdownBuilder.php index c02a44629de..8d01f4158ab 100644 --- a/src/Glpi/Toolbox/MarkdownBuilder.php +++ b/src/Glpi/Toolbox/MarkdownBuilder.php @@ -65,6 +65,8 @@ public function getMarkdown(): string * @param string $prefix Header type (#, ##, ...) * @param string $content Header content * @param string|null $css_class Css class to add to this header + * + * @return void */ protected function addHeader( string $prefix, @@ -80,6 +82,8 @@ protected function addHeader( * * @param string $content Header content * @param string|null $css_class Css class to add to this header + * + * @return void */ public function addH1(string $content, ?string $css_class = null) { @@ -91,6 +95,8 @@ public function addH1(string $content, ?string $css_class = null) * * @param string $content Header content * @param string|null $css_class Css class to add to this header + * + * @return void */ public function addH2(string $content, ?string $css_class = null) { @@ -102,6 +108,8 @@ public function addH2(string $content, ?string $css_class = null) * * @param string $content Header content * @param string|null $css_class Css class to add to this header + * + * @return void */ public function addH3(string $content, ?string $css_class = null) { @@ -113,6 +121,8 @@ public function addH3(string $content, ?string $css_class = null) * * @param string $content Header content * @param string|null $css_class Css class to add to this header + * + * @return void */ public function addH4(string $content, ?string $css_class = null) { @@ -124,6 +134,8 @@ public function addH4(string $content, ?string $css_class = null) * * @param string $content Header content * @param string|null $css_class Css class to add to this header + * + * @return void */ public function addH5(string $content, ?string $css_class = null) { @@ -135,6 +147,8 @@ public function addH5(string $content, ?string $css_class = null) * * @param string $content Header content * @param string|null $css_class Css class to add to this header + * + * @return void */ public function addH6(string $content, ?string $css_class = null) { @@ -145,6 +159,8 @@ public function addH6(string $content, ?string $css_class = null) * Add a table row * * @param array $values + * + * @return void */ public function addTableRow(array $values) { @@ -155,6 +171,8 @@ public function addTableRow(array $values) * Add a table header * * @param array $headers + * + * @return void */ public function addTableHeader(array $headers) { @@ -166,6 +184,8 @@ public function addTableHeader(array $headers) /** * Helper function to encapsulate single line code * + * @param string $code + * * @return string */ public static function code($code): string @@ -176,6 +196,8 @@ public static function code($code): string /** * Helper function create a navigation link * + * @param string $label + * * @return string */ public static function navigationLink($label) @@ -187,6 +209,8 @@ public static function navigationLink($label) /** * Helper function create a summary entry * + * @param string $label + * * @return void */ public function addSummaryEntry($label) diff --git a/src/Glpi/Toolbox/URL.php b/src/Glpi/Toolbox/URL.php index 9dd1c0c7966..d7832ca52a3 100644 --- a/src/Glpi/Toolbox/URL.php +++ b/src/Glpi/Toolbox/URL.php @@ -188,7 +188,7 @@ private static function extractPluginItemtypeFromUrlPath(string $path): ?string } } - private static function extractedPathContainsNamespace(string $path) + private static function extractedPathContainsNamespace(string $path): bool { return str_contains($path, "/"); } diff --git a/src/Plugin.php b/src/Plugin.php index 0bc02f1e8c1..2efbb486e0a 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -1872,7 +1872,7 @@ public static function doHookFunction($name, $parm = null) * or callable function * @param mixed ...$args [optional] One or more arguments passed to hook function * - * @return mixed $data + * @return mixed|void $data **/ public static function doOneHook($plugin_key, $hook, ...$args) { diff --git a/src/Stat.php b/src/Stat.php index 776bf0cfba9..b14825854f6 100644 --- a/src/Stat.php +++ b/src/Stat.php @@ -1650,7 +1650,7 @@ public static function showItems($target, $date1, $date2, $start, $itemtype = nu $header_num = 1; if ($is_html_output) { - echo $output::showHeader($end_display - $start + 1, 2, 1); + echo $output::showHeader($end_display - $start + 1, 2, true); echo $output::showNewLine(); echo $output::showHeaderItem(_sn('Associated element', 'Associated elements', $numrows), $header_num); if ($view_entities) {