Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.3.x' into 1.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Mar 16, 2024
2 parents c9f5ceb + a32bc86 commit 8148308
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 0 deletions.
6 changes: 6 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ parameters:
- stubs/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.stub
- stubs/Symfony/Component/OptionsResolver/Options.stub
- stubs/Symfony/Component/Process/Process.stub
- stubs/Symfony/Component/PropertyAccess/Exception/AccessException.stub
- stubs/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.stub
- stubs/Symfony/Component/PropertyAccess/Exception/InvalidArgumentException.stub
- stubs/Symfony/Component/PropertyAccess/Exception/RuntimeException.stub
- stubs/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.stub
- stubs/Symfony/Component/PropertyAccess/PropertyAccessorInterface.stub
- stubs/Symfony/Component/PropertyAccess/PropertyPathInterface.stub
- stubs/Symfony/Component/Security/Acl/Model/AclInterface.stub
- stubs/Symfony/Component/Security/Acl/Model/EntryInterface.stub
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\PropertyAccess\Exception;

class AccessException extends RuntimeException
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\PropertyAccess\Exception;

interface ExceptionInterface extends \Throwable
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\PropertyAccess\Exception;

class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\PropertyAccess\Exception;

class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\PropertyAccess\Exception;

class UnexpectedTypeException extends RuntimeException
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Symfony\Component\PropertyAccess;

interface PropertyAccessorInterface
{

/**
* @phpstan-template T of object|array<mixed>
* @phpstan-param T &$objectOrArray
* @phpstan-param-out ($objectOrArray is object ? T : array<mixed>) $objectOrArray
* @phpstan-param string|PropertyPathInterface $propertyPath
* @phpstan-param mixed $value
*
* @return void
*
* @throws Exception\InvalidArgumentException If the property path is invalid
* @throws Exception\AccessException If a property/index does not exist or is not public
* @throws Exception\UnexpectedTypeException If a value within the path is neither object nor array
*/
public function setValue(&$objectOrArray, $propertyPath, $value);

}
1 change: 1 addition & 0 deletions tests/Type/Symfony/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleOptionCommand.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleOptionLazyCommand.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/kernel_interface.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/property_accessor.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/request_get_content.php');

$ref = new ReflectionMethod(Request::class, 'getSession');
Expand Down
13 changes: 13 additions & 0 deletions tests/Type/Symfony/data/property_accessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types = 1);

use function PHPStan\Testing\assertType;

$propertyAccessor = new \Symfony\Component\PropertyAccess\PropertyAccessor();

$array = [1 => 'ea'];
$propertyAccessor->setValue($array, 'foo', 'bar');
assertType('array', $array);

$object = new \stdClass();
$propertyAccessor->setValue($object, 'foo', 'bar');
assertType('stdClass', $object);

0 comments on commit 8148308

Please sign in to comment.