Skip to content

Native parameter attributes may not be used on promoted properties #9420

Closed
@TimWolla

Description

@TimWolla

Description

The following code:

<?php

class Foo {
    public function __construct(
        #[SensitiveParameter]
        public string $password
    )
    {
        throw new \Exception('foo');
    }
}

new Foo('bar');

Resulted in this output:

Fatal error: Attribute "SensitiveParameter" cannot target property (allowed targets: parameter) in php-src/test.php on line 4

But I expected this output instead:

Fatal error: Uncaught Exception: foo in php-src/test.php:9
Stack trace:
#0 php-src/test.php(13): Foo->__construct(Object(SensitiveParameterValue))
#1 {main}
  thrown in /tmp/php-src/test.php on line 9

PHP Version

Current git master

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions