laminas / laminas-view

Flexible view layer supporting and providing multiple view layers, helpers, and more
https://docs.laminas.dev/laminas-view/
BSD 3-Clause "New" or "Revised" License
74 stars 46 forks source link

PhpRenderer @method for layout() return type is incomplete #247

Closed InvisibleSmiley closed 5 months ago

InvisibleSmiley commented 5 months ago

Bug Report

Q A
Version(s) 2.35.x, 3.0.x

Summary

PhpRenderer @method for method layout() is incomplete. The method actually returns ModelInterface|Layout, cf. Layout::__invoke. Actually the annotation there is wrong, too, since it never returns null.

https://github.com/laminas/laminas-view/blob/3.0.x/src/Renderer/PhpRenderer.php#L72 https://github.com/laminas/laminas-view/blob/3.0.x/src/Helper/Layout.php#L38

https://github.com/laminas/laminas-view/blob/2.35.x/src/Renderer/PhpRenderer.php#L76 https://github.com/laminas/laminas-view/blob/2.35.x/src/Helper/Layout.php#L38

Current behavior

Static analysis of code calling PhpRenderer::layout() and passing the result to PhpRenderer::render() fails

How to reproduce

<?php
$renderer = new \Laminas\View\Renderer\PhpRenderer();
$renderer->render($renderer->layout());

Expected behavior

Static analysis reports no error with the example code

gsteel commented 5 months ago

A patch would be most welcome 👍