Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Glpi/Api/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/Api/APIRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/Api/HL/Controller/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 15 additions & 2 deletions src/Glpi/Api/HL/GraphQLGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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';
Expand Down
9 changes: 7 additions & 2 deletions src/Glpi/Api/HL/RoutePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Glpi/Application/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public static function isSet(): bool
return defined('GLPI_ENVIRONMENT_TYPE');
}

/**
* @return array
*/
public static function getValues()
{
$values = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/Application/View/Extension/DocumentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 8 additions & 0 deletions src/Glpi/Application/View/Extension/PluginExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/Glpi/Application/View/Extension/TeamExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

namespace Glpi\Application\View\Extension;

use CommonDBTM;
use Glpi\Features\TeamworkInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
Expand All @@ -51,6 +52,13 @@ public function getFilters(): array
];
}

/**
* @param class-string<CommonDBTM> $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)) {
Expand Down
18 changes: 17 additions & 1 deletion src/Glpi/Cache/I18nCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/Glpi/CalDAV/Backend/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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)
{

Expand Down
12 changes: 12 additions & 0 deletions src/Glpi/CalDAV/Backend/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
6 changes: 6 additions & 0 deletions src/Glpi/CalDAV/Plugin/CalDAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

Expand Down
3 changes: 2 additions & 1 deletion src/Glpi/CalDAV/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ public function __construct()
}

/**
*
* @param Throwable $exception
*
* @return void
*/
public function logException(Throwable $exception)
{
Expand Down
1 change: 1 addition & 0 deletions src/Glpi/Console/Assets/CleanSoftwareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
*
* @param InputInterface $input
*
* @return void
* @throws InvalidArgumentException
*/
private function validateInput(InputInterface $input)
Expand Down
1 change: 1 addition & 0 deletions src/Glpi/Console/Assets/PurgeSoftwareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
*
* @param InputInterface $input
*
* @return void
* @throws InvalidArgumentException
*/
private function validateInput(InputInterface $input)
Expand Down
1 change: 1 addition & 0 deletions src/Glpi/Console/Cache/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/Glpi/Console/Cache/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

class DebugCommand extends Command
{
/** @var bool */
protected $requires_db_up_to_date = false;

protected function configure()
Expand Down
4 changes: 2 additions & 2 deletions src/Glpi/Console/CommandLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private function getCommands()
*
* return void
*/
private function findCoreCommands()
private function findCoreCommands(): void
{

$basedir = $this->rootdir . DIRECTORY_SEPARATOR . 'src';
Expand Down Expand Up @@ -293,7 +293,7 @@ private function findPluginCommands()
*
* return void
*/
private function findToolsCommands()
private function findToolsCommands(): void
{

$basedir = $this->rootdir . DIRECTORY_SEPARATOR . 'tools';
Expand Down
Loading