Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using @phpstan-type and returning said type in a docblock attempts to load a non-existing class #6834

Open
nesl247 opened this issue Nov 27, 2024 · 0 comments

Comments

@nesl247
Copy link
Contributor

nesl247 commented Nov 27, 2024

API Platform version(s) affected: 3.3.12

Description
When viewing documentation and using @phpstan-type CustomType array{} and @returns CustomType, an error is thrown.

  "@context": "/contexts/Error",
  "@type": "hydra:Error",
  "hydra:title": "An error occurred",
  "hydra:description": "Class \"Satws\\Scarface\\Insight\\Reports\\InsightReportInsights\" does not exist",
  "trace": [
    {
      "namespace": "",
      "short_class": "",
      "class": "",
      "type": "",
      "function": "",
      "file": "/srv/app/vendor/api-platform/core/src/JsonSchema/DefinitionNameFactory.php",
      "line": 35,
      "args": []
    },
    {
      "namespace": "",
      "short_class": "ReflectionClass",
      "class": "ReflectionClass",
      "type": "-\u003E",
      "function": "__construct",
      "file": "/srv/app/vendor/api-platform/core/src/JsonSchema/DefinitionNameFactory.php",
      "line": 35,
      "args": [
        [
          "string",
          "Satws\\Scarface\\Insight\\Reports\\InsightReportInsights"
        ]
      ]
    },

If you use @phpstan-returns instead, the error will go away.

How to reproduce

<?php

#[ApiResource]
/**
* @phpstan-type CustomType array{test: string}
*/
class Test 
{
  /**
   * @returns CustomType
   */
  public function __construct(public array $property) {}
}

Possible Solution

Additional Context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant