Skip to content

Commit

Permalink
Convert assertions to docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Brown committed Jan 5, 2018
1 parent 415cf34 commit 9996b89
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
6 changes: 2 additions & 4 deletions src/NodeCompiler/CompileNodeToValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ private function compileConstFetch(Node\Expr\ConstFetch $constNode)
*/
private function compileClassConstFetch(Node\Expr\ClassConstFetch $node, CompilerContext $context)
{
if ($node->class instanceof Node\Expr || $node->name instanceof Node\Expr\Error) {
throw new \LogicException('Found unexpected value when evaluating class constant');
}

/** @var Node\Name $node->class */
$className = $node->class->toString();

if ($node->name === 'class') {
Expand All @@ -143,6 +140,7 @@ private function compileClassConstFetch(Node\Expr\ClassConstFetch $node, Compile
$classInfo = $context->getReflector()->reflect($className);
}

/** @var string $node->name */
$reflectionConstant = $classInfo->getReflectionConstant($node->name);

return $this->__invoke(
Expand Down
6 changes: 4 additions & 2 deletions src/Reflection/Adapter/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,11 @@ public function hasProperty($name)
}

/**
* {@inheritDoc}
* @param string $name
*
* @return ReflectionProperty|null
*/
public function getProperty($name) : ?ReflectionProperty
public function getProperty($name)
{
$betterReflectionProperty = $this->betterReflectionClass->getProperty($name);

Expand Down
6 changes: 4 additions & 2 deletions src/Reflection/Adapter/ReflectionObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ public function hasProperty($name)
}

/**
* {@inheritDoc}
* @param string $name
*
* @return ReflectionProperty|null
*/
public function getProperty($name) : ?ReflectionProperty
public function getProperty($name)
{
$property = $this->betterReflectionObject->getProperty($name);

Expand Down
11 changes: 3 additions & 8 deletions src/Reflection/ReflectionParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,16 @@ private function parseDefaultValueNode() : void
$defaultValueNode = $this->node->default;

if ($defaultValueNode instanceof Node\Expr\ClassConstFetch) {
if ($defaultValueNode->class instanceof Node\Expr) {
throw new LogicException('Class constant classes cannot be expressions');
}

if ($defaultValueNode->name instanceof Node\Expr\Error) {
throw new LogicException('Cannot deal with error nodes');
}

/** @var Node\Name $defaultValueNode->class */
$className = $defaultValueNode->class->toString();

if ($className === 'self' || $className === 'static') {
/** @var string $defaultValueNode->name */
$className = $this->findParentClassDeclaringConstant($defaultValueNode->name);
}

$this->isDefaultValueConstant = true;
/** @var string $defaultValueNode->name */
$this->defaultValueConstantName = $className . '::' . $defaultValueNode->name;
}

Expand Down

0 comments on commit 9996b89

Please sign in to comment.