Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

"require": {
"php": "8.2.* || 8.3.* || 8.4.* || 8.5.*",
"phpdocumentor/reflection-docblock": "^5.2",
"phpdocumentor/reflection-docblock": "^5.2 || ^6.0",
"sebastian/comparator": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"doctrine/instantiator": "^1.2 || ^2.0",
"sebastian/recursion-context": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
Expand Down
1 change: 0 additions & 1 deletion spec/Prophecy/Doubler/Generator/ClassCodeGeneratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace spec\Prophecy\Doubler\Generator;

use phpDocumentor\Reflection\DocBlock\Tags\Method;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ArgumentNode;
Expand Down
1 change: 0 additions & 1 deletion spec/Prophecy/Prophecy/ObjectProphecySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace spec\Prophecy\Prophecy;

use phpDocumentor\Reflection\DocBlock\Tags\Method;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Argument\ArgumentsWildcard;
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Doubler/ClassPatch/MagicCallPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function apply(ClassNode $node)
$argumentNode = new ArgumentNode($argument->getName());
$methodNode->addArgument($argumentNode);
}
} else {
} elseif (method_exists($tag, 'getArguments')) {
// Reflection Docblock < 5.4.0.
foreach ($tag->getArguments() as $argument) {
$argumentNode = new ArgumentNode($argument['name']);
Expand Down
6 changes: 6 additions & 0 deletions src/Prophecy/PhpDocumentor/ClassTagRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use phpDocumentor\Reflection\DocBlock\Tags\Method;
use phpDocumentor\Reflection\DocBlockFactory;
use phpDocumentor\Reflection\Exception\CannotCreateTag;
use phpDocumentor\Reflection\Types\ContextFactory;

/**
Expand Down Expand Up @@ -50,6 +51,11 @@ public function getTagList(\ReflectionClass $reflectionClass)
return $methods;
} catch (\InvalidArgumentException $e) {
return array();
} catch (CannotCreateTag $e) {
// In version 6.0, all deprecated methods have been removed from "ReflectionDocblock".
// Now, exceptions are thrown when trying to create a tag with a type and in other
// situations that previously did not throw exceptions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks suspicious to me. AFAICT, we should not be trying to create tags directly (and if we currently do, we should instead fix the root cause). In which case does this exception happen in a way that should be caught to ignore all tags ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to say, because I don't use this package and I don't fully understand what's going on inside it. I'll take a closer look.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the behavior without adding this catch statement ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the static create method of the Method tag is not meant to be called anymore (the proper tag factory should be used instead), the actual root cause should be investigated (inspecting the stack trace to see where it is called). It might be an issue in the way we use the library (which then must be fixed) or an upstream bug. But silently ignoring all tags when a CannotCreateTag exception happen while this exception only happens when reaching an unsupported code path does not make sense (and would probably break support for magic methods)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix the problem in ReflectionDocblock and come back here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next step would be debugging which tag is attempted to be created in the StandardTagFactory (and potentially also debugging what is the doc comment from which the phpdoc is parsed).

I suspect this is an upstream issue.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that all we need to do is restart CI after ReflectionDocBlock release.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return array();
}
}
}
1 change: 1 addition & 0 deletions src/Prophecy/Util/ExportUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static function toArray($value)
// above (fast) mechanism nor with reflection in Zend.
// Format the output similarly to print_r() in this case
if ($value instanceof \SplObjectStorage) {
/** @var \SplObjectStorage<object, mixed> $value */
foreach ($value as $key => $val) {
// Use the same identifier that would be printed alongside the object's representation elsewhere.
$array[spl_object_id($val)] = array(
Expand Down
Loading