Skip to content

Commit 8b973ab

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Dotenv][ErrorHandler][EventDispatcher] Use CPP
1 parent dcd51b3 commit 8b973ab

7 files changed

+27
-38
lines changed

Diff for: Compiler.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
class Compiler implements ResetInterface
2222
{
2323
private string $source = '';
24-
private array $functions;
2524

26-
public function __construct(array $functions)
27-
{
28-
$this->functions = $functions;
25+
public function __construct(
26+
private array $functions,
27+
) {
2928
}
3029

3130
public function getFunction(string $name): array

Diff for: Expression.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
*/
1919
class Expression
2020
{
21-
protected string $expression;
22-
23-
public function __construct(string $expression)
24-
{
25-
$this->expression = $expression;
21+
public function __construct(
22+
protected string $expression,
23+
) {
2624
}
2725

2826
/**

Diff for: ExpressionFunction.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
*/
3131
class ExpressionFunction
3232
{
33-
private string $name;
3433
private \Closure $compiler;
3534
private \Closure $evaluator;
3635

@@ -39,9 +38,11 @@ class ExpressionFunction
3938
* @param callable $compiler A callable able to compile the function
4039
* @param callable $evaluator A callable able to evaluate the function
4140
*/
42-
public function __construct(string $name, callable $compiler, callable $evaluator)
43-
{
44-
$this->name = $name;
41+
public function __construct(
42+
private string $name,
43+
callable $compiler,
44+
callable $evaluator,
45+
) {
4546
$this->compiler = $compiler(...);
4647
$this->evaluator = $evaluator(...);
4748
}

Diff for: ParsedExpression.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@
2020
*/
2121
class ParsedExpression extends Expression
2222
{
23-
private Node $nodes;
24-
25-
public function __construct(string $expression, Node $nodes)
26-
{
23+
public function __construct(
24+
string $expression,
25+
private Node $nodes,
26+
) {
2727
parent::__construct($expression);
28-
29-
$this->nodes = $nodes;
3028
}
3129

3230
public function getNodes(): Node

Diff for: Parser.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ class Parser
2929
private TokenStream $stream;
3030
private array $unaryOperators;
3131
private array $binaryOperators;
32-
private array $functions;
3332
private ?array $names;
3433
private bool $lint = false;
3534

36-
public function __construct(array $functions)
37-
{
38-
$this->functions = $functions;
39-
35+
public function __construct(
36+
private array $functions,
37+
) {
4038
$this->unaryOperators = [
4139
'not' => ['precedence' => 50],
4240
'!' => ['precedence' => 50],

Diff for: SerializedParsedExpression.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020
*/
2121
class SerializedParsedExpression extends ParsedExpression
2222
{
23-
private string $nodes;
24-
2523
/**
2624
* @param string $expression An expression
2725
* @param string $nodes The serialized nodes for the expression
2826
*/
29-
public function __construct(string $expression, string $nodes)
30-
{
27+
public function __construct(
28+
string $expression,
29+
private string $nodes,
30+
) {
3131
$this->expression = $expression;
32-
$this->nodes = $nodes;
3332
}
3433

3534
public function getNodes(): Node

Diff for: Token.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
*/
1919
class Token
2020
{
21-
public string $type;
22-
public string|int|float|null $value;
23-
public ?int $cursor;
24-
2521
public const EOF_TYPE = 'end of expression';
2622
public const NAME_TYPE = 'name';
2723
public const NUMBER_TYPE = 'number';
@@ -33,11 +29,11 @@ class Token
3329
* @param self::*_TYPE $type
3430
* @param int|null $cursor The cursor position in the source
3531
*/
36-
public function __construct(string $type, string|int|float|null $value, ?int $cursor)
37-
{
38-
$this->type = $type;
39-
$this->value = $value;
40-
$this->cursor = $cursor;
32+
public function __construct(
33+
public string $type,
34+
public string|int|float|null $value,
35+
public ?int $cursor,
36+
) {
4137
}
4238

4339
/**

0 commit comments

Comments
 (0)