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

Bump dep #416

Merged
merged 7 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ jobs:
strategy:
matrix:
php-version:
- '7.4'
- '8.0'
- '8.1'
dependencies: [highest]
allowed-to-fail: [false]
symfony-require: ['']
variant: [normal]
include:
- php-version: '7.4'
- php-version: '8.0'
dependencies: lowest
allowed-to-fail: false
variant: normal
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
],
"homepage": "https://github.com/sonata-project/sonata-doctrine-extensions",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"doctrine/dbal": "^2.13 || ^3.1",
Copy link
Member

Choose a reason for hiding this comment

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

we could also drop dbal 2

"doctrine/persistence": "^1.3.6 || ^2.0 || ^3.0"
"doctrine/persistence": "^2.0 || ^3.0"
},
"require-dev": {
"doctrine/common": "^2.7 || ^3.0",
Copy link
Member

Choose a reason for hiding this comment

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

this should be bumped too right?

Expand All @@ -41,9 +41,9 @@
"phpunit/phpunit": "^9.5.13",
"psalm/plugin-phpunit": "^0.16",
"rector/rector": "^0.12",
"symfony/dependency-injection": "^4.4 || ^5.3 || ^6.0",
"symfony/expression-language": "^4.4 || ^5.3 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.3 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/expression-language": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/phpunit-bridge": "^6.0",
"vimeo/psalm": "^4.1"
},
Expand All @@ -54,8 +54,8 @@
"doctrine/orm": "<2.5"
},
"suggest": {
"doctrine/mongodb-odm": "If you use mongo",
"doctrine/orm": "If you use doctrine orm",
"doctrine/phpcr-odm": "If you use doctrine phpcr",
"symfony/framework-bundle": "If you want to use symfony"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
]);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74,
LevelSetList::UP_TO_PHP_80,
]);

$rectorConfig->importNames();
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/AdapterChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AdapterChain implements AdapterInterface
/**
* @var AdapterInterface[]
*/
protected $adapters = [];
private $adapters = [];

public function addAdapter(AdapterInterface $adapter): void
{
Expand Down
10 changes: 2 additions & 8 deletions src/Adapter/ORM/DoctrineORMAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@
*/
class DoctrineORMAdapter implements AdapterInterface
{
/**
* @var ManagerRegistry
*/
protected $registry;

public function __construct(ManagerRegistry $registry)
public function __construct(private ManagerRegistry $registry)
{
$this->registry = $registry;
}

public function getNormalizedIdentifier($model)
Expand All @@ -53,7 +47,7 @@ public function getNormalizedIdentifier($model)
));
}

$manager = $this->registry->getManagerForClass(\get_class($model));
$manager = $this->registry->getManagerForClass($model::class);

if (!$manager instanceof EntityManagerInterface) {
return null;
Expand Down
12 changes: 3 additions & 9 deletions src/Adapter/PHPCR/DoctrinePHPCRAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@
*/
class DoctrinePHPCRAdapter implements AdapterInterface
{
/**
* @var ManagerRegistry
*/
protected $registry;

public function __construct(ManagerRegistry $registry)
public function __construct(private ManagerRegistry $registry)
{
$this->registry = $registry;
}

public function getNormalizedIdentifier($model)
Expand All @@ -62,7 +56,7 @@ public function getNormalizedIdentifier($model)
));
}

$manager = $this->registry->getManagerForClass(\get_class($model));
$manager = $this->registry->getManagerForClass($model::class);

if (!$manager instanceof DocumentManager) {
return null;
Expand All @@ -72,7 +66,7 @@ public function getNormalizedIdentifier($model)
return null;
}

$class = $manager->getClassMetadata(\get_class($model));
$class = $manager->getClassMetadata($model::class);

\assert($class instanceof ClassMetadata);

Expand Down
7 changes: 3 additions & 4 deletions src/Bridge/Symfony/Resources/config/doctrine_orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Sonata\Doctrine\Adapter\ORM\DoctrineORMAdapter;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// Use "service" function for creating references to services when dropping support for Symfony 4.4
$containerConfigurator->services()

->set('sonata.doctrine.adapter.doctrine_orm', DoctrineORMAdapter::class)
->args([
new ReferenceConfigurator('doctrine'),
service('doctrine'),
]);
};
7 changes: 3 additions & 4 deletions src/Bridge/Symfony/Resources/config/doctrine_phpcr.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Sonata\Doctrine\Adapter\PHPCR\DoctrinePHPCRAdapter;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// Use "service" function for creating references to services when dropping support for Symfony 4.4
$containerConfigurator->services()

->set('sonata.doctrine.adapter.doctrine_phpcr', DoctrinePHPCRAdapter::class)
->args([
new ReferenceConfigurator('doctrine_phpcr'),
service('doctrine_phpcr'),
]);
};
3 changes: 2 additions & 1 deletion src/Bridge/Symfony/Resources/config/mapper_orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Sonata\Doctrine\Mapper\ORM\DoctrineORMMapper;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->services()
Expand Down
3 changes: 2 additions & 1 deletion src/Bridge/Symfony/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Sonata\Doctrine\Adapter\AdapterChain;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->services()
Expand Down
6 changes: 1 addition & 5 deletions src/Mapper/Builder/OptionsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@ final class OptionsBuilder
*/
private array $options = [];

private ?string $type;

/**
* NEXT_MAJOR: Make the arguments mandatory.
*/
private function __construct(?string $type = null, ?string $fieldName = null, ?string $targetEntity = null)
private function __construct(private ?string $type = null, ?string $fieldName = null, ?string $targetEntity = null)
Copy link
Member

Choose a reason for hiding this comment

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

multiline

{
$this->type = $type;

if (null !== $fieldName) {
$this->options['fieldName'] = $fieldName;
}
Expand Down
3 changes: 0 additions & 3 deletions src/Mapper/DoctrineCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ private function __construct()
{
}

/**
* @return DoctrineCollector
*/
public static function getInstance(): self
{
if (null === self::$instance) {
Expand Down
22 changes: 5 additions & 17 deletions src/Model/BaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,13 @@
*/
abstract class BaseManager implements ManagerInterface, ClearableManagerInterface
{
/**
* @var ManagerRegistry
*/
protected $registry;

/**
* @var string
*
* @phpstan-var class-string<T>
*/
protected $class;

/**
* @phpstan-param class-string<T> $class
*/
public function __construct(string $class, ManagerRegistry $registry)
{
$this->registry = $registry;
$this->class = $class;
public function __construct(
protected string $class,
protected ManagerRegistry $registry
) {
}

/**
Expand Down Expand Up @@ -188,7 +176,7 @@ protected function checkObject($object): void
throw new \InvalidArgumentException(sprintf(
'Object must be instance of %s, %s given',
$this->class,
\is_object($object) ? \get_class($object) : \gettype($object)
get_debug_type($object)
));
}
}
Expand Down
7 changes: 1 addition & 6 deletions tests/App/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
]);
}

/**
* TODO: Add typehint when support for Symfony < 5.1 is dropped.
*
* @param RoutingConfigurator $routes
*/
protected function configureRoutes($routes): void
protected function configureRoutes(RoutingConfigurator $routes): void
{
}

Expand Down