diff --git a/Library/Operators/Bitwise/BitwiseBaseOperator.php b/Library/Operators/Bitwise/BitwiseBaseOperator.php index e557d25f4c..7a68a61cf2 100644 --- a/Library/Operators/Bitwise/BitwiseBaseOperator.php +++ b/Library/Operators/Bitwise/BitwiseBaseOperator.php @@ -101,8 +101,11 @@ public function optimizeConstantFolding(array $expression, CompilationContext $c } /** + * {@inheritdoc} + * * @param array $expression * @param CompilationContext $compilationContext + * @return bool|CompiledExpression */ public function compile($expression, CompilationContext $compilationContext) { diff --git a/kernels/ZendEngine3/operators.c b/kernels/ZendEngine3/operators.c index 3950f2acce..2b5d649c77 100644 --- a/kernels/ZendEngine3/operators.c +++ b/kernels/ZendEngine3/operators.c @@ -506,6 +506,16 @@ int zephir_bitwise_or_function(zval *result, zval *op1, zval *op2) return status; } +/** + * Do bitwise_xor function keeping ref_count and is_ref + */ +int zephir_bitwise_xor_function(zval *result, zval *op1, zval *op2) +{ + int status; + status = bitwise_xor_function(result, op1, op2); + return status; +} + /** * Check if a zval is less/equal than other */ diff --git a/test/bitwise.zep b/test/bitwise.zep index 48e3d003eb..de7134cf7e 100644 --- a/test/bitwise.zep +++ b/test/bitwise.zep @@ -948,4 +948,20 @@ class Bitwise { return a & ~b; } + + protected function getInt(int num) -> int + { + return num; + } + + /** + * @issue 1581 + */ + public function testbitwiseXor() + { + var i = this->getInt(123), + j = this->getInt(321); + + return i ^ j; + } } diff --git a/unit-tests/Extension/BitwiseTest.php b/unit-tests/Extension/BitwiseTest.php index 6c363e539b..2e869f181c 100644 --- a/unit-tests/Extension/BitwiseTest.php +++ b/unit-tests/Extension/BitwiseTest.php @@ -128,5 +128,11 @@ public function testBitwise() // Bitwise NOT $this->assertSame($t->testBitwiseNot(666), -667); $this->assertSame($t->testBitwiseAndNot(5, 4), 1); + + /** + * Bitwise XOR + * @issue 1581 + */ + $this->assertSame(123 ^ 321, $t->testbitwiseXor()); } }