Skip to content

Commit

Permalink
Merge pull request #549 from eigan/handle-deprecations
Browse files Browse the repository at this point in the history
Handle deprecations
  • Loading branch information
eigan authored May 8, 2023
2 parents 032a639 + a22e68a commit ad94c82
Show file tree
Hide file tree
Showing 29 changed files with 94 additions and 918 deletions.
19 changes: 19 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ We recommend using eloquent instead.

This release supports a minimum doctrine/orm version of 2.14 due to a number of deprecations and new features that we are taking advantage of.


## Proxy namespace required
You must now set a namespace for your proxies. Use the configuration option `proxies.namespace`. the previous default value was `DoctrineProxies`.

Expand Down Expand Up @@ -41,3 +42,21 @@ is removed in Doctrine.
## Short namespaces

Short namespaces such as `Entities:User` are no longer supported by Doctrine and have been removed.

## Metadata driver `config` removed
Used deprecated YamlDriver and was not supported by doctrine.

## Logging configuration changed
DBAL deprecated the SQLLogger functionality in favor of the new middleware functionality.
Logging moved to the new middlewares section.
```php
'middlewares' => [
\LaravelDoctrine\ORM\Loggers\FileLogger::class
],
```

### Clockwork logger removed
Out of scope for this package.

### Laravel debugbar logger removed
Laravel debugbar does not support the new Middleware to Doctrine. Open for PR to re-add this functionality.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"phpunit/phpunit": "^9.3",
"mockery/mockery": "^1.3.1",
"barryvdh/laravel-debugbar": "~3.0",
"itsgoingd/clockwork": "^5.0",
"illuminate/log": "^9.0",
"illuminate/notifications": "^9.0",
"illuminate/queue": "^9.0",
"phpstan/phpstan": "^1.9"
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-deprecation-rules": "^1.1"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 14 additions & 14 deletions config/doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| paths setting to the appropriate path and replace App namespace
| by your own namespace.
|
| Available meta drivers: attributes|fluent|annotations|yaml|simplified_yaml|xml|simplified_xml|config|static_php|php
| Available meta drivers: attributes|fluent|xml|simplified_xml|static_php|php
|
| Available connections: mysql|oracle|pgsql|sqlite|sqlsrv
| (Connections can be configured in the database config)
Expand All @@ -32,12 +32,15 @@
'paths' => [
base_path('app/Entities')
],

'repository' => Doctrine\ORM\EntityRepository::class,

'proxies' => [
'namespace' => 'DoctrineProxies',
'path' => storage_path('proxies'),
'auto_generate' => env('DOCTRINE_PROXY_AUTOGENERATE', false)
],

/*
|--------------------------------------------------------------------------
| Doctrine events
Expand All @@ -51,7 +54,9 @@
'listeners' => [],
'subscribers' => []
],

'filters' => [],

/*
|--------------------------------------------------------------------------
| Doctrine mapping types
Expand All @@ -76,6 +81,14 @@
*/
'mapping_types' => [
//'enum' => 'string'
],

/**
* References:
* https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/architecture.html#middlewares
*/
'middlewares' => [
// Doctrine\DBAL\Logging\Middleware::class
]
]
],
Expand Down Expand Up @@ -140,19 +153,6 @@
],
/*
|--------------------------------------------------------------------------
| Enable query logging with laravel file logging,
| debugbar, clockwork or an own implementation.
| Setting it to false, will disable logging
|
| Available:
| - LaravelDoctrine\ORM\Loggers\LaravelDebugbarLogger
| - LaravelDoctrine\ORM\Loggers\ClockworkLogger
| - LaravelDoctrine\ORM\Loggers\FileLogger
|--------------------------------------------------------------------------
*/
'logger' => env('DOCTRINE_LOGGER', false),
/*
|--------------------------------------------------------------------------
| Cache
|--------------------------------------------------------------------------
|
Expand Down
113 changes: 18 additions & 95 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ parameters:
count: 1
path: src/Auth/DoctrineUserProvider.php

-
message: "#^Cannot call method fetch\\(\\) on Doctrine\\\\DBAL\\\\Result\\|int\\|string\\.$#"
count: 2
path: src/Auth/Passwords/DoctrineTokenRepository.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Auth\\\\Passwords\\\\DoctrineTokenRepository\\:\\:__construct\\(\\) has parameter \\$throttle with no type specified\\.$#"
count: 1
path: src/Auth/Passwords/DoctrineTokenRepository.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Auth\\\\Passwords\\\\DoctrineTokenRepository\\:\\:deleteExisting\\(\\) should return int but returns Doctrine\\\\DBAL\\\\Result\\|int\\|string\\.$#"
count: 1
path: src/Auth/Passwords/DoctrineTokenRepository.php

-
message: "#^Cannot access offset 'config' on Illuminate\\\\Contracts\\\\Foundation\\\\Application\\.$#"
count: 1
Expand Down Expand Up @@ -325,41 +315,6 @@ parameters:
count: 1
path: src/Configuration/MetaData/Attributes.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Configuration\\\\MetaData\\\\Config\\:\\:resolve\\(\\) has parameter \\$settings with no value type specified in iterable type array\\.$#"
count: 1
path: src/Configuration/MetaData/Config.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Configuration\\\\MetaData\\\\Config\\\\ConfigDriver\\:\\:__construct\\(\\) has parameter \\$mappings with no value type specified in iterable type array\\.$#"
count: 1
path: src/Configuration/MetaData/Config/ConfigDriver.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Configuration\\\\MetaData\\\\Config\\\\ConfigDriver\\:\\:getAllClassNames\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Configuration/MetaData/Config/ConfigDriver.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Configuration\\\\MetaData\\\\Config\\\\ConfigDriver\\:\\:getElement\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Configuration/MetaData/Config/ConfigDriver.php

-
message: "#^PHPDoc tag @throws with type LaravelDoctrine\\\\ORM\\\\Configuration\\\\MetaData\\\\Config\\\\MappingException is not subtype of Throwable$#"
count: 1
path: src/Configuration/MetaData/Config/ConfigDriver.php

-
message: "#^Property LaravelDoctrine\\\\ORM\\\\Configuration\\\\MetaData\\\\Config\\\\ConfigDriver\\:\\:\\$mappings type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Configuration/MetaData/Config/ConfigDriver.php

-
message: "#^Return type \\(array\\) of method LaravelDoctrine\\\\ORM\\\\Configuration\\\\MetaData\\\\Config\\\\ConfigDriver\\:\\:getElement\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\<object\\>\\) of method Doctrine\\\\Persistence\\\\Mapping\\\\Driver\\\\FileDriver\\:\\:getElement\\(\\)$#"
count: 1
path: src/Configuration/MetaData/Config/ConfigDriver.php

-
message: "#^Call to method setFluentFactory\\(\\) on an unknown class LaravelDoctrine\\\\Fluent\\\\FluentDriver\\.$#"
count: 1
Expand Down Expand Up @@ -495,6 +450,11 @@ parameters:
count: 1
path: src/Console/DumpDatabaseCommand.php

-
message: "#^Class LaravelDoctrine\\\\ORM\\\\Console\\\\EnsureProductionSettingsCommand extends deprecated class Doctrine\\\\ORM\\\\Tools\\\\Console\\\\Command\\\\EnsureProductionSettingsCommand\\.$#"
count: 1
path: src/Console/EnsureProductionSettingsCommand.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\DoctrineExtender\\:\\:extend\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -600,6 +560,11 @@ parameters:
count: 1
path: src/DoctrineServiceProvider.php

-
message: "#^Fetching class constant class of deprecated class LaravelDoctrine\\\\ORM\\\\Console\\\\EnsureProductionSettingsCommand\\.$#"
count: 1
path: src/DoctrineServiceProvider.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\DoctrineServiceProvider\\:\\:boot\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -825,11 +790,6 @@ parameters:
count: 1
path: src/EntityManagerFactory.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\EntityManagerFactory\\:\\:setLogger\\(\\) has no return type specified\\.$#"
count: 1
path: src/EntityManagerFactory.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\EntityManagerFactory\\:\\:setMetadataDriver\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -1015,6 +975,14 @@ parameters:
count: 1
path: src/IlluminateRegistry.php

-
message: """
#^Call to method fromNamespaceAlias\\(\\) of deprecated class Doctrine\\\\ORM\\\\Exception\\\\UnknownEntityNamespace\\:
No replacement planned\\.$#
"""
count: 1
path: src/IlluminateRegistry.php

-
message: "#^Cannot call method getName\\(\\) on ReflectionClass\\|false\\.$#"
count: 1
Expand Down Expand Up @@ -1150,41 +1118,6 @@ parameters:
count: 1
path: src/IlluminateRegistry.php

-
message: "#^Access to an undefined property Doctrine\\\\DBAL\\\\Logging\\\\SQLLogger\\:\\:\\$queries\\.$#"
count: 1
path: src/Loggers/Clockwork/DoctrineDataSource.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\Clockwork\\\\DoctrineDataSource\\:\\:getDatabaseQueries\\(\\) has no return type specified\\.$#"
count: 1
path: src/Loggers/Clockwork/DoctrineDataSource.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\ClockworkLogger\\:\\:register\\(\\) has no return type specified\\.$#"
count: 1
path: src/Loggers/ClockworkLogger.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\Debugbar\\\\DoctrineCollector\\:\\:getWidgets\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Loggers/Debugbar/DoctrineCollector.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\File\\\\DoctrineFileLogger\\:\\:startQuery\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
path: src/Loggers/File/DoctrineFileLogger.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\File\\\\DoctrineFileLogger\\:\\:startQuery\\(\\) has parameter \\$types with no value type specified in iterable type array\\.$#"
count: 1
path: src/Loggers/File/DoctrineFileLogger.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\FileLogger\\:\\:register\\(\\) has no return type specified\\.$#"
count: 1
path: src/Loggers/FileLogger.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\Formatters\\\\FormatQueryKeywords\\:\\:format\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1240,16 +1173,6 @@ parameters:
count: 1
path: src/Loggers/Formatters/ReplaceQueryParams.php

-
message: "#^Call to an undefined method DebugBar\\\\DataCollector\\\\DataCollectorInterface\\:\\:getDebugStack\\(\\)\\.$#"
count: 1
path: src/Loggers/LaravelDebugbarLogger.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\LaravelDebugbarLogger\\:\\:register\\(\\) has no return type specified\\.$#"
count: 1
path: src/Loggers/LaravelDebugbarLogger.php

-
message: "#^Method LaravelDoctrine\\\\ORM\\\\Loggers\\\\Logger\\:\\:register\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
3 changes: 2 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ parameters:
message: '~^Function app not found.$~'

includes:
- phpstan-baseline.neon
- phpstan-baseline.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
10 changes: 5 additions & 5 deletions src/Auth/Passwords/DoctrineTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function create(CanResetPassword $user)
'token' => $this->hasher->make($token),
'date' => new Carbon('now')
])
->execute();
->executeStatement();

return $token;
}
Expand All @@ -125,7 +125,7 @@ protected function deleteExisting(CanResetPassword $user)
->delete($this->table)
->where('email = :email')
->setParameter('email', $user->getEmailForPasswordReset())
->execute();
->executeStatement();
}

/**
Expand All @@ -145,7 +145,7 @@ public function exists(CanResetPassword $user, $token)
->where('email = :email')
->setParameter('email', $email)
->setMaxResults(1)
->execute()->fetch();
->executeQuery()->fetchAssociative();

return $record
&& !$this->tokenExpired($record['created_at'])
Expand Down Expand Up @@ -178,7 +178,7 @@ public function recentlyCreatedToken(CanResetPassword $user)
->from($this->table)
->where('email = :email')
->setParameter('email', $user->getEmailForPasswordReset())
->execute()->fetch();
->executeQuery()->fetchAssociative();

return $record && $this->tokenRecentlyCreated($record['created_at']);
}
Expand Down Expand Up @@ -224,7 +224,7 @@ public function deleteExpired()
->delete($this->table)
->where('created_at < :expiredAt')
->setParameter('expiredAt', $expiredAt)
->execute();
->executeStatement();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Configuration/MetaData/Annotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Doctrine\ORM\ORMSetup;
use Illuminate\Support\Arr;

/**
* @deprecated
*/
class Annotations extends MetaData
{
/**
Expand Down
35 changes: 0 additions & 35 deletions src/Configuration/MetaData/Config.php

This file was deleted.

Loading

0 comments on commit ad94c82

Please sign in to comment.