From cab6fd531e3dc3a6072b0a212b38c7c756e88bc0 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Thu, 10 Dec 2015 09:14:03 +0100 Subject: [PATCH 1/6] [Security] backported phpdoc from Guard component. --- .../EntryPoint/AuthenticationEntryPointInterface.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php b/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php index 0d7595d407..c8e43e535f 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php @@ -24,7 +24,17 @@ use Symfony\Component\HttpFoundation\Response; interface AuthenticationEntryPointInterface { /** - * Starts the authentication scheme. + * Returns a response that directs the user to authenticate. + * + * This is called when an anonymous request accesses a resource that + * requires authentication. The job of this method is to return some + * response that "helps" the user start into the authentication process. + * + * Examples: + * A) For a form login, you might redirect to the login page + * return new RedirectResponse('/login'); + * B) For an API token authentication system, you return a 401 response + * return new Response('Auth header required', 401); * * @param Request $request The request that resulted in an AuthenticationException * @param AuthenticationException $authException The exception that started the authentication process From 99535506e84ae56ae690d6a8b59472b3a6adb550 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 10 Dec 2015 15:12:08 +0100 Subject: [PATCH 2/6] Clean useless deprecation silencing --- src/Symfony/Bundle/FrameworkBundle/Client.php | 2 +- .../Tests/TokenParser/LegacyRenderTokenParserTest.php | 5 ----- src/Symfony/Component/Form/Tests/AbstractLayoutTest.php | 4 ---- .../Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php | 1 - .../EventListener/LegacyBindRequestListenerTest.php | 2 -- src/Symfony/Component/HttpKernel/Client.php | 2 +- src/Symfony/Component/Locale/Tests/LocaleTest.php | 2 -- src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php | 5 ----- src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php | 2 -- src/Symfony/Component/Routing/Tests/RouteTest.php | 2 -- 10 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index 43b51abec9..4f569131ad 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -165,7 +165,7 @@ class Client extends BaseClient $code = <<iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - } - /** * @dataProvider getTestsForRender */ diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index ea56310dd5..51800331a5 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -127,8 +127,6 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg */ public function testLegacyEnctype() { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $form = $this->factory->createNamedBuilder('name', 'form') ->add('file', 'file') ->getForm(); @@ -141,8 +139,6 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg */ public function testLegacyNoEnctype() { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $form = $this->factory->createNamedBuilder('name', 'form') ->add('text', 'text') ->getForm(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php index 410ce46889..4f0c614658 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php @@ -25,7 +25,6 @@ class DefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase { ini_set('session.save_handler', 'files'); ini_set('session.save_path', sys_get_temp_dir()); - ini_set('error_reporting', -1 & ~E_USER_DEPRECATED); } protected function setUp() diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php index 521f7b3c17..37765991cc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php @@ -37,8 +37,6 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $path = tempnam(sys_get_temp_dir(), 'sf2'); touch($path); diff --git a/src/Symfony/Component/HttpKernel/Client.php b/src/Symfony/Component/HttpKernel/Client.php index a65b8318a9..5bf9eb517c 100644 --- a/src/Symfony/Component/HttpKernel/Client.php +++ b/src/Symfony/Component/HttpKernel/Client.php @@ -105,7 +105,7 @@ class Client extends BaseClient $code = <<iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - \Locale::setDefault('en'); } diff --git a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php index a2cb3b5b31..c8f38be011 100644 --- a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php +++ b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php @@ -18,11 +18,6 @@ use Symfony\Component\Locale\Stub\StubLocale; */ class StubLocaleTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - } - public function testGetCurrenciesData() { $currencies = StubLocale::getCurrenciesData('en'); diff --git a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php index 00219f08d1..c363df5e49 100644 --- a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php @@ -51,8 +51,6 @@ class RouteTest extends \PHPUnit_Framework_TestCase */ public function testLegacyGetPattern() { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $route = new Route(array('value' => '/Blog')); $this->assertEquals($route->getPattern(), '/Blog'); } diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index fdb8bbfbd8..a143b356b6 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -206,8 +206,6 @@ class RouteTest extends \PHPUnit_Framework_TestCase */ public function testLegacyPattern() { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $route = new Route('/{foo}'); $this->assertEquals('/{foo}', $route->getPattern()); From 1eaef57c13f337ba57b43a6cbd6f60d420ac214a Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Fri, 11 Dec 2015 18:53:49 +0100 Subject: [PATCH 3/6] [2.7][Console] Table: fix some PhpDoc --- src/Symfony/Component/Console/Helper/Table.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 6f5fbd047c..9426f695bb 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -332,7 +332,7 @@ class Table $columns[] = $this->getNumberOfColumns($row); } - return $this->numberOfColumns = max($columns); + $this->numberOfColumns = max($columns); } private function buildTableRows($rows) @@ -487,7 +487,7 @@ class Table * * @param array $row * - * @return array() + * @return array */ private function getRowColumns($row) { @@ -529,8 +529,6 @@ class Table /** * Gets column width. * - * @param int $column - * * @return int */ private function getColumnSeparatorWidth() From 5dc9bd9fe31987bc8eeea9d41d33b62c6c1c40cf Mon Sep 17 00:00:00 2001 From: Krzysztof Piasecki Date: Mon, 14 Dec 2015 18:44:11 +0100 Subject: [PATCH 4/6] Remove unnecessary test Question interface guarantees, that $validator is callable or null --- src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php index 77130f9776..dc2141e99f 100644 --- a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php @@ -32,7 +32,7 @@ class SymfonyQuestionHelper extends QuestionHelper { $validator = $question->getValidator(); $question->setValidator(function ($value) use ($validator) { - if (null !== $validator && is_callable($validator)) { + if (null !== $validator) { $value = $validator($value); } From 6c9bb86b47792a8a87cf77a14159d16a1ad29e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=83=C2=A9vin=20Dunglas?= Date: Sat, 5 Dec 2015 00:04:49 +0100 Subject: [PATCH 5/6] [PropertyAccess] minor: constants as internal and removed unused var --- .../PropertyAccess/PropertyAccessor.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index a55ccf3399..5270df26f3 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -21,18 +21,69 @@ use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException; */ class PropertyAccessor implements PropertyAccessorInterface { + /** + * @internal + */ const VALUE = 0; + + /** + * @internal + */ const IS_REF = 1; + + /** + * @internal + */ const ACCESS_HAS_PROPERTY = 0; + + /** + * @internal + */ const ACCESS_TYPE = 1; + + /** + * @internal + */ const ACCESS_NAME = 2; + + /** + * @internal + */ const ACCESS_REF = 3; + + /** + * @internal + */ const ACCESS_ADDER = 4; + + /** + * @internal + */ const ACCESS_REMOVER = 5; + + /** + * @internal + */ const ACCESS_TYPE_METHOD = 0; + + /** + * @internal + */ const ACCESS_TYPE_PROPERTY = 1; + + /** + * @internal + */ const ACCESS_TYPE_MAGIC = 2; + + /** + * @internal + */ const ACCESS_TYPE_ADDER_AND_REMOVER = 3; + + /** + * @internal + */ const ACCESS_TYPE_NOT_FOUND = 4; private $magicCall; From 457b3f00472c50d7e6000f480bbd84420303f775 Mon Sep 17 00:00:00 2001 From: Ilya Antipenko Date: Thu, 26 Nov 2015 23:41:57 +0200 Subject: [PATCH 6/6] [PropertyAccessor] A little refactor - Remove obsolete code - Remove excessive actions - Fix phpdoc & comments --- .../PropertyAccess/PropertyAccessor.php | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 008f55001f..a328f7e931 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -62,6 +62,9 @@ class PropertyAccessor implements PropertyAccessorInterface /** * Should not be used by application code. Use * {@link PropertyAccess::createPropertyAccessor()} instead. + * + * @param bool $magicCall + * @param bool $throwExceptionOnInvalidIndex */ public function __construct($magicCall = false, $throwExceptionOnInvalidIndex = false) { @@ -365,7 +368,7 @@ class PropertyAccessor implements PropertyAccessorInterface } } elseif (!$access[self::ACCESS_HAS_PROPERTY] && property_exists($object, $property)) { // Needed to support \stdClass instances. We need to explicitly - // exclude $classHasProperty, otherwise if in the previous clause + // exclude $access[self::ACCESS_HAS_PROPERTY], otherwise if // a *protected* property was found on the class, property_exists() // returns true, consequently the following line will result in a // fatal error. @@ -411,7 +414,6 @@ class PropertyAccessor implements PropertyAccessorInterface $getsetter = lcfirst($camelProp); // jQuery style, e.g. read: last(), write: last($item) $isser = 'is'.$camelProp; $hasser = 'has'.$camelProp; - $classHasProperty = $reflClass->hasProperty($property); if ($reflClass->hasMethod($getter) && $reflClass->getMethod($getter)->isPublic()) { $access[self::ACCESS_TYPE] = self::ACCESS_TYPE_METHOD; @@ -429,13 +431,10 @@ class PropertyAccessor implements PropertyAccessorInterface $access[self::ACCESS_TYPE] = self::ACCESS_TYPE_PROPERTY; $access[self::ACCESS_NAME] = $property; $access[self::ACCESS_REF] = false; - } elseif ($classHasProperty && $reflClass->getProperty($property)->isPublic()) { + } elseif ($access[self::ACCESS_HAS_PROPERTY] && $reflClass->getProperty($property)->isPublic()) { $access[self::ACCESS_TYPE] = self::ACCESS_TYPE_PROPERTY; $access[self::ACCESS_NAME] = $property; $access[self::ACCESS_REF] = true; - - $result[self::VALUE] = &$object->$property; - $result[self::IS_REF] = true; } elseif ($this->magicCall && $reflClass->hasMethod('__call') && $reflClass->getMethod('__call')->isPublic()) { // we call the getter and hope the __call do the job $access[self::ACCESS_TYPE] = self::ACCESS_TYPE_MAGIC; @@ -506,7 +505,7 @@ class PropertyAccessor implements PropertyAccessorInterface $this->writeCollection($object, $property, $value, $access[self::ACCESS_ADDER], $access[self::ACCESS_REMOVER]); } elseif (!$access[self::ACCESS_HAS_PROPERTY] && property_exists($object, $property)) { // Needed to support \stdClass instances. We need to explicitly - // exclude $classHasProperty, otherwise if in the previous clause + // exclude $access[self::ACCESS_HAS_PROPERTY], otherwise if // a *protected* property was found on the class, property_exists() // returns true, consequently the following line will result in a // fatal error. @@ -579,7 +578,6 @@ class PropertyAccessor implements PropertyAccessorInterface private function getWriteAccessInfo($object, $property, $value) { $key = get_class($object).'::'.$property; - $guessedAdders = ''; if (isset($this->writePropertyCache[$key])) { $access = $this->writePropertyCache[$key]; @@ -594,13 +592,7 @@ class PropertyAccessor implements PropertyAccessorInterface if (is_array($value) || $value instanceof \Traversable) { $methods = $this->findAdderAndRemover($reflClass, $singulars); - if (null === $methods) { - // It is sufficient to include only the adders in the error - // message. If the user implements the adder but not the remover, - // an exception will be thrown in findAdderAndRemover() that - // the remover has to be implemented as well. - $guessedAdders = '"add'.implode('()", "add', $singulars).'()", '; - } else { + if (null !== $methods) { $access[self::ACCESS_TYPE] = self::ACCESS_TYPE_ADDER_AND_REMOVER; $access[self::ACCESS_ADDER] = $methods[0]; $access[self::ACCESS_REMOVER] = $methods[1]; @@ -608,11 +600,9 @@ class PropertyAccessor implements PropertyAccessorInterface } if (!isset($access[self::ACCESS_TYPE])) { - $setter = 'set'.$this->camelize($property); + $setter = 'set'.$camelized; $getsetter = lcfirst($camelized); // jQuery style, e.g. read: last(), write: last($item) - $classHasProperty = $reflClass->hasProperty($property); - if ($this->isMethodAccessible($reflClass, $setter, 1)) { $access[self::ACCESS_TYPE] = self::ACCESS_TYPE_METHOD; $access[self::ACCESS_NAME] = $setter; @@ -622,7 +612,7 @@ class PropertyAccessor implements PropertyAccessorInterface } elseif ($this->isMethodAccessible($reflClass, '__set', 2)) { $access[self::ACCESS_TYPE] = self::ACCESS_TYPE_PROPERTY; $access[self::ACCESS_NAME] = $property; - } elseif ($classHasProperty && $reflClass->getProperty($property)->isPublic()) { + } elseif ($access[self::ACCESS_HAS_PROPERTY] && $reflClass->getProperty($property)->isPublic()) { $access[self::ACCESS_TYPE] = self::ACCESS_TYPE_PROPERTY; $access[self::ACCESS_NAME] = $property; } elseif ($this->magicCall && $this->isMethodAccessible($reflClass, '__call', 2)) {