Skip to content

Block, invalid passed variables #363

@Izolant

Description

@Izolant

Version: 3.1

Bug Description

Variables are passed invalid to block

Steps To Reproduce

The issue you can reproduce on: https://fiddle.nette.org/nette/#87a55c3e23

Expected Behavior

$name = hack instead error, or $value = hack (as hack is 2nd passed variable to block)

Possible Solution

Instead of rendering block with parameters in array => maybe could be used variadic arguments?

Ie, instead:
$this->renderBlock('BLOCK', [$name, 0 => 'hack'] + [], 'html') /* line 1 */;
$name = $ʟ_args[0] ?? $ʟ_args['name'] ?? null;
$value = $ʟ_args[1] ?? $ʟ_args['value'] ?? null;

use:
$this->renderBlock('BLOCK', $this->parameters($name, 01, 02), 'html') /* line 1 */;
$name = $ʟ_args[0] ?? null;
$value = $ʟ_args[1] ?? null;

public function parameters(...$allParams){
return $allParams;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions