Using new keyword in attribute

If i use new keyword in any attribute the IDE says: "Constant expression contains invalid operations"

Example:

============================

#[MyAttr(arg1: new MyModel())]

class Test { /* ... */ }

============================

Above code is working with php 8.1.0RC1

So i think this is the IDE fault !!

(My PhpStorm version: 2021.2.2)

Ref: https://wiki.php.net/rfc/new_in_initializers

1 comment
Comment actions Permalink

This will be supported starting IDE version 2021.3: https://youtrack.jetbrains.com/issue/WI-62095.

0

Please sign in to leave a comment.