Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public properties are reported to be maybe undefined #70

Open
szepeviktor opened this issue Jul 10, 2023 · 2 comments
Open

Public properties are reported to be maybe undefined #70

szepeviktor opened this issue Jul 10, 2023 · 2 comments

Comments

@szepeviktor
Copy link
Contributor

szepeviktor commented Jul 10, 2023

class Option extends Component
{
    /**
     * The option name.
     */
    public string $name;

    public function __construct(string $name)
    {
        $this->name = $name;
    }

    public function render(): View
    {
        return $this->view('components.cookie.option', [
            'acceptText' => __(':name engedélyezése', ['name' => $this->label]),
            'declineText' => __(':name elutasítása', ['name' => $this->label]),
        ]);
    }
}

AFAIK public Model properties are available in blade templates.
Bladestan reports {{ $name }} as

Variable $name might not be defined.

Please advise.

@AJenbo
Copy link
Contributor

AJenbo commented Jul 10, 2023

Workaround:

        return $this->view('components.cookie.option', [
            'acceptText' => __(':name engedélyezése', ['name' => $this->label]),
            'declineText' => __(':name elutasítása', ['name' => $this->label]),
            'name' => $this->name,
        ]);

The issue here is that bladestan does not import them in to the context automatically, but if you do so explicitly it will be able to see them correctly.

spawnia added a commit to spawnia/bladestan that referenced this issue Sep 20, 2023
Only adds a failing test case for now.
See TomasVotruba#70.
@spawnia
Copy link
Contributor

spawnia commented Sep 20, 2023

I added a failing test case for this with #82.

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

No branches or pull requests

3 participants