Skip to content

Commit eafad05

Browse files
committed
Skip Pedentry method sort for generated files
1 parent bc7618d commit eafad05

File tree

2 files changed

+51
-40
lines changed

2 files changed

+51
-40
lines changed

src/Builder/Variable.php

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@
1818
*/
1919
final class Variable
2020
{
21-
/**
22-
* A variable that returns the current datetime value.
23-
* NOW returns the same value for all members of the deployment and remains the same throughout all stages of the
24-
* aggregation pipeline.
25-
*
26-
* New in MongoDB 4.2.
27-
*/
28-
public static function now(): ResolvesToDate
29-
{
30-
return new Expression\Variable('NOW');
31-
}
32-
3321
/**
3422
* A variable that returns the current timestamp value.
3523
* CLUSTER_TIME is only available on replica sets and sharded clusters.
@@ -43,15 +31,6 @@ public static function clusterTime(): ResolvesToTimestamp
4331
return new Expression\Variable('CLUSTER_TIME');
4432
}
4533

46-
/**
47-
* References the root document, i.e. the top-level document, currently being processed in the aggregation pipeline
48-
* stage.
49-
*/
50-
public static function root(): ResolvesToObject
51-
{
52-
return new Expression\Variable('ROOT');
53-
}
54-
5534
/**
5635
* References the start of the field path being processed in the aggregation pipeline stage.
5736
* Unless documented otherwise, all stages start with CURRENT the same as ROOT.
@@ -64,29 +43,43 @@ public static function current(string $fieldPath = ''): ResolvesToAny
6443
}
6544

6645
/**
67-
* A variable which evaluates to the missing value. Allows for the conditional exclusion of fields. In a $project,
68-
* a field set to the variable REMOVE is excluded from the output.
69-
* Can be used with $cond operator for conditionally exclude fields.
46+
* One of the allowed results of a $redact expression.
7047
*
71-
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#std-label-remove-example
48+
* $redact returns the fields at the current document level, excluding embedded documents. To include embedded
49+
* documents and embedded documents within arrays, apply the $cond expression to the embedded documents to determine
50+
* access for these embedded documents.
51+
*
52+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
7253
*/
73-
public static function remove(): ResolvesToAny
54+
public static function descend(): ExpressionInterface
7455
{
75-
return new Expression\Variable('REMOVE');
56+
return new Expression\Variable('DESCEND');
7657
}
7758

7859
/**
7960
* One of the allowed results of a $redact expression.
8061
*
81-
* $redact returns the fields at the current document level, excluding embedded documents. To include embedded
82-
* documents and embedded documents within arrays, apply the $cond expression to the embedded documents to determine
83-
* access for these embedded documents.
62+
* $redact returns or keeps all fields at this current document/embedded document level, without further inspection
63+
* of the fields at this level. This applies even if the included field contains embedded documents that may have
64+
* different access levels.
8465
*
8566
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
8667
*/
87-
public static function descend(): ExpressionInterface
68+
public static function keep(): ExpressionInterface
8869
{
89-
return new Expression\Variable('DESCEND');
70+
return new Expression\Variable('KEEP');
71+
}
72+
73+
/**
74+
* A variable that returns the current datetime value.
75+
* NOW returns the same value for all members of the deployment and remains the same throughout all stages of the
76+
* aggregation pipeline.
77+
*
78+
* New in MongoDB 4.2.
79+
*/
80+
public static function now(): ResolvesToDate
81+
{
82+
return new Expression\Variable('NOW');
9083
}
9184

9285
/**
@@ -104,17 +97,24 @@ public static function prune(): ExpressionInterface
10497
}
10598

10699
/**
107-
* One of the allowed results of a $redact expression.
108-
*
109-
* $redact returns or keeps all fields at this current document/embedded document level, without further inspection
110-
* of the fields at this level. This applies even if the included field contains embedded documents that may have
111-
* different access levels.
100+
* A variable which evaluates to the missing value. Allows for the conditional exclusion of fields. In a $project,
101+
* a field set to the variable REMOVE is excluded from the output.
102+
* Can be used with $cond operator for conditionally exclude fields.
112103
*
113-
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
104+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#std-label-remove-example
114105
*/
115-
public static function keep(): ExpressionInterface
106+
public static function remove(): ResolvesToAny
116107
{
117-
return new Expression\Variable('KEEP');
108+
return new Expression\Variable('REMOVE');
109+
}
110+
111+
/**
112+
* References the root document, i.e. the top-level document, currently being processed in the aggregation pipeline
113+
* stage.
114+
*/
115+
public static function root(): ResolvesToObject
116+
{
117+
return new Expression\Variable('ROOT');
118118
}
119119

120120
/**

tests/PedantryTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests;
44

5+
use MongoDB;
56
use RecursiveDirectoryIterator;
67
use RecursiveIteratorIterator;
78
use ReflectionClass;
@@ -10,6 +11,7 @@
1011

1112
use function array_filter;
1213
use function array_map;
14+
use function in_array;
1315
use function realpath;
1416
use function str_contains;
1517
use function str_replace;
@@ -25,6 +27,11 @@
2527
*/
2628
class PedantryTest extends TestCase
2729
{
30+
private const SKIPPED_CLASSES = [
31+
// Generated
32+
MongoDB\Builder\Stage\FluentFactoryTrait::class,
33+
];
34+
2835
/** @dataProvider provideProjectClassNames */
2936
public function testMethodsAreOrderedAlphabeticallyByVisibility($className): void
3037
{
@@ -74,6 +81,10 @@ public function provideProjectClassNames()
7481
}
7582

7683
$className = 'MongoDB\\' . str_replace(DIRECTORY_SEPARATOR, '\\', substr($file->getRealPath(), strlen($srcDir) + 1, -4));
84+
if (in_array($className, self::SKIPPED_CLASSES)) {
85+
continue;
86+
}
87+
7788
$classNames[$className][] = $className;
7889
}
7990

0 commit comments

Comments
 (0)