Skip to content

Commit c158ab0

Browse files
committed
Add doc types on classes under GLpi namepsace
1 parent 0eb60fb commit c158ab0

File tree

75 files changed

+630
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+630
-69
lines changed

src/Glpi/Api/API.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,35 @@
9393
abstract class API
9494
{
9595
// permit writing to $_SESSION
96+
/** @var bool */
9697
protected $session_write = false;
98+
/** @var string */
9799

98100
public static $api_url = "";
101+
/** @var string */
99102
public static $content_type = "application/json";
103+
/** @var string */
100104
protected $format = "json";
105+
/** @var string */
101106
protected $iptxt = "";
107+
/** @var string */
102108
protected $ipnum = "";
109+
/** @var array */
103110
protected $app_tokens = [];
111+
/** @var int */
104112
protected $apiclients_id = 0;
113+
/** @var ?DeprecatedInterface */
105114
protected $deprecated_item = null;
115+
/** @var string */
106116
protected $request_uri;
117+
/** @var array */
107118
protected $url_elements;
119+
/** @var string */
108120
protected $verb;
121+
/** @var array */
109122
protected $parameters;
110-
protected $debug = 0;
123+
/** @var bool */
124+
protected $debug = false;
111125

112126
/**
113127
* @param integer $nb Unused value

src/Glpi/Api/APIRest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function call()
150150
if (isset($this->parameters['debug'])) {
151151
$this->debug = $this->parameters['debug'];
152152
if (empty($this->debug)) {
153-
$this->debug = 1;
153+
$this->debug = true;
154154
}
155155
}
156156

src/Glpi/Api/HL/Controller/AssetController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ public function index(Request $request): Response
15281528
return new JSONResponse($asset_paths);
15291529
}
15301530

1531-
private static function getGlobalAssetSchema($asset_schemas)
1531+
private static function getGlobalAssetSchema(array $asset_schemas): array
15321532
{
15331533
$asset_types = self::getAssetTypes();
15341534
$asset_schemas = array_filter($asset_schemas, static fn($key) => !str_starts_with($key, '_') && in_array($key, $asset_types, true), ARRAY_FILTER_USE_KEY);

src/Glpi/Api/HL/GraphQLGenerator.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@
3535

3636
namespace Glpi\Api\HL;
3737

38+
use Closure;
3839
use Glpi\Api\HL\Doc as Doc;
3940
use Glpi\Debug\Profiler;
41+
use GraphQL\Type\Definition\ListOfType;
4042
use GraphQL\Type\Definition\ObjectType;
43+
use GraphQL\Type\Definition\ScalarType;
4144
use GraphQL\Type\Definition\Type;
4245
use Throwable;
4346

@@ -57,6 +60,9 @@ private function normalizeTypeName(string $type_name): string
5760
return str_replace([' ', '-'], ['', '_'], $type_name);
5861
}
5962

63+
/**
64+
* @return string
65+
*/
6066
public function getSchema()
6167
{
6268
Profiler::getInstance()->start('GraphQLGenerator::loadTypes', Profiler::CATEGORY_HLAPI);
@@ -87,7 +93,7 @@ public function getSchema()
8793
return $schema_str;
8894
}
8995

90-
private function writeType($type_name, ObjectType|callable $type): string
96+
private function writeType(string $type_name, ObjectType|callable $type): string
9197
{
9298
$type_name = $this->normalizeTypeName($type_name);
9399
$type_str = "type $type_name {\n";
@@ -118,7 +124,7 @@ private function writeType($type_name, ObjectType|callable $type): string
118124
return $type_str;
119125
}
120126

121-
private function loadTypes()
127+
private function loadTypes(): void
122128
{
123129
$component_schemas = OpenAPIGenerator::getComponentSchemas($this->api_version);
124130
foreach ($component_schemas as $schema_name => $schema) {
@@ -173,6 +179,13 @@ private function convertRESTSchemaToGraphQLSchema(string $schema_name, array $sc
173179
]);
174180
}
175181

182+
/**
183+
* @param array $property
184+
* @param string|null $name
185+
* @param string $prefix
186+
*
187+
* @return Closure|ListOfType|ObjectType|ScalarType|void
188+
*/
176189
private function convertRESTPropertyToGraphQLType(array $property, ?string $name = null, string $prefix = '')
177190
{
178191
$type = $property['type'] ?? 'string';

src/Glpi/Api/HL/RoutePath.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ public function getAttributesFromPath(string $path): array
224224
return $attributes;
225225
}
226226

227+
/**
228+
* @param string $path
229+
*
230+
* @return bool
231+
*/
227232
public function isValidPath($path): bool
228233
{
229234
// Ensure no placeholders are left
@@ -368,13 +373,13 @@ public function matchesAPIVersion(string $api_version): bool
368373
);
369374
}
370375

371-
private function setPath(string $path)
376+
private function setPath(string $path): void
372377
{
373378
$this->path = $path;
374379
$this->route->path = $path;
375380
}
376381

377-
private function setPriority(int $priority)
382+
private function setPriority(int $priority): void
378383
{
379384
$this->priority = $priority;
380385
$this->route->priority = $priority;

src/Glpi/Application/Environment.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public static function isSet(): bool
6969
return defined('GLPI_ENVIRONMENT_TYPE');
7070
}
7171

72+
/**
73+
* @return array
74+
*/
7275
public static function getValues()
7376
{
7477
$values = [];

src/Glpi/Application/View/Extension/DocumentExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DocumentExtension extends AbstractExtension
4949
/**
5050
* Static cache for user defined files extensions icons.
5151
*/
52-
private static $extensionIcon = null;
52+
private static ?array $extensionIcon = null;
5353

5454
public function getFilters(): array
5555
{

src/Glpi/Application/View/Extension/PluginExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ public function callPluginHookFunction(string $name, $params = null, bool $retur
9696
}
9797
}
9898

99+
/**
100+
* @param string $plugin
101+
* @param string $name
102+
* @param array $params
103+
* @param bool $return_result
104+
*
105+
* @return mixed|void
106+
*/
99107
public function callPluginOneHook(string $plugin, string $name, $params = null, bool $return_result = false)
100108
{
101109
$result = Plugin::doOneHook($plugin, $name, $params);

src/Glpi/Application/View/Extension/TeamExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
namespace Glpi\Application\View\Extension;
3737

38+
use CommonDBTM;
3839
use Glpi\Features\TeamworkInterface;
3940
use Twig\Extension\AbstractExtension;
4041
use Twig\TwigFilter;
@@ -51,6 +52,13 @@ public function getFilters(): array
5152
];
5253
}
5354

55+
/**
56+
* @param class-string<CommonDBTM> $itemtype
57+
* @param int $role
58+
* @param int $nb
59+
*
60+
* @return string
61+
*/
5462
public function getTeamRoleName($itemtype, int $role, int $nb = 1): string
5563
{
5664
if (is_a($itemtype, TeamworkInterface::class, true)) {

src/Glpi/Cache/I18nCache.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,39 @@
4444
*/
4545
class I18nCache
4646
{
47-
private $cache;
47+
private CacheInterface $cache;
4848

4949
public function __construct(CacheInterface $cache)
5050
{
5151
$this->cache = $cache;
5252
}
5353

54+
/**
55+
* @param string $key
56+
*
57+
* @return mixed
58+
*/
5459
public function getItem($key)
5560
{
5661
return $this->cache->get($key);
5762
}
5863

64+
/**
65+
* @param string $key
66+
* @param mixed $value
67+
*
68+
* @return bool
69+
*/
5970
public function setItem($key, $value)
6071
{
6172
return $this->cache->set($key, $value);
6273
}
6374

75+
/**
76+
* @param string $key
77+
*
78+
* @return bool
79+
*/
6480
public function removeItem($key)
6581
{
6682
return $this->cache->delete($key);

0 commit comments

Comments
 (0)