Skip to content

Commit

Permalink
Merge 2c42642 into c06ae32
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianKresse committed Feb 25, 2021
2 parents c06ae32 + 2c42642 commit f6f3ee4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/ValueResolver/NodeExpressionResolver.php
Expand Up @@ -142,6 +142,17 @@ protected function resolveScalarLNumber(LNumber $node): int
return $node->value;
}

protected function resolveExprUnaryMinus(Expr\UnaryMinus $node)
{
$value = $this->resolve($node->expr);
return -1 * $value;
}

protected function resolveExprUnaryPlus(Expr\UnaryMinus $node)
{
return $this->resolve($node->expr);
}

protected function resolveScalarString(String_ $node): string
{
return $node->value;
Expand Down
8 changes: 4 additions & 4 deletions tests/ReflectionMethodTest.php
Expand Up @@ -20,15 +20,15 @@ public function testGetClosureMethod()
public function testInvokeMethod()
{
$refMethod = $this->parsedRefClass->getMethod('funcWithReturnArgs');
$retValue = $refMethod->invoke(null, 1, 2, 3);
$this->assertEquals([1, 2, 3], $retValue);
$retValue = $refMethod->invoke(null, 1, 2, 3, -100, -10.5);
$this->assertEquals([1, 2, 3, -100, -10.5], $retValue);
}

public function testInvokeArgsMethod()
{
$refMethod = $this->parsedRefClass->getMethod('funcWithReturnArgs');
$retValue = $refMethod->invokeArgs(null, [1, 2, 3]);
$this->assertEquals([1, 2, 3], $retValue);
$retValue = $refMethod->invokeArgs(null, [1, 2, 3, -100, -10.5]);
$this->assertEquals([1, 2, 3, -100, -10.5], $retValue);
}

public function testDebugInfoMethod()
Expand Down
11 changes: 8 additions & 3 deletions tests/Stub/FileWithClasses55.php
Expand Up @@ -9,6 +9,7 @@ abstract class ImplicitAbstractClass
private $a = 'foo';
protected $b = 'bar';
public $c = 'baz';
public $d = -1;

abstract function test();
}
Expand Down Expand Up @@ -39,6 +40,7 @@ protected static function prototypeMethod()
abstract class AbstractClassWithMethods extends BaseClass
{
const TEST = 5;
const TEST2 = -5;

public function __construct(){}
public function __destruct(){}
Expand All @@ -56,14 +58,14 @@ final function finalFunc(){}
*/
public static function funcWithDocAndBody()
{
static $a =5, $test = '1234';
static $a =5, $b = -5, $test = '1234';

return 'hello';
}

public static function funcWithReturnArgs($a, $b = 100, $c = 10.0)
public static function funcWithReturnArgs($a, $b = 100, $c = 10.0, $d = -100, $e = -10.5)
{
return [$a, $b, $c];
return [$a, $b, $c, $d, $e];
}

public static function prototypeMethod()
Expand Down Expand Up @@ -102,6 +104,7 @@ class ClassWithProperties
private $privateProperty = 123;
protected $protectedProperty = 'a';
public $publicProperty = 42.0;
private $privateProperty2 = -123;

/**
* Some message to test docBlock
Expand Down Expand Up @@ -228,6 +231,8 @@ class ClassWithScalarConstants
const C = 'foo';
const D = false;
const E = null;
const F = -5;
const G = -6.123;
}

class ClassWithMagicConstants
Expand Down
1 change: 1 addition & 0 deletions tests/Stub/FileWithClasses71.php
Expand Up @@ -58,6 +58,7 @@ class ClassWithPhp71Features
private const PRIVATE_CONST = 4;

public const CALCULATED_CONST = 1 + 1;
public const CALCULATED_CONST2 = -1 + -1;

public function returnsVoid() : void {}
public function acceptsIterable(iterable $iterable) : iterable {}
Expand Down

0 comments on commit f6f3ee4

Please sign in to comment.