diff --git a/src/Helper.php b/src/Helper.php index f5e9901..cb566ea 100644 --- a/src/Helper.php +++ b/src/Helper.php @@ -5,14 +5,15 @@ * Contains base methods that all messages will use. */ +use Closure; +use DateTime; use Exception; +use DateTimeZone; + use UnexpectedValueException; use Psr\Http\Message\MessageInterface; use Psr\Http\Message\ServerRequestInterface; -use DateTime; -use DateTimeZone; - abstract class Helper { // SagePay date format, ISO 8601 with microseconds. diff --git a/src/Request/AbstractRequest.php b/src/Request/AbstractRequest.php index fb4a0e4..188b73b 100644 --- a/src/Request/AbstractRequest.php +++ b/src/Request/AbstractRequest.php @@ -13,6 +13,7 @@ use Academe\SagePay\Psr7\Factory\FactoryInterface; use Academe\SagePay\Psr7\Factory\DiactorosFactory; use Academe\SagePay\Psr7\Factory\GuzzleFactory; +use Academe\SagePay\Psr7\Factory\RequestFactoryInterface; use UnexpectedValueException; use JsonSerializable; use Exception; @@ -179,7 +180,7 @@ protected function setFactory(RequestFactoryInterface $factory) protected function withFactory(RequestFactoryInterface $factory) { $clone = clone $this; - return $clone->setAuth($factory); + return $clone->setFactory($factory); } /** diff --git a/src/Request/CreatePayment.php b/src/Request/CreatePayment.php index 983fbbe..77b3222 100644 --- a/src/Request/CreatePayment.php +++ b/src/Request/CreatePayment.php @@ -12,6 +12,8 @@ use Academe\SagePay\Psr7\Model\Auth; use Academe\SagePay\Psr7\PaymentMethod\PaymentMethodInterface; use Academe\SagePay\Psr7\Money\AmountInterface; +use Academe\SagePay\Psr7\Request\Model\AddressInterface; +use Academe\SagePay\Psr7\Request\Model\PersonInterface; class CreatePayment extends AbstractRequest { @@ -263,10 +265,9 @@ public static function getApply3DSecures() } /** - * @param ShippingAddress $shippingAddress - * @return Transaction + * @return self clone */ - public function withShippingAddress(ShippingAddress $shippingAddress) + public function withShippingAddress(AddressInterface $shippingAddress) { $copy = clone $this; $copy->shippingAddress = $shippingAddress; @@ -274,10 +275,9 @@ public function withShippingAddress(ShippingAddress $shippingAddress) } /** - * @param ShippingRecipient $shippingRecipient - * @return Transaction + * @return self clone */ - public function withShippingRecipient(ShippingRecipient $shippingRecipient) + public function withShippingRecipient(PersonInterface $shippingRecipient) { $copy = clone $this; $copy->shippingRecipient = $shippingRecipient; diff --git a/src/Request/CreateRepeatPayment.php b/src/Request/CreateRepeatPayment.php index 6e2e8cb..c0e014a 100644 --- a/src/Request/CreateRepeatPayment.php +++ b/src/Request/CreateRepeatPayment.php @@ -12,8 +12,9 @@ use Academe\SagePay\Psr7\Model\Endpoint; use Academe\SagePay\Psr7\Model\Auth; use Academe\SagePay\Psr7\Money\AmountInterface; -use Academe\SagePay\Psr7\Model\AddressInterface; use Academe\SagePay\Psr7\Model\PersonInterface; +use Academe\SagePay\Psr7\Request\Model\AddressInterface; +use Academe\SagePay\Psr7\Request\Model\PersonInterface as ModelPersonInterface; class CreateRepeatPayment extends AbstractRequest { @@ -29,6 +30,7 @@ class CreateRepeatPayment extends AbstractRequest // Optional or overridable data. protected $shippingAddress; protected $shippingRecipient; + protected $giftAid; /** * @var string The prefix is added to the name fields when sending to Sage Pay @@ -87,7 +89,7 @@ public function __construct( * @param ShippingAddress $shippingAddress * @return Transaction */ - public function withShippingAddress(ShippingAddress $shippingAddress) + public function withShippingAddress(AddressInterface $shippingAddress) { $copy = clone $this; $copy->shippingAddress = $shippingAddress; @@ -98,7 +100,7 @@ public function withShippingAddress(ShippingAddress $shippingAddress) * @param ShippingRecipient $shippingRecipient * @return Repeat */ - public function withShippingRecipient(ShippingRecipient $shippingRecipient) + public function withShippingRecipient(ModelPersonInterface $shippingRecipient) { $copy = clone $this; $copy->shippingRecipient = $shippingRecipient; diff --git a/src/Request/FetchInstructions.php b/src/Request/FetchInstructions.php index c0cdeae..f44028c 100644 --- a/src/Request/FetchInstructions.php +++ b/src/Request/FetchInstructions.php @@ -18,5 +18,6 @@ class FetchInstructions extends AbstractInstruction #[\ReturnTypeWillChange] public function jsonSerialize() { + return []; } } diff --git a/src/Response/AbstractCollection.php b/src/Response/AbstractCollection.php index 8541006..83580d8 100644 --- a/src/Response/AbstractCollection.php +++ b/src/Response/AbstractCollection.php @@ -2,11 +2,14 @@ namespace Academe\SagePay\Psr7\Response; +use ArrayIterator; +use IteratorAggregate; + /** * A a collection of instructions. */ -abstract class AbstractCollection extends AbstractResponse implements \IteratorAggregate +abstract class AbstractCollection extends AbstractResponse implements IteratorAggregate { /** * The list of items. @@ -22,6 +25,7 @@ abstract class AbstractCollection extends AbstractResponse implements \IteratorA /** * @return ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->items); diff --git a/src/Response/AbstractResponse.php b/src/Response/AbstractResponse.php index 003a200..92833e5 100644 --- a/src/Response/AbstractResponse.php +++ b/src/Response/AbstractResponse.php @@ -24,6 +24,8 @@ abstract class AbstractResponse extends AbstractMessage implements Http, RFC4918 */ protected $httpCode; + protected $status; + /** * Can initialise with a PSR7 message, an array, a value object or a JSON string. * diff --git a/src/Response/InstructionCollection.php b/src/Response/InstructionCollection.php index e45dcca..a6c9b7e 100644 --- a/src/Response/InstructionCollection.php +++ b/src/Response/InstructionCollection.php @@ -16,9 +16,6 @@ class InstructionCollection extends AbstractCollection */ protected $permittedClass = AbstractInstruction::class; - /** - * - */ public function setData($data, $httpCode = null) { if ($httpCode) { @@ -37,6 +34,8 @@ public function setData($data, $httpCode = null) $this->add(ResponseFactory::fromData($instruction, $httpCode)); } } + + return $this; } /** diff --git a/src/Response/NoContent.php b/src/Response/NoContent.php index 434bbd4..442e954 100644 --- a/src/Response/NoContent.php +++ b/src/Response/NoContent.php @@ -11,10 +11,12 @@ class NoContent extends AbstractResponse { /** - * No data to set (this is an empty messgae body). + * No data to set (this is an empty message body). + * @inheritDoc */ public function setData($data) { + return $this; } /** diff --git a/src/Response/SessionKey.php b/src/Response/SessionKey.php index 33701ae..05ad608 100644 --- a/src/Response/SessionKey.php +++ b/src/Response/SessionKey.php @@ -81,7 +81,7 @@ public function isValid() } // Do we have a 404 HTTP response code recorded? - if ($this->getHttpCode() !== null && $this->getHttpCode() === $this::NOT_FOUND) { + if ($this->getHttpCode() !== null && $this->getHttpCode() === static::NOT_FOUND) { return false; }