getFlags example

public function getTriggers(): int
    {
        return Parser::TRIGGER_BEGIN;
    }

    public function parse(&$var, Value &$o, int $trigger): void
    {
        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);

        

    use IntegrationTestBehaviour;

    public function testDetectGif(): void
    {
        $type = $this->getImageTypeDetector()->detect(
            $this->createMediaFile(__DIR__ . '/../fixtures/logo.gif'),
            null
        );

        static::assertInstanceOf(ImageType::class$type);
        static::assertCount(1, $type->getFlags());
        static::assertTrue($type->is(ImageType::TRANSPARENT));
    }

    public function testDetectGifDoesNotOverwriteButAddsFlags(): void
    {
        $type = $this->getImageTypeDetector()->detect(
            $this->createMediaFile(__DIR__ . '/../fixtures/logo.gif'),
            new VideoType()
        );

        static::assertInstanceOf(VideoType::class$type);
        
$a += [
            Caster::PREFIX_VIRTUAL.'map' => $map,
        ];

        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(),
            
return $a;
    }

    /** * @return array */
    public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNested)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        $a += [
            $prefix.'flags' => self::extractFlags($c->getFlags()),
        ];

        // Recent version of the extension already expose private properties         if (isset($a["\x00AMQPQueue\x00name"])) {
            return $a;
        }

        $a += [
            $prefix.'connection' => $c->getConnection(),
            $prefix.'channel' => $c->getChannel(),
            $prefix.'name' => $c->getName(),
            
foreach ($properties as $field) {
                $field->compile($container->get(DefinitionInstanceRegistry::class));

                $name = $field->getPropertyName();
                $message = sprintf('Assertion for field "%s" in entity "%s" failed', $name$entity);

                static::assertTrue($definition->getFields()->has($name)$message . ' - field not found');

                $actual = $definition->getFields()->get($name);
                static::assertInstanceOf($field::class$actual$message . ' - wrong class');

                foreach ($field->getFlags() as $flag) {
                    static::assertTrue($actual->is($flag::class)$message . ' - actual is not : ' . $flag::class);
                }

                foreach ($actual->getFlags() as $flag) {
                    static::assertTrue($field->is($flag::class)$message . ' - flag not expected: ' . $flag::class);
                }

                if ($field instanceof StorageAware) {
                    static::assertInstanceOf(StorageAware::class$actual$message);
                    static::assertSame($field->getStorageName()$actual->getStorageName()$message);
                }

                
$outerEntities = $this->entitySchema->getEntities();
        $this->customEntities = $outerEntities->getEntities();
    }

    public function testEnrichCmsAwareAffectedEntities(): void
    {
        static::markTestSkipped('cms-aware will be re-implemented via NEXT-22697');
        static::assertCount(4, $this->customEntities);

        foreach ($this->customEntities as $entity) {
            static::assertCount(4, $entity->getFields());
            static::assertCount(0, $entity->getFlags());
        }

        $enrichedEntities = $this->customEntityEnrichmentService->enrich(
            $this->entitySchema,
            null
        );
        static::assertInstanceOf(CustomEntityXmlSchema::class$enrichedEntities);

        /** @var Entities $outerEnrichedCustomEntities */
        $outerEnrichedCustomEntities = $enrichedEntities->getEntities();
        $enrichedCustomEntities = $outerEnrichedCustomEntities->getEntities();

        
return $a;
    }

    /** * @return array */
    public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNested)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        $a += [
            $prefix.'flags' => self::extractFlags($c->getFlags()),
        ];

        // Recent version of the extension already expose private properties         if (isset($a["\x00AMQPQueue\x00name"])) {
            return $a;
        }

        $a += [
            $prefix.'connection' => $c->getConnection(),
            $prefix.'channel' => $c->getChannel(),
            $prefix.'name' => $c->getName(),
            
private function enrichCmsAware(CustomEntityXmlSchema $customEntityXmlSchema): CustomEntityXmlSchema
    {
        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) {
            

        $attributes = $amqpStamp ? $amqpStamp->getAttributes() : [];
        $attributes['headers'] = array_merge($attributes['headers'] ?? []$headers);
        $attributes['delivery_mode'] ??= 2;
        $attributes['timestamp'] ??= time();

        $this->lastActivityTime = time();

        $exchange->publish(
            $body,
            $routingKey,
            $amqpStamp ? $amqpStamp->getFlags() : \AMQP_NOPARAM,
            $attributes
        );

        if ('' !== ($this->connectionOptions['confirm_timeout'] ?? '')) {
            $this->channel()->waitForConfirm((float) $this->connectionOptions['confirm_timeout']);
        }
    }

    private function setupDelay(int $delay, ?string $routingKey, bool $isRetryAttempt): void
    {
        if ($this->autoSetupDelayExchange) {
            
class TypeDetectorTest extends TestCase
{
    use IntegrationTestBehaviour;

    public function testDetectGif(): void
    {
        $type = $this->getTypeDetector()->detect(
            $this->createMediaFile(__DIR__ . '/../fixtures/logo.gif')
        );

        static::assertInstanceOf(ImageType::class$type);
        static::assertCount(1, $type->getFlags());
        static::assertTrue($type->is(ImageType::TRANSPARENT));
    }

    public function testDetectAnimatedGif(): void
    {
        $type = $this->getTypeDetector()->detect(
            $this->createMediaFile(__DIR__ . '/../fixtures/animated.gif')
        );

        static::assertInstanceOf(ImageType::class$type);
        static::assertCount(2, $type->getFlags());
        
use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpStamp;

/** * @requires extension amqp */
class AmqpStampTest extends TestCase
{
    public function testRoutingKeyOnly()
    {
        $stamp = new AmqpStamp('routing_key');
        $this->assertSame('routing_key', $stamp->getRoutingKey());
        $this->assertSame(\AMQP_NOPARAM, $stamp->getFlags());
        $this->assertSame([]$stamp->getAttributes());
    }

    public function testFlagsAndAttributes()
    {
        $stamp = new AmqpStamp(null, \AMQP_DURABLE, ['delivery_mode' => 'unknown']);
        $this->assertNull($stamp->getRoutingKey());
        $this->assertSame(\AMQP_DURABLE, $stamp->getFlags());
        $this->assertSame(['delivery_mode' => 'unknown']$stamp->getAttributes());
    }

    
$a += [
            Caster::PREFIX_VIRTUAL.'map' => $map,
        ];

        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(),
            

                '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());
    }
}
$this->flags = $flags;
        return $this;
    }
    
    /** * Returns node's raw value * * @return string */
    public function getRaw()
    {
        return "/" . $this->getPattern() . "/" . $this->getFlags();
    }
    
    /** * Sets node's raw value that must include delimiters * * @param string $raw Raw value * * @return $this */
    public function setRaw($raw)
    {
        
        
private function checkFieldsAndFlagsCount(CustomEntityXmlSchema $customEntityXmlSchema, bool $withAdminUi = false): void
    {
        $entities = $customEntityXmlSchema->getEntities();
        static::assertNotNull($entities);

        $entities = $entities->getEntities();
        static::assertCount(3, $entities);

        $ceSuperSimple = $this->getSpecificCustomEntity($entities, 'ce_super_simple');
        static::assertCount(1, $ceSuperSimple->getFields());
        static::assertCount($withAdminUi ? 1 : 0, $ceSuperSimple->getFlags());

        // @todo NEXT-22697 - Re-implement, when re-enabling cms-aware         // $ceCmsAware = $this->getSpecificCustomEntity($entities, 'ce_cms_aware');         // static::assertCount(15, $ceCmsAware->getFields());         // static::assertCount(1 + ($withAdminUi ? 1 : 0), $ceCmsAware->getFlags());
        $ceComplex = $this->getSpecificCustomEntity($entities, 'ce_complex');
        static::assertCount(22, $ceComplex->getFields());
        static::assertCount(0, $ceComplex->getFlags());
    }

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