setFlags example

$queue = $this->createDelayQueue($delay$routingKey$isRetryAttempt);
        $queue->declareQueue(); // the delay queue always need to be declared because the name is dynamic and cannot be declared in advance         $queue->bind($this->connectionOptions['delay']['exchange_name']$this->getRoutingKeyForDelay($delay$routingKey$isRetryAttempt));
    }

    private function getDelayExchange(): \AMQPExchange
    {
        if (!isset($this->amqpDelayExchange)) {
            $this->amqpDelayExchange = $this->amqpFactory->createExchange($this->channel());
            $this->amqpDelayExchange->setName($this->connectionOptions['delay']['exchange_name']);
            $this->amqpDelayExchange->setType(\AMQP_EX_TYPE_DIRECT);
            $this->amqpDelayExchange->setFlags(\AMQP_DURABLE);
        }

        return $this->amqpDelayExchange;
    }

    /** * Creates a delay queue that will delay for a certain amount of time. * * This works by setting message TTL for the delay and pointing * the dead letter exchange to the original exchange. The result * is that after the TTL, the message is sent to the dead-letter-exchange, * which is the original exchange, resulting on it being put back into * the original queue. */


        return $a;
    }

    private static function castSplArray(\ArrayObject|\ArrayIterator $c, array $a, Stub $stub, bool $isNested): array
    {
        $prefix = Caster::PREFIX_VIRTUAL;
        $flags = $c->getFlags();

        if (!($flags & \ArrayObject::STD_PROP_LIST)) {
            $c->setFlags(\ArrayObject::STD_PROP_LIST);
            $a = Caster::castObject($c$c::classmethod_exists($c, '__debugInfo')$stub->class);
            $c->setFlags($flags);
        }

        unset($a["\0ArrayObject\0storage"]$a["\0ArrayIterator\0storage"]);

        $a += [
            $prefix.'storage' => $c->getArrayCopy(),
            $prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST),
            $prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS),
        ];
        

        if (!$var instanceof ArrayObject) {
            return;
        }

        $flags = $var->getFlags();

        if (ArrayObject::STD_PROP_LIST === $flags) {
            return;
        }

        $var->setFlags(ArrayObject::STD_PROP_LIST);

        $o = $this->parser->parse($var$o);

        $var->setFlags($flags);

        $this->parser->haltParse();
    }
}
foreach ($customEntityXmlSchema->getEntities()?->getEntities() ?? [] as $entity) {
            if ($entity->isCmsAware() !== true) {
                continue;
            }

            $fields = $entity->getFields();
            $fields = array_merge($fields, CmsAwareFields::getCmsAwareFields());
            $entity->setFields($fields);

            $flags = $entity->getFlags();
            $flags = [...$flags, ...['cms-aware' => ['name' => $entity->getName()]]];
            $entity->setFlags($flags);
        }

        return $customEntityXmlSchema;
    }

    private function enrichAdminUi(CustomEntityXmlSchema $customEntityXmlSchema, AdminUiXmlSchema $adminUiXmlSchema): CustomEntityXmlSchema
    {
        $adminUiEntitiesConfig = $adminUiXmlSchema->getAdminUi()?->getEntities();
        if ($adminUiEntitiesConfig === null) {
            return $customEntityXmlSchema;
        }

        

}

class DummyList extends \ArrayObject
{
    public $list;

    public function __construct(array $list)
    {
        $this->list = $list;

        $this->setFlags(\ArrayObject::STD_PROP_LIST);
    }

    public function count(): int
    {
        return \count($this->list);
    }

    public function getIterator(): \ArrayIterator
    {
        return new \ArrayIterator($this->list);
    }
}

            [
                'name' => 'field2',
            ],
        ];

        $entity->setFields($fields);
        static::assertEquals($fields$entity->getFields());

        $flags = [];

        $entity->setFlags($flags);
        static::assertEquals($flags$entity->getFlags());

        $entity->setCustomFieldsAware(true);
        static::assertTrue($entity->getCustomFieldsAware());

        $entity->setLabelProperty('name');
        static::assertEquals('name', $entity->getLabelProperty());
    }
}

    public function __construct(
        string $storageName,
        string $propertyName
    ) {
        $propertyMapping = [
            (new FloatField('netPrice', 'netPrice'))->addFlags(new Required()),
            (new FloatField('totalPrice', 'totalPrice'))->addFlags(new Required()),
            (new JsonField('calculatedTaxes', 'calculatedTaxes'))->addFlags(new Required()),
            (new JsonField('taxRules', 'taxRules'))->addFlags(new Required()),
            (new FloatField('positionPrice', 'positionPrice'))->addFlags(new Required()),
            (new FloatField('rawTotal', 'rawTotal'))->setFlags(new Required()),
            (new StringField('taxStatus', 'taxStatus'))->addFlags(new Required()),
        ];

        parent::__construct($storageName$propertyName$propertyMapping);
    }

    protected function getSerializerClass(): string
    {
        return CartPriceFieldSerializer::class;
    }
}
$this->validator
            ->expects(static::exactly(2))
            ->method('validate')
            ->with($data->getValue()static::callback(static function D$constraint): bool {
                return $constraint instanceof NotNull || ($constraint instanceof Type && $constraint->type === \DateInterval::class);
            }))
            ->willReturn(new ConstraintViolationList([new ConstraintViolation('error', 'error', [], '', 'key', 'value')]));

        static::expectException(WriteConstraintViolationException::class);

        $this->dateIntervalFieldSerializer->encode(
            (new DateIntervalField('name', 'name'))->setFlags(new Required()),
            $this->createStub(EntityExistence::class),
            $data,
            $this->createMock(WriteParameterBag::class)
        )->current();
    }

    public function testEncodeMethodWithStringWillReturnDateIntervalString(): void
    {
        $data = new KeyValuePair('key', 'P2Y5DT2S', false);

        $dateIntervalString = $this->dateIntervalFieldSerializer->encode(
            
$this->validator
            ->expects(static::exactly(2))
            ->method('validate')
            ->with($data->getValue()static::callback(static function D$constraint): bool {
                return $constraint instanceof NotNull || ($constraint instanceof Type && $constraint->type === CronExpression::class);
            }))
            ->willReturn(new ConstraintViolationList([new ConstraintViolation('error', 'error', [], '', 'key', 'value')]));

        static::expectException(WriteConstraintViolationException::class);

        $this->intervalFieldSerializer->encode(
            (new CronIntervalField('name', 'name'))->setFlags(new Required()),
            $this->createStub(EntityExistence::class),
            $data,
            $this->createMock(WriteParameterBag::class)
        )->current();
    }

    public function testEncodeMethodWithStringWillReturnCronIntervalString(): void
    {
        $data = new KeyValuePair('key', self::COMPLEX_CRON, false);

        $cronExpression = $this->intervalFieldSerializer->encode(
            


        return $a;
    }

    private static function castSplArray(\ArrayObject|\ArrayIterator $c, array $a, Stub $stub, bool $isNested): array
    {
        $prefix = Caster::PREFIX_VIRTUAL;
        $flags = $c->getFlags();

        if (!($flags & \ArrayObject::STD_PROP_LIST)) {
            $c->setFlags(\ArrayObject::STD_PROP_LIST);
            $a = Caster::castObject($c$c::classmethod_exists($c, '__debugInfo')$stub->class);
            $c->setFlags($flags);
        }

        unset($a["\0ArrayObject\0storage"]$a["\0ArrayIterator\0storage"]);

        $a += [
            $prefix.'storage' => $c->getArrayCopy(),
            $prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST),
            $prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS),
        ];
        

    public function setRaw($raw)
    {
        
        $parts = explode("/", substr($raw, 1));
        $flags = array_pop($parts);
        $this->setPattern(implode("/", $parts));
        $this->setFlags($flags);
        return $this;
    }
    
    /** * Returns node's value * * @return string */
    public function getValue()
    {
        return $this->getRaw();
    }


    /** @dataProvider getCastFileInfoTests */
    public function testCastFileInfo($file$dump)
    {
        $this->assertDumpMatchesFormat($dumpnew \SplFileInfo($file));
    }

    public function testCastFileObject()
    {
        $var = new \SplFileObject(__FILE__);
        $var->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY);
        $dump = <<<'EOTXT' SplFileObject { %Apath: "%sCaster" filename: "SplCasterTest.php" basename: "SplCasterTest.php" pathname: "%sSplCasterTest.php" extension: "php" realPath: "%sSplCasterTest.php" aTime: %s-%s-%d %d:%d:%d mTime: %s-%s-%d %d:%d:%d cTime: %s-%s-%d %d:%d:%d inode: %i size: %d perms: 0%d owner: %d group: %d type: "file" writable: true readable: true executable: false file: true dir: false link: false %AcsvControl: array:%d [ 0 => "," 1 => """ %A] flags: DROP_NEW_LINE|SKIP_EMPTY maxLineLen: 0 fstat: array:26 [ "dev" => %d "ino" => %i "nlink" => %d "rdev" => 0 "blksize" => %i "blocks" => %i …20 ] eof: false key: 0 }
protected function loadResource(string $resource): array
    {
        $messages = [];

        try {
            $file = new \SplFileObject($resource, 'rb');
        } catch (\RuntimeException $e) {
            throw new NotFoundResourceException(sprintf('Error opening file "%s".', $resource), 0, $e);
        }

        $file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY);
        $file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);

        foreach ($file as $data) {
            if (false === $data) {
                continue;
            }

            if (!str_starts_with($data[0], '#') && isset($data[1]) && 2 === \count($data)) {
                $messages[$data[0]] = $data[1];
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.