---
title: "analyse/classes/invalid-new"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="analyse/classes/invalid-new" />

In the [`analyse-basic`](/docs/rules/presets/analyse-basic) preset and every stricter one. Report only. **Planned: not in Pun yet.** Enabling it is a config error.

## Replaces

- [`InstantiationRule`](https://phpstan.org/error-identifiers/argument.bitmaskNotAllowed) (phpstan-classes)
- [`AbstractInstantiation`](https://mago.carthage.software/1.61.0/en/tools/analyzer/overview/) (mago-analyzer)
- [`EnumInstantiation`](https://mago.carthage.software/1.61.0/en/tools/analyzer/overview/) (mago-analyzer)
- [`InterfaceInstantiation`](https://mago.carthage.software/1.61.0/en/tools/analyzer/overview/) (mago-analyzer)
- [`InvalidMethodAccess`](https://mago.carthage.software/1.61.0/en/tools/analyzer/overview/) (mago-analyzer)
- [`class.notFound`](https://phpstan.org/error-identifiers/class.notFound) (phpstan)
- [`new.abstract`](https://phpstan.org/error-identifiers/new.abstract) (phpstan)
- [`new.dateTime`](https://phpstan.org/error-identifiers/new.dateTime) (phpstan)
- [`new.dateTimeImmutable`](https://phpstan.org/error-identifiers/new.dateTimeImmutable) (phpstan)
- [`new.enum`](https://phpstan.org/error-identifiers/new.enum) (phpstan)
- [`new.interface`](https://phpstan.org/error-identifiers/new.interface) (phpstan)
- [`new.noConstructor`](https://phpstan.org/error-identifiers/new.noConstructor) (phpstan)
- [`new.nonObject`](https://phpstan.org/error-identifiers/new.nonObject) (phpstan)
- [`new.privateConstructor`](https://phpstan.org/error-identifiers/new.privateConstructor) (phpstan)
- [`new.protectedConstructor`](https://phpstan.org/error-identifiers/new.protectedConstructor) (phpstan)
- [`new.trait`](https://phpstan.org/error-identifiers/new.trait) (phpstan)

[More analyse/classes rules](/docs/rules/analyse/classes) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
