Skip to main content
The Deprecated API analyzer scans your plugin code for outdated PocketMine-MP API methods, classes, and constants that have been removed or replaced in newer API versions.

What it detects

This analyzer identifies three types of deprecated API usage:
  • Deprecated methods - Method calls that have been replaced in PM4/PM5
  • Deprecated classes - Classes that have been moved or removed
  • Deprecated constants - Constants that no longer exist
All detected issues are reported as warnings with the replacement API clearly specified.

Common deprecated APIs

Level to World migration (PM4)

PocketMine-MP 4.0.0 renamed “Level” to “World” across the entire API.
$level = $player->getLevel();
$player->setLevel($world);
$spawn = $server->getLevelNonNull("world");
The pocketmine\level namespace was completely removed in PM4. Update all imports to pocketmine\world.

Player messaging methods (PM4-PM5)

Several player messaging methods were renamed for consistency.
$player->addTitle("Title");
$player->addSubTitle("Subtitle");
$player->addActionBarMessage("Action");
$player->sendPopup("Popup"); // PM5
$player->sendTip("Tip"); // PM5

Metadata system (removed in PM4)

The metadata system was completely removed in PocketMine-MP 4.0.0.
$entity->setMetadata("custom_key", new StringMetadataValue($plugin, "value"));
$meta = $entity->getMetadata("custom_key");
if ($entity->hasMetadata("custom_key")) {
    $entity->removeMetadata("custom_key", $plugin);
}

AsyncTask local storage (PM5)

Thread-local storage methods were deprecated in favor of static class properties.
class MyTask extends AsyncTask {
    public function onRun(): void {
        $this->storeLocal("key", $value);
        $data = $this->fetchLocal("key");
    }
}

Entity visibility methods (PM5)

$player->hidePlayer($otherPlayer);
$player->showPlayer($otherPlayer);
if ($player->canSee($otherPlayer)) {
    // ...
}

Resource methods (PM5)

class MyPlugin extends PluginBase {
    public function onEnable(): void {
        $this->saveResource("config.yml");
        $resource = $this->getResource("data.json");
    }
}

Item and enchantment changes (PM5)

Item equality methods

if ($item1->equals($item2)) {
    // Items are equal
}

Enchantment compatibility

$flags = $enchantment->getPrimaryItemFlags();
$flags = $enchantment->getSecondaryItemFlags();
$enchantment->hasPrimaryItemType($item->getTypeId());

Full list of detected deprecations

The analyzer detects 74 deprecated methods, 8 deprecated classes, and 1 deprecated constant:
  • getLevel, setLevel, getLevelNonNull → Use World methods
  • teleportImmediateteleport
  • addTitle, addSubTitle, addActionBarMessagesend* equivalents
  • sendPopup, sendTipsendToastNotification
  • getMetadata, setMetadata, hasMetadata, removeMetadata → Custom storage
  • getPlayerExactgetPlayerByPrefix or custom lookup
  • hidePlayer, showPlayer, canSee → Entity spawn/despawn methods
  • getResource, saveResource → PHP file functions with getResourcePath()
  • AsyncTask local storage methods → Static properties
  • canTickgetApplyInterval()
  • getCollisionCubesgetBlockCollisionBoxes
  • getFullBlockgetBlock()->getStateId()
  • equalsequalsExact or canStackWith
  • Enchantment flag methods → ItemEnchantmentTags
  • toHTML → Custom implementation
  • getMemoryUsageProcess::getAdvancedMemoryUsage()
  • pocketmine\level\Levelpocketmine\world\World
  • pocketmine\level\Positionpocketmine\world\Position
  • pocketmine\level\Locationpocketmine\world\Location
  • pocketmine\level\ChunkManagerpocketmine\world\ChunkManager
  • pocketmine\level\format\Chunkpocketmine\world\format\Chunk
  • pocketmine\tile\Tilepocketmine\block\tile\Tile
  • pocketmine\metadata\Metadatable → Custom data storage
  • pocketmine\plugin\PluginLogger → PSR-3 Logger

How it works

The analyzer uses PHP-Parser to traverse the abstract syntax tree (AST) of your code and:
  1. Scans method calls - Checks both $obj->method() and Class::method() calls
  2. Scans use statements - Detects deprecated class imports
  3. Scans fully qualified names - Catches inline \pocketmine\level\Level usage
  4. Scans constants - Identifies deprecated constant references
Each detected issue includes the line number, deprecated API name, replacement suggestion, and the API version when it was deprecated.

Example output

When the analyzer finds deprecated API usage, it reports:
Method 'getLevel' is deprecated since API 4.0.0. Use getWorld instead.
  File: src/Main.php:45
  Severity: WARNING
  Fix: Replace with getWorld

Configuration

Disable this analyzer in retina.yml:
excludeAnalyzers:
  - DeprecatedApi
Or exclude just deprecated API warnings:
excludeCategories:
  - deprecated_api

See also

PHPStan analyzer

Advanced static analysis with PHPStan integration

Thread safety analyzer

Detect thread safety violations in async tasks

Build docs developers (and LLMs) love