diff --git a/src/Common/CreditCard.php b/src/Common/CreditCard.php index 45a08472..a1f97d05 100644 --- a/src/Common/CreditCard.php +++ b/src/Common/CreditCard.php @@ -377,7 +377,7 @@ public function getNumber() public function setNumber($value) { // strip non-numeric characters - return $this->setParameter('number', preg_replace('/\D/', '', $value)); + return $this->setParameter('number', preg_replace('/\D/', '', (string) $value)); } /** @@ -412,8 +412,10 @@ public function getNumberMasked($mask = 'X') */ public function getBrand() { + $number = (string) $this->getNumber(); + foreach ($this->getSupportedBrands() as $brand => $val) { - if (preg_match($val, $this->getNumber())) { + if (preg_match($val, $number)) { return $brand; } } diff --git a/src/Common/Helper.php b/src/Common/Helper.php index e03dfb54..7886aecd 100644 --- a/src/Common/Helper.php +++ b/src/Common/Helper.php @@ -63,7 +63,7 @@ protected static function convertToLowercase($str) public static function validateLuhn($number) { $str = ''; - foreach (array_reverse(str_split($number)) as $i => $c) { + foreach (array_reverse(str_split((string) $number)) as $i => $c) { $str .= $i % 2 ? $c * 2 : $c; } diff --git a/src/Common/Message/AbstractResponse.php b/src/Common/Message/AbstractResponse.php index e958f4b2..d78f21a7 100644 --- a/src/Common/Message/AbstractResponse.php +++ b/src/Common/Message/AbstractResponse.php @@ -215,7 +215,7 @@ public function getRedirectResponse() $hiddenFields .= sprintf( '', htmlentities($key, ENT_QUOTES, 'UTF-8', false), - htmlentities($value, ENT_QUOTES, 'UTF-8', false) + htmlentities((string) $value, ENT_QUOTES, 'UTF-8', false) )."\n"; } diff --git a/tests/Common/GatewayFactoryTest.php b/tests/Common/GatewayFactoryTest.php index 25dba511..45cccb43 100644 --- a/tests/Common/GatewayFactoryTest.php +++ b/tests/Common/GatewayFactoryTest.php @@ -7,6 +7,9 @@ class GatewayFactoryTest extends TestCase { + /** @var GatewayFactory */ + protected $factory; + public static function setUpBeforeClass() : void { m::mock('alias:Omnipay\\SpareChange\\TestGateway'); diff --git a/tests/Common/ItemBagTest.php b/tests/Common/ItemBagTest.php index 4552b9c1..460690ee 100644 --- a/tests/Common/ItemBagTest.php +++ b/tests/Common/ItemBagTest.php @@ -6,6 +6,9 @@ class ItemBagTest extends TestCase { + /** @var ItemBag */ + protected $bag; + public function setUp() : void { $this->bag = new ItemBag; diff --git a/tests/Common/ItemTest.php b/tests/Common/ItemTest.php index 4e22db18..c653e646 100644 --- a/tests/Common/ItemTest.php +++ b/tests/Common/ItemTest.php @@ -6,6 +6,9 @@ class ItemTest extends TestCase { + /** @var Item */ + protected $item; + public function setUp() : void { $this->item = new Item;