Skip to content

Update Error Docs#14854

Open
phpstan-bot wants to merge 1 commit into
phpstan:2.2.xfrom
phpstan-bot:create-pull-request/patch-2o5tq93
Open

Update Error Docs#14854
phpstan-bot wants to merge 1 commit into
phpstan:2.2.xfrom
phpstan-bot:create-pull-request/patch-2o5tq93

Conversation

@phpstan-bot

Copy link
Copy Markdown
Contributor

This PR updates the PHPStan error identifier documentation in website/errors/.

Changes

New: new.nonObject

Added documentation for the previously undocumented new.nonObject identifier, reported by PHPStan\Rules\Classes\InstantiationRule when new $expr is used with a value that is neither a class-name string nor an object (e.g. an int, float, bool, or array). At runtime PHP throws an Error in this case.

The doc includes:

  • A minimal triggering example (new $value with int $value)
  • An explanation of the PHP semantics, noting that this check is part of bleeding edge
  • Fixes: typing the variable as class-string, or narrowing the type so it can only hold an object

The example was verified against the playground API, confirming the error reports (only under bleeding edge, since the rule is gated behind the newOnNonObject feature toggle).

Reviewed: phpunit.attributeRequiresPhpVersion

The commit's errorsIdentifiers.json diff for this identifier was a pure source-location refactor — the rule logic moved from AttributeRequiresPhpVersionRule.php to the new AttributeVersionRequirementHelper.php. The error messages and trigger conditions are unchanged, so the existing documentation remains accurate and needs no update.

- Documented the `new.nonObject` identifier (bleeding edge `InstantiationRule`),
  reported when instantiating a value that is neither a class-name string nor an object
- Verified the example via the playground API (error only fires under bleeding edge)
- The `phpunit.attributeRequiresPhpVersion` diff was a source-location refactor
  (logic moved to AttributeVersionRequirementHelper); existing doc remains accurate
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

Successfully merging this pull request may close these issues.

1 participant