Skip to content

Fix deprecated issues #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Common/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Common/Message/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function getRedirectResponse()
$hiddenFields .= sprintf(
'<input type="hidden" name="%1$s" value="%2$s" />',
htmlentities($key, ENT_QUOTES, 'UTF-8', false),
htmlentities($value, ENT_QUOTES, 'UTF-8', false)
htmlentities((string) $value, ENT_QUOTES, 'UTF-8', false)
)."\n";
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Common/GatewayFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

class GatewayFactoryTest extends TestCase
{
/** @var GatewayFactory */
protected $factory;

public static function setUpBeforeClass() : void
{
m::mock('alias:Omnipay\\SpareChange\\TestGateway');
Expand Down
3 changes: 3 additions & 0 deletions tests/Common/ItemBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

class ItemBagTest extends TestCase
{
/** @var ItemBag */
protected $bag;

public function setUp() : void
{
$this->bag = new ItemBag;
Expand Down
3 changes: 3 additions & 0 deletions tests/Common/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

class ItemTest extends TestCase
{
/** @var Item */
protected $item;

public function setUp() : void
{
$this->item = new Item;
Expand Down