Skip to content

Commit

Permalink
Fix PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Feb 15, 2025
1 parent 3d2fc31 commit eb3ba86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
20 changes: 4 additions & 16 deletions src/inventory/data/CreativeGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,15 @@ final class CreativeGroup{
public readonly Translatable|string $name;

Check failure on line 32 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $name. Assign it in the constructor.

Check failure on line 32 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $name. Assign it in the constructor.

Check failure on line 32 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $name. Assign it in the constructor.

Check failure on line 32 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $name. Assign it in the constructor.

Check failure on line 32 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $name. Assign it in the constructor.

Check failure on line 32 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $name. Assign it in the constructor.
public readonly ?Item $icon;

Check failure on line 33 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $icon. Assign it in the constructor.

Check failure on line 33 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $icon. Assign it in the constructor.

Check failure on line 33 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $icon. Assign it in the constructor.

Check failure on line 33 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $icon. Assign it in the constructor.

Check failure on line 33 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $icon. Assign it in the constructor.

Check failure on line 33 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Class pocketmine\inventory\data\CreativeGroup has an uninitialized readonly property $icon. Assign it in the constructor.

private function __construct(){
private function __construct(CreativeCategory $categoryId, Translatable|string $name, ?Item $icon){

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $categoryId.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $icon.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $name.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $categoryId.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $icon.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $name.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $categoryId.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $icon.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $name.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $categoryId.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $icon.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $name.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $categoryId.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $icon.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $name.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $categoryId.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $icon.

Check failure on line 35 in src/inventory/data/CreativeGroup.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 / PHPStan analysis

Constructor of class pocketmine\inventory\data\CreativeGroup has an unused parameter $name.
//NOOP
}

public static function anonymous(CreativeCategory $categoryId) : self{
$result = new self();

$result->categoryId = $categoryId;
$result->name = "";
$result->icon = null;

return $result;
return new self($categoryId, "", null);
}

public static function named(CreativeCategory $categoryId, Translatable|string $name, Item $icon) : self{
$result = new self();

$result->categoryId = $categoryId;
$result->name = $name;
$result->icon = $icon;

return $result;
public static function named(CreativeCategory $categoryId, Translatable|string $name, ?Item $icon = null) : self{
return new self($categoryId, $name, $icon);
}
}
2 changes: 1 addition & 1 deletion src/network/mcpe/cache/CreativeInventoryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function buildCreativeInventoryCache(CreativeInventory $inventory) : Cre

$groups[] = new CreativeGroupEntry(
$categoryId,
$group->name instanceof Translatable ? $group->name->getText() : (string) $group->name,
$group->name instanceof Translatable ? $group->name->getText() : $group->name,
$group->icon === null ? ItemStack::null() : $typeConverter->coreItemStackToNet($group->icon)
);
}
Expand Down

0 comments on commit eb3ba86

Please sign in to comment.