From 05681ecf872b044161841b703d06ea8cb4706c01 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 9 Nov 2017 11:03:38 +0100 Subject: [PATCH] Remove some unneeded checks/tests --- .../BaseDateTimeTransformer.php | 10 ------ .../DateTimeToArrayTransformer.php | 3 -- .../DateTimeToStringTransformer.php | 3 -- ...teTimeToLocalizedStringTransformerTest.php | 16 ---------- .../Tests/Fixtures/ReturnTyped.php | 31 ------------------- .../Fixtures/TestClassTypeErrorInsideCall.php | 28 ----------------- .../Tests/PropertyAccessorTest.php | 22 ------------- .../Token/RememberMeTokenTest.php | 12 ------- .../Stopwatch/Tests/StopwatchEventTest.php | 8 ----- 9 files changed, 133 deletions(-) delete mode 100644 src/Symfony/Component/PropertyAccess/Tests/Fixtures/ReturnTyped.php delete mode 100644 src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassTypeErrorInsideCall.php diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php index a442742fff868..7652621b65d5d 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php @@ -13,7 +13,6 @@ use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; abstract class BaseDateTimeTransformer implements DataTransformerInterface { @@ -33,19 +32,10 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface * @param string $inputTimezone The name of the input timezone * @param string $outputTimezone The name of the output timezone * - * @throws UnexpectedTypeException if a timezone is not a string * @throws InvalidArgumentException if a timezone is not valid */ public function __construct(string $inputTimezone = null, string $outputTimezone = null) { - if (null !== $inputTimezone && !is_string($inputTimezone)) { - throw new UnexpectedTypeException($inputTimezone, 'string'); - } - - if (null !== $outputTimezone && !is_string($outputTimezone)) { - throw new UnexpectedTypeException($outputTimezone, 'string'); - } - $this->inputTimezone = $inputTimezone ?: date_default_timezone_get(); $this->outputTimezone = $outputTimezone ?: date_default_timezone_get(); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php index cacedf83c3dae..8edc501fca277 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * Transforms between a normalized time and a localized time string/array. @@ -31,8 +30,6 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer * @param string $outputTimezone The output timezone * @param array $fields The date fields * @param bool $pad Whether to use padding - * - * @throws UnexpectedTypeException if a timezone is not a string */ public function __construct(string $inputTimezone = null, string $outputTimezone = null, array $fields = null, bool $pad = false) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index a30fa6728350b..c93d2c995d965 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * Transforms between a date string and a DateTime object. @@ -48,8 +47,6 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer * @param string $inputTimezone The name of the input timezone * @param string $outputTimezone The name of the output timezone * @param string $format The date format - * - * @throws UnexpectedTypeException if a timezone is not a string */ public function __construct(string $inputTimezone = null, string $outputTimezone = null, string $format = 'Y-m-d H:i:s') { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index 47f831b537cb9..e13d43b475deb 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -306,22 +306,6 @@ public function testReverseTransformWrapsIntlErrors() $transformer->reverseTransform('12345'); } - /** - * @expectedException \TypeError - */ - public function testValidateDateFormatOption() - { - new DateTimeToLocalizedStringTransformer(null, null, 'foobar'); - } - - /** - * @expectedException \TypeError - */ - public function testValidateTimeFormatOption() - { - new DateTimeToLocalizedStringTransformer(null, null, null, 'foobar'); - } - /** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/ReturnTyped.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/ReturnTyped.php deleted file mode 100644 index b6a9852715d79..0000000000000 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/ReturnTyped.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess\Tests\Fixtures; - -/** - * @author Kévin Dunglas - */ -class ReturnTyped -{ - public function getFoos(): array - { - return 'It doesn\'t respect the return type on purpose'; - } - - public function addFoo(\DateTime $dateTime) - { - } - - public function removeFoo(\DateTime $dateTime) - { - } -} diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassTypeErrorInsideCall.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassTypeErrorInsideCall.php deleted file mode 100644 index 44a93900fae34..0000000000000 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassTypeErrorInsideCall.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess\Tests\Fixtures; - -class TestClassTypeErrorInsideCall -{ - public function expectsDateTime(\DateTime $date) - { - } - - public function getProperty() - { - } - - public function setProperty($property) - { - $this->expectsDateTime(null); // throws TypeError - } -} diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 7e8f6cbd82c3c..f160be61f325f 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -15,14 +15,12 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException; use Symfony\Component\PropertyAccess\PropertyAccessor; -use Symfony\Component\PropertyAccess\Tests\Fixtures\ReturnTyped; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClass; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicCall; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicGet; use Symfony\Component\PropertyAccess\Tests\Fixtures\Ticket5775Object; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassSetValue; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassIsWritable; -use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassTypeErrorInsideCall; use Symfony\Component\PropertyAccess\Tests\Fixtures\TypeHinted; class PropertyAccessorTest extends TestCase @@ -634,24 +632,4 @@ public function setFoo($foo) return $obj; } - - /** - * @expectedException \TypeError - */ - public function testThrowTypeErrorInsideSetterCall() - { - $object = new TestClassTypeErrorInsideCall(); - - $this->propertyAccessor->setValue($object, 'property', 'foo'); - } - - /** - * @expectedException \TypeError - */ - public function testDoNotDiscardReturnTypeError() - { - $object = new ReturnTyped(); - - $this->propertyAccessor->setValue($object, 'foos', array(new \DateTime())); - } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php index 32131b001b248..fefb81099756f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php @@ -29,18 +29,6 @@ public function testConstructor() $this->assertTrue($token->isAuthenticated()); } - /** - * @expectedException \TypeError - */ - public function testConstructorSecretCannotBeNull() - { - new RememberMeToken( - $this->getUser(), - null, - null - ); - } - /** * @expectedException \InvalidArgumentException */ diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index fa10bd2ddfab3..c1f64f9bfd821 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -154,14 +154,6 @@ public function testStartTime() $this->assertEquals(0, $event->getStartTime(), null, self::DELTA); } - /** - * @expectedException \TypeError - */ - public function testInvalidOriginThrowsAnException() - { - new StopwatchEvent('abc'); - } - public function testHumanRepresentation() { $event = new StopwatchEvent(microtime(true) * 1000);