Skip to content

Commit

Permalink
Fix PHPDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Sep 16, 2024
1 parent 9c0ef97 commit 46a01ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 76 deletions.
72 changes: 3 additions & 69 deletions .phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -1,72 +1,6 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
// identifier: classConstant.nonObject
'message' => '#^Cannot access constant class on object\\|false\\.$#',
'count' => 6,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: staticProperty.nonObject
'message' => '#^Cannot access static property \\$rightname on object\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method add\\(\\) on object\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method check\\(\\) on object\\|false\\.$#',
'count' => 5,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method delete\\(\\) on object\\|false\\.$#',
'count' => 2,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method getLinkURL\\(\\) on object\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method redirectToList\\(\\) on object\\|false\\.$#',
'count' => 3,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method restore\\(\\) on object\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method update\\(\\) on object\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: staticMethod.nonObject
'message' => '#^Cannot call static method displayFullPageForItem\\(\\) on object\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: staticMethod.nonObject
'message' => '#^Cannot call static method getDefinition\\(\\) on object\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/front/asset/asset.form.php',
];
$ignoreErrors[] = [
// identifier: booleanOr.alwaysFalse
'message' => '#^Result of \\|\\| is always false\\.$#',
Expand Down Expand Up @@ -2001,7 +1935,7 @@
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method Glpi\\\\Asset\\\\Asset\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\Asset\\)\\|false but returns object\\.$#',
'message' => '#^Method Glpi\\\\Asset\\\\Asset\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\Asset\\)\\|false but returns Glpi\\\\Asset\\\\Asset\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Asset/Asset.php',
];
Expand All @@ -2019,13 +1953,13 @@
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method Glpi\\\\Asset\\\\AssetModel\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\AssetModel\\)\\|false but returns CommonDBTM\\.$#',
'message' => '#^Method Glpi\\\\Asset\\\\AssetModel\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\AssetModel\\)\\|false but returns Glpi\\\\Asset\\\\AssetModel\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Asset/AssetModel.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method Glpi\\\\Asset\\\\AssetType\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\AssetType\\)\\|false but returns CommonDBTM\\.$#',
'message' => '#^Method Glpi\\\\Asset\\\\AssetType\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\AssetType\\)\\|false but returns Glpi\\\\Asset\\\\AssetType\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Asset/AssetType.php',
];
Expand Down
3 changes: 3 additions & 0 deletions front/asset/asset.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@

if (array_key_exists('id', $_REQUEST) && !Asset::isNewId($_REQUEST['id'])) {
$asset = Asset::getById($_REQUEST['id']);
if ($asset === false) {
$asset = null;
}
} else {
$definition = new AssetDefinition();
$classname = array_key_exists('class', $_GET) && $definition->getFromDBBySystemName((string)$_GET['class'])
Expand Down
20 changes: 13 additions & 7 deletions src/Glpi/Asset/AssetDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
use Glpi\Search\SearchOption;
use Profile;
use ProfileRight;
use RuleDictionnaryDropdownCollection;
use Session;

final class AssetDefinition extends CommonDBTM
Expand Down Expand Up @@ -861,6 +860,7 @@ public static function getSpecificValueToSelect($field, $name = '', $values = ''
*
* @param bool $with_namespace
* @return string
* @phpstan-return class-string<\Glpi\Asset\Asset>
*/
public function getAssetClassName(bool $with_namespace = true): string
{
Expand All @@ -877,7 +877,8 @@ public function getAssetClassName(bool $with_namespace = true): string
* Get the definition's concrete asset model class name.
*
* @param bool $with_namespace
* @return class-string<CommonDBTM>
* @return string
* @phpstan-return class-string<\Glpi\Asset\AssetModel>
*/
public function getAssetModelClassName(bool $with_namespace = true): string
{
Expand All @@ -888,7 +889,8 @@ public function getAssetModelClassName(bool $with_namespace = true): string
* Get the definition's concrete asset type class name.
*
* @param bool $with_namespace
* @return class-string<CommonDBTM>
* @return string
* @phpstan-return class-string<\Glpi\Asset\AssetType>
*/
public function getAssetTypeClassName(bool $with_namespace = true): string
{
Expand All @@ -899,7 +901,8 @@ public function getAssetTypeClassName(bool $with_namespace = true): string
* Get the definition's concrete asset model dictionary class name.
*
* @param bool $with_namespace
* @return class-string<RuleDictionnaryDropdownCollection>
* @return string
* @phpstan-return class-string<\Glpi\Asset\RuleDictionaryModel>
*/
public function getAssetModelDictionaryClassName(bool $with_namespace = true): string
{
Expand All @@ -914,7 +917,8 @@ public function getAssetModelDictionaryClassName(bool $with_namespace = true): s
* Get the definition's concrete asset model dictionary collection class name.
*
* @param bool $with_namespace
* @return class-string<RuleDictionnaryDropdownCollection>
* @return string
* @phpstan-return class-string<\Glpi\Asset\RuleDictionaryModelCollection>
*/
public function getAssetModelDictionaryCollectionClassName(bool $with_namespace = true): string
{
Expand All @@ -929,7 +933,8 @@ public function getAssetModelDictionaryCollectionClassName(bool $with_namespace
* Get the definition's concrete asset type dictionary class name.
*
* @param bool $with_namespace
* @return class-string<RuleDictionnaryDropdownCollection>
* @return string
* @phpstan-return class-string<\Glpi\Asset\RuleDictionaryType>
*/
public function getAssetTypeDictionaryClassName(bool $with_namespace = true): string
{
Expand All @@ -944,7 +949,8 @@ public function getAssetTypeDictionaryClassName(bool $with_namespace = true): st
* Get the definition's concrete asset type dictionary collection class name.
*
* @param bool $with_namespace
* @return class-string<RuleDictionnaryDropdownCollection>
* @return string
* @phpstan-return class-string<\Glpi\Asset\RuleDictionaryTypeCollection>
*/
public function getAssetTypeDictionaryCollectionClassName(bool $with_namespace = true): string
{
Expand Down

0 comments on commit 46a01ec

Please sign in to comment.