Skip to content
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

Add support for PHP 8.4 #301

Merged
merged 6 commits into from
Dec 1, 2024
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
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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this depedency? Wouldn't this mean that it would conflict with Laravel 11 installs?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically can't upgrade to ^8.2 because of this.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kyryl-bogach! Huge thank you for pointing this out to me. I was doing some tinkering the other day and accidentally committed this (I can't believe I did that!) 🤦‍♂️

I've just removed it now, so you should be able to upgrade to v8.2.1 🤞

Sorry about that!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much sir! 🙏🏻

},
"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