Skip to content

Commit c78ebd5

Browse files
committed
Roave#134 suppress exceptions in parsing Fqsen expressions for documented property types
1 parent 5df06ce commit c78ebd5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/DetectChanges/BCBreak/PropertyBased/PropertyDocumentedTypeChanged.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\PropertyBased;
66

7+
use InvalidArgumentException;
78
use Roave\BackwardCompatibility\Change;
89
use Roave\BackwardCompatibility\Changes;
910
use Roave\BackwardCompatibility\Formatter\ReflectionPropertyName;
@@ -34,8 +35,13 @@ public function __invoke(ReflectionProperty $fromProperty, ReflectionProperty $t
3435
return Changes::empty();
3536
}
3637

37-
$fromTypes = array_unique($fromProperty->getDocBlockTypeStrings());
38-
$toTypes = array_unique($toProperty->getDocBlockTypeStrings());
38+
try {
39+
$fromTypes = array_unique($fromProperty->getDocBlockTypeStrings());
40+
$toTypes = array_unique($toProperty->getDocBlockTypeStrings());
41+
} catch (InvalidArgumentException $failedToParseDocblock) {
42+
// @TODO #134 improve docblock parsing upstream to remove this generic try-catch
43+
return Changes::empty();
44+
}
3945

4046
sort($fromTypes);
4147
sort($toTypes);

test/unit/DetectChanges/BCBreak/PropertyBased/PropertyDocumentedTypeChangedTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ class TheClass {
108108
* @var int
109109
*/
110110
private $propertyTypeBeingDuplicatedAreNotBcBreaks;
111+
112+
/**
113+
* @var GenericType<T1, T2>
114+
*/
115+
public $propertyWithComplexDocblockThatCannotBeParsed;
111116
}
112117
PHP
113118
,
@@ -172,6 +177,11 @@ class TheClass {
172177
* @var int|int
173178
*/
174179
private $propertyTypeBeingDuplicatedAreNotBcBreaks;
180+
181+
/**
182+
* @var GenericType<T1, T2>
183+
*/
184+
public $propertyWithComplexDocblockThatCannotBeParsed;
175185
}
176186
PHP
177187
,
@@ -196,6 +206,7 @@ class TheClass {
196206
'privateDocblockToDifferentDocblock' => ['[BC] CHANGED: Type documentation for property TheClass#$privateDocblockToDifferentDocblock changed from int to float'],
197207
'duplicatePropertyTypesBeingDeduplicatedAreNotBcBreaks' => [],
198208
'propertyTypeBeingDuplicatedAreNotBcBreaks' => [],
209+
'propertyWithComplexDocblockThatCannotBeParsed' => [],
199210
];
200211

201212
return array_combine(

0 commit comments

Comments
 (0)