From 6c5a83a8a8fde8e4efee92c327e4712f59f8d9a9 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 17 Jan 2023 15:36:50 +0100 Subject: [PATCH] make deprecated client argument optional in recipients list --- Tests/ApiTestCase.php | 6 +++--- Tests/ValueObject/SmsBinaryMessageTest.php | 5 ++--- Tests/ValueObject/SmsMessageAbstractTest.php | 1 - src/RecipientsList/RecipientsList.php | 10 ++++++---- src/RecipientsList/RecipientsListInterface.php | 2 +- src/Request/Request.php | 1 - 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Tests/ApiTestCase.php b/Tests/ApiTestCase.php index 371e89f..049c361 100644 --- a/Tests/ApiTestCase.php +++ b/Tests/ApiTestCase.php @@ -31,7 +31,7 @@ abstract class ApiTestCase extends TestCase * @return mixed * @throws ReflectionException */ - public function callMethod(object $object, string $methodName, array $arguments = []) + public function callMethod($object, string $methodName, array $arguments = []) { $class = new ReflectionClass($object); $method = $class->getMethod($methodName); @@ -47,7 +47,7 @@ abstract class ApiTestCase extends TestCase * @param $value * @throws ReflectionException */ - public function setValue(object $object, string $valueName, $value) + public function setValue($object, string $valueName, $value) { $reflection = new ReflectionClass($object); $property = $reflection->getProperty($valueName); @@ -63,7 +63,7 @@ abstract class ApiTestCase extends TestCase * @return mixed * @throws ReflectionException */ - public function getValue(object $object, string $valueName) + public function getValue($object, string $valueName) { $reflection = new ReflectionClass($object); $property = $reflection->getProperty($valueName); diff --git a/Tests/ValueObject/SmsBinaryMessageTest.php b/Tests/ValueObject/SmsBinaryMessageTest.php index 7b01e1c..b446c82 100644 --- a/Tests/ValueObject/SmsBinaryMessageTest.php +++ b/Tests/ValueObject/SmsBinaryMessageTest.php @@ -15,9 +15,8 @@ declare(strict_types=1); namespace D3\LinkmobilityClient\Tests\ValueObject; -use Assert\InvalidArgumentException; -use D3\LinkmobilityClient\Tests\ApiTestCase; use D3\LinkmobilityClient\ValueObject\SmsBinaryMessage; +use Phlib\SmsLength\Exception\InvalidArgumentException; use Phlib\SmsLength\SmsLength; use PHPUnit\Framework\MockObject\MockObject; use ReflectionException; @@ -94,7 +93,7 @@ class SmsBinaryMessageTest extends SmsMessageAbstractTest if ($valid) { $smsLengthMock->expects($this->never())->method('validate')->willReturn(true); } else { - $smsLengthMock->expects($this->atLeastOnce())->method('validate')->willThrowException(new \Phlib\SmsLength\Exception\InvalidArgumentException()); + $smsLengthMock->expects($this->atLeastOnce())->method('validate')->willThrowException(new InvalidArgumentException()); } /** @var SmsBinaryMessage|MockObject $message */ diff --git a/Tests/ValueObject/SmsMessageAbstractTest.php b/Tests/ValueObject/SmsMessageAbstractTest.php index e5b4946..3db54a5 100644 --- a/Tests/ValueObject/SmsMessageAbstractTest.php +++ b/Tests/ValueObject/SmsMessageAbstractTest.php @@ -19,7 +19,6 @@ use Assert\InvalidArgumentException; use D3\LinkmobilityClient\Tests\ApiTestCase; use D3\LinkmobilityClient\ValueObject\SmsBinaryMessage; use Phlib\SmsLength\SmsLength; -use PHPUnit\Framework\MockObject\MockObject; use ReflectionException; abstract class SmsMessageAbstractTest extends ApiTestCase diff --git a/src/RecipientsList/RecipientsList.php b/src/RecipientsList/RecipientsList.php index 2ff75d1..ff08e02 100644 --- a/src/RecipientsList/RecipientsList.php +++ b/src/RecipientsList/RecipientsList.php @@ -32,12 +32,14 @@ class RecipientsList implements RecipientsListInterface, Iterator private $recipients = []; /** - * @deprecated unused client parameter will removed - * @param Client $client + * @deprecated unused client parameter will remove + * @param Client|null $client */ - public function __construct(Client $client) + public function __construct(Client $client = null) { - $this->setClient($client); + if ($client) { + $this->setClient( $client ); + } } /** diff --git a/src/RecipientsList/RecipientsListInterface.php b/src/RecipientsList/RecipientsListInterface.php index 91f8165..6b038dd 100644 --- a/src/RecipientsList/RecipientsListInterface.php +++ b/src/RecipientsList/RecipientsListInterface.php @@ -21,7 +21,7 @@ use D3\LinkmobilityClient\ValueObject\Recipient; interface RecipientsListInterface { /** - * @deprecated unused client parameter will removed + * @deprecated unused client parameter will remove * @param Client $client */ public function __construct(Client $client); diff --git a/src/Request/Request.php b/src/Request/Request.php index 4f12ffd..0b7fd94 100644 --- a/src/Request/Request.php +++ b/src/Request/Request.php @@ -25,7 +25,6 @@ use D3\LinkmobilityClient\ValueObject\Recipient; use D3\LinkmobilityClient\ValueObject\Sender; use D3\LinkmobilityClient\ValueObject\SmsMessageAbstract; use D3\LinkmobilityClient\ValueObject\SmsMessageInterface; -use D3\LinkmobilityClient\ValueObject\StringValueObject; use GuzzleHttp\RequestOptions; use InvalidArgumentException;