Skip to content

Commit

Permalink
Merge branch 'development' into #2255-php8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Nov 7, 2021
2 parents fcb4484 + db604d1 commit 1847b65
Show file tree
Hide file tree
Showing 40 changed files with 275 additions and 277 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ box.phar
*.gcno
*.gcda

# Ignore CI autogenerated release-notes.md
release-notes.md

# Use this as your own wish list or a temporary buffer
LATER
php-zephir-parser/
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format based on [Keep a Changelog](http://keepachangelog.com)
and this project adheres to [Semantic Versioning](http://semver.org).

## [Unreleased]
### Fixed
- Fixed left `null` with `string` condition [#2299](https://github.com/zephir-lang/zephir/issues/2299)

## [0.15.2] - 2021-10-24
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
use Zephir\CompilationContext;
use Zephir\Variable;

/**
* TODO: Make it abstract
*/
class BaseOperator
abstract class AbstractOperator
{
protected string $operator;

Expand Down Expand Up @@ -52,26 +49,28 @@ public function setExpectReturn(bool $expecting, ?Variable $expectingVariable =
* @param array $expression
* @param bool $init
*
* @return Variable
* @return Variable|null
*/
public function getExpectedNonLiteral(CompilationContext $compilationContext, array $expression, bool $init = true): ?Variable
{
$isExpecting = $this->expecting;
$symbolVariable = $this->expectingVariable;

if ($isExpecting) {
if (\is_object($symbolVariable)) {
if ('variable' == $symbolVariable->getType() && !$symbolVariable->isLocalOnly()) {
if (!$init) {
return $symbolVariable;
}
$symbolVariable->initVariant($compilationContext);
} else {
$symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression);
if (!$this->expecting) {
return $symbolVariable;
}

if ($symbolVariable !== null) {
if ('variable' === $symbolVariable->getType() && !$symbolVariable->isLocalOnly()) {
if (!$init) {
return $symbolVariable;
}

$symbolVariable->initVariant($compilationContext);
} else {
$symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression);
}
} else {
$symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression);
}

return $symbolVariable;
Expand All @@ -89,10 +88,9 @@ public function getExpectedNonLiteral(CompilationContext $compilationContext, ar
*/
public function getExpected(CompilationContext $compilationContext, array $expression, bool $init = true): ?Variable
{
$isExpecting = $this->expecting;
$symbolVariable = $this->expectingVariable;

if ($isExpecting) {
if ($this->expecting) {
if (\is_object($symbolVariable)) {
if ('variable' === $symbolVariable->getType()) {
if (!$init) {
Expand Down Expand Up @@ -138,10 +136,9 @@ public function getExpected(CompilationContext $compilationContext, array $expre
*/
public function getExpectedComplexLiteral(CompilationContext $compilationContext, string $type = 'variable'): ?Variable
{
$isExpecting = $this->expecting;
$symbolVariable = $this->expectingVariable;

if ($isExpecting) {
if ($this->expecting) {
if (\is_object($symbolVariable)) {
if ($symbolVariable->getType() === $type || 'return_value' === $symbolVariable->getName()) {
$symbolVariable->initVariant($compilationContext);
Expand Down
2 changes: 0 additions & 2 deletions Library/Operators/Arithmetical/AddOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace Zephir\Operators\Arithmetical;

/**
* AddOperator.
*
* Generates an arithmetical operation according to the operands
*/
class AddOperator extends ArithmeticalBaseOperator
Expand Down
6 changes: 2 additions & 4 deletions Library/Operators/Arithmetical/ArithmeticalBaseOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
use Zephir\Exception;
use Zephir\Exception\CompilerException;
use Zephir\Expression;
use Zephir\Operators\BaseOperator;
use Zephir\Operators\AbstractOperator;
use Zephir\Variable;

/**
* BaseOperator.
*
* This is the base operator for commutative, associative and distributive
* arithmetic operators
*/
class ArithmeticalBaseOperator extends BaseOperator
class ArithmeticalBaseOperator extends AbstractOperator
{
protected bool $literalOnly = true;

Expand Down
2 changes: 0 additions & 2 deletions Library/Operators/Arithmetical/DivOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Zephir\Expression;

/**
* DivOperator.
*
* Generates an arithmetical operation according to the operands
*/
class DivOperator extends ArithmeticalBaseOperator
Expand Down
2 changes: 0 additions & 2 deletions Library/Operators/Arithmetical/ModOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Zephir\Expression;

/**
* ModOperator.
*
* Generates an arithmetical operation according to the operands
*/
class ModOperator extends ArithmeticalBaseOperator
Expand Down
2 changes: 0 additions & 2 deletions Library/Operators/Arithmetical/MulOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace Zephir\Operators\Arithmetical;

/**
* MulOperator.
*
* Generates an arithmetical operation according to the operands
*/
class MulOperator extends ArithmeticalBaseOperator
Expand Down
2 changes: 0 additions & 2 deletions Library/Operators/Arithmetical/SubOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace Zephir\Operators\Arithmetical;

/**
* SubOperator.
*
* Generates an arithmetical operation according to the operands
*/
class SubOperator extends ArithmeticalBaseOperator
Expand Down
6 changes: 2 additions & 4 deletions Library/Operators/Bitwise/BitwiseBaseOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
use Zephir\CompiledExpression;
use Zephir\Exception\CompilerException;
use Zephir\Expression;
use Zephir\Operators\BaseOperator;
use Zephir\Operators\AbstractOperator;

/**
* BaseOperator.
*
* This is the base operator for commutative, associative and distributive
* arithmetic operators
*/
class BitwiseBaseOperator extends BaseOperator
class BitwiseBaseOperator extends AbstractOperator
{
protected bool $literalOnly = true;

Expand Down
4 changes: 2 additions & 2 deletions Library/Operators/Bitwise/BitwiseNotOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Zephir\CompiledExpression;
use Zephir\Exception\CompilerException;
use Zephir\Expression;
use Zephir\Operators\BaseOperator;
use Zephir\Operators\AbstractOperator;

class BitwiseNotOperator extends BaseOperator
class BitwiseNotOperator extends AbstractOperator
{
/**
* @param $expression
Expand Down
Loading

0 comments on commit 1847b65

Please sign in to comment.