Skip to content

Commit 29c50ad

Browse files
phpstan-botclaude
andcommitted
Revert describeBody() extraction, inline static- prefix in isCommonCallable branch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4715a4a commit 29c50ad

1 file changed

Lines changed: 62 additions & 35 deletions

File tree

src/Type/ClosureType.php

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -280,44 +280,71 @@ public function describe(VerbosityLevel $level): string
280280
{
281281
return $level->handle(
282282
static fn (): string => 'Closure',
283-
fn (): string => $this->describeBody(true, false),
284-
fn (): string => $this->describeBody(true, true),
285-
);
286-
}
283+
function (): string {
284+
if ($this->isCommonCallable) {
285+
return $this->isPure()->yes() ? 'pure-Closure' : 'Closure';
286+
}
287+
288+
$printer = new Printer();
289+
$selfWithoutParameterNames = new self(
290+
array_map(static fn (ParameterReflection $p): ParameterReflection => new DummyParameter(
291+
'',
292+
$p->getType(),
293+
optional: $p->isOptional() && !$p->isVariadic(),
294+
passedByReference: PassedByReference::createNo(),
295+
variadic: $p->isVariadic(),
296+
defaultValue: $p->getDefaultValue(),
297+
), $this->parameters),
298+
$this->returnType,
299+
$this->variadic,
300+
$this->templateTypeMap,
301+
$this->resolvedTemplateTypeMap,
302+
$this->callSiteVarianceMap,
303+
$this->templateTags,
304+
$this->throwPoints,
305+
$this->impurePoints,
306+
$this->invalidateExpressions,
307+
$this->usedVariables,
308+
$this->acceptsNamedArguments,
309+
$this->mustUseReturnValue,
310+
);
287311

288-
private function describeBody(bool $showPure, bool $showStatic): string
289-
{
290-
if ($this->isCommonCallable) {
291-
$prefix = $showStatic && $this->isStatic->yes() ? 'static-' : '';
292-
$name = $showPure && $this->isPure()->yes() ? 'pure-Closure' : 'Closure';
293-
return $prefix . $name;
294-
}
312+
return $printer->print($selfWithoutParameterNames->toPhpDocNode());
313+
},
314+
function (): string {
315+
if ($this->isCommonCallable) {
316+
$prefix = $this->isStatic->yes() ? 'static-' : '';
317+
$name = $this->isPure()->yes() ? 'pure-Closure' : 'Closure';
318+
return $prefix . $name;
319+
}
320+
321+
$printer = new Printer();
322+
$selfWithoutParameterNames = new self(
323+
array_map(static fn (ParameterReflection $p): ParameterReflection => new DummyParameter(
324+
'',
325+
$p->getType(),
326+
optional: $p->isOptional() && !$p->isVariadic(),
327+
passedByReference: PassedByReference::createNo(),
328+
variadic: $p->isVariadic(),
329+
defaultValue: $p->getDefaultValue(),
330+
), $this->parameters),
331+
$this->returnType,
332+
$this->variadic,
333+
$this->templateTypeMap,
334+
$this->resolvedTemplateTypeMap,
335+
$this->callSiteVarianceMap,
336+
$this->templateTags,
337+
$this->throwPoints,
338+
$this->impurePoints,
339+
$this->invalidateExpressions,
340+
$this->usedVariables,
341+
$this->acceptsNamedArguments,
342+
$this->mustUseReturnValue,
343+
);
295344

296-
$printer = new Printer();
297-
$selfWithoutParameterNames = new self(
298-
array_map(static fn (ParameterReflection $p): ParameterReflection => new DummyParameter(
299-
'',
300-
$p->getType(),
301-
optional: $p->isOptional() && !$p->isVariadic(),
302-
passedByReference: PassedByReference::createNo(),
303-
variadic: $p->isVariadic(),
304-
defaultValue: $p->getDefaultValue(),
305-
), $this->parameters),
306-
$this->returnType,
307-
$this->variadic,
308-
$this->templateTypeMap,
309-
$this->resolvedTemplateTypeMap,
310-
$this->callSiteVarianceMap,
311-
$this->templateTags,
312-
$this->throwPoints,
313-
$this->impurePoints,
314-
$this->invalidateExpressions,
315-
$this->usedVariables,
316-
$this->acceptsNamedArguments,
317-
$this->mustUseReturnValue,
345+
return $printer->print($selfWithoutParameterNames->toPhpDocNode());
346+
},
318347
);
319-
320-
return $printer->print($selfWithoutParameterNames->toPhpDocNode());
321348
}
322349

323350
public function isOffsetAccessLegal(): TrinaryLogic

0 commit comments

Comments
 (0)