Skip to content

Commit

Permalink
Support Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Propaganistas committed Mar 12, 2024
1 parent 32a6a06 commit 2dc9935
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 161 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.0, 8.1, 8.2, 8.3 ]
laravel: [ 9, 10 ]
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 10, 11 ]
stability: [ prefer-lowest, prefer-stable ]
exclude:
- php: 8.0
laravel: 10
- php: 8.1
laravel: 11

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} (${{ matrix.stability }})

Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit

- name: Run phpstan
run: vendor/bin/phpstan analyse --error-format=github
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
}
],
"require": {
"php": "^8.0",
"illuminate/contracts": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0",
"illuminate/validation": "^9.0|^10.0",
"php": "^8.1",
"illuminate/contracts": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"illuminate/validation": "^10.0|^11.0",
"giggsey/libphonenumber-for-php": "^7.0|^8.0"
},
"require-dev": {
"orchestra/testbench": "*",
"phpunit/phpunit": "^9.5.10",
"nunomaduro/larastan": "^2.4",
"laravel/pint": "^1.4"
"phpunit/phpunit": "^10.5",
"larastan/larastan": "^2.9",
"laravel/pint": "^1.14"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/larastan/larastan/extension.neon

parameters:

Expand Down
23 changes: 10 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<directory suffix=".php">tests</directory>
<exclude>tests/TestCase.php</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Concerns/PhoneNumberFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function isValidName($format): bool
return ! is_null($format) && in_array(strtoupper($format), $formats, true);
}

public static function getHumanReadableName($format): string|null
public static function getHumanReadableName($format): ?string
{
$name = array_search($format, static::all(), true);

Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/PhoneNumberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function isValidName($type): bool
return ! is_null($type) && in_array(strtoupper($type), $types, true);
}

public static function getHumanReadableName($type): string|null
public static function getHumanReadableName($type): ?string
{
$name = array_search($type, static::all(), true);

Expand Down
2 changes: 1 addition & 1 deletion src/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(?string $number, $country = [])
$this->countries = Arr::wrap($country);
}

public function getCountry(): string|null
public function getCountry(): ?string
{
// Try to detect the country first from the number itself.
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Phone.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use libphonenumber\PhoneNumberType as libPhoneNumberType;
use Propaganistas\LaravelPhone\Concerns\PhoneNumberCountry;
use Propaganistas\LaravelPhone\Concerns\PhoneNumberType;
use Propaganistas\LaravelPhone\Exceptions\NumberParseException;
use Propaganistas\LaravelPhone\Exceptions\IncompatibleTypesException;
use Propaganistas\LaravelPhone\Exceptions\NumberParseException;
use Propaganistas\LaravelPhone\PhoneNumber;

class Phone implements Rule, ValidatorAwareRule
Expand Down
13 changes: 7 additions & 6 deletions tests/E164PhoneNumberCastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace Propaganistas\LaravelPhone\Tests;

use Illuminate\Database\Eloquent\Model;
use PHPUnit\Framework\Attributes\Test;
use Propaganistas\LaravelPhone\Casts\E164PhoneNumberCast;
use Propaganistas\LaravelPhone\PhoneNumber;
use UnexpectedValueException;

class E164PhoneNumberCastTest extends TestCase
{
/** @test */
#[Test]
public function it_mutates_to_e164_number()
{
$model = new ModelWithE164Cast;
Expand All @@ -21,7 +22,7 @@ public function it_mutates_to_e164_number()
$this->assertEquals('+3212345678', $model->getAttributes()['phone']);
}

/** @test */
#[Test]
public function it_mutates_to_e164_number_with_implicit_country_field()
{
$model = new ModelWithE164Cast;
Expand All @@ -35,7 +36,7 @@ public function it_mutates_to_e164_number_with_implicit_country_field()
$this->assertEquals('+3212345678', $model->getAttributes()['phone']);
}

/** @test */
#[Test]
public function it_mutates_to_e164_number_with_explicit_country_field()
{
$model = new ModelWithE164CastAndCountryField;
Expand All @@ -49,7 +50,7 @@ public function it_mutates_to_e164_number_with_explicit_country_field()
$this->assertEquals('+3212345678', $model->getAttributes()['phone']);
}

/** @test */
#[Test]
public function it_gets_phone_object()
{
$model = new ModelWithE164Cast;
Expand All @@ -58,7 +59,7 @@ public function it_gets_phone_object()
$this->assertEquals(PhoneNumber::class, get_class($model->phone));
}

/** @test */
#[Test]
public function it_throws_when_accessing_non_international_value()
{
$model = new ModelWithE164Cast();
Expand All @@ -67,7 +68,7 @@ public function it_throws_when_accessing_non_international_value()
$model->phone;
}

/** @test */
#[Test]
public function it_serializes()
{
$model = new ModelWithE164Cast();
Expand Down
Loading

0 comments on commit 2dc9935

Please sign in to comment.