Skip to content

Commit

Permalink
Merge pull request #301 from ash-jc-allen/php-8.4
Browse files Browse the repository at this point in the history
Add support for PHP 8.4
  • Loading branch information
ash-jc-allen authored Dec 1, 2024
2 parents f9094f9 + 7529190 commit 9402b79
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2, 8.3]
php: [8.1, 8.2, 8.3, 8.4]
laravel: [10.*, 11.*]
include:
- laravel: 11.*
Expand Down Expand Up @@ -44,5 +44,10 @@ jobs:
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest
- name: Copy PhpStan config for Laravel 10
if: matrix.laravel == '10.*'
run: cp phpstan-laravel-10.neon phpstan.neon

- name: Run Larastan
run: vendor/bin/phpstan analyse
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2, 8.3]
php: [8.1, 8.2, 8.3, 8.4]
laravel: [10.*, 11.*]
include:
- laravel: 11.*
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"illuminate/database": "^10.0|^11.0",
"hashids/hashids": "^4.0|^5.0",
"whichbrowser/parser": "^2.1",
"ashallendesign/laravel-config-validator": "^2.6.1"
"ashallendesign/laravel-config-validator": "^2.6.1",
"laravel/framework": "^10.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
Expand Down
18 changes: 18 additions & 0 deletions phpstan-laravel-10.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
includes:
- ./vendor/larastan/larastan/extension.neon

parameters:

paths:
- src

level: 6

ignoreErrors:
- '#PHPDoc tag @use contains generic type Illuminate\\Database\\Eloquent\\Factories\\HasFactory<AshAllenDesign\\ShortURL\\Models\\Factories\\ShortURLVisitFactory> but trait Illuminate\\Database\\Eloquent\\Factories\\HasFactory is not generic.#'
- '#Method AshAllenDesign\\ShortURL\\Models\\ShortURLVisit::shortURL\(\) should return Illuminate\\Database\\Eloquent\\Relations\\BelongsTo<AshAllenDesign\\ShortURL\\Models\\ShortURL, \$this\(AshAllenDesign\\ShortURL\\Models\\ShortURLVisit\)> but returns Illuminate\\Database\\Eloquent\\Relations\\BelongsTo<AshAllenDesign\\ShortURL\\Models\\ShortURL, AshAllenDesign\\ShortURL\\Models\\ShortURLVisit>.#'
- '#Method AshAllenDesign\\ShortURL\\Models\\ShortURL::visits\(\) should return Illuminate\\Database\\Eloquent\\Relations\\HasMany<AshAllenDesign\\ShortURL\\Models\\ShortURLVisit, \$this\(AshAllenDesign\\ShortURL\\Models\\ShortURL\)> but returns Illuminate\\Database\\Eloquent\\Relations\\HasMany<AshAllenDesign\\ShortURL\\Models\\ShortURLVisit>.#'
- '#Generic type Illuminate\\Database\\Eloquent\\Relations\\HasMany<AshAllenDesign\\ShortURL\\Models\\ShortURLVisit, \$this\(AshAllenDesign\\ShortURL\\Models\\ShortURL\)> in PHPDoc tag @return specifies 2 template types, but class Illuminate\\Database\\Eloquent\\Relations\\HasMany supports only 1: TRelatedModel#'
- '#PHPDoc tag @use contains generic type Illuminate\\Database\\Eloquent\\Factories\\HasFactory<AshAllenDesign\\ShortURL\\Models\\Factories\\ShortURLFactory> but trait Illuminate\\Database\\Eloquent\\Factories\\HasFactory is not generic.#'

checkMissingIterableValueType: false
2 changes: 1 addition & 1 deletion src/Classes/KeyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function generateRandom(): string
* seed value to the key generator. If no seed is passed, a random
* key will be generated.
*/
public function generateKeyUsing(int $seed = null): string
public function generateKeyUsing(?int $seed = null): string
{
return $seed
? $this->hashids->encode($seed)
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/UrlKeyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ interface UrlKeyGenerator
{
public function generateRandom(): string;

public function generateKeyUsing(int $seed = null): string;
public function generateKeyUsing(?int $seed = null): string;
}
6 changes: 5 additions & 1 deletion src/Models/ShortURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace AshAllenDesign\ShortURL\Models;

use AshAllenDesign\ShortURL\Models\Factories\ShortURLFactory;
use Carbon\CarbonInterface;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\Factory;
Expand Down Expand Up @@ -34,6 +35,9 @@
*/
class ShortURL extends Model
{
/**
* @use HasFactory<ShortURLFactory>
*/
use HasFactory;

/**
Expand Down Expand Up @@ -111,7 +115,7 @@ protected static function newFactory()
/**
* A short URL can be visited many times.
*
* @return HasMany<ShortURLVisit>
* @return HasMany<ShortURLVisit, $this>
*/
public function visits(): HasMany
{
Expand Down
6 changes: 5 additions & 1 deletion src/Models/ShortURLVisit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace AshAllenDesign\ShortURL\Models;

use AshAllenDesign\ShortURL\Models\Factories\ShortURLVisitFactory;
use Carbon\CarbonInterface;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
Expand All @@ -26,6 +27,9 @@
*/
class ShortURLVisit extends Model
{
/**
* @use HasFactory<ShortURLVisitFactory>
*/
use HasFactory;

public const DEVICE_TYPE_MOBILE = 'mobile';
Expand Down Expand Up @@ -94,7 +98,7 @@ protected static function newFactory()
/**
* A URL visit belongs to one specific shortened URL.
*
* @return BelongsTo<ShortURL, ShortURLVisit>
* @return BelongsTo<ShortURL, $this>
*/
public function shortURL(): BelongsTo
{
Expand Down

0 comments on commit 9402b79

Please sign in to comment.