Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection][3.3] Warning: stripos() expects parameter 1 to be string, array given  #25245

Closed
@Phantas0s

Description

@Phantas0s
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3

I have this bug which is related (I think) to some modification you did in the ContainerBuilder.

Warning: stripos() expects parameter 1 to be string, array given 
in /var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php on line 1376

This is due to some environment variables I have which is an array. In the ContainerBuilder:

    public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs = null)
    {
        if (null === $format) {
            $format = '%%env(%s)%%';
        }

        if (is_array($value)) {
            $result = array();
            foreach ($value as $k => $v) {
                $result[$this->resolveEnvPlaceholders($k, $format, $usedEnvs)] = $this->resolveEnvPlaceholders($v, $format, $usedEnvs);
            }

            return $result;
        }

        if (!is_string($value)) {
            return $value;
        }

        $bag = $this->getParameterBag();
        if (true === $format) {
            $value = $bag->resolveValue($value);
        }

I think you need to put this condition

        if (true === $format) {
            $value = $bag->resolveValue($value);
        }

before this conditional:

    if (is_array($value)) {
            $result = array();
            foreach ($value as $k => $v) {
                $result[$this->resolveEnvPlaceholders($k, $format, $usedEnvs)] = $this->resolveEnvPlaceholders($v, $format, $usedEnvs);
            }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions