Skip to content

Commit 66137cf

Browse files
zonuexestaabm
authored andcommitted
Drop comments that restate the code
The two comments in the generator described what the loops below them plainly do. In SimpleImpurePoint, resolvePureUnlessParameterPassedVerdict() and narrowByConditionalPurity() read off their names, and the Yes/No/Maybe gloss on resolveConditionalPurityVerdict() explained TrinaryLogic rather than this method. Kept only the parts that are not obvious: that a function can carry both flags at once, and when each verdict returns null.
1 parent 438f00c commit 66137cf

2 files changed

Lines changed: 3 additions & 21 deletions

File tree

‎bin/generate-function-metadata.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ public function enterNode(Node $node)
132132
throw new ShouldNotHappenException($functionName);
133133
}
134134

135-
// An entry can carry both conditions at once (e.g. preg_replace_callback,
136-
// which is pure unless its callback is impure or its 'count' is passed),
137-
// so keep every condition the hand-maintained entry declares.
138135
$conditions = [];
139136
foreach (['pureUnlessCallableIsImpureParameters', 'pureUnlessParameterPassedParameters'] as $conditionKey) {
140137
if (!isset($metadata[$functionName][$conditionKey])) {
@@ -232,8 +229,6 @@ public function enterNode(Node $node)
232229
);
233230

234231
foreach ($metadata as $name => $meta) {
235-
// An entry is either unconditional or carries one or both of the conditional
236-
// purity keys, so encode every key it has instead of just the first one.
237232
$entries = [];
238233
if (isset($meta['hasSideEffects'])) {
239234
$entries[] = sprintf('%s => %s', $escape('hasSideEffects'), $escape($meta['hasSideEffects']));

‎src/Reflection/Callables/SimpleImpurePoint.php‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,9 @@ public static function createFromVariant(FunctionReflection|ExtendedMethodReflec
135135
}
136136

137137
/**
138-
* Purity verdict of a call to a variant that declares conditional purity.
139-
*
140138
* A function can carry both flags at once (e.g. preg_replace_callback, which is
141-
* pure unless its callback is impure or its $count is passed). It stays pure only
142-
* when both verdicts agree it is pure, so they are combined: Yes = pure,
143-
* No = impure, Maybe = possibly impure. Returns null when the variant declares
144-
* neither flag, so the caller keeps its current behavior.
139+
* pure unless its callback is impure or its $count is passed), so the two
140+
* verdicts are combined. Returns null when the variant declares neither flag.
145141
*
146142
* @param Arg[] $args
147143
*/
@@ -157,11 +153,6 @@ public static function resolveConditionalPurityVerdict(ParametersAcceptor $varia
157153
}
158154

159155
/**
160-
* Applies the conditional purity verdict of this call site to impure points that
161-
* were resolved without one - a callable value's impure points are computed from
162-
* its ParametersAcceptor alone, so a first-class callable of a conditionally pure
163-
* function arrives here as an unconditional "possibly impure" point.
164-
*
165156
* @param SimpleImpurePoint[] $impurePoints
166157
* @param Arg[] $args
167158
* @return SimpleImpurePoint[]
@@ -250,11 +241,7 @@ public static function resolvePureUnlessCallableIsImpureVerdict(ParametersAccept
250241
}
251242

252243
/**
253-
* Purity verdict for parameters flagged with @pure-unless-parameter-passed:
254-
* the call stays pure as long as none of those (by-ref out) parameters
255-
* received an argument. Returns Yes when no flagged parameter was passed,
256-
* No when at least one was, and null when the variant has no such parameters
257-
* (so the caller keeps its current behavior).
244+
* Returns null when the variant has no flagged parameters.
258245
*
259246
* @param Arg[] $args
260247
*/

0 commit comments

Comments
 (0)