Skip to content

Group use imports and Phalcon classes are not resolved correctly #128

@Hector68

Description

@Hector68

PHPantom version

phpantom_lsp 0.8.0

Installation method

Pre-built binary from GitHub Releases

Operating system

macOS aarch64 (Apple Silicon)

Editor

Zed

Bug description

Description

phpantom_lsp reports multiple unknown_class and unknown_member errors for valid classes in a Phalcon project.

The project uses:

  • Phalcon
  • PSR-4 autoload
  • grouped use imports
  • phalcon/ide-stubs

However, the language server fails to resolve:

  • grouped imports
  • Phalcon framework classes
  • inherited controller properties like $this->request and $this->response

Environment

  • macOS
  • Zed IDE
  • phpantom_lsp installed via Homebrew
  • Rust installed via rustup

Example

All classes exist and are autoloadable.

Example path:

text src/Project/CatalogIndex/Services/Validation/ComplementsScenarioValidation.php

Namespace:

php namespace Project\CatalogIndex\Services\Validation;

Current behavior

Additionally:

text Class 'Phalcon\Http\ResponseInterface' not found Property 'request' not found Property 'response' not found

Expected behavior

  • Grouped use imports should resolve correctly
  • Phalcon classes from phalcon/ide-stubs should be indexed
  • Inherited controller properties (request, response) should be recognized

Additional info

composer dump-autoload -o works correctly.

The classes are correctly resolved by:

  • PhpStorm
  • Intelephense
  • Composer autoload

Steps to reproduce

Running:

bash phpantom_lsp analyze src/Project/CatalogIndex/Controllers/ProductController.php

Code ProductController contains

use Project\CatalogIndex\Services\Validation\{
    ComplementsScenarioValidation,
    ProductByModelValidation,
    ProductByArticleValidation,
    RelatedModelsValidation,
    SectionAllFilterValidation,
    SectionModelFilterValidation
};

Error output or panic trace

Produces:

text Class 'ComplementsScenarioValidation' not found Class 'ProductByModelValidation' not found Class 'ProductByArticleValidation' not found Class 'RelatedModelsValidation' not found Class 'SectionAllFilterValidation' not found Class 'SectionModelFilterValidation' not found

.phpantom.toml

[php]
# Override the detected PHP version (default: inferred from composer.json, or 8.5).
version = "8.3"

[diagnostics]
# Report member access on subjects whose type could not be resolved.
# Useful for discovering gaps in type coverage. Off by default.
# unresolved-member-access = true

[indexing]
# How PHPantom discovers classes across the workspace.
#   "composer" (default) - use Composer classmap, self-scan on fallback
#   "self"    - always self-scan, ignore Composer classmap
#   "none"    - no proactive scanning, Composer classmap only
# strategy = "composer"

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions