Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ jobs:

- name: Install composer dependencies
run: |
# Install code check tools
composer run cs:install

# Install app dependencies
composer install --no-interaction --prefer-dist

# Check code checker and coding standards
- name: Check coding standards
run: |
composer run cs:check
Expand All @@ -37,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4'] # 8.0
php: ['7.2', '7.3', '7.4', '8.0']

name: PHP ${{ matrix.php }} tests
steps:
Expand All @@ -52,6 +51,9 @@ jobs:

- name: Install composer dependencies
run: |
# Remove unnecesery packages
composer remove phpstan/phpstan phpstan/phpstan-nette --dev --no-interaction
# Install app dependencies
composer install --no-interaction --prefer-dist

- name: Run tests
Expand All @@ -65,3 +67,29 @@ jobs:
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true

benchmark:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.4']

name: Benchmark on PHP ${{ matrix.php }}
steps:
- name: Git clone
uses: actions/checkout@master

- name: Install PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php }}

- name: Install composer dependencies
run: |
# Install benchmarking tool
composer global require phpbench/phpbench @dev
# Install app dependencies
composer install --no-interaction --prefer-dist

- name: Run benchmarks
run: phpbench run
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h1 align="center">
Math PHP computational engine
Mathematicator Framework Engine
</h1>

<p align="center">
Expand All @@ -10,20 +10,21 @@

[![Integrity check](https://github.com/mathematicator-core/engine/workflows/Integrity%20check/badge.svg)](https://github.com/mathematicator-core/engine/actions?query=workflow%3A%22Integrity+check%22)
[![codecov](https://codecov.io/gh/mathematicator-core/engine/branch/master/graph/badge.svg)](https://codecov.io/gh/mathematicator-core/engine)
[![Latest stable version](https://poser.pugx.org/mathematicator-core/engine/v/stable)](https://packagist.org/packages/mathematicator-core/engine)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](./LICENSE)
[![PHPStan Enabled](https://img.shields.io/badge/PHPStan-enabled%20L8-brightgreen.svg?style=flat)](https://phpstan.org/)

Extremely complex library for advance work with math patterns, tokens and computing.
This is a Mathematicator Framework common library for advance work with
math patterns, tokens and computing. The library is considered as
a sublayer for other tools in Mathematicator Framework.

> Please help improve this documentation by sending a Pull request.

Install by Composer:
## Installation

```
composer require mathematicator-core/engine
```

### What is this package responsible for?
## Features

This package contains set of tools that other [mathematicator-core](https://github.com/mathematicator-core)
packages have in common.
Expand Down Expand Up @@ -141,8 +142,31 @@ one to the most abstract one:
</tr>
</table>

**Third-party packages:**

⚠️ Not guaranteed!

<table>
<tr>
<td>
<b>
<a href="https://github.com/cothema/math-php-api">
REST API
</a>
</b>
</td>
<td>
Install the whole pack as a REST API service
on your server (Docker ready) or
access it via public cloud REST API.
</td>
</tr>
</table>

## Contribution

> Please help to improve this documentation by sending a Pull request.

### Tests

All new contributions should have its unit tests in `/tests` directory.
Expand All @@ -154,6 +178,13 @@ This package uses [Nette Tester](https://tester.nette.org/). You can run tests v
composer test
````

For benchmarking, we use [phpbench](https://github.com/phpbench/phpbench).
You can run benchmarks this way:
```bash
composer global require phpbench/phpbench @dev # only the first time
phpbench run
````

Before PR, please run complete code check via command:
```bash
composer cs:install # only first time
Expand Down
Empty file added benchmarks/.gitkeep
Empty file.
4 changes: 0 additions & 4 deletions common.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ services:

extensions:
psr11: Contributte\Psr11\DI\Psr11ContainerExtension

orm.annotations:
paths:
Mathematicator: %appDir%/../vendor/mathematicator-core/engine/src
18 changes: 8 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@
],
"require": {
"php": ">=7.2",
"baraja-core/localization": "^1.0",
"contributte/psr11-container-interface": "^0.4.1",
"mathematicator-core/numbers": "^2.0@dev",
"mathematicator-core/tokenizer": "^2.0@dev",
"mathematicator-core/numbers": "^2.1@dev",
"mathematicator-core/tokenizer": "^2.1@dev",
"nette/di": "^3.0",
"nette/utils": "^3.0",
"symfony/yaml": "^5.0",
"symfony/translation": "^4.0 || ^5.0"
"symfony/translation": "^5.0"
},
"require-dev": {
"baraja-core/doctrine": "^2.0",
"brainmaestro/composer-git-hooks": "^2.8",
"nette/bootstrap": "^3.0.1",
"nette/tester": "^2.3",
Expand Down Expand Up @@ -56,12 +54,12 @@
"composer create-project nette/coding-standard temp/coding-standard ^2 --no-progress"
],
"cs:check": [
"php temp/code-checker/code-checker --short-arrays --strict-types --no-progress",
"php temp/coding-standard/ecs check src --config temp/coding-standard/coding-standard-php71.yml"
"php temp/code-checker/code-checker -d src -d tests -d benchmarks --short-arrays --strict-types --no-progress",
"php temp/coding-standard/ecs check src tests benchmarks --config temp/coding-standard/coding-standard-php71.yml"
],
"cs:fix": [
"php temp/code-checker/code-checker -d src -d tests --short-arrays --strict-types --fix --no-progress",
"php temp/coding-standard/ecs check src --config temp/coding-standard/coding-standard-php71.yml --fix"
"php temp/code-checker/code-checker -d src -d tests -d benchmarks --short-arrays --strict-types --fix --no-progress",
"php temp/coding-standard/ecs check src tests benchmarks --config temp/coding-standard/coding-standard-php71.yml --fix"
],
"phpstan": "vendor/bin/phpstan analyse src -c phpstan.neon --level 8 --no-progress",
"fix": [
Expand All @@ -79,7 +77,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "2.1.x-dev"
},
"hooks": {
"post-merge": "composer install",
Expand Down
4 changes: 4 additions & 0 deletions phpbench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"bootstrap": "vendor/autoload.php",
"path": "benchmarks"
}
5 changes: 2 additions & 3 deletions tests/bootstrap.php → tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ public static function boot(): Container

$configurator->createRobotLoader()
->addDirectory(__DIR__ . '/../src')
->addDirectory(__DIR__ . '/Mocks')
->register();

$configurator
// TODO make this work: ->addConfig(__DIR__ . '/../common.neon')
->addConfig(__DIR__ . '/test.common.neon');
->addConfig(__DIR__ . '/../common.neon')
->addConfig(__DIR__ . '/../vendor/mathematicator-core/tokenizer/common.neon');

$container = $configurator->createContainer();

Expand Down
4 changes: 2 additions & 2 deletions tests/EngineTests/EngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
namespace Mathematicator\Engine\Tests;


use Mathematicator\Engine\Entity\Box;
use Mathematicator\Engine\Engine;
use Mathematicator\Engine\Entity\Box;
use Mathematicator\Engine\Entity\EngineMultiResult;
use Mathematicator\Engine\Entity\EngineSingleResult;
use Nette\DI\Container;
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../bootstrap.php';
require __DIR__ . '/../Bootstrap.php';

class EngineTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/EngineTests/Entity/BoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class BoxTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/EngineTests/Entity/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class ContextTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/EngineTests/Entity/DynamicConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class DynamicConfigurationTest extends TestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/EngineTests/Entity/EngineResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use Mathematicator\Engine\Entity\Box;
use Mathematicator\Engine\Entity\EngineMultiResult;
use Mathematicator\Engine\Entity\EngineSingleResult;
use Mathematicator\Engine\Exception\NoResultsException;
use Mathematicator\Engine\Entity\Source;
use Mathematicator\Engine\Exception\NoResultsException;
use Mathematicator\Engine\Router\DynamicRoute;
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class EngineResultTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/EngineTests/Entity/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class QueryTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/EngineTests/Entity/SourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class SourceTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/EngineTests/Formatter/FixSpacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class FixSpacesTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/EngineTests/Formatter/NaturalTextFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class NaturalTextFormatterTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/EngineTests/Helper/CzechTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Tester\TestCase;
use function time;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class CzechTest extends TestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/EngineTests/Helper/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@


use Error;
use Mathematicator\Engine\Helper\DateTime;
use Mathematicator\Engine\Exception\MathematicatorException;
use Mathematicator\Engine\Helper\DateTime;
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class DateTimeTest extends TestCase
{
Expand Down
5 changes: 2 additions & 3 deletions tests/EngineTests/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@


use Error;
use Mathematicator\Engine\Helpers;
use Mathematicator\Engine\Entity\Query;
use Mathematicator\Engine\Helpers;
use Nette\Utils\ArrayHash;
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../bootstrap.php';
require __DIR__ . '/../Bootstrap.php';

class HelpersTest extends TestCase
{

public function testCreateInstance(): void
{
Assert::exception(function () {
Expand Down
5 changes: 2 additions & 3 deletions tests/EngineTests/MathFunction/FunctionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
namespace Mathematicator\Engine\Tests\MathFunction;


use Mathematicator\Engine\MathFunction\FunctionManager;
use Mathematicator\Engine\MathFunction\Entity\Sin ;
use Mathematicator\Engine\MathFunction\FunctionManager;
use RuntimeException;
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../Bootstrap.php';

class FunctionManagerTest extends TestCase
{

public function testBasic(): void
{
$sin = FunctionManager::getFunction('sin');
Expand Down
3 changes: 2 additions & 1 deletion tests/EngineTests/NumberRewriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
use Tester\Assert;
use Tester\TestCase;

require __DIR__ . '/../bootstrap.php';
require __DIR__ . '/../Bootstrap.php';

class NumberRewriterTest extends TestCase
{

/** @var NumberRewriter */
private $numberRewriter;


public function __construct(Container $container)
{
$this->numberRewriter = $container->getByType(NumberRewriter::class);
Expand Down
Loading