Skip to content

Bug: Attribute "..." cannot target parameter (allowed targets: property) #52247

@devajmeireles

Description

@devajmeireles

Laravel Version

11.17

PHP Version

8.2.21

Database Driver & Version

No response

Description

The PR: #52167 accidentally introduced what I think is a potential breaking change related to attribute usage through container. This bug was originally reported here: tallstackui/tallstackui#567.


One of my open-source package contains an attribute that we use only to mark properties to skip certain conditions (see below). After upgrading any of my projects using this package to Laravel 11.17 this error happens:

CleanShot 2024-07-23 at 16 46 19@2x


The source of the error matches the changes made in the PR mentioned above:

CleanShot 2024-07-23 at 16 50 30@2x

Here: https://github.com/laravel/framework/pull/52167/files#diff-cc160328d7d447677b8d359453f4416c820a9117c5efd500a3f0361d1d5bab1a

Steps To Reproduce

IDK exactly how to reproduce this, but I guess it just try to use an attribute in a public parameter, like this:

<?php

namespace App\Attributes;

use Attribute;

#[Attribute(Attribute::TARGET_PROPERTY)]
class SkipDebug
{
    //
}
use App\Attributes\SkipDebug;

public function __construct(
    #[SkipDebug]
    public ?string $size = null,
) {
    //
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions