Skip to content

fix(preprocessor): reject variadic promoted properties and callable property/constant types - #64

Open
AlessioGiacobbe wants to merge 2 commits into
swoole:masterfrom
AlessioGiacobbe:split/promotion-callable-types
Open

fix(preprocessor): reject variadic promoted properties and callable property/constant types#64
AlessioGiacobbe wants to merge 2 commits into
swoole:masterfrom
AlessioGiacobbe:split/promotion-callable-types

Conversation

@AlessioGiacobbe

Copy link
Copy Markdown
Contributor

Two declaration gaps: variadic promoted constructor properties (__construct(public int ...$x)) compiled — the promotion was registered before the variadic check (Zend: "Cannot declare variadic promoted property") — and callable in property types (declared, promoted, union members) and class/interface constant types was accepted, where Zend rejects it ("Property A::$x cannot have type callable"; constants previously failed only incidentally with a confusing default-value error).

Messages include the full type string for composite types. Each rule probed against Zend 8.4.13.

Part of the split of #39.

…roperty/constant types

Two promotion/type gaps against Zend (probed on 8.4.13):

- `__construct(public int ...$x)` was accepted and even registered
  the property before the variadic-position check ran. A variadic
  parameter collects its arguments into an array, so there is no single
  value to promote; Zend fatals with "Cannot declare variadic promoted
  property". The check now precedes the property registration.
- `callable` is a calling-scope-dependent type, so Zend forbids it in
  property types (declared, promoted, interface hooked) and class
  constant types (class and interface), bare or as a nullable/union
  member: "Property A::$x cannot have type ?callable" /
  "Class constant A::X cannot have type callable". Intersection
  members are left to the compound-type validation, which rejects
  every non-class standard type there.

`void`/`never` property and parameter types were already rejected by
parseTypeDecl ("The type `void`/`never` is allowed only for return
type") - verified, no change needed; union members are covered by the
compound-type validation.
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