Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare (strict_types=1); namespace Rector\Symfony\NodeFactory\Annotations; use Re..

Decoded Output download

<?php

declare (strict_types=1);
namespace Rector\Symfony\NodeFactory\Annotations;

use Rector\BetterPhpDocParser\PhpDoc\StringNode;
use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser;
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode;
final class StringValueQuoteWrapper
{
    /**
     * @readonly
     * @var \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser
     */
    private $arrayParser;
    public function __construct(ArrayParser $arrayParser)
    {
        $this->arrayParser = $arrayParser;
    }
    /**
     * @return mixed|CurlyListNode|StringNode
     * @param mixed $value
     */
    public function wrap($value, ?string $key)
    {
        if (\is_string($value)) {
            return new StringNode($value);
        }
        if (\is_array($value)) {
            return $this->wrapArray($value, $key);
        }
        return $value;
    }
    /**
     * @param mixed[] $value
     */
    private function wrapArray(array $value, ?string $key) : CurlyListNode
    {
        // include quotes in groups
        if (\in_array($key, ['groups', 'schemes', 'choices'], \true)) {
            foreach ($value as $nestedKey => $nestedValue) {
                if (\is_numeric($nestedValue)) {
                    continue;
                }
                $value[$nestedKey] = new StringNode($nestedValue);
            }
        }
        $arrayItemNodes = $this->arrayParser->createArrayFromValues($value);
        return new CurlyListNode($arrayItemNodes);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare (strict_types=1);
namespace Rector\Symfony\NodeFactory\Annotations;

use Rector\BetterPhpDocParser\PhpDoc\StringNode;
use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser;
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode;
final class StringValueQuoteWrapper
{
    /**
     * @readonly
     * @var \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser
     */
    private $arrayParser;
    public function __construct(ArrayParser $arrayParser)
    {
        $this->arrayParser = $arrayParser;
    }
    /**
     * @return mixed|CurlyListNode|StringNode
     * @param mixed $value
     */
    public function wrap($value, ?string $key)
    {
        if (\is_string($value)) {
            return new StringNode($value);
        }
        if (\is_array($value)) {
            return $this->wrapArray($value, $key);
        }
        return $value;
    }
    /**
     * @param mixed[] $value
     */
    private function wrapArray(array $value, ?string $key) : CurlyListNode
    {
        // include quotes in groups
        if (\in_array($key, ['groups', 'schemes', 'choices'], \true)) {
            foreach ($value as $nestedKey => $nestedValue) {
                if (\is_numeric($nestedValue)) {
                    continue;
                }
                $value[$nestedKey] = new StringNode($nestedValue);
            }
        }
        $arrayItemNodes = $this->arrayParser->createArrayFromValues($value);
        return new CurlyListNode($arrayItemNodes);
    }
}

Function Calls

None

Variables

None

Stats

MD5 64f7c5d87a7d01da99a4dac6859c7ad2
Eval Count 0
Decode Time 95 ms