Skip to content

Commit

Permalink
Revert BC breaking parameter type changes and mark helpers @final w…
Browse files Browse the repository at this point in the history
…here possible

Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jul 20, 2023
1 parent 4a2ba1a commit 4364ebd
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 25 deletions.
25 changes: 7 additions & 18 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@
</RedundantConditionGivenDocblockType>
</file>
<file src="src/Helper/HeadLink.php">
<ArgumentTypeCoercion>
<code>$item</code>
</ArgumentTypeCoercion>
<MethodSignatureMustProvideReturnType>
<code>offsetSet</code>
</MethodSignatureMustProvideReturnType>
Expand All @@ -237,7 +240,6 @@
<code>$href</code>
<code>$index</code>
<code>$item</code>
<code>$item</code>
<code><![CDATA[$this->autoEscape ? $this->escapeAttribute($attributes[$itemKey]) : $attributes[$itemKey]]]></code>
<code><![CDATA[$this->autoEscape ? $this->escapeAttribute($value) : $value]]></code>
<code>$value</code>
Expand All @@ -258,7 +260,6 @@
<code>$href</code>
<code>$index</code>
<code>$item</code>
<code>$item</code>
<code>$media</code>
<code>$title</code>
<code>$type</code>
Expand All @@ -277,6 +278,7 @@
</file>
<file src="src/Helper/HeadMeta.php">
<ArgumentTypeCoercion>
<code>$item</code>
<code>$value</code>
<code>$value</code>
</ArgumentTypeCoercion>
Expand Down Expand Up @@ -349,10 +351,6 @@
<code>$content</code>
<code>$index</code>
<code>$index</code>
<code><![CDATA[$item->attributes['conditional']]]></code>
<code><![CDATA[$item->type]]></code>
<code><![CDATA[$item->type]]></code>
<code>$key</code>
<code><![CDATA[$this->autoEscape ? $this->escapeAttribute($value) : $value]]></code>
<code>$value</code>
</MixedArgument>
Expand All @@ -364,8 +362,6 @@
<code><![CDATA[$attrs['src']]]></code>
<code>$content</code>
<code>$index</code>
<code>$key</code>
<code>$type</code>
<code>$value</code>
</MixedAssignment>
<MixedInferredReturnType>
Expand All @@ -374,16 +370,6 @@
<MixedMethodCall>
<code>isHtml5</code>
</MixedMethodCall>
<MixedOperand>
<code><![CDATA[$item->attributes['conditional']]]></code>
<code><![CDATA[$item->source]]></code>
<code>$type</code>
</MixedOperand>
<MixedPropertyFetch>
<code><![CDATA[$item->attributes]]></code>
<code><![CDATA[$item->source]]></code>
<code><![CDATA[$item->type]]></code>
</MixedPropertyFetch>
<MixedReturnStatement>
<code>parent::__call($method, $args)</code>
<code>parent::__call($method, $args)</code>
Expand Down Expand Up @@ -411,6 +397,9 @@
<MethodSignatureMustProvideReturnType>
<code>offsetSet</code>
</MethodSignatureMustProvideReturnType>
<MismatchingDocblockParamType>
<code>ObjectShape</code>
</MismatchingDocblockParamType>
<MixedArgument>
<code>$content</code>
<code>$index</code>
Expand Down
4 changes: 3 additions & 1 deletion src/Helper/HeadLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Laminas\View\Exception;
use Laminas\View\Helper\Placeholder\Container\AbstractContainer;
use Laminas\View\Helper\Placeholder\Container\AbstractStandalone;
use stdClass;

use function array_intersect;
use function array_keys;
Expand Down Expand Up @@ -36,6 +37,7 @@
* @method HeadLink offsetSetAlternate($index, $href, $type, $title, $extras = [])
* @method HeadLink prependAlternate($href, $type, $title, $extras = [])
* @method HeadLink setAlternate($href, $type, $title, $extras = [])
* @final
*/
class HeadLink extends AbstractStandalone
{
Expand Down Expand Up @@ -300,7 +302,7 @@ public function set($value)
*
* @return string
*/
public function itemToString(object $item)
public function itemToString(stdClass $item)
{
$attributes = (array) $item;
$link = '<link';
Expand Down
4 changes: 3 additions & 1 deletion src/Helper/HeadMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Laminas\View\Exception;
use Laminas\View\Helper\Placeholder\Container\AbstractContainer;
use Laminas\View\Helper\Placeholder\Container\AbstractStandalone;
use stdClass;

use function array_shift;
use function array_unshift;
Expand Down Expand Up @@ -63,6 +64,7 @@
* itemprop?: string,
* }
* @extends AbstractStandalone<int, ObjectShape>
* @final
*/
class HeadMeta extends AbstractStandalone
{
Expand Down Expand Up @@ -254,7 +256,7 @@ public function createData($type, $typeValue, $content, array $modifiers)
* @throws Exception\InvalidArgumentException
* @return string
*/
public function itemToString(object $item)
public function itemToString(stdClass $item)
{
if (! in_array($item->type, $this->typeKeys)) {
throw new Exception\InvalidArgumentException(sprintf(
Expand Down
8 changes: 4 additions & 4 deletions src/Helper/HeadScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ protected function isValid($value)
*
* @internal This method will become private in version 3.0
*
* @param mixed $item Item to convert
* @param string $indent String to add before the item
* @param string $escapeStart Starting sequence
* @param string $escapeEnd Ending sequence
* @param ObjectShape $item Item to convert
* @param string $indent String to add before the item
* @param string $escapeStart Starting sequence
* @param string $escapeEnd Ending sequence
* @return string
*/
public function itemToString($item, $indent, $escapeStart, $escapeEnd)
Expand Down
3 changes: 2 additions & 1 deletion src/Helper/HeadStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* @method HeadStyle prependStyle(string $content, array $attributes = [])
* @method HeadStyle setStyle(string $content, array $attributes = [])
* @method HeadStyle setIndent(int|string $indent)
* @final
*/
class HeadStyle extends AbstractStandalone
{
Expand Down Expand Up @@ -369,7 +370,7 @@ private function styleTagAttributesString(object $item): string
* @param string $indent Indentation to use
* @return string
*/
public function itemToString(object $item, $indent)
public function itemToString(stdClass $item, $indent)
{
if (! isset($item->content) || ! is_string($item->content) || $item->content === '') {
return '';
Expand Down
1 change: 1 addition & 0 deletions src/Helper/HeadTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @method HeadTitle set(string $string)
* @method HeadTitle prepend(string $string)
* @method HeadTitle append(string $string)
* @final
*/
class HeadTitle extends AbstractStandalone
{
Expand Down
2 changes: 2 additions & 0 deletions src/Helper/InlineScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Helper for setting and retrieving script elements for inclusion in HTML body
* section
*
* @final
*/
class InlineScript extends HeadScript
{
Expand Down

0 comments on commit 4364ebd

Please sign in to comment.