Skip to content

Commit 86691d3

Browse files
authored
#2 Refactoring to 2.2.x-dev
2 parents a2a9932 + d4ca4ba commit 86691d3

7 files changed

Lines changed: 257 additions & 35 deletions

File tree

.github/workflows/main.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,23 @@ jobs:
2020

2121
- name: Install composer dependencies
2222
run: |
23-
composer create-project nette/code-checker temp/code-checker ^3 --no-progress
24-
composer create-project nette/coding-standard temp/coding-standard ^2 --no-progress
25-
23+
# Install code check tools
24+
composer run cs:install
2625
# Install app dependencies
2726
composer install --no-interaction --prefer-dist
2827
29-
# Check code checker and coding standards
3028
- name: Check coding standards
3129
run: |
32-
php temp/code-checker/code-checker --short-arrays --strict-types --fix --no-progress
33-
php temp/coding-standard/ecs check src --config temp/coding-standard/coding-standard-php71.yml
30+
composer run cs:check
3431
3532
- name: Check PHPStan rules
36-
run: vendor/bin/phpstan analyse src -c phpstan.neon --level 8 --no-progress
33+
run: composer run phpstan
3734

3835
build:
3936
runs-on: ubuntu-latest
4037
strategy:
4138
matrix:
42-
php: ['7.2', '7.3', '7.4'] # 8.0
39+
php: ['7.2', '7.3', '7.4'] # '8.0'
4340

4441
name: PHP ${{ matrix.php }} tests
4542
steps:
@@ -54,10 +51,13 @@ jobs:
5451

5552
- name: Install composer dependencies
5653
run: |
54+
# Remove unnecesery packages
55+
composer remove phpstan/phpstan phpstan/phpstan-nette --dev --no-interaction
56+
# Install app dependencies
5757
composer install --no-interaction --prefer-dist
5858
5959
- name: Run tests
60-
run: vendor/bin/tester -s -c tests/php.ini -p php tests --coverage coverage.xml --coverage-src src
60+
run: composer run test
6161

6262
- name: Upload coverage to Codecov
6363
uses: codecov/codecov-action@v1
@@ -67,3 +67,29 @@ jobs:
6767
flags: unittests
6868
name: codecov-umbrella
6969
fail_ci_if_error: true
70+
71+
benchmark:
72+
runs-on: ubuntu-latest
73+
strategy:
74+
matrix:
75+
php: ['7.4']
76+
77+
name: Benchmark on PHP ${{ matrix.php }}
78+
steps:
79+
- name: Git clone
80+
uses: actions/checkout@master
81+
82+
- name: Install PHP
83+
uses: shivammathur/setup-php@master
84+
with:
85+
php-version: ${{ matrix.php }}
86+
87+
- name: Install composer dependencies
88+
run: |
89+
# Install benchmarking tool
90+
composer global require phpbench/phpbench @dev
91+
# Install app dependencies
92+
composer install --no-interaction --prefer-dist
93+
94+
- name: Run benchmarks
95+
run: phpbench run

README.md

Lines changed: 160 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,181 @@
1-
Math smart statistics
2-
=====================
1+
<h1 align="center">
2+
PHP Statistic Algorithms
3+
</h1>
4+
5+
<p align="center">
6+
<a href="https://mathematicator.com" target="_blank">
7+
<img src="https://avatars3.githubusercontent.com/u/44620375?s=100&v=4">
8+
</a>
9+
</p>
310

411
[![Integrity check](https://github.com/mathematicator-core/statistic/workflows/Integrity%20check/badge.svg)](https://github.com/mathematicator-core/statistic/actions?query=workflow%3A%22Integrity+check%22)
512
[![codecov](https://codecov.io/gh/mathematicator-core/statistic/branch/master/graph/badge.svg)](https://codecov.io/gh/mathematicator-core/statistic)
13+
[![Latest Stable Version](https://poser.pugx.org/mathematicator-core/statistic/v/stable)](https://packagist.org/packages/mathematicator-core/statistic)
14+
[![Latest Unstable Version](https://poser.pugx.org/mathematicator-core/statistic/v/unstable)](https://packagist.org/packages/mathematicator-core/statistic)
615
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](./LICENSE)
7-
8-
Smart statistic algorithms.
16+
[![PHPStan Enabled](https://img.shields.io/badge/PHPStan-enabled%20L8-brightgreen.svg?style=flat)](https://phpstan.org/)
917

1018
> Please help improve this documentation by sending a Pull request.
1119
12-
Install using Composer:
20+
## Installation
1321

1422
```
1523
composer require mathematicator-core/statistic
1624
```
1725

18-
Contribution
19-
----
26+
## Mathematicator Framework tools structure
27+
28+
The biggest advantage is that you can choose which layer best fits
29+
your needs and start build on the top of it, immediately, without the need
30+
to create everything by yourself. Our tools are tested for bugs
31+
and tuned for performance, so you can save a significant amount
32+
of your time, money, and effort.
33+
34+
Framework tend to be modular as much as possible, so you should be able
35+
to create an extension on each layer and its sublayers.
36+
37+
**Mathematicator framework layers** ordered from the most concrete
38+
one to the most abstract one:
39+
40+
<table>
41+
<tr>
42+
<td>
43+
<b>
44+
<a href="https://github.com/mathematicator-core/search">
45+
Search
46+
</a>
47+
</b>
48+
</td>
49+
<td>
50+
Modular search engine layer that calls its sublayers
51+
and creates user interface.
52+
</td>
53+
</tr>
54+
<tr>
55+
<td>
56+
<b>
57+
<a href="https://github.com/mathematicator-core/vizualizator">
58+
Vizualizator
59+
</a>
60+
</b>
61+
</td>
62+
<td>
63+
Elegant graphic visualizer that can render to
64+
SVG, PNG, JPG and Base64.<br />
65+
<u>Extensions:</u>
66+
<b>
67+
<a href="https://github.com/mathematicator-core/mandelbrot-set">
68+
Mandelbrot set generator
69+
</a>
70+
</b>
71+
</td>
72+
</tr>
73+
<tr>
74+
<td>
75+
<b>
76+
<a href="https://github.com/mathematicator-core/calculator">
77+
Calculator
78+
</a>
79+
</b>
80+
</td>
81+
<td>
82+
Modular advance calculations layer.
83+
<br />
84+
<u>Extensions:</u>
85+
<b>
86+
<a href="https://github.com/mathematicator-core/integral-solver">
87+
Integral Solver
88+
</a>,
89+
<a href="https://github.com/mathematicator-core/statistic">
90+
Statistics
91+
</a>
92+
</b>
93+
</td>
94+
</tr>
95+
<tr>
96+
<td>
97+
<b>
98+
<a href="https://github.com/mathematicator-core/engine">
99+
Engine
100+
</a>
101+
</b>
102+
</td>
103+
<td>
104+
Core logic layer that maintains basic controllers,
105+
DAOs, translator, common exceptions, routing etc.
106+
</td>
107+
</tr>
108+
<tr>
109+
<td>
110+
<b>
111+
<a href="https://github.com/mathematicator-core/tokenizer">
112+
Tokenizer
113+
</a>
114+
</b>
115+
</td>
116+
<td>
117+
Tokenizer that can convert string (user input / LaTeX) to numbers
118+
and operators.
119+
</td>
120+
</tr>
121+
<tr>
122+
<td>
123+
<b>
124+
<a href="https://github.com/mathematicator-core/numbers">
125+
Numbers
126+
</a>
127+
</b>
128+
</td>
129+
<td>
130+
Fast & secure storage for numbers with arbitrary precision.
131+
It supports Human string and LaTeX output and basic conversions.
132+
</td>
133+
</tr>
134+
</table>
135+
136+
**Third-party packages:**
137+
138+
⚠️ Not guaranteed!
139+
140+
<table>
141+
<tr>
142+
<td>
143+
<b>
144+
<a href="https://github.com/cothema/math-php-api">
145+
REST API
146+
</a>
147+
</b>
148+
</td>
149+
<td>
150+
Install the whole pack as a REST API service
151+
on your server (Docker ready) or
152+
access it via public cloud REST API.
153+
</td>
154+
</tr>
155+
</table>
156+
157+
## Contribution
20158

21159
### Tests
22160

23161
All new contributions should have its unit tests in `/tests` directory.
24162

25-
Before you send a PR, please, check that all tests pass.
163+
Before you send a PR, please, check all tests pass.
26164

27165
This package uses [Nette Tester](https://tester.nette.org/). You can run tests via command:
28166
```bash
29-
vendor/bin/tester -c tests/php.ini tests
167+
composer test
168+
````
169+
170+
For benchmarking, we use [phpbench](https://github.com/phpbench/phpbench).
171+
You can run benchmarks this way:
172+
```bash
173+
composer global require phpbench/phpbench @dev # only the first time
174+
phpbench run
175+
````
176+
177+
Before PR, please run complete code check via command:
178+
```bash
179+
composer cs:install # only first time
180+
composer fix # otherwise pre-commit hook can fail
30181
````
File renamed without changes.

composer.json

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mathematicator-core/statistic",
3-
"description": "Smart statistic algorithms.",
3+
"description": "PHP Statistic Algorithms",
44
"homepage": "https://github.com/mathematicator-core/statistic",
55
"authors": [
66
{
@@ -13,21 +13,62 @@
1313
"baraja-core/doctrine": "^2.0"
1414
},
1515
"require-dev": {
16+
"brainmaestro/composer-git-hooks": "^2.8",
1617
"nette/bootstrap": "^3.0.1",
1718
"nette/tester": "^2.0",
1819
"phpstan/phpstan": "^0.12.18",
19-
"tracy/tracy": "^2.7",
2020
"phpstan/phpstan-nette": "^0.12.6"
2121
},
2222
"autoload": {
23-
"classmap": [
24-
"src/"
25-
]
23+
"psr-4": {
24+
"Mathematicator\\Statistics\\": "src/"
25+
}
26+
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"Mathematicator\\Statistics\\Tests\\": "tests/StatisticsTests/"
30+
}
2631
},
2732
"scripts": {
28-
"phpstan": [
29-
"vendor/bin/phpstan analyse src -c phpstan.neon --level 8 --no-progress"
30-
]
33+
"post-install-cmd": "cghooks add --ignore-lock",
34+
"post-update-cmd": "cghooks update",
35+
"cs:install": [
36+
"composer create-project nette/code-checker temp/code-checker ^3 --no-progress",
37+
"composer create-project nette/coding-standard temp/coding-standard ^2 --no-progress"
38+
],
39+
"cs:check": [
40+
"php temp/code-checker/code-checker -d src -d tests -d benchmarks --short-arrays --strict-types --no-progress",
41+
"php temp/coding-standard/ecs check src tests benchmarks --config temp/coding-standard/coding-standard-php71.yml"
42+
],
43+
"cs:fix": [
44+
"php temp/code-checker/code-checker -d src -d tests -d benchmarks --short-arrays --strict-types --fix --no-progress",
45+
"php temp/coding-standard/ecs check src tests benchmarks --config temp/coding-standard/coding-standard-php71.yml --fix"
46+
],
47+
"phpstan": "vendor/bin/phpstan analyse src -c phpstan.neon --level 8 --no-progress",
48+
"fix": [
49+
"composer update",
50+
"composer cs:fix",
51+
"composer phpstan",
52+
"composer test"
53+
],
54+
"test": "vendor/bin/tester -s -c tests/php.ini -p php tests --coverage coverage.xml --coverage-src src",
55+
"cghooks": "vendor/bin/cghooks"
3156
},
32-
"minimum-stability": "stable"
57+
"minimum-stability": "stable",
58+
"config": {
59+
"sort-packages": true
60+
},
61+
"extra": {
62+
"branch-alias": {
63+
"dev-master": "2.2.x-dev"
64+
},
65+
"hooks": {
66+
"post-merge": "composer install",
67+
"pre-commit": [
68+
"composer cs:check",
69+
"composer phpstan",
70+
"composer test"
71+
]
72+
}
73+
}
3374
}

phpbench.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"bootstrap": "vendor/autoload.php",
3+
"path": "benchmarks"
4+
}

tests/Bootstrap.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
declare(strict_types=1);
44

5-
namespace Mathematicator\Statistic\Tests;
6-
7-
// TODO: require __DIR__ . '/../vendor/autoload.php';
5+
namespace Mathematicator\Statistics\Tests;
86

97
use Nette\Configurator;
108
use Nette\DI\Container;
119
use Tester\Environment;
1210

13-
Environment::setup();
11+
if (\is_file($autoload = __DIR__ . '/../vendor/autoload.php')) {
12+
require_once $autoload;
13+
Environment::setup();
14+
}
1415

1516
class Bootstrap
1617
{
@@ -26,8 +27,7 @@ public static function boot(): Container
2627
->register();
2728

2829
$configurator
29-
->addConfig(__DIR__ . '/../common.neon')
30-
->addConfig(__DIR__ . '/config.neon');
30+
->addConfig(__DIR__ . '/../common.neon');
3131

3232
return $configurator->createContainer();
3333
}

tests/StatisticTests/StatisticsManagerTest.php renamed to tests/StatisticsTests/StatisticsManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Mathematicator\Statistic\Test;
5+
namespace Mathematicator\Statistics\Test;
66

77

88
use Tester\Assert;
99
use Tester\TestCase;
1010

11-
require __DIR__ . '/../bootstrap.php';
11+
require __DIR__ . '/../Bootstrap.php';
1212

1313
class StatisticsManagerTest extends TestCase
1414
{

0 commit comments

Comments
 (0)