Skip to content

Commit

Permalink
Merge pull request #142 from Roave/fix/#134-ignore-fqsen-parsing-errors
Browse files Browse the repository at this point in the history
#134 suppress exceptions in parsing `Fqsen` expressions for documented property types
  • Loading branch information
Ocramius authored Jul 17, 2019
2 parents 5df06ce + c78ebd5 commit 4d3cac1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\PropertyBased;

use InvalidArgumentException;
use Roave\BackwardCompatibility\Change;
use Roave\BackwardCompatibility\Changes;
use Roave\BackwardCompatibility\Formatter\ReflectionPropertyName;
Expand Down Expand Up @@ -34,8 +35,13 @@ public function __invoke(ReflectionProperty $fromProperty, ReflectionProperty $t
return Changes::empty();
}

$fromTypes = array_unique($fromProperty->getDocBlockTypeStrings());
$toTypes = array_unique($toProperty->getDocBlockTypeStrings());
try {
$fromTypes = array_unique($fromProperty->getDocBlockTypeStrings());
$toTypes = array_unique($toProperty->getDocBlockTypeStrings());
} catch (InvalidArgumentException $failedToParseDocblock) {
// @TODO #134 improve docblock parsing upstream to remove this generic try-catch
return Changes::empty();
}

sort($fromTypes);
sort($toTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ class TheClass {
* @var int
*/
private $propertyTypeBeingDuplicatedAreNotBcBreaks;
/**
* @var GenericType<T1, T2>
*/
public $propertyWithComplexDocblockThatCannotBeParsed;
}
PHP
,
Expand Down Expand Up @@ -172,6 +177,11 @@ class TheClass {
* @var int|int
*/
private $propertyTypeBeingDuplicatedAreNotBcBreaks;
/**
* @var GenericType<T1, T2>
*/
public $propertyWithComplexDocblockThatCannotBeParsed;
}
PHP
,
Expand All @@ -196,6 +206,7 @@ class TheClass {
'privateDocblockToDifferentDocblock' => ['[BC] CHANGED: Type documentation for property TheClass#$privateDocblockToDifferentDocblock changed from int to float'],
'duplicatePropertyTypesBeingDeduplicatedAreNotBcBreaks' => [],
'propertyTypeBeingDuplicatedAreNotBcBreaks' => [],
'propertyWithComplexDocblockThatCannotBeParsed' => [],
];

return array_combine(
Expand Down

0 comments on commit 4d3cac1

Please sign in to comment.