Skip to content

Commit 805f9a1

Browse files
authored
Merge branch 'laravel-doctrine:3.1.x' into use-overrides-for-connection-settings
2 parents 4826f0a + 3a38bf9 commit 805f9a1

File tree

18 files changed

+191
-78
lines changed

18 files changed

+191
-78
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ on:
1313
jobs:
1414
phpunit:
1515
name: "PHPUnit"
16-
runs-on: "ubuntu-20.04"
16+
runs-on: "ubuntu-24.04"
1717

1818
strategy:
1919
fail-fast: false
2020
matrix:
2121
php-version:
2222
- "8.2"
2323
- "8.3"
24+
- "8.4"
2425
dependencies:
2526
- "highest"
2627
- "lowest"
@@ -54,30 +55,7 @@ jobs:
5455
- name: "Run PHPUnit"
5556
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"
5657

57-
- name: "Upload coverage file"
58-
uses: "codecov/codecov-action@v4"
58+
- name: "Upload coverage"
59+
uses: "codecov/codecov-action@v5"
5960
with:
60-
name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ matrix.dbal-version }}.coverage"
61-
files: "./coverage.xml"
62-
63-
upload_coverage:
64-
name: "Upload coverage to Codecov"
65-
runs-on: "ubuntu-20.04"
66-
needs:
67-
- "phpunit"
68-
69-
steps:
70-
- name: "Checkout"
71-
uses: "actions/checkout@v2"
72-
with:
73-
fetch-depth: 2
74-
75-
- name: "Download coverage files"
76-
uses: "actions/download-artifact@v4"
77-
with:
78-
path: "reports"
79-
80-
- name: "Upload to Codecov"
81-
uses: "codecov/codecov-action@v2"
82-
with:
83-
directory: "reports"
61+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
php-version:
1515
- "8.2"
1616
- "8.3"
17+
- "8.4"
1718

1819
steps:
1920
- name: "Checkout code"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ composer.lock
1111
/tests/Stubs/storage/doctrine.generated.php
1212
.idea
1313
laravel-doctrine-orm.iml
14+
/workbench/bootstrap/cache/*
15+
!/workbench/bootstrap/cache/.gitkeep
16+
/workbench/storage/logs/*
17+
/workbench/vendor

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Laravel Doctrine ORM
99
An integration library for Laravel and Doctrine ORM
1010

1111
[![Build Status](https://github.com/laravel-doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/laravel-doctrine/orm/actions/workflows/continuous-integration.yml?query=branch%3Amain)
12-
[![Code Coverage](https://codecov.io/gh/laravel-doctrine/orm/branch/3.0.x/graph/badge.svg?token=3CpQzDXOWX)](https://codecov.io/gh/laravel-doctrine/orm)
12+
[![Code Coverage](https://codecov.io/gh/laravel-doctrine/orm/graph/badge.svg?token=3CpQzDXOWX)](https://codecov.io/gh/laravel-doctrine/orm)
1313
[![PHPStan](https://img.shields.io/badge/PHPStan-level%201-brightgreen.svg)](https://img.shields.io/badge/PHPStan-level%201-brightgreen.svg)
1414
[![Documentation](https://readthedocs.org/projects/laravel-doctrine-orm-official/badge/?version=latest)](https://laravel-doctrine-orm-official.readthedocs.io/en/latest/)
1515
[![Packagist Downloads](https://img.shields.io/packagist/dd/laravel-doctrine/orm)](https://packagist.org/packages/laravel-doctrine/orm)

composer.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@
2121
"php": "^8.2",
2222
"doctrine/dbal": "^3.0 || ^4.0",
2323
"doctrine/orm": "^3.1",
24-
"doctrine/persistence": "^3.3",
25-
"illuminate/auth": "^10.0|^11.0",
26-
"illuminate/console": "^10.0|^11.0",
27-
"illuminate/container": "^10.0|^11.0",
28-
"illuminate/contracts": "^10.0|^11.0",
29-
"illuminate/pagination": "^10.0|^11.0",
30-
"illuminate/routing": "^10.0|^11.0",
31-
"illuminate/support": "^10.0|^11.0",
32-
"illuminate/validation": "^10.0|^11.0",
33-
"illuminate/view": "^10.0|^11.0",
24+
"doctrine/persistence": "^3.3 || ^4.0",
25+
"illuminate/auth": "^10.0|^11.0 || ^12.0",
26+
"illuminate/console": "^10.0|^11.0 || ^12.0",
27+
"illuminate/container": "^10.0|^11.0 || ^12.0",
28+
"illuminate/contracts": "^10.0|^11.0 || ^12.0",
29+
"illuminate/pagination": "^10.0|^11.0 || ^12.0",
30+
"illuminate/routing": "^10.0|^11.0 || ^12.0",
31+
"illuminate/support": "^10.0|^11.0 || ^12.0",
32+
"illuminate/validation": "^10.0|^11.0 || ^12.0",
33+
"illuminate/view": "^10.0|^11.0 || ^12.0",
3434
"symfony/cache": "^6.0|^7.0",
3535
"symfony/serializer": "^5.0|^6.0|^7.0"
3636
},
3737
"require-dev": {
3838
"doctrine/coding-standard": "^12.0",
39-
"illuminate/log": "^10.0 || ^11.0",
40-
"illuminate/notifications": "^10.0 || ^11.0",
41-
"illuminate/queue": "^10.0 || ^11.0",
39+
"illuminate/log": "^10.0 || ^11.0 || ^12.0",
40+
"illuminate/notifications": "^10.0 || ^11.0 || ^12.0",
41+
"illuminate/queue": "^10.0 || ^11.0 || ^12.0",
4242
"mockery/mockery": "^1.6.12",
4343
"nikic/php-parser": "^4.19 || ^5.0",
4444
"php-parallel-lint/php-parallel-lint": "^1.4",
45-
"phpstan/phpstan": "^1.9",
46-
"phpstan/phpstan-deprecation-rules": "^1.1",
45+
"phpstan/phpstan": "^1.9 || ^2.1",
46+
"phpstan/phpstan-deprecation-rules": "^1.1 || ^2.0",
4747
"phpunit/phpunit": "^11.4",
4848
"fakerphp/faker": "^1.23",
49-
"laravel/framework": "^10.0 || ^11.0",
50-
"orchestra/testbench": "^9.5"
49+
"laravel/framework": "^10.0 || ^11.0 || ^12.0",
50+
"orchestra/testbench": "^9.5 || ^10.0"
5151
},
5252
"conflict": {
5353
"laravel/lumen": "*"

src/Auth/Authenticatable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trait Authenticatable
1212
protected string $password;
1313

1414
#[ORM\Column(name: 'remember_token', type: 'string', nullable: true)]
15-
protected string $rememberToken;
15+
protected string|null $rememberToken;
1616

1717
/**
1818
* Get the column name for the primary key
@@ -56,7 +56,7 @@ public function getAuthPassword(): string
5656
/**
5757
* Get the token value for the "remember me" session.
5858
*/
59-
public function getRememberToken(): string
59+
public function getRememberToken(): string|null
6060
{
6161
return $this->rememberToken;
6262
}

src/Console/EntityManagerProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
use Doctrine\ORM\EntityManagerInterface;
88
use Doctrine\ORM\Tools\Console\EntityManagerProvider as DoctrineEntityManagerProvider;
99
use Doctrine\Persistence\ManagerRegistry;
10+
use Illuminate\Contracts\Container\Container;
1011

1112
use function assert;
1213

1314
class EntityManagerProvider implements DoctrineEntityManagerProvider
1415
{
15-
public function __construct(private ManagerRegistry $managerRegistry)
16+
public function __construct(private Container $container)
1617
{
1718
}
1819

1920
public function getDefaultManager(): EntityManagerInterface
2021
{
21-
$entityManager = $this->managerRegistry->getManager();
22+
$entityManager = $this->container->make(ManagerRegistry::class)->getManager();
2223

2324
assert($entityManager instanceof EntityManagerInterface);
2425

@@ -27,7 +28,7 @@ public function getDefaultManager(): EntityManagerInterface
2728

2829
public function getManager(string $name): EntityManagerInterface
2930
{
30-
$entityManager = $this->managerRegistry->getManager($name);
31+
$entityManager = $this->container->make(ManagerRegistry::class)->getManager($name);
3132

3233
assert($entityManager instanceof EntityManagerInterface);
3334

src/DoctrineServiceProvider.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131
use LaravelDoctrine\ORM\Exceptions\ExtensionNotFound;
3232
use LaravelDoctrine\ORM\Extensions\ExtensionManager;
3333
use LaravelDoctrine\ORM\Notifications\DoctrineChannel;
34+
use LaravelDoctrine\ORM\Testing\Factory as EntityFactory;
3435
use LaravelDoctrine\ORM\Validation\PresenceVerifierProvider;
3536

3637
use function assert;
3738
use function class_exists;
3839
use function config;
3940
use function config_path;
41+
use function database_path;
42+
use function fake;
4043

4144
class DoctrineServiceProvider extends ServiceProvider
4245
{
@@ -68,6 +71,7 @@ public function register(): void
6871
$this->registerExtensions();
6972
$this->registerConsoleCommands();
7073
$this->registerCustomTypes();
74+
$this->registerEntityFactory();
7175
$this->registerProxyAutoloader();
7276

7377
if (! $this->shouldRegisterDoctrinePresenceValidator()) {
@@ -270,6 +274,20 @@ public function extendNotificationChannel(): void
270274
});
271275
}
272276

277+
/**
278+
* Register the Entity factory instance in the container.
279+
*/
280+
protected function registerEntityFactory(): void
281+
{
282+
$this->app->singleton(EntityFactory::class, static function ($app) {
283+
return EntityFactory::construct(
284+
fake(),
285+
$app->make('registry'),
286+
database_path('factories'),
287+
);
288+
});
289+
}
290+
273291
/**
274292
* Register proxy autoloader
275293
*/

src/IlluminateRegistry.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function getDefaultConnectionName(): string
9090
*
9191
* @param string $name The connection name (null for the default one).
9292
*/
93-
public function getConnection(string|null $name = null): mixed
93+
public function getConnection(string|null $name = null): object
9494
{
9595
$name = $name ?: $this->getDefaultConnectionName();
9696

@@ -156,7 +156,7 @@ public function getDefaultManagerName(): string
156156
*
157157
* @param string $name The object manager name (null for the default one).
158158
*/
159-
public function getManager(string|null $name = null): mixed
159+
public function getManager(string|null $name = null): ObjectManager
160160
{
161161
$name ??= $this->getDefaultManagerName();
162162

@@ -260,7 +260,7 @@ public function purgeManager(string|null $name = null): void
260260
*
261261
* @param string|null $name The object manager name (null for the default one).
262262
*/
263-
public function resetManager(string|null $name = null): mixed
263+
public function resetManager(string|null $name = null): ObjectManager
264264
{
265265
$this->closeManager($name);
266266

src/Notifications/DoctrineChannel.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Doctrine\Persistence\ManagerRegistry;
88
use Illuminate\Notifications\Notification as LaravelNotification;
9+
use InvalidArgumentException;
910
use LaravelDoctrine\ORM\Exceptions\NoEntityManagerFound;
1011
use RuntimeException;
1112

@@ -25,9 +26,13 @@ public function send(mixed $notifiable, LaravelNotification $notification): void
2526
$entity = $this->getEntity($notifiable, $notification);
2627

2728
if (method_exists($notifiable, 'routeNotificationForDoctrine')) {
28-
$em = $this->registry->getManager(
29-
$notifiable->routeNotificationFor('doctrine', $notification),
30-
);
29+
try {
30+
$em = $this->registry->getManager(
31+
$notifiable->routeNotificationFor('doctrine', $notification),
32+
);
33+
} catch (InvalidArgumentException) {
34+
$em = null;
35+
}
3136
} else {
3237
$em = $this->registry->getManagerForClass($entity::class);
3338
}

0 commit comments

Comments
 (0)