Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.x' into 1-to-2
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Dec 4, 2023
2 parents bd15044 + 05664fa commit 2619cc0
Show file tree
Hide file tree
Showing 87 changed files with 639 additions and 916 deletions.
16 changes: 8 additions & 8 deletions lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@

use Doctrine\ODM\PHPCR\HierarchyInterface;
use PHPCR\NodeInterface;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* This class represents an abstract "file".
*/
#[ODM\MappedSuperclass(mixins: ['mix:created'])]
#[PHPCR\MappedSuperclass(mixins: ['mix:created'])]
abstract class AbstractFile implements HierarchyInterface
{
#[ODM\Id(strategy: 'parent')]
#[PHPCR\Id(strategy: 'parent')]
protected string $id;

#[ODM\Node]
#[PHPCR\Node]
protected NodeInterface $node;

#[ODM\Nodename]
#[PHPCR\Nodename]
protected string $nodename = '';

#[ODM\ParentDocument]
#[PHPCR\ParentDocument]
protected ?object $parent;

#[ODM\Field(property: 'jcr:created', type: 'date')]
#[PHPCR\Field(property: 'jcr:created', type: 'date')]
protected ?\DateTimeInterface $created = null;

#[ODM\Field(property: 'jcr:createdBy', type: 'string')]
#[PHPCR\Field(property: 'jcr:createdBy', type: 'string')]
protected ?string $createdBy = null;

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ODM/PHPCR/Document/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
namespace Doctrine\ODM\PHPCR\Document;

use Doctrine\ODM\PHPCR\Exception\RuntimeException;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* This class represents a JCR file, aka nt:file.
*
* @see http://wiki.apache.org/jackrabbit/nt:file
*/
#[ODM\Document(nodeType: 'nt:file', mixins: [], referenceable: true)]
#[PHPCR\Document(nodeType: 'nt:file', mixins: [], referenceable: true)]
class File extends AbstractFile
{
#[ODM\Child(nodeName: 'jcr:content', cascade: 'all')]
#[PHPCR\Child(nodeName: 'jcr:content', cascade: 'all')]
protected Resource $content;

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ODM/PHPCR/Document/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\PHPCR\HierarchyInterface;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* This class represents a Folder in the repository, aka nt:folder.
Expand All @@ -15,16 +15,16 @@
* To add files or folders to a folder, create the new File/Folder and set
* this document as parent, then persist the new File/Folder.
*/
#[ODM\Document(nodeType: 'nt:folder', mixins: [])]
#[PHPCR\Document(nodeType: 'nt:folder', mixins: [])]
class Folder extends AbstractFile
{
/**
* @var Collection<HierarchyInterface>
*/
#[ODM\Children(cascade: 'all')]
#[PHPCR\Children(cascade: 'all')]
protected Collection $children;

#[ODM\Child(cascade: 'all')]
#[PHPCR\Child(cascade: 'all')]
protected AbstractFile $child;

public function __construct()
Expand Down
16 changes: 8 additions & 8 deletions lib/Doctrine/ODM/PHPCR/Document/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\PHPCR\Exception\BadMethodCallException;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;
use PHPCR\NodeInterface;

/**
Expand All @@ -14,34 +14,34 @@
* It is used as a default document, for example with the ParentDocument annotation.
* You can not use this to create nodes as it has no type annotation.
*/
#[ODM\Document]
#[PHPCR\Document]
class Generic
{
/**
* Id (path) of this document.
*/
#[ODM\Id(strategy: 'parent')]
#[PHPCR\Id(strategy: 'parent')]
protected string $id;

#[ODM\Node]
#[PHPCR\Node]
protected NodeInterface $node;

#[ODM\Nodename]
#[PHPCR\Nodename]
protected string $nodename = '';

#[ODM\ParentDocument]
#[PHPCR\ParentDocument]
protected object $parent;

/**
* @var Collection<object>
*/
#[ODM\Children]
#[PHPCR\Children]
protected Collection $children;

/**
* @var Collection<object>
*/
#[ODM\MixedReferrers]
#[PHPCR\MixedReferrers]
protected Collection $referrers;

public function __construct()
Expand Down
22 changes: 11 additions & 11 deletions lib/Doctrine/ODM/PHPCR/Document/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@
namespace Doctrine\ODM\PHPCR\Document;

use Doctrine\ODM\PHPCR\Exception\BadMethodCallException;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;
use PHPCR\NodeInterface;

/**
* This class represents a jcr nt:resource and is used by the File document.
*
* @see http://wiki.apache.org/jackrabbit/nt:resource
*/
#[ODM\Document(nodeType: 'nt:resource')]
#[PHPCR\Document(nodeType: 'nt:resource')]
class Resource
{ #[ODM\Id]
{ #[PHPCR\Id]
protected string $id;

/**
* @var NodeInterface
*/
#[ODM\Node]
#[PHPCR\Node]
protected NodeInterface $node;

#[ODM\Nodename]
#[PHPCR\Nodename]
protected string $nodename;

#[ODM\ParentDocument]
#[PHPCR\ParentDocument]
protected object $parent;

/**
* @var resource
*/
#[ODM\Field(property: 'jcr:data', type: 'binary')]
#[PHPCR\Field(property: 'jcr:data', type: 'binary')]
protected $data;

Check failure on line 35 in lib/Doctrine/ODM/PHPCR/Document/Resource.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Doctrine\ODM\PHPCR\Document\Resource referenced with incorrect case: Doctrine\ODM\PHPCR\Document\resource.

#[ODM\Field(property: 'jcr:mimeType', type: 'string')]
#[PHPCR\Field(property: 'jcr:mimeType', type: 'string')]
protected string $mimeType = 'application/octet-stream';

#[ODM\Field(property: 'jcr:encoding', type: 'string', nullable: true)]
#[PHPCR\Field(property: 'jcr:encoding', type: 'string', nullable: true)]
protected string $encoding;

#[ODM\Field(property: 'jcr:lastModified', type: 'date')]
#[PHPCR\Field(property: 'jcr:lastModified', type: 'date')]
protected \DateTimeInterface $lastModified;

#[ODM\Field(property: 'jcr:lastModifiedBy', type: 'string')]
#[PHPCR\Field(property: 'jcr:lastModifiedBy', type: 'string')]
protected string $lastModifiedBy;

/**
Expand Down
12 changes: 6 additions & 6 deletions lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public function __construct(
string $repositoryClass = null,
string $translator = null,
array $mixins = null,
bool $inheritMixins = true,
bool|null $inheritMixins = null,
string $versionable = null,
bool $referenceable = false,
bool $uniqueNodeType = false,
array $childClasses = [],
bool $isLeaf = false,
bool|null $referenceable = null,
bool|null $uniqueNodeType = null,
string|array|null $childClasses = null,
bool|null $isLeaf = null,
) {
$this->nodeType = $nodeType;
$this->repositoryClass = $repositoryClass;
Expand All @@ -28,7 +28,7 @@ public function __construct(
$this->versionable = $versionable;
$this->referenceable = $referenceable;
$this->uniqueNodeType = $uniqueNodeType;
$this->childClasses = $childClasses;
$this->childClasses = $childClasses ? (array) $childClasses : null;
$this->isLeaf = $isLeaf;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad
$metadata->setTranslator($documentAttribute->translator);
}

if ([] !== $documentAttribute->childClasses) {
if ($documentAttribute->childClasses) {
$metadata->setChildClasses($documentAttribute->childClasses);
}

Expand Down
9 changes: 4 additions & 5 deletions tests/Doctrine/Tests/Models/Blog/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@

namespace Doctrine\Tests\Models\Blog;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* Comment will be a child of the Post in the test scenario.
*
* Used for Join tests
*
* @PHPCRODM\Document()
*/
#[PHPCR\Document]
class Comment
{
/** @PHPCRODM\Id() */
#[PHPCR\Id]
public $id;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $title;
}
12 changes: 5 additions & 7 deletions tests/Doctrine/Tests/Models/Blog/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@

namespace Doctrine\Tests\Models\Blog;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* @PHPCRODM\Document()
*/
#[PHPCR\Document]
class Post
{
/** @PHPCRODM\Id() */
#[PHPCR\Id]
public $id;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $title;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $username;
}
16 changes: 7 additions & 9 deletions tests/Doctrine/Tests/Models/Blog/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@

namespace Doctrine\Tests\Models\Blog;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* @PHPCRODM\Document()
*/
#[PHPCR\Document]
class User
{
/** @PHPCRODM\Id() */
#[PHPCR\Id]
public $id;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $username;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $name;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $status;

/** @PHPCRODM\Field(type="long", nullable=true) */
#[PHPCR\Field(type: 'long', nullable: true)]
public $age;
}
20 changes: 8 additions & 12 deletions tests/Doctrine/Tests/Models/CMS/CmsAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,27 @@

use Doctrine\ODM\PHPCR\DocumentRepository;
use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface;
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsAddressRepository", referenceable=true)
*/
#[PHPCR\Document(repositoryClass: CmsAddressRepository::class, referenceable: true)]
class CmsAddress
{
/** @PHPCRODM\Id(strategy="repository") */
#[PHPCR\Id(strategy: 'repository')]
public $id;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $country;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $zip;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $city;

/** @PHPCRODM\ReferenceOne(targetDocument="CmsUser") */
#[PHPCR\ReferenceOne(targetDocument: CmsUser::class)]
public $user;

/**
* @PHPCRODM\Uuid
*/
#[PHPCR\Uuid]
public $uuid;

public function getId()
Expand Down
19 changes: 9 additions & 10 deletions tests/Doctrine/Tests/Models/CMS/CmsArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@
namespace Doctrine\Tests\Models\CMS;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;
use mysql_xdevapi\CrudOperationBindable;

/**
* @PHPCRODM\Document
*/
#[PHPCR\Document]
class CmsArticle
{
/** @PHPCRODM\Id */
#[PHPCR\Id]
public $id;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $topic;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $text;

/** @PHPCRODM\ReferenceOne(targetDocument="CmsUser") */
#[PHPCR\ReferenceOne(targetDocument: CmsUser::class)]
public $user;

public $comments;

/** @PHPCRODM\ReferenceMany(targetDocument="CmsArticlePerson") */
#[PHPCR\ReferenceMany(targetDocument: CmsArticlePerson::class)]
public $persons;

/** @PHPCRODM\Field(type="binary", nullable=true) */
#[PHPCR\Field(type: 'binary', nullable: true)]
public $attachments;

public function __construct()
Expand Down
Loading

0 comments on commit 2619cc0

Please sign in to comment.