Skip to content

Commit

Permalink
Drop Laravel 8, Symfony 5.4 and PHP 7 support (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Oct 10, 2023
2 parents 7ae3472 + 8e1882d commit 9e206a8
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 233 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,7 @@ jobs:
matrix:
include:
- deps: 'low'
php: 7.3
experimental: false
composer: v2

- deps: 'stable'
php: 8.1
symfony: '5.x'
laravel: '8.x'
experimental: false
composer: v2

- deps: 'stable'
php: 8.1
symfony: '6.x'
laravel: '9.x'
php: '8.0'
experimental: false
composer: v2

Expand All @@ -54,6 +40,14 @@ jobs:
experimental: true
composer: preview

# TODO enable when Laravel allows Symfony 7
#- deps: 'dev'
# php: 8.3
# symfony: '7.x'
# laravel: '11.x'
# experimental: true
# composer: preview

steps:
- uses: actions/checkout@v2

Expand Down
50 changes: 24 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,39 @@
"type": "symfony-bundle",

"require": {
"php": "^7.3 || ^8.0",
"illuminate/database": "^8.68 || ^9.0 || ^10.0",
"illuminate/events": "^8.12 || ^9.0 || ^10.0",
"illuminate/console": "^8.12 || ^9.39 || ^10.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"php": "^8.0",
"illuminate/database": "^9.0 || ^10.0",
"illuminate/events": "^9.0 || ^10.0",
"illuminate/console": "^9.39 || ^10.0",
"symfony/framework-bundle": "^6.0",
"symfony/dependency-injection": "^6.0",
"jdorn/sql-formatter": "^1.2.17"
},
"require-dev": {
"doctrine/annotations": "1.*",
"mockery/mockery": "^1.3",
"symfony/maker-bundle": "^1.20",
"symfony/console": "^5.4 || ^6.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"symfony/finder": "^5.4 || ^6.0",
"symfony/yaml": "^5.4 || ^6.0",
"symfony/form": "^5.4 || ^6.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/dom-crawler": "^5.4 || ^6.0",
"symfony/validator": "^5.4 || ^6.0",
"symfony/security-bundle": "^5.4 || ^6.0",
"symfony/twig-bundle": "^5.4 || ^6.0",
"symfony/twig-bridge": "^5.4 || ^6.0",
"symfony/var-dumper": "^5.4 || ^6.0",
"symfony/process": "^5.4 || ^6.0",
"symfony/maker-bundle": "^1.44",
"mockery/mockery": "^1.6",
"symfony/console": "^6.0",
"symfony/event-dispatcher": "^6.0",
"symfony/http-kernel": "^6.0",
"symfony/finder": "^6.0",
"symfony/yaml": "^6.0",
"symfony/form": "^6.0",
"symfony/phpunit-bridge": "^6.0",
"symfony/browser-kit": "^6.0",
"symfony/dom-crawler": "^6.0",
"symfony/validator": "^6.0",
"symfony/security-bundle": "^6.0",
"symfony/twig-bundle": "^6.0",
"symfony/twig-bridge": "^6.0",
"symfony/var-dumper": "^6.0",
"symfony/process": "^6.0",
"twig/twig": "^1.26 || ^2.0 || ^3.0",
"vimeo/psalm": "^3.18.2 || ^4.0",
"psalm/plugin-symfony": "^1.5.0 || ^2.0 || ^3.0"
},
"conflict": {
"illuminate/console": ">=9.21,<9.39",
"illuminate/contracts": "<8.68",
"illuminate/support": "<8.45"
"illuminate/console": ">=9.21,<9.39"
},

"autoload": { "psr-4": { "WouterJ\\EloquentBundle\\": "src" } },
Expand Down
13 changes: 8 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php" colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="./vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="WouterJEloquentBundle">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory>./src</directory>
</whitelist>
</filter>
</include>
</coverage>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
Expand Down
6 changes: 0 additions & 6 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
<referencedMethod name="WouterJ\EloquentBundle\Seeder::run"/>
</errorLevel>
</UndefinedMethod>
<!-- BC for Laravel <9 -->
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="Illuminate\Database\Console\Seeds\WithoutModelEvents"/>
</errorLevel>
</UndefinedClass>
</issueHandlers>

<plugins>
Expand Down
11 changes: 1 addition & 10 deletions src/Migrations/Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace WouterJ\EloquentBundle\Migrations;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Migrations\MigrationCreator;
use Symfony\Bundle\MakerBundle\FileManager;

Expand Down Expand Up @@ -39,17 +38,9 @@ public function create($name, $path, $table = null, $create = false): string
$path = $this->getPath($name, $path);
$stub = $this->getStub($table, $create);

if (!trait_exists(WithoutModelEvents::class)) {
// BC for Laravel <9
/** @psalm-suppress TooManyArguments BC with Laravel <9 */
$populatedStub = $this->populateStub($name, $stub, $table);
} else {
/** @psalm-suppress TooFewArguments BC with Laravel <9 */
$populatedStub = $this->populateStub($stub, $table);
}
$populatedStub = $this->populateStub($stub, $table);
$this->fileManager->dumpFile($path, $populatedStub);

/** @psalm-suppress TooManyArguments BC with Laravel <9 */
$this->firePostCreateHooks($table, $path);

return $path;
Expand Down
21 changes: 20 additions & 1 deletion src/Migrations/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace WouterJ\EloquentBundle\Migrations;

use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
use Illuminate\Database\Migrations\MigrationRepositoryInterface;
use Illuminate\Database\Migrations\Migrator as LaravelMigrator;
Expand All @@ -32,9 +33,27 @@ public function __construct(MigrationRepositoryInterface $repository, Resolver $
if (class_exists(Filesystem::class)) {
parent::__construct($repository, $resolver, new Filesystem());
} else {
// compat with Laravel 8
// BC with Laravel <10
$this->repository = $repository;
$this->resolver = $resolver;
/** @psalm-suppress InvalidPropertyAssignmentValue */
$this->files = new class {
public function getRequire($path, array $data = [])
{
if (is_file($path)) {
$__path = $path;
$__data = $data;

return (static function () use ($__path, $__data) {
extract($__data, EXTR_SKIP);

return require $__path;
})();
}

throw new FileNotFoundException("File does not exist at path {$path}.");
}
};
}
}

Expand Down
35 changes: 7 additions & 28 deletions src/Security/EloquentUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,9 @@ public function loadUserByIdentifier(string $identifier): UserInterface
->where($this->usernameAttribute, $identifier)
->first();
if (null === $user) {
if (class_exists(UserNotFoundException::class)) {
$e = new UserNotFoundException();
$e->setUserIdentifier($identifier);
} else {
/** @psalm-suppress UndefinedClass BC with symfony/security-core <5.3 */
$e = new UsernameNotFoundException();
/**
* @psalm-suppress UndefinedMethod https://github.com/vimeo/psalm/issues/5750
* @psalm-suppress UndefinedClass
*/
$e->setUsername($identifier);
}

/** @psalm-suppress InvalidThrow */
$e = new UserNotFoundException();
$e->setUserIdentifier($identifier);

throw $e;
}

Expand All @@ -83,20 +72,10 @@ public function refreshUser(UserInterface $user): UserInterface
$refreshedUser = $this->createModel()->newQuery()->where($user->getKeyName(), $user->getKey())->first();
if (null === $refreshedUser) {
$userIdentifier = $user->getAttribute($this->usernameAttribute);
if (class_exists(UserNotFoundException::class)) {
$e = new UserNotFoundException();
$e->setUserIdentifier($userIdentifier);
} else {
/** @psalm-suppress UndefinedClass BC with symfony/security-core <5.3 */
$e = new UsernameNotFoundException();
/**
* @psalm-suppress UndefinedMethod https://github.com/vimeo/psalm/issues/5750
* @psalm-suppress UndefinedClass
*/
$e->setUsername($userIdentifier);
}

/** @psalm-suppress InvalidThrow */

$e = new UserNotFoundException();
$e->setUserIdentifier($userIdentifier);

throw $e;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/factories/PersonFactory-9.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PersonFactory extends Factory
/**
* Define the model's default state.
*
* @return array<string, mixed>
* @return array
*/
public function definition()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/factories/PostFactory-9.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PostFactory extends Factory
/**
* Define the model's default state.
*
* @return array<string, mixed>
* @return array
*/
public function definition()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/factories/TalkFactory-9.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TalkFactory extends Factory
/**
* Define the model's default state.
*
* @return array<string, mixed>
* @return array
*/
public function definition()
{
Expand Down
28 changes: 0 additions & 28 deletions tests/Fixtures/migrations/blank.php

This file was deleted.

31 changes: 0 additions & 31 deletions tests/Fixtures/migrations/create.php

This file was deleted.

32 changes: 0 additions & 32 deletions tests/Fixtures/migrations/update.php

This file was deleted.

0 comments on commit 9e206a8

Please sign in to comment.