Skip to content

Commit 442a725

Browse files
authored
Allow Laravel 11 (#143)
2 parents 83628f8 + 708ff3e commit 442a725

File tree

10 files changed

+43
-41
lines changed

10 files changed

+43
-41
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ jobs:
2727
composer: v2
2828

2929
- deps: 'stable'
30-
php: 8.3
30+
php: '8.3'
3131
symfony: '6.x'
3232
laravel: '10.x'
3333
experimental: false
3434
composer: v2
3535

3636
- deps: 'dev'
37-
php: 8.3
37+
php: '8.3'
3838
symfony: '7.x'
3939
laravel: '11.x'
4040
experimental: false
4141
composer: v2
4242

4343
- deps: 'dev'
44-
php: 8.4
44+
php: '8.4'
4545
symfony: '7.x'
4646
laravel: '11.x'
4747
experimental: true
@@ -84,13 +84,13 @@ jobs:
8484
echo "LARAVEL_REQUIRE=$(echo '${{ matrix.laravel }}' | tr x \\*)" >> $GITHUB_ENV
8585
fi
8686
87-
if [ "${{ matrix.symfony }}" = "7.x" ]; then
88-
# Psalm Symfony Plugin doesn't support Symfony 7 yet
89-
composer remove --no-update --dev vimeo/psalm psalm/plugin-symfony
87+
#if [ "${{ matrix.symfony }}" = "7.x" ]; then
88+
# # Psalm Symfony Plugin doesn't support Symfony 7 yet
89+
# composer remove --no-update --dev vimeo/psalm psalm/plugin-symfony
9090
91-
# Carbon needs version 3
92-
composer require --no-update nesbot/carbon:"3.x-dev as 2.99.0"
93-
fi
91+
# # Carbon needs version 3
92+
# composer require --no-update nesbot/carbon:"3.x-dev as 2.99.0"
93+
#fi
9494
9595
echo "PHP_VERSION=${{ matrix.php }}" >> $GITHUB_ENV
9696

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
"require": {
99
"php": "^8.0",
10-
"illuminate/database": "^9.0 || ^10.0",
11-
"illuminate/events": "^9.0 || ^10.0",
12-
"illuminate/console": "^9.39 || ^10.0",
10+
"illuminate/database": "^9.0 || ^10.0 || ^11.0",
11+
"illuminate/events": "^9.0 || ^10.0 || ^11.0",
12+
"illuminate/console": "^9.39 || ^10.0 || ^11.0",
1313
"symfony/framework-bundle": "^6.0 || ^7.0",
1414
"symfony/dependency-injection": "^6.0 || ^7.0",
1515
"jdorn/sql-formatter": "^1.2.17"
@@ -33,12 +33,12 @@
3333
"symfony/twig-bridge": "^6.0 || ^7.0",
3434
"symfony/var-dumper": "^6.0 || ^7.0",
3535
"symfony/process": "^6.0 || ^7.0",
36-
"twig/twig": "^1.26 || ^2.0 || ^3.0",
37-
"vimeo/psalm": "^3.18.2 || ^4.0",
38-
"psalm/plugin-symfony": "^1.5.0 || ^2.0 || ^3.0"
36+
"twig/twig": "^2.0 || ^3.0",
37+
"vimeo/psalm": "^5.0",
38+
"psalm/plugin-symfony": "^5.0"
3939
},
4040
"conflict": {
41-
"illuminate/console": ">=9.21,<9.39"
41+
"nesbot/carbon": "<2.63"
4242
},
4343

4444
"autoload": { "psr-4": { "WouterJ\\EloquentBundle\\": "src" } },

psalm.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns="https://getpsalm.org/schema/config"
55
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
6+
findUnusedBaselineEntry="true"
7+
findUnusedCode="false"
68
errorLevel="4"
79
>
810
<projectFiles>
@@ -22,8 +24,14 @@
2224
<UndefinedMethod>
2325
<errorLevel type="suppress">
2426
<referencedMethod name="WouterJ\EloquentBundle\Seeder::run"/>
27+
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::fixXmlConfig"/>
2528
</errorLevel>
2629
</UndefinedMethod>
30+
<UndefinedInterfaceMethod>
31+
<errorLevel type="suppress">
32+
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::scalarNode"/>
33+
</errorLevel>
34+
</UndefinedInterfaceMethod>
2735
</issueHandlers>
2836

2937
<plugins>

src/Command/BaseMigrateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function getMigrationPath(): string
4646
return $this->migrationPath;
4747
}
4848

49-
protected function getMigrationPaths(InputInterface $input = null): array
49+
protected function getMigrationPaths(?InputInterface $input = null): array
5050
{
5151
if (null !== $input && $input->hasOption('path') && null !== $path = $input->getOption('path')) {
5252
return [getcwd().'/'.$path];

src/DataCollector/EloquentDataCollector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ public function __construct(Manager $capsule, QueryListener $queryListener)
3838

3939
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
4040
{
41-
/** @psalm-suppress UndefinedInterfaceMethod */
4241
$connections = array_map(function ($config) {
4342
return $this->cloneVar($config);
44-
}, $this->capsule->getContainer()['config']['database.connections']);
43+
}, $this->capsule->getContainer()->make('config')['database.connections']);
4544

4645
$usedConnections = [];
4746
foreach (array_keys($this->capsule->getDatabaseManager()->getConnections()) as $name) {

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ class Configuration implements ConfigurationInterface
2626
public function getConfigTreeBuilder(): TreeBuilder
2727
{
2828
$treeBuilder = new TreeBuilder('wouterj_eloquent');
29-
/** @psalm-suppress RedundantCondition */
30-
if (method_exists($treeBuilder, 'getRootNode')) {
31-
$root = $treeBuilder->getRootNode();
32-
} else {
33-
/** @psalm-suppress UndefinedMethod */
34-
$root = $treeBuilder->root('wouterj_eloquent');
35-
}
29+
$root = $treeBuilder->getRootNode();
3630

3731
$this->addAliasesSection($root);
3832
$this->addCapsuleSection($root);

src/Factory/Factory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
use Illuminate\Database\Eloquent\Model;
77

88
/**
9-
* @psalm-suppress TooManyTemplateParams BC with Laravel 8
109
* @template TModel of Model
1110
* @extends IlluminateFactory<TModel>
1211
*/
1312
abstract class Factory extends IlluminateFactory
1413
{
1514
public function modelName(): string
1615
{
17-
/** @psalm-suppress RedundantPropertyInitializationCheck */
18-
$resolver = static::$modelNameResolver ?? function (self $factory) {
16+
$resolver = static::$modelNameResolver ?: function (self $factory) {
1917
$name = $factory::class;
2018
if (str_ends_with($name, 'Factory')) {
2119
$name = substr($name, 0, -7);

src/Migrations/Migrator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public function __construct(MigrationRepositoryInterface $repository, Resolver $
3636
// BC with Laravel <10
3737
$this->repository = $repository;
3838
$this->resolver = $resolver;
39-
/** @psalm-suppress InvalidPropertyAssignmentValue */
40-
$this->files = new class {
39+
$this->files = new class extends Filesystem {
4140
public function getRequire($path, array $data = [])
4241
{
4342
if (is_file($path)) {

src/Security/EloquentUserProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
use Symfony\Component\Security\Core\User\UserProviderInterface;
2121

2222
/**
23-
* @template TUserObject of Model&UserInterface
23+
* @psalm-suppress TooManyTemplateParams BC with Symfony 6
24+
* @template-covariant TUserObject of Model&UserInterface
25+
* @implements UserProviderInterface<TUserObject>
2426
*
2527
* @final
2628
* @author Wouter de Jong <wouter@wouterj.nl>

tests/DataCollector/EloquentDataCollectorTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace WouterJ\EloquentBundle\DataCollector;
1313

14+
use Illuminate\Container\Container;
1415
use Illuminate\Database\Capsule\Manager;
16+
use Illuminate\Support\Fluent;
1517
use WouterJ\EloquentBundle\MockeryTrait;
1618
use Symfony\Component\HttpFoundation\Request;
1719
use Symfony\Component\HttpFoundation\Response;
@@ -21,14 +23,18 @@ class EloquentDataCollectorTest extends TestCase
2123
{
2224
use MockeryTrait;
2325

26+
private Container $container;
2427
private $capsule;
2528
private $queryListener;
2629
private $collector;
2730

2831
protected function setUp(): void
2932
{
33+
$this->container = new Container();
34+
$this->container->instance('config', new Fluent(['database.connections' => []]));
35+
3036
$this->capsule = \Mockery::mock(Manager::class);
31-
$this->capsule->allows()->getContainer()->andReturn(['config' => ['database.connections' => []]])->byDefault();
37+
$this->capsule->allows()->getContainer()->andReturn($this->container);
3238
$this->capsule->allows()->getDatabaseManager()->andReturn(new class{
3339
public function getConnections() { return []; }
3440
})->byDefault();
@@ -42,14 +48,10 @@ public function getConnections() { return []; }
4248
/** @test */
4349
public function it_collects_connections()
4450
{
45-
$this->capsule->allows()->getContainer()->andReturn([
46-
'config' => [
47-
'database.connections' => [
48-
'db1' => ['db' => 'foobar'],
49-
'db2' => ['db' => 'something else']
50-
],
51-
],
52-
]);
51+
$this->container['config']['database.connections'] = [
52+
'db1' => ['db' => 'foobar'],
53+
'db2' => ['db' => 'something else']
54+
];
5355

5456
$this->capsule->allows()->getDatabaseManager()->andReturn(new class{
5557
public function getConnections() {

0 commit comments

Comments
 (0)