Skip to content

Commit

Permalink
Removed reference to webmozart/assert dependency in sources, since …
Browse files Browse the repository at this point in the history
…we are not requiring it ourselves

All code paths using `webmozart/assert` were mostly type-checks about unhappy paths that should not (in theory)
be possible.

Ref: #572 (comment)
  • Loading branch information
Ocramius committed May 7, 2020
1 parent beca868 commit 8142147
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/Reflection/Adapter/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
use Roave\BetterReflection\Reflection\ReflectionMethod as BetterReflectionMethod;
use Roave\BetterReflection\Reflection\ReflectionObject as BetterReflectionObject;
use Roave\BetterReflection\Reflection\ReflectionProperty as BetterReflectionProperty;
use Webmozart\Assert\Assert;
use function array_combine;
use function array_map;
use function array_values;
use function assert;
use function func_num_args;
use function is_array;
use function is_object;
use function is_string;
use function sprintf;
Expand Down Expand Up @@ -333,8 +334,8 @@ public function getTraits()
}, $traits)
);

Assert::isArray(
$traitsByName,
assert(
is_array($traitsByName),
sprintf(
'Could not create an array<trait-string, ReflectionClass> for class "%s"',
$this->betterReflectionClass->getName()
Expand Down
9 changes: 5 additions & 4 deletions src/Reflection/Adapter/ReflectionObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
use Roave\BetterReflection\Reflection\ReflectionMethod as BetterReflectionMethod;
use Roave\BetterReflection\Reflection\ReflectionObject as BetterReflectionObject;
use Roave\BetterReflection\Reflection\ReflectionProperty as BetterReflectionProperty;
use Webmozart\Assert\Assert;
use function array_combine;
use function array_map;
use function array_values;
use function assert;
use function func_num_args;
use function is_array;
use function sprintf;
use function strtolower;

Expand Down Expand Up @@ -286,10 +287,10 @@ public function getTraits()
}, $traits)
);

Assert::isArray(
$traitsByName,
assert(
is_array($traitsByName),
sprintf(
'Could not create an array<trait-string, ReflectionClass> for object of type "%s"',
'Could not create an array<trait-string, ReflectionClass> for class "%s"',
$this->betterReflectionObject->getName()
)
);
Expand Down
6 changes: 4 additions & 2 deletions src/Util/GetFirstDocComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

use PhpParser\Comment\Doc;
use PhpParser\NodeAbstract;
use Webmozart\Assert\Assert;
use function assert;
use function is_string;

/**
* @internal
Expand All @@ -18,7 +19,8 @@ public static function forNode(NodeAbstract $node) : string
foreach ($node->getComments() as $comment) {
if ($comment instanceof Doc) {
$text = $comment->getReformattedText();
Assert::string($text);

assert(is_string($text));

return $text;
}
Expand Down

0 comments on commit 8142147

Please sign in to comment.