Skip to content

Service name must be a non-empty string. with phpstan v2.1.34 #9605

@AlexSkrypnyk

Description

@AlexSkrypnyk

Bug Report

Subject Details
Rector version e.g. v2.3.1 (invoke vendor/bin/rector --version)
phpstan version e.g. v2.1.34 (invoke vendor/bin/rector --version)

Rector 2.3.1 fails when used with PHPStan 2.1.34 due to several breaking API changes in PHPStan. The errors include:

  1. Removed Visitor Classes
  PHP Warning: Undefined array key 0 in PHPStanContainerMemento.php on line 35
  [ERROR] "Service name must be a non-empty string." On line: 291

Cause: PHPStan 2.1.34 removed VariadicFunctionsVisitor and VariadicMethodsVisitor
classes. Rector's PHPStanContainerMemento.php still references them.

  1. Changed OptimizedSingleFileSourceLocator Constructor
  [ERROR] Argument #2 ($cache) must be of type PHPStan\Cache\Cache, string given

Cause: OptimizedSingleFileSourceLocator::__construct() signature changed from
(FileNodesFetcher, string) to (FileNodesFetcher, Cache, PhpVersion, string).

  1. FiberScope Introduction
  [ERROR] "Cannot suspend outside of a fiber"

Cause: PHPStan 2.1.34 introduces FiberScope for scope resolution. The node
callback in PHPStanNodeScopeResolver.php expects MutatingScope but now receives
FiberScope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions