Skip to content

Commit

Permalink
Merge pull request #19 from harikt/create-func
Browse files Browse the repository at this point in the history
create_function has been DEPRECATED as of PHP 7.2.0
  • Loading branch information
pdt256 committed Dec 12, 2019
2 parents 2a50506 + 2e920b5 commit 8d1cd60
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4

before_script:
- composer install --prefer-dist
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
}
},
"require-dev": {
"phpunit/phpunit": "4.0.*",
"squizlabs/php_codesniffer": "1.5.5"
"phpunit/phpunit": "7.0.*",
"squizlabs/php_codesniffer": "3.5.*"
},
"require": {
"php": ">=7.1"
Expand Down
4 changes: 3 additions & 1 deletion src/RateAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public function getRates()

protected function sortByCost()
{
uasort($this->rates, create_function('$a, $b', 'return ($a->getCost() > $b->getCost());'));
uasort($this->rates, function ($a, $b) {
return ($a->getCost() > $b->getCost());
});
}
}
6 changes: 4 additions & 2 deletions src/Ship.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ public function getAllDisplayRates($rates)
return $display_rates;
}

protected function sortByCost(& $rates)
protected function sortByCost(&$rates)
{
uasort($rates, create_function('$a, $b', 'return ($a->getCost() > $b->getCost());'));
uasort($rates, function ($a, $b) {
return ($a->getCost() > $b->getCost());
});
}
}
2 changes: 1 addition & 1 deletion src/UPS/Rate.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public function __construct($options = [])
]);

$this->setRequestAdapter(Arr::get($options, 'requestAdapter', new RateRequest\Post()));

}

protected function validate()
{
$this->validatePackages();
Expand Down
4 changes: 3 additions & 1 deletion tests/ArrTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace pdt256\Shipping;

class ArrTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class ArrTest extends TestCase
{
public function providerGet()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Fedex/FedexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use pdt256\Shipping\Shipment;
use pdt256\Shipping\Quote;
use DateTime;
use PHPUnit\Framework\TestCase;

class RateTest extends \PHPUnit_Framework_TestCase
class RateTest extends TestCase
{
/** @var Shipment */
protected $shipment;
Expand Down Expand Up @@ -182,6 +183,5 @@ public function testMissingMeterNumber()
'requestAdapter' => new StubFedex,
]);
$rateAdapter->getRates();

}
}
3 changes: 2 additions & 1 deletion tests/PackageDimensionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
use pdt256\Shipping\RateRequest\StubFedex;
use pdt256\Shipping\RateRequest\StubUPS;
use pdt256\Shipping\RateRequest\StubUSPS;
use PHPUnit\Framework\TestCase;

class PackageDimensionsValidationTrait extends \PHPUnit_Framework_TestCase
class PackageDimensionsValidationTrait extends TestCase
{
protected function getNormalPackage()
{
Expand Down
4 changes: 3 additions & 1 deletion tests/PackageTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace pdt256\Shipping;

class PackageTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class PackageTest extends TestCase
{
public function testCreate()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/QuoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
namespace pdt256\Shipping;

use DateTime;
use PHPUnit\Framework\TestCase;

class QuoteTest extends \PHPUnit_Framework_TestCase
class QuoteTest extends TestCase
{
public function testCreate()
{
Expand Down
4 changes: 3 additions & 1 deletion tests/RateAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace pdt256\Shipping;

class RateAdapterTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class RateAdapterTest extends TestCase
{
public function testCreate()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/ShipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
namespace pdt256\Shipping;

use DateTime;
use PHPUnit\Framework\TestCase;

class ShipTest extends \PHPUnit_Framework_TestCase
class ShipTest extends TestCase
{
/** @var Shipment */
public $shipment;
Expand Down
4 changes: 3 additions & 1 deletion tests/ShipmentTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace pdt256\Shipping;

class ShipmentTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class ShipmentTest extends TestCase
{
public function testCreate()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/UPS/RateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
use pdt256\Shipping\Package;
use pdt256\Shipping\Shipment;
use pdt256\Shipping\Quote;
use PHPUnit\Framework\TestCase;

class RateTest extends \PHPUnit_Framework_TestCase
class RateTest extends TestCase
{
/** @var Shipment */
protected $shipment;
Expand Down
3 changes: 2 additions & 1 deletion tests/USPS/RateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
use pdt256\Shipping\Package;
use pdt256\Shipping\Shipment;
use pdt256\Shipping\Quote;
use PHPUnit\Framework\TestCase;

class RateTest extends \PHPUnit_Framework_TestCase
class RateTest extends TestCase
{
/** @var Shipment */
protected $shipment;
Expand Down
4 changes: 3 additions & 1 deletion tests/ValidatorTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace pdt256\Shipping;

class ValidatorTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class ValidatorTest extends TestCase
{
/**
* @expectedException \LogicException
Expand Down

0 comments on commit 8d1cd60

Please sign in to comment.