Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[PropertyAccess] Add missing arguments to PropertyAccess::createPropertyAccessor() #18977

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add the second $enableMagicCall missing argument
  • Loading branch information
chalasr committed Jun 9, 2016
commit 5e61d25a3f0cdeefabbe123a5f6704ffcb331a26
10 changes: 7 additions & 3 deletions src/Symfony/Component/PropertyAccess/PropertyAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ final class PropertyAccess
*
* @return PropertyAccessor The new property accessor
*/
public static function createPropertyAccessor($throwExceptionOnInvalidIndex = false)
public static function createPropertyAccessor($throwExceptionOnInvalidIndex = false, $magicCall = false)
{
return self::createPropertyAccessorBuilder($throwExceptionOnInvalidIndex)->getPropertyAccessor();
return self::createPropertyAccessorBuilder($throwExceptionOnInvalidIndex, $magicCall)->getPropertyAccessor();
}

/**
Expand All @@ -37,14 +37,18 @@ public static function createPropertyAccessor($throwExceptionOnInvalidIndex = fa
*
* @return PropertyAccessorBuilder The new property accessor builder
*/
public static function createPropertyAccessorBuilder($enableExceptionOnInvalidIndex = false)
public static function createPropertyAccessorBuilder($enableExceptionOnInvalidIndex = false, $enableMagicCall = false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with this change. A builder is exactly there to dynamically set the behavior and not have a huge list of arguments. If there are new flags for the property accessor, you don't want to add every new field as argument for the builder. Then there is no point of a builder.

{
$propertyAccessorBuilder = new PropertyAccessorBuilder();

if ($enableExceptionOnInvalidIndex) {
$propertyAccessorBuilder->enableExceptionOnInvalidIndex();
}

if ($enableMagicCall) {
$propertyAccessorBuilder->enableMagicCall();
}

return $propertyAccessorBuilder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ public function testCreatePropertyAccessorWithExceptionOnInvalidIndex()
{
$this->assertInstanceOf(PropertyAccessor::class, PropertyAccess::createPropertyAccessor(true));
}

public function testCreatePropertyAccessorWithMagicCallEnabled()
{
$this->assertInstanceOf(PropertyAccessor::class, PropertyAccess::createPropertyAccessor(false, true));
}
}