Skip to content

Cause error: Error: Cannot access trait constant self::CONTROL_FLASH_MESSAGE directly #315

@zeleznypa

Description

@zeleznypa

Last change on this line cause an error.

? is_object($tmp = $param->getDefaultValue()) ? ['object' => $tmp::class] : ['value' => $tmp]

Previous code works well

? is_object($tmp = Reflection::getParameterDefaultValue($param)) ? ['object' => $tmp::class] : ['value' => $tmp]

When I have a Presenter that use trait that contains the following code:

<?php

declare(strict_types=1);

namespace Interitty\FlashMessageControl;

use Nette\ComponentModel\IComponent as ComponentInterface;

use function assert;

trait FlashMessageControlHelperTrait
{
    /** All available control name constants */
    public const CONTROL_FLASH_MESSAGE = 'flashMessage';

    /**
     * Componentby name getter
     *
     * @param bool $throw Throw exception if component doesn't exist?
     * @return ComponentInterface|null
     */
    abstract public function getComponent(string $name, bool $throw = true): ?ComponentInterface;

    /**
     * FlashMessage control getter
     *
     * @param string $name [OPTIONAL]
     * @return FlashMessageControl
     */
    public function getComponentFlashMessage(string $name = self::CONTROL_FLASH_MESSAGE): FlashMessageControl
    {
        $control = $this->getComponent($name);
        assert($control instanceof FlashMessageControl);
        return $control;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions