Skip to content

Conversation

@tpetry
Copy link
Contributor

@tpetry tpetry commented Sep 13, 2021

The Illuminate\View\View class is implementing the Illuminate\Contracts\View\View contract which extends the Illuminate\Contracts\Support\Renderable contract. The renderable contract is ensuring a contract for the render method always return a string:

    /**
     * Get the evaluated contents of the object.
     *
     * @return string
     */
    public function render();

But the View class implementing the contract is specifying a return type violating the contract:

/**
     * Get the string contents of the view.
     *
     * @param  callable|null  $callback
     * @return array|string
     *
     * @throws \Throwable
     */
    public function render(callable $callback = null) {}

Because of this wrong type hint PhpStan is incorrectly throwing errors.

The Illuminate\View\View class is implementing the Illuminate\Contracts\View\View contract which extends the Illuminate\Contracts\Support\Renderable contract. The renderable contract is ensuring a contract for the render method always return a string:
```php
    /**
     * Get the evaluated contents of the object.
     *
     * @return string
     */
    public function render();
```

But the View class implementing the contract is specifying a return type violating the contract:
```php
/**
     * Get the string contents of the view.
     *
     * @param  callable|null  $callback
     * @return array|string
     *
     * @throws \Throwable
     */
    public function render(callable $callback = null) {}
```
@taylorotwell taylorotwell merged commit 55d3f78 into laravel:8.x Sep 13, 2021
@tpetry tpetry deleted the tpetry-patch-1 branch September 13, 2021 19:08
wouterj pushed a commit to wouterj/laravel-framework that referenced this pull request Sep 15, 2021
The Illuminate\View\View class is implementing the Illuminate\Contracts\View\View contract which extends the Illuminate\Contracts\Support\Renderable contract. The renderable contract is ensuring a contract for the render method always return a string:
```php
    /**
     * Get the evaluated contents of the object.
     *
     * @return string
     */
    public function render();
```

But the View class implementing the contract is specifying a return type violating the contract:
```php
/**
     * Get the string contents of the view.
     *
     * @param  callable|null  $callback
     * @return array|string
     *
     * @throws \Throwable
     */
    public function render(callable $callback = null) {}
```
victorvilella pushed a commit to cdsistemas/framework that referenced this pull request Oct 12, 2021
The Illuminate\View\View class is implementing the Illuminate\Contracts\View\View contract which extends the Illuminate\Contracts\Support\Renderable contract. The renderable contract is ensuring a contract for the render method always return a string:
```php
    /**
     * Get the evaluated contents of the object.
     *
     * @return string
     */
    public function render();
```

But the View class implementing the contract is specifying a return type violating the contract:
```php
/**
     * Get the string contents of the view.
     *
     * @param  callable|null  $callback
     * @return array|string
     *
     * @throws \Throwable
     */
    public function render(callable $callback = null) {}
```
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.

2 participants