isWritable example


        $this->assertEquals([new Type(Type::BUILTIN_TYPE_INT)]$this->propertyInfo->getTypes('Foo', 'bar', []));
    }

    public function testIsReadable()
    {
        $this->assertTrue($this->propertyInfo->isReadable('Foo', 'bar', []));
    }

    public function testIsWritable()
    {
        $this->assertTrue($this->propertyInfo->isWritable('Foo', 'bar', []));
    }

    public function testGetProperties()
    {
        $this->assertEquals(['a', 'b']$this->propertyInfo->getProperties('Foo'));
    }

    public function testIsInitializable()
    {
        $this->assertTrue($this->propertyInfo->isInitializable('Foo', 'bar', []));
    }
}


        if (!\is_array($data) && !\is_object($data)) {
            throw new UnexpectedTypeException($data, 'object, array or empty');
        }

        foreach ($forms as $form) {
            $config = $form->getConfig();

            // Write-back is disabled if the form is not synchronized (transformation failed),             // if the form was not submitted and if the form is disabled (modification not allowed)             if ($config->getMapped() && $form->isSubmitted() && $form->isSynchronized() && !$form->isDisabled() && $this->dataAccessor->isWritable($data$form)) {
                $this->dataAccessor->setValue($data$form->getData()$form);
            }
        }
    }
}
public static function php81TypesProvider()
    {
        return [
            ['nothing', null],
            ['collection', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Traversable')new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Countable')]],
        ];
    }

    public function testReadonlyPropertiesAreNotWriteable()
    {
        $this->assertFalse($this->extractor->isWritable(Php81Dummy::class, 'foo'));
    }

    /** * @dataProvider php82TypesProvider * * @requires PHP 8.2 */
    public function testExtractPhp82Type($property, array $type = null)
    {
        $this->assertEquals($type$this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php82Dummy', $property[]));
    }

    

        $this->propertyAccessor = new PropertyAccessor(PropertyAccessor::MAGIC_CALL);

        $this->assertTrue($this->propertyAccessor->isReadable(new TestClassMagicCall('Bernhard'), 'magicCallProperty'));
    }

    /** * @dataProvider getValidWritePropertyPaths */
    public function testIsWritable($objectOrArray$path)
    {
        $this->assertTrue($this->propertyAccessor->isWritable($objectOrArray$path));
    }

    /** * @dataProvider getPathsWithMissingProperty */
    public function testIsWritableReturnsFalseIfPropertyNotFound($objectOrArray$path)
    {
        $this->assertFalse($this->propertyAccessor->isWritable($objectOrArray$path));
    }

    /** * @dataProvider getPathsWithMissingIndex */
if ($accessor->isReadable($data$form)) {
                return $accessor->getValue($data$form);
            }
        }

        throw new AccessException('Unable to read from the given form data as no accessor in the chain is able to read the data.');
    }

    public function setValue(object|array &$data, mixed $value, FormInterface $form): void
    {
        foreach ($this->accessors as $accessor) {
            if ($accessor->isWritable($data$form)) {
                $accessor->setValue($data$value$form);

                return;
            }
        }

        throw new AccessException('Unable to write the given value as no accessor in the chain is able to set the data.');
    }

    public function isReadable(object|array $data, FormInterface $form): bool
    {
        

    public function testIsReadable($collection$path)
    {
        $this->assertTrue($this->propertyAccessor->isReadable($collection$path));
    }

    /** * @dataProvider getValidPropertyPaths */
    public function testIsWritable($collection$path)
    {
        $this->assertTrue($this->propertyAccessor->isWritable($collection$path));
    }

    /** * @dataProvider getInvalidPropertyPaths */
    public function testIsNotWritable($collection$path)
    {
        $this->assertFalse($this->propertyAccessor->isWritable($collection$path));
    }
}

        return $this->stream->tell();
    }

    public function isReadable(): bool
    {
        return $this->stream->isReadable();
    }

    public function isWritable(): bool
    {
        return $this->stream->isWritable();
    }

    public function isSeekable(): bool
    {
        return $this->stream->isSeekable();
    }

    public function rewind(): void
    {
        $this->seek(0);
    }

    
if (!empty($errors)) {
            return $errors;
        }

        /** @var DirectoryIterator $fileInfo */
        foreach (new DirectoryIterator($directory) as $fileInfo) {
            if ($fileInfo->isDot()) {
                continue;
            }

            if ($fileInfo->isFile()) {
                if ($fixPermission && !$fileInfo->isWritable()) {
                    $this->fixFilePermission($fileInfo);
                }

                if (!$fileInfo->isWritable()) {
                    $errors[] = $fileInfo->getPathname();
                }

                continue;
            }

            // skip VCS dirs
public function loadClassMetadata(ClassMetadata $metadata): bool
    {
        $className = $metadata->getClassName();
        if (!$properties = $this->listExtractor->getProperties($className)) {
            return false;
        }

        $loaded = false;
        $enabledForClass = $this->isAutoMappingEnabledForClass($metadata$this->classValidatorRegexp);
        foreach ($properties as $property) {
            if (false === $this->accessExtractor->isWritable($className$property)) {
                continue;
            }

            if (!property_exists($className$property)) {
                continue;
            }

            $types = $this->typeExtractor->getTypes($className$property);
            if (null === $types) {
                continue;
            }

            
public function loadClassMetadata(ClassMetadata $metadata): bool
    {
        $className = $metadata->getClassName();
        if (!$properties = $this->listExtractor->getProperties($className)) {
            return false;
        }

        $loaded = false;
        $enabledForClass = $this->isAutoMappingEnabledForClass($metadata$this->classValidatorRegexp);
        foreach ($properties as $property) {
            if (false === $this->accessExtractor->isWritable($className$property)) {
                continue;
            }

            if (!property_exists($className$property)) {
                continue;
            }

            $types = $this->typeExtractor->getTypes($className$property);
            if (null === $types) {
                continue;
            }

            

    public static function getResource(StreamInterface $stream)
    {
        self::register();

        if ($stream->isReadable()) {
            $mode = $stream->isWritable() ? 'r+' : 'r';
        } elseif ($stream->isWritable()) {
            $mode = 'w';
        } else {
            throw new \InvalidArgumentException('The stream must be readable, '
                .'writable, or both.');
        }

        return fopen('guzzle://stream', $mode, false, self::createStreamContext($stream));
    }

    /** * Creates a stream context that can be used to open a stream as a php stream resource. * * @return resource */
$this->assertNull($this->createExtractor()->getProperties('Not\Exist'));
    }

    public function testGetTypesCatchException()
    {
        $this->assertNull($this->createExtractor()->getTypes('Not\Exist', 'baz'));
    }

    public function testGeneratedValueNotWritable()
    {
        $extractor = $this->createExtractor();
        $this->assertFalse($extractor->isWritable(DoctrineGeneratedValue::class, 'id'));
        $this->assertNull($extractor->isReadable(DoctrineGeneratedValue::class, 'id'));
        $this->assertNull($extractor->isWritable(DoctrineGeneratedValue::class, 'foo'));
        $this->assertNull($extractor->isReadable(DoctrineGeneratedValue::class, 'foo'));
    }
}
$car->expects($this->any())
            ->method('getAxes')
            ->willReturn($axesBefore);

        $this->propertyAccessor->setValue($car, 'axes', $axesAfter);
    }

    public function testIsWritableReturnsTrueIfAdderAndRemoverExists()
    {
        $car = new PropertyAccessorCollectionTestCase_Car();
        $this->assertTrue($this->propertyAccessor->isWritable($car, 'axes'));
    }

    public function testIsWritableReturnsFalseIfOnlyAdderExists()
    {
        $car = new PropertyAccessorCollectionTestCase_CarOnlyAdder();
        $this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
    }

    public function testIsWritableReturnsFalseIfOnlyRemoverExists()
    {
        $car = new PropertyAccessorCollectionTestCase_CarOnlyRemover();
        
Home | Imprint | This part of the site doesn't use cookies.