Skip to content

Commit eabedc3

Browse files
committed
Moar types.
1 parent bbe82cf commit eabedc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+153
-444
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ use Ruler\Value;
411411

412412
class ALotGreaterThan extends VariableOperator implements Proposition
413413
{
414-
public function evaluate(Context $context)
414+
public function evaluate(Context $context): bool
415415
{
416416
list($left, $right) = $this->getOperands();
417417
$value = $right->prepareValue($context)->getValue() * 10;

src/Context.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ public function __construct(array $values = [])
7070
* Check if a fact is defined.
7171
*
7272
* @param string $name The unique name for the fact
73-
*
74-
* @return bool
7573
*/
7674
public function offsetExists($name): bool
7775
{
@@ -221,10 +219,8 @@ public function raw($name)
221219

222220
/**
223221
* Get all defined fact names.
224-
*
225-
* @return array An array of fact names
226222
*/
227-
public function keys()
223+
public function keys(): array
228224
{
229225
return \array_keys($this->keys);
230226
}
@@ -233,10 +229,8 @@ public function keys()
233229
* Check whether a value is a Closure or invokable object.
234230
*
235231
* @param mixed $callable
236-
*
237-
* @return bool
238232
*/
239-
protected function isCallable($callable)
233+
protected function isCallable($callable): bool
240234
{
241235
return \is_object($callable) && \is_callable($callable);
242236
}

src/Operator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(...$operands)
3232
}
3333
}
3434

35-
public function getOperands()
35+
public function getOperands(): array
3636
{
3737
switch ($this->getOperandCardinality()) {
3838
case self::UNARY:

src/Operator/Addition.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Addition extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $left */
2828
/** @var VariableOperand $right */

src/Operator/Ceil.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Ceil extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $operand */
2828
[$operand] = $this->getOperands();

src/Operator/Complement.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Ruler\Context;
1515
use Ruler\Set;
16+
use Ruler\Value;
1617
use Ruler\VariableOperand;
1718

1819
/**
@@ -22,7 +23,7 @@
2223
*/
2324
class Complement extends VariableOperator implements VariableOperand
2425
{
25-
public function prepareValue(Context $context)
26+
public function prepareValue(Context $context): Value
2627
{
2728
$complement = null;
2829
/** @var VariableOperand $operand */

src/Operator/ContainsSubset.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class ContainsSubset extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/Division.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Division extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $left */
2828
/** @var VariableOperand $right */

src/Operator/DoesNotContainSubset.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class DoesNotContainSubset extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/EndsWith.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class EndsWith extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/EndsWithInsensitive.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class EndsWithInsensitive extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/EqualTo.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class EqualTo extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/Exponentiate.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Exponentiate extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $left */
2828
/** @var VariableOperand $right */

src/Operator/Floor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Floor extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $operand */
2828
[$operand] = $this->getOperands();

src/Operator/GreaterThan.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class GreaterThan extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/GreaterThanOrEqualTo.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class GreaterThanOrEqualTo extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/Intersect.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Ruler\Context;
1515
use Ruler\Set;
16+
use Ruler\Value;
1617
use Ruler\VariableOperand;
1718

1819
/**
@@ -22,7 +23,7 @@
2223
*/
2324
class Intersect extends VariableOperator implements VariableOperand
2425
{
25-
public function prepareValue(Context $context)
26+
public function prepareValue(Context $context): Value
2627
{
2728
$intersect = null;
2829
/** @var VariableOperand $operand */

src/Operator/LessThan.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class LessThan extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/LessThanOrEqualTo.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class LessThanOrEqualTo extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/LogicalAnd.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ class LogicalAnd extends LogicalOperator
2323
{
2424
/**
2525
* @param Context $context Context with which to evaluate this Proposition
26-
*
27-
* @return bool
2826
*/
29-
public function evaluate(Context $context)
27+
public function evaluate(Context $context): bool
3028
{
3129
/** @var Proposition $operand */
3230
foreach ($this->getOperands() as $operand) {

src/Operator/LogicalNot.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ class LogicalNot extends LogicalOperator
2323
{
2424
/**
2525
* @param Context $context Context with which to evaluate this Proposition
26-
*
27-
* @return bool
2826
*/
29-
public function evaluate(Context $context)
27+
public function evaluate(Context $context): bool
3028
{
3129
/** @var Proposition $operand */
3230
[$operand] = $this->getOperands();

src/Operator/LogicalOperator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract class LogicalOperator extends PropositionOperator implements Propositio
2323
/**
2424
* array of propositions.
2525
*
26-
* @param array $props
26+
* @param Proposition[] $props
2727
*/
2828
public function __construct(array $props = [])
2929
{

src/Operator/LogicalOr.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ class LogicalOr extends LogicalOperator
2323
{
2424
/**
2525
* @param Context $context Context with which to evaluate this Proposition
26-
*
27-
* @return bool
2826
*/
29-
public function evaluate(Context $context)
27+
public function evaluate(Context $context): bool
3028
{
3129
/** @var Proposition $operand */
3230
foreach ($this->getOperands() as $operand) {

src/Operator/LogicalXor.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ class LogicalXor extends LogicalOperator
2323
{
2424
/**
2525
* @param Context $context Context with which to evaluate this Proposition
26-
*
27-
* @return bool
2826
*/
29-
public function evaluate(Context $context)
27+
public function evaluate(Context $context): bool
3028
{
3129
$true = 0;
3230
/** @var Proposition $operand */

src/Operator/Max.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Max extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $operand */
2828
[$operand] = $this->getOperands();

src/Operator/Min.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Min extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $operand */
2828
[$operand] = $this->getOperands();

src/Operator/Modulo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Modulo extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $left */
2828
/** @var VariableOperand $right */

src/Operator/Multiplication.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Multiplication extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $left */
2828
/** @var VariableOperand $right */

src/Operator/Negation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Negation extends VariableOperator implements VariableOperand
2424
{
25-
public function prepareValue(Context $context)
25+
public function prepareValue(Context $context): Value
2626
{
2727
/** @var VariableOperand $operand */
2828
[$operand] = $this->getOperands();

src/Operator/NotEqualTo.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class NotEqualTo extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/NotSameAs.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class NotSameAs extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

src/Operator/PropositionOperator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
*/
2020
abstract class PropositionOperator extends BaseOperator
2121
{
22-
public function addOperand($operand)
22+
public function addOperand($operand): void
2323
{
2424
$this->addProposition($operand);
2525
}
2626

27-
public function addProposition(Proposition $operand)
27+
public function addProposition(Proposition $operand): void
2828
{
2929
if (static::UNARY === $this->getOperandCardinality()
3030
&& 0 < \count($this->operands)

src/Operator/SameAs.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ class SameAs extends VariableOperator implements Proposition
2424
{
2525
/**
2626
* @param Context $context Context with which to evaluate this Proposition
27-
*
28-
* @return bool
2927
*/
30-
public function evaluate(Context $context)
28+
public function evaluate(Context $context): bool
3129
{
3230
/** @var VariableOperand $left */
3331
/** @var VariableOperand $right */

0 commit comments

Comments
 (0)