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

fix cs to avoid deprecation in php 8.3 #867

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 9 additions & 8 deletions cli-config.doctrine_dbal.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
* Add instances of commands for eventual implementation specific commands to this array.
*/

$extraCommands = array();
$extraCommands = [];
$extraCommands[] = new \Jackalope\Tools\Console\Command\InitDoctrineDbalCommand();

$params = array(
$params = [
'driver' => 'pdo_mysql',
'host' => '127.0.0.1',
'user' => 'root',
'password' => '',
'dbname' => 'phpcr_odm_tests',
);
'charset' => 'utf8mb4',
];

$dbConn = \Doctrine\DBAL\DriverManager::getConnection($params);

Expand All @@ -31,7 +32,7 @@ if (isset($argv[1])
&& $argv[1] != 'help'
) {
$factory = new \Jackalope\RepositoryFactoryDoctrineDBAL();
$repository = $factory->getRepository(array('jackalope.doctrine_dbal_connection' => $dbConn));
$repository = $factory->getRepository(['jackalope.doctrine_dbal_connection' => $dbConn]);
$credentials = new \PHPCR\SimpleCredentials(null, null);
$session = $repository->login($credentials, $workspace);

Expand All @@ -44,11 +45,11 @@ if (isset($argv[1])

$dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config);

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
$helperSet = new \Symfony\Component\Console\Helper\HelperSet([
'phpcr' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session),
'phpcr_console_dumper' => new \PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper(),
'dm' => new \Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper(null, $dm),
));
]);

if (class_exists('Symfony\Component\Console\Helper\QuestionHelper')) {
$helperSet->set(new \Symfony\Component\Console\Helper\QuestionHelper(), 'question');
Expand All @@ -57,7 +58,7 @@ if (isset($argv[1])
}
} elseif (isset($argv[1]) && $argv[1] == 'jackalope:init:dbal') {
// special case: the init command needs the db connection, but a session is impossible if the db is not yet initialized
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
$helperSet = new \Symfony\Component\Console\Helper\HelperSet([
'connection' => new \Jackalope\Tools\Console\Helper\DoctrineDbalHelper($dbConn)
));
]);
}
10 changes: 5 additions & 5 deletions cli-config.jackrabbit.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Add instances of commands for eventual implementation specific commands to this array.
*/

$extraCommands = array();
$extraCommands = [];
$extraCommands[] = new \Jackalope\Tools\Console\Command\JackrabbitCommand();

if (! isset($argv[1])
Expand All @@ -19,9 +19,9 @@ if (! isset($argv[1])
return;
}

$params = array(
$params = [
'jackalope.jackrabbit_uri' => 'http://127.0.0.1:8080/server/',
);
];

$workspace = 'default';
$user = 'admin';
Expand All @@ -42,11 +42,11 @@ $config->setMetadataDriverImpl($driver);

$dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config);

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
$helperSet = new \Symfony\Component\Console\Helper\HelperSet([
'phpcr' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session),
'phpcr_console_dumper' => new \PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper(),
'dm' => new \Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper(null, $dm),
));
]);

if (class_exists('Symfony\Component\Console\Helper\QuestionHelper')) {
$helperSet->set(new \Symfony\Component\Console\Helper\QuestionHelper(), 'question');
Expand Down
16 changes: 8 additions & 8 deletions docs/en/cookbook/custom_documentclass_mapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ custom mapper::

/* prepare the doctrine configuration */
$config = new \Doctrine\ODM\PHPCR\Configuration();
$map = array(
$map = [
'standard-templating-kit:pages/stkSection' => \Sandbox\MagnoliaBundle\Document\Section::class,
);
];
$mapper = new MagnoliaDocumentClassMapper($map);
$config->setDocumentClassMapper($mapper);

Expand Down Expand Up @@ -125,18 +125,18 @@ of instantiating the default one. An example from the `symfony cmf sandbox`_

$container
->register('doctrine.odm_configuration', '%doctrine_phpcr.odm.configuration.class%')
->addMethodCall('setDocumentClassMapper', array(
->addMethodCall('setDocumentClassMapper', [
new Reference('sandbox_magnolia.odm_mapper'),
))
])
;

$container ->setDefinition('sandbox_amgnolia.odm_mapper', new Definition(
MagnoliaDocumentClassMapper::class,
array(
array(
[
[
'standard-templating-kit:pages/stkSection' => Section::class,
),
),
],
],
));

.. _`symfony cmf sandbox`: https://github.com/symfony-cmf/cmf-sandbox/tree/magnolia_integration
2 changes: 2 additions & 0 deletions docs/en/reference/installation-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Bootstrap will roughly look like this when using mysql as storage backend::
'user' => $user,
'password' => $pass,
'dbname' => 'phpcr_odm_tutorial',
'charset' => 'utf8mb4', // only when using MySQL
];

// Bootstrap Doctrine DBAL
Expand Down Expand Up @@ -253,6 +254,7 @@ A complete configuration could look like this::
'user' => $user,
'password' => $pass,
'dbname' => 'phpcr_odm_tutorial',
'charset' => 'utf8mb4',
];
$dbConn = \Doctrine\DBAL\DriverManager::getConnection($params);
$parameters = ['jackalope.doctrine_dbal_connection' => $dbConn];
Expand Down
1 change: 1 addition & 0 deletions docs/en/reference/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ your project root directory::
'user' => 'root',
'password' => '',
'dbname' => 'phpcr_odm_tutorial',
'charset' => 'utf8mb4',
];

$workspace = 'default';
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/ChildrenCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ChildrenCollection extends PersistentCollection
* @param int $fetchDepth Optional fetch depth, -1 to not override
* @param string|null $locale The locale to use during the loading of this collection
*/
public function __construct(DocumentManagerInterface $dm, object $document, array|string $filter = null, int $fetchDepth = -1, string $locale = null)
public function __construct(DocumentManagerInterface $dm, object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null)
{
parent::__construct($dm);
$this->document = $document;
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder
return $this->wrapped->createPhpcrQueryBuilder();
}

public function getDocumentsByPhpcrQuery(QueryInterface $query, string $className = null, string $primarySelector = null): Collection
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection
{
return $this->wrapped->getDocumentsByPhpcrQuery($query, $className, $primarySelector);
}
Expand Down Expand Up @@ -168,17 +168,17 @@ public function reorder(object $document, string $srcName, string $targetName, b
$this->wrapped->reorder($document, $srcName, $targetName, $before);
}

public function getChildren(object $document, array|string $filter = null, int $fetchDepth = -1, string $locale = null): ChildrenCollection
public function getChildren(object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null): ChildrenCollection
{
return $this->wrapped->getChildren($document, $filter, $fetchDepth, $locale);
}

public function getReferrers(object $document, string $type = null, string $name = null, string $locale = null, string $refClass = null): ReferrersCollection
public function getReferrers(object $document, ?string $type = null, ?string $name = null, ?string $locale = null, ?string $refClass = null): ReferrersCollection
{
return $this->wrapped->getReferrers($document, $type, $name, $locale, $refClass);
}

public function flush(object|array $document = null): void
public function flush(object|array|null $document = null): void
{
$this->wrapped->flush($document);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class DocumentClassMapper implements DocumentClassMapperInterface
{
private function expandClassName(DocumentManagerInterface $dm, string $className = null): ?string
private function expandClassName(DocumentManagerInterface $dm, ?string $className = null): ?string
{
if (null === $className) {
return null;
Expand All @@ -26,7 +26,7 @@ private function expandClassName(DocumentManagerInterface $dm, string $className
return $className;
}

public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, string $className = null): string
public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, ?string $className = null): string
{
$className = $this->expandClassName($dm, $className);

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/DocumentClassMapperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface DocumentClassMapperInterface
* @throws ClassMismatchException if $node represents a class that is not
* a descendant of $className
*/
public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, string $className = null): string;
public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, ?string $className = null): string;

/**
* Write any relevant meta data into the node to be able to map back to a class name later.
Expand Down
12 changes: 6 additions & 6 deletions lib/Doctrine/ODM/PHPCR/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DocumentManager implements DocumentManagerInterface
private LocaleChooserInterface $localeChooserStrategy;
private ValueConverter $valueConverter;

public function __construct(SessionInterface $session, Configuration $config = null, EventManager $evm = null)
public function __construct(SessionInterface $session, ?Configuration $config = null, ?EventManager $evm = null)
{
$this->session = $session;
$this->config = $config ?: new Configuration();
Expand Down Expand Up @@ -136,7 +136,7 @@ public function getPhpcrSession(): SessionInterface
/**
* Factory method to create a Document Manager.
*/
public static function create(SessionInterface $session, Configuration $config = null, EventManager $evm = null): DocumentManager
public static function create(SessionInterface $session, ?Configuration $config = null, ?EventManager $evm = null): DocumentManager
{
return new self($session, $config, $evm);
}
Expand Down Expand Up @@ -342,7 +342,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder
return new PhpcrQueryBuilder($qm->getQOMFactory());
}

public function getDocumentsByPhpcrQuery(QueryInterface $query, string $className = null, string $primarySelector = null): Collection
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection
{
$this->errorIfClosed();

Expand Down Expand Up @@ -504,14 +504,14 @@ public function refresh($document): void
$this->unitOfWork->refresh($document);
}

public function getChildren(object $document, array|string $filter = null, int $fetchDepth = -1, string $locale = null): ChildrenCollection
public function getChildren(object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null): ChildrenCollection
{
$this->errorIfClosed();

return new ChildrenCollection($this, $document, $filter, $fetchDepth, $locale);
}

public function getReferrers(object $document, string $type = null, string $name = null, string $locale = null, $refClass = null): ReferrersCollection
public function getReferrers(object $document, ?string $type = null, ?string $name = null, ?string $locale = null, $refClass = null): ReferrersCollection
{
$this->errorIfClosed();

Expand All @@ -530,7 +530,7 @@ public function getReferrers(object $document, string $type = null, string $name
* @throws InvalidArgumentException if $document is neither null nor a
* document or an array of documents
*/
public function flush(object|array $document = null): void
public function flush(object|array|null $document = null): void
{
if (null !== $document && !is_object($document) && !is_array($document)) {
throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder;
* @param string|null $className document class
* @param string|null $primarySelector name of the selector for the document to return in case of a join query
*/
public function getDocumentsByPhpcrQuery(QueryInterface $query, string $className = null, string $primarySelector = null): Collection;
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection;

/**
* Bind the translatable fields of the document in the specified locale.
Expand Down Expand Up @@ -331,7 +331,7 @@ public function reorder(object $document, string $srcName, string $targetName, b
*
* @throws InvalidArgumentException if $document is not an object
*/
public function getChildren(object $document, array|string $filter = null, int $fetchDepth = -1, string $locale = null): ChildrenCollection;
public function getChildren(object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null): ChildrenCollection;

/**
* Get the documents that refer a given document using an optional name.
Expand All @@ -353,7 +353,7 @@ public function getChildren(object $document, array|string $filter = null, int $
*
* @throws InvalidArgumentException if $document is not an object
*/
public function getReferrers(object $document, string $type = null, string $name = null, string $locale = null, string $refClass = null): ReferrersCollection;
public function getReferrers(object $document, ?string $type = null, ?string $name = null, ?string $locale = null, ?string $refClass = null): ReferrersCollection;

/**
* Gets a reference to the document identified by the given type and identifier
Expand Down Expand Up @@ -480,7 +480,7 @@ public function getUnitOfWork(): UnitOfWork;
* @throws InvalidArgumentException if $document is neither null nor a
* document or an array of documents
*/
public function flush(object|array $document = null): void;
public function flush(object|array|null $document = null): void;

/**
* Closes the DocumentManager. All entities that are currently managed
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/DocumentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function findAll(): Collection
*
* @return Collection the objects matching the criteria
*/
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): Collection
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): Collection
{
$qb = $this->createQueryBuilder('a');

Expand Down Expand Up @@ -199,7 +199,7 @@ public function getClassMetadata(): ClassMetadata
*
* @see \PHPCR\PropertyType
*/
public function quote(string $val, int $type = null): string
public function quote(string $val, ?int $type = null): string
{
return $this->dm->quote($val, $type);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Id/AssignedIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AssignedIdGenerator extends IdGenerator
*
* {@inheritdoc}
*/
public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string
public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string
{
if (!$class->identifier || !$id = $class->getFieldValue($document, $class->identifier)) {
throw new IdException('ID could not be read from the document instance using the AssignedIdGenerator.');
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Id/AutoIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AutoIdGenerator extends ParentIdGenerator
*
* {@inheritdoc}
*/
public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string
public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string
{
if (null === $parent) {
$parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null;
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Id/IdException.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function parentIdCouldNotBeDetermined(object $document, string $pa
return new self($message);
}

public static function illegalName(object $document, string $fieldName, string $nodeName, \Throwable $previous = null): self
public static function illegalName(object $document, string $fieldName, string $nodeName, ?\Throwable $previous = null): self
{
$message = sprintf(
'Nodename property "%s" of document "%s" contains the illegal PHPCR value "%s".',
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Id/IdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ public static function create(int $generatorType): IdGenerator
/**
* Generate the actual id, to be overwritten by extending classes.
*/
abstract public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string;
abstract public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string;
}
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Id/ParentIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ParentIdGenerator extends IdGenerator
*
* {@inheritdoc}
*/
public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string
public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string
{
if (null === $parent) {
$parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null;
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Id/RepositoryIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RepositoryIdGenerator extends IdGenerator
*
* {@inheritdoc}
*/
public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string
public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string
{
if (null === $parent) {
$parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null;
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Id/RepositoryIdInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
*/
interface RepositoryIdInterface
{
public function generateId(object $document, object $parent = null): string;
public function generateId(object $document, ?object $parent = null): string;
}
6 changes: 3 additions & 3 deletions lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#[\Attribute(\Attribute::TARGET_PROPERTY)]
final class Child implements MappingAttribute
{
public array|null $cascade;
public ?array $cascade;

/**
* @param string[]|string $cascade
*/
public function __construct(
public null|string $nodeName = null,
array|string $cascade = null,
public ?string $nodeName = null,
array|string|null $cascade = null,
) {
$this->cascade = null === $cascade ? null : (array) $cascade;
}
Expand Down
Loading
Loading