Skip to content

Commit

Permalink
Merge pull request #2571 from doctrine/2.5.x-merge-up-into-2.6.x_Igo5…
Browse files Browse the repository at this point in the history
…0bIR

Merge release 2.5.4 into 2.6.x
  • Loading branch information
malarzm authored Nov 4, 2023
2 parents b7c7838 + 990a35c commit a79db39
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 46 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
4 changes: 1 addition & 3 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@3.0.0"
with:
php-version: "8.2"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@3.1.0"
7 changes: 4 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
php-version:
- "8.1"
- "8.2"
- "8.3"
mongodb-version:
- "6.0"
- "5.0"
Expand Down Expand Up @@ -53,7 +54,7 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
with:
fetch-depth: 2

Expand All @@ -66,7 +67,7 @@ jobs:
key: "extcache-v1"

- name: Cache extensions
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
Expand Down Expand Up @@ -106,7 +107,7 @@ jobs:
composer-options: "--prefer-dist"

- name: "Upload composer.lock as build artifact"
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: composer.lock
path: composer.lock
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
performance-tests:
name: "Performance Tests"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"

strategy:
matrix:
Expand All @@ -24,7 +24,7 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: Setup cache environment
id: extcache
Expand All @@ -35,7 +35,7 @@ jobs:
key: "extcache-v1"

- name: Cache extensions
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
release:
name: "Git tag, release & create merge-up PR"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.4.1"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@3.1.0"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"

strategy:
matrix:
Expand All @@ -19,7 +19,7 @@ jobs:

steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: Setup cache environment
id: extcache
Expand All @@ -30,7 +30,7 @@ jobs:
key: "extcache-v1"

- name: Cache extensions
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
Expand Down Expand Up @@ -60,16 +60,16 @@ jobs:

static-analysis-psalm:
name: "Static Analysis with Psalm"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"

strategy:
matrix:
php-version:
- "8.1"
- "8.2"

steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"require-dev": {
"ext-bcmath": "*",
"doctrine/coding-standard": "^11.0",
"doctrine/coding-standard": "^12.0",
"jmikola/geojson": "^1.0",
"phpbench/phpbench": "^1.0.0",
"phpstan/phpstan": "^1.10.11",
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Iterator/CachingIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public function __construct(Traversable $iterator)
/** @see https://php.net/countable.count */
public function count(): int
{
$currentKey = key($this->items);
$this->exhaustIterator();
for (reset($this->items); key($this->items) !== $currentKey; next($this->items));

return count($this->items);
}
Expand Down
28 changes: 14 additions & 14 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public function loadMetadataForClass($className, \Doctrine\Persistence\Mapping\C
$metadata->setDefaultDiscriminatorValue((string) $xmlRoot->{'default-discriminator-value'}['value']);
}

if (isset($xmlRoot->{'indexes'})) {
foreach ($xmlRoot->{'indexes'}->{'index'} as $index) {
if (isset($xmlRoot->indexes)) {
foreach ($xmlRoot->indexes->index as $index) {
$this->addIndex($metadata, $index);
}
}
Expand Down Expand Up @@ -475,15 +475,15 @@ private function addReferenceMapping(ClassMetadata $class, ?SimpleXMLElement $re
$mapping['defaultDiscriminatorValue'] = (string) $reference->{'default-discriminator-value'}['value'];
}

if (isset($reference->{'sort'})) {
foreach ($reference->{'sort'}->{'sort'} as $sort) {
if (isset($reference->sort)) {
foreach ($reference->sort->sort as $sort) {
$attr = $sort->attributes();
$mapping['sort'][(string) $attr['field']] = (string) ($attr['order'] ?? 'asc');
}
}

if (isset($reference->{'criteria'})) {
foreach ($reference->{'criteria'}->{'criteria'} as $criteria) {
if (isset($reference->criteria)) {
foreach ($reference->criteria->criteria as $criteria) {
$attr = $criteria->attributes();
$mapping['criteria'][(string) $attr['field']] = (string) $attr['value'];
}
Expand All @@ -497,8 +497,8 @@ private function addReferenceMapping(ClassMetadata $class, ?SimpleXMLElement $re
$mapping['alsoLoadFields'] = explode(',', (string) $attributes['also-load']);
}

if (isset($reference->{'prime'})) {
foreach ($reference->{'prime'}->{'field'} as $field) {
if (isset($reference->prime)) {
foreach ($reference->prime->field as $field) {
$attr = $field->attributes();
$mapping['prime'][] = (string) $attr['name'];
}
Expand All @@ -514,7 +514,7 @@ private function addIndex(ClassMetadata $class, SimpleXMLElement $xmlIndex): voi

$keys = [];

foreach ($xmlIndex->{'key'} as $key) {
foreach ($xmlIndex->key as $key) {
$keys[(string) $key['name']] = (string) ($key['order'] ?? 'asc');
}

Expand All @@ -536,8 +536,8 @@ private function addIndex(ClassMetadata $class, SimpleXMLElement $xmlIndex): voi
$options['unique'] = ((string) $attributes['unique'] === 'true');
}

if (isset($xmlIndex->{'option'})) {
foreach ($xmlIndex->{'option'} as $option) {
if (isset($xmlIndex->option)) {
foreach ($xmlIndex->option as $option) {
$options[(string) $option['name']] = $this->convertXMLElementValue((string) $option['value']);
}
}
Expand Down Expand Up @@ -636,7 +636,7 @@ private function setShardKey(ClassMetadata $class, SimpleXMLElement $xmlShardkey

$keys = [];
$options = [];
foreach ($xmlShardkey->{'key'} as $key) {
foreach ($xmlShardkey->key as $key) {
$keys[(string) $key['name']] = (string) ($key['order'] ?? 'asc');
}

Expand All @@ -648,8 +648,8 @@ private function setShardKey(ClassMetadata $class, SimpleXMLElement $xmlShardkey
$options['numInitialChunks'] = (int) $attributes['numInitialChunks'];
}

if (isset($xmlShardkey->{'option'})) {
foreach ($xmlShardkey->{'option'} as $option) {
if (isset($xmlShardkey->option)) {
foreach ($xmlShardkey->option as $option) {
$options[(string) $option['name']] = $this->convertXMLElementValue((string) $option['value']);
}
}
Expand Down
16 changes: 8 additions & 8 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@
<InvalidPropertyFetch>
<code><![CDATA[$xmlRoot->field]]></code>
<code><![CDATA[$xmlRoot->id]]></code>
<code><![CDATA[$xmlRoot->indexes]]></code>
<code><![CDATA[$xmlRoot->{'also-load-methods'}]]></code>
<code><![CDATA[$xmlRoot->{'default-discriminator-value'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-field'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-map'}]]></code>
<code><![CDATA[$xmlRoot->{'embed-many'}]]></code>
<code><![CDATA[$xmlRoot->{'embed-one'}]]></code>
<code><![CDATA[$xmlRoot->{'indexes'}]]></code>
<code><![CDATA[$xmlRoot->{'lifecycle-callbacks'}]]></code>
<code><![CDATA[$xmlRoot->{'read-preference'}]]></code>
<code><![CDATA[$xmlRoot->{'reference-many'}]]></code>
Expand All @@ -97,13 +97,13 @@
<NoInterfaceProperties>
<code><![CDATA[$xmlRoot->field]]></code>
<code><![CDATA[$xmlRoot->id]]></code>
<code><![CDATA[$xmlRoot->indexes]]></code>
<code><![CDATA[$xmlRoot->{'also-load-methods'}]]></code>
<code><![CDATA[$xmlRoot->{'default-discriminator-value'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-field'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-map'}]]></code>
<code><![CDATA[$xmlRoot->{'embed-many'}]]></code>
<code><![CDATA[$xmlRoot->{'embed-one'}]]></code>
<code><![CDATA[$xmlRoot->{'indexes'}]]></code>
<code><![CDATA[$xmlRoot->{'lifecycle-callbacks'}]]></code>
<code><![CDATA[$xmlRoot->{'read-preference'}]]></code>
<code><![CDATA[$xmlRoot->{'reference-many'}]]></code>
Expand All @@ -125,30 +125,30 @@
<code><![CDATA[isset($field->{'generator-option'})]]></code>
<code><![CDATA[isset($partialFilterExpressionMapping->and)]]></code>
<code><![CDATA[isset($partialFilterExpressionMapping->field)]]></code>
<code><![CDATA[isset($reference->{'criteria'})]]></code>
<code><![CDATA[isset($reference->criteria)]]></code>
<code><![CDATA[isset($reference->prime)]]></code>
<code><![CDATA[isset($reference->sort)]]></code>
<code><![CDATA[isset($reference->{'default-discriminator-value'})]]></code>
<code><![CDATA[isset($reference->{'discriminator-field'})]]></code>
<code><![CDATA[isset($reference->{'discriminator-map'})]]></code>
<code><![CDATA[isset($reference->{'prime'})]]></code>
<code><![CDATA[isset($reference->{'sort'})]]></code>
<code><![CDATA[isset($xmlIndex->{'option'})]]></code>
<code><![CDATA[isset($xmlIndex->option)]]></code>
<code><![CDATA[isset($xmlIndex->{'partial-filter-expression'})]]></code>
<code><![CDATA[isset($xmlReadPreference->{'tag-set'})]]></code>
<code><![CDATA[isset($xmlRoot->field)]]></code>
<code><![CDATA[isset($xmlRoot->id)]]></code>
<code><![CDATA[isset($xmlRoot->indexes)]]></code>
<code><![CDATA[isset($xmlRoot->{'default-discriminator-value'})]]></code>
<code><![CDATA[isset($xmlRoot->{'discriminator-field'})]]></code>
<code><![CDATA[isset($xmlRoot->{'discriminator-map'})]]></code>
<code><![CDATA[isset($xmlRoot->{'embed-many'})]]></code>
<code><![CDATA[isset($xmlRoot->{'embed-one'})]]></code>
<code><![CDATA[isset($xmlRoot->{'indexes'})]]></code>
<code><![CDATA[isset($xmlRoot->{'lifecycle-callbacks'})]]></code>
<code><![CDATA[isset($xmlRoot->{'read-preference'})]]></code>
<code><![CDATA[isset($xmlRoot->{'reference-many'})]]></code>
<code><![CDATA[isset($xmlRoot->{'reference-one'})]]></code>
<code><![CDATA[isset($xmlRoot->{'schema-validation'})]]></code>
<code><![CDATA[isset($xmlRoot->{'shard-key'})]]></code>
<code><![CDATA[isset($xmlShardkey->{'option'})]]></code>
<code><![CDATA[isset($xmlShardkey->option)]]></code>
</RedundantCondition>
<TypeDoesNotContainType>
<code><![CDATA[$xmlRoot->getName() === 'document']]></code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,32 @@ public function testToArrayAfterPartialIteration(): void
public function testCount(): void
{
$iterator = new CachingIterator($this->getTraversable([1, 2, 3]));
$this->assertCount(3, $iterator);
self::assertCount(3, $iterator);
}

public function testCountAfterPartialIteration(): void
{
$iterator = new CachingIterator($this->getTraversable([1, 2, 3]));

$iterator->rewind();
$this->assertTrue($iterator->valid());
$this->assertSame(0, $iterator->key());
$this->assertSame(1, $iterator->current());
self::assertTrue($iterator->valid());
self::assertSame(0, $iterator->key());
self::assertSame(1, $iterator->current());

$iterator->next();
$this->assertCount(3, $iterator);
self::assertSame(1, $iterator->key());
self::assertSame(2, $iterator->current());

self::assertCount(3, $iterator);
self::assertTrue($iterator->valid());
self::assertSame(1, $iterator->key());
self::assertSame(2, $iterator->current());
}

public function testCountWithEmptySet(): void
{
$iterator = new CachingIterator($this->getTraversable([]));
$this->assertCount(0, $iterator);
self::assertCount(0, $iterator);
}

/**
Expand Down Expand Up @@ -172,7 +178,7 @@ public function rewind(): void
};

$iterator = new CachingIterator($nestedIterator);
$this->assertCount(1, $iterator);
self::assertCount(1, $iterator);
}

/**
Expand Down

0 comments on commit a79db39

Please sign in to comment.