Skip to content

Commit

Permalink
#2186 - Add types in properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Apr 7, 2021
1 parent ef534d9 commit 6ea0c75
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 53 deletions.
6 changes: 3 additions & 3 deletions Library/Operators/Arithmetical/AddOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
class AddOperator extends ArithmeticalBaseOperator
{
protected $operator = '+';
protected string $operator = '+';

protected $bitOperator = '|';
protected string $bitOperator = '|';

protected $zvalOperator = 'zephir_add_function';
protected string $zvalOperator = 'zephir_add_function';
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
class ArithmeticalBaseOperator extends BaseOperator
{
protected $literalOnly = true;
protected bool $literalOnly = true;

/**
* This tries to perform arithmetical operations.
Expand Down
6 changes: 3 additions & 3 deletions Library/Operators/Arithmetical/DivOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
*/
class DivOperator extends ArithmeticalBaseOperator
{
protected $operator = '/';
protected string $operator = '/';

protected $bitOperator = '-';
protected string $bitOperator = '-';

protected $zvalOperator = 'div_function';
protected string $zvalOperator = 'div_function';

/**
* Compiles the arithmetical division operation.
Expand Down
6 changes: 3 additions & 3 deletions Library/Operators/Arithmetical/ModOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
*/
class ModOperator extends ArithmeticalBaseOperator
{
protected $operator = '%';
protected string $operator = '%';

protected $bitOperator = '-';
protected string $bitOperator = '-';

protected $zvalOperator = 'mod_function';
protected string $zvalOperator = 'mod_function';

/**
* Compiles the arithmetical modulus operation.
Expand Down
6 changes: 3 additions & 3 deletions Library/Operators/Arithmetical/MulOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
class MulOperator extends ArithmeticalBaseOperator
{
protected $operator = '*';
protected string $operator = '*';

protected $bitOperator = '+';
protected string $bitOperator = '+';

protected $zvalOperator = 'mul_function';
protected string $zvalOperator = 'mul_function';
}
6 changes: 3 additions & 3 deletions Library/Operators/Arithmetical/SubOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
class SubOperator extends ArithmeticalBaseOperator
{
protected $operator = '-';
protected string $operator = '-';

protected $bitOperator = '&';
protected string $bitOperator = '&';

protected $zvalOperator = 'zephir_sub_function';
protected string $zvalOperator = 'zephir_sub_function';
}
26 changes: 14 additions & 12 deletions Library/Operators/BaseOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,29 @@
use Zephir\CompilationContext;
use Zephir\Variable;

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

protected $expecting = true;
protected bool $expecting = true;

protected $readOnly = false;
protected bool $readOnly = false;

protected $literalOnly = true;
protected bool $literalOnly = true;

/** @var Variable|null */
protected $expectingVariable;
protected ?Variable $expectingVariable = null;

/**
* Sets if the variable must be resolved into a direct variable symbol
* create a temporary value or ignore the return value.
*
* @param bool $expecting
* @param Variable $expectingVariable
* @param bool $expecting
* @param Variable|null $expectingVariable
*/
public function setExpectReturn($expecting, Variable $expectingVariable = null)
public function setExpectReturn(bool $expecting, Variable $expectingVariable = null)
{
$this->expecting = $expecting;
$this->expectingVariable = $expectingVariable;
Expand Down Expand Up @@ -166,7 +168,7 @@ public function getExpectedComplexLiteral(CompilationContext $compilationContext
*
* @return bool
*/
public function isExpecting()
public function isExpecting(): bool
{
return $this->expecting;
}
Expand All @@ -176,7 +178,7 @@ public function isExpecting()
*
* @param bool $readOnly
*/
public function setReadOnly($readOnly)
public function setReadOnly(bool $readOnly): void
{
$this->readOnly = $readOnly;
}
Expand All @@ -186,7 +188,7 @@ public function setReadOnly($readOnly)
*
* @return bool
*/
public function isReadOnly()
public function isReadOnly(): bool
{
return $this->readOnly;
}
Expand Down
6 changes: 3 additions & 3 deletions Library/Operators/Bitwise/BitwiseAndOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class BitwiseAndOperator extends BitwiseBaseOperator
{
protected $operator = '&';
protected string $operator = '&';

protected $bitOperator = '&';
protected string $bitOperator = '&';

protected $zvalOperator = 'zephir_bitwise_and_function';
protected string $zvalOperator = 'zephir_bitwise_and_function';
}
2 changes: 1 addition & 1 deletion Library/Operators/Bitwise/BitwiseBaseOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
class BitwiseBaseOperator extends BaseOperator
{
protected $literalOnly = true;
protected bool $literalOnly = true;

/**
* This tries to perform arithmetical operations
Expand Down
6 changes: 3 additions & 3 deletions Library/Operators/Bitwise/BitwiseOrOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class BitwiseOrOperator extends BitwiseBaseOperator
{
protected $operator = '|';
protected string $operator = '|';

protected $bitOperator = '|';
protected string $bitOperator = '|';

protected $zvalOperator = 'zephir_bitwise_or_function';
protected string $zvalOperator = 'zephir_bitwise_or_function';
}
6 changes: 3 additions & 3 deletions Library/Operators/Bitwise/BitwiseXorOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class BitwiseXorOperator extends BitwiseBaseOperator
{
protected $operator = '^';
protected string $operator = '^';

protected $bitOperator = '^';
protected string $bitOperator = '^';

protected $zvalOperator = 'zephir_bitwise_xor_function';
protected string $zvalOperator = 'zephir_bitwise_xor_function';
}
6 changes: 3 additions & 3 deletions Library/Operators/Bitwise/ShiftLeftOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class ShiftLeftOperator extends BitwiseBaseOperator
{
protected $operator = '<<';
protected string $operator = '<<';

protected $bitOperator = '<<';
protected string $bitOperator = '<<';

protected $zvalOperator = 'zephir_shift_left_function';
protected string $zvalOperator = 'zephir_shift_left_function';
}
6 changes: 3 additions & 3 deletions Library/Operators/Bitwise/ShiftRightOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class ShiftRightOperator extends BitwiseBaseOperator
{
protected $operator = '>>';
protected string $operator = '>>';

protected $bitOperator = '>>';
protected string $bitOperator = '>>';

protected $zvalOperator = 'zephir_shift_right_function';
protected string $zvalOperator = 'zephir_shift_right_function';
}
4 changes: 2 additions & 2 deletions Library/Operators/Logical/AndOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

class AndOperator extends LogicalBaseOperator
{
protected $operator = '&&';
protected string $operator = '&&';

protected $bitOperator = '&&';
protected string $bitOperator = '&&';

public function compile($expression, CompilationContext $compilationContext)
{
Expand Down
4 changes: 2 additions & 2 deletions Library/Operators/Logical/OrOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

class OrOperator extends LogicalBaseOperator
{
protected $operator = '||';
protected string $operator = '||';

protected $bitOperator = '||';
protected string $bitOperator = '||';

public function compile($expression, CompilationContext $compilationContext)
{
Expand Down
5 changes: 3 additions & 2 deletions Library/Operators/Other/NewInstanceOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@

use Zephir\CompilationContext;
use Zephir\CompiledExpression;
use function Zephir\escape_class;
use Zephir\Exception\CompilerException;
use Zephir\Expression;
use Zephir\MethodCall;
use Zephir\Operators\BaseOperator;

use function Zephir\escape_class;

/**
* NewInstance.
*
* Creates a new instance of a class
*/
class NewInstanceOperator extends BaseOperator
{
protected $literalOnly = false;
protected bool $literalOnly = false;

/**
* Creates a new instance.
Expand Down
2 changes: 1 addition & 1 deletion Library/Operators/Other/NewInstanceTypeOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
class NewInstanceTypeOperator extends BaseOperator
{
protected $literalOnly = false;
protected bool $literalOnly = false;

/**
* Executes the operator.
Expand Down
2 changes: 1 addition & 1 deletion Library/Operators/Other/TypeHintOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class TypeHintOperator extends BaseOperator
{
private $strict = false;
private bool $strict = false;

/**
* Sets if the type hint is strict or not.
Expand Down
2 changes: 1 addition & 1 deletion Library/Operators/Other/UnlikelyOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class UnlikelyOperator extends BaseOperator
{
/***
/**
* Compile unlikely operator
*
* @param $expression
Expand Down

0 comments on commit 6ea0c75

Please sign in to comment.