Skip to content

Commit cdf1773

Browse files
committed
PHP 8 compatibility.
1 parent b537992 commit cdf1773

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717
}
1818
],
1919
"require": {
20-
"php": ">=7.2",
20+
"php": "^8.0",
2121
"mathematicator-core/tokenizer": "^2.1",
2222
"mathematicator-core/engine": "^2.0",
2323
"mathematicator-core/numbers": "^2.1"
2424
},
2525
"require-dev": {
26-
"brainmaestro/composer-git-hooks": "dev-master",
27-
"nette/bootstrap": "^3.0",
28-
"nette/tester": "^2.3",
2926
"phpstan/phpstan": "^0.12.74",
27+
"tracy/tracy": "^2.8",
3028
"phpstan/phpstan-nette": "^0.12.14",
3129
"spaze/phpstan-disallowed-calls": "^1.1",
32-
"roave/security-advisories": "dev-master"
30+
"roave/security-advisories": "dev-master",
31+
"jetbrains/phpstorm-attributes": "^1.0",
32+
"brainmaestro/composer-git-hooks": "dev-master",
33+
"nette/bootstrap": "^3.0",
34+
"nette/tester": "^2.3"
3335
},
3436
"autoload": {
3537
"psr-4": {

src/IntegralResult.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@ final class IntegralResult
1212
{
1313

1414
/** @var IToken[] */
15-
private $queryTokens;
15+
private array $queryTokens;
1616

17-
/** @var string */
18-
private $queryLaTeX;
17+
private string $queryLaTeX;
1918

20-
/** @var string|null */
21-
private $result;
19+
private ?string $result = null;
2220

23-
/** @var string */
24-
private $differential;
21+
private string $differential;
2522

26-
/** @var bool */
27-
private $singleToken;
23+
private bool $singleToken;
2824

2925
/** @var Step[] */
30-
private $steps = [];
26+
private array $steps = [];
3127

3228

3329
/**
@@ -44,7 +40,7 @@ public function __construct(array $queryTokens, string $queryLaTeX, string $diff
4440

4541
public function isFinalResult(): bool
4642
{
47-
return strpos($this->getResult(), '?') === false;
43+
return str_contains($this->getResult(), '?') === false;
4844
}
4945

5046

src/IntegralSolver.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Mathematicator\Tokenizer\Token\SubToken;
1717
use Mathematicator\Tokenizer\Token\VariableToken;
1818
use Mathematicator\Tokenizer\Tokenizer;
19-
use Nette\Tokenizer\Exception;
2019

2120
/**
2221
* This class is user interface for call inner integral logic.
@@ -29,16 +28,13 @@ class IntegralSolver
2928
{
3029

3130
/** @var IRule[] */
32-
public $rules = [];
31+
public array $rules = [];
3332

34-
/** @var Tokenizer */
35-
private $tokenizer;
33+
private Tokenizer $tokenizer;
3634

37-
/** @var QueryNormalizer */
38-
private $queryNormalizer;
35+
private QueryNormalizer $queryNormalizer;
3936

40-
/** @var Solver */
41-
private $solver;
37+
private Solver $solver;
4238

4339

4440
public function __construct(Tokenizer $tokenizer, QueryNormalizer $queryNormalizer, Solver $solver)
@@ -66,7 +62,6 @@ public function process(string $query, ?string $differential = null): IntegralRe
6662

6763
/**
6864
* @param IToken[] $tokens
69-
* @return IntegralResult
7065
* @throws MathematicatorException
7166
*/
7267
public function processByTokens(array $tokens, ?string $differential = null): IntegralResult
@@ -117,7 +112,7 @@ public function processByTokens(array $tokens, ?string $differential = null): In
117112
} else {
118113
$result->addStep(new Step('Přibližné řešení', $resultLaTeX, 'Nepodařilo se najít primitivní funkci, řešení je zobrazeno přibližně.'));
119114
}
120-
} catch (Exception $e) {
115+
} catch (\Throwable) {
121116
$result->addStep(new Step('Řešení', null, 'Řešení se nepodařilo vykreslit.'));
122117
}
123118

@@ -171,7 +166,6 @@ private function explodeToParts(array $tokens): array
171166

172167
/**
173168
* @param IToken[] $tokens
174-
* @return string
175169
*/
176170
private function resolveDifferential(array $tokens, ?string $preferenceDifferential = null, int $level = 0): string
177171
{

src/Solver/Solver.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ final class Solver
1515
{
1616
/**
1717
* @param IToken[] $tokens
18-
* @return string
1918
* @throws CanNotSolveException|MathematicatorException
2019
*/
2120
public function solvePart(array $tokens): string

0 commit comments

Comments
 (0)