-
Notifications
You must be signed in to change notification settings - Fork 93
Add param out for propertyAccessor #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi, just for my understanding - this could be simply I had a local stub with something like that and got an error when updating because of this PR -> could remove my local stub -> thx! :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
doesn't give the same beahvior It fails
You'll get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah OK, makes sense. Thx! |
||
* @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); | ||
|
||
} |
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For conditional phpstan-param-out