Skip to content

Commit c714195

Browse files
authored
New code style and PHP 8.1+ (#8)
1 parent 05624e6 commit c714195

Some content is hidden

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

70 files changed

+1351
-2086
lines changed

.editorconfig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#
2-
# JBZoo Toolbox - SimpleTypes
2+
# JBZoo Toolbox - SimpleTypes.
33
#
44
# This file is part of the JBZoo Toolbox project.
55
# For the full copyright and license information, please view the LICENSE
66
# file that was distributed with this source code.
77
#
8-
# @package SimpleTypes
98
# @license MIT
109
# @copyright Copyright (C) JBZoo.com, All rights reserved.
11-
# @link https://github.com/JBZoo/SimpleTypes
10+
# @see https://github.com/JBZoo/SimpleTypes
1211
#
1312

1413
# EditorConfig is awesome: http://EditorConfig.org

.gitattributes

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#
2-
# JBZoo Toolbox - SimpleTypes
2+
# JBZoo Toolbox - SimpleTypes.
33
#
44
# This file is part of the JBZoo Toolbox project.
55
# For the full copyright and license information, please view the LICENSE
66
# file that was distributed with this source code.
77
#
8-
# @package SimpleTypes
98
# @license MIT
109
# @copyright Copyright (C) JBZoo.com, All rights reserved.
11-
# @link https://github.com/JBZoo/SimpleTypes
10+
# @see https://github.com/JBZoo/SimpleTypes
1211
#
1312

1413
/.github export-ignore

.github/workflows/main.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#
2-
# JBZoo Toolbox - SimpleTypes
2+
# JBZoo Toolbox - SimpleTypes.
33
#
44
# This file is part of the JBZoo Toolbox project.
55
# For the full copyright and license information, please view the LICENSE
66
# file that was distributed with this source code.
77
#
8-
# @package SimpleTypes
98
# @license MIT
109
# @copyright Copyright (C) JBZoo.com, All rights reserved.
11-
# @link https://github.com/JBZoo/SimpleTypes
10+
# @see https://github.com/JBZoo/SimpleTypes
1211
#
1312

1413
name: CI
@@ -21,7 +20,7 @@ on:
2120
branches:
2221
- 'master'
2322
schedule:
24-
- cron: '25 */8 * * *'
23+
- cron: '8 */8 * * *'
2524

2625
env:
2726
COLUMNS: 120
@@ -35,20 +34,22 @@ jobs:
3534
JBZOO_COMPOSER_UPDATE_FLAGS: ${{ matrix.composer_flags }}
3635
strategy:
3736
matrix:
38-
php-version: [ 7.4, 8.0, 8.1 ]
37+
php-version: [ 8.1, 8.2 ]
38+
coverage: [ xdebug, none ]
3939
composer_flags: [ "--prefer-lowest", "" ]
4040
steps:
4141
- name: Checkout code
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v3
4343
with:
4444
fetch-depth: 0
4545

4646
- name: Setup PHP
4747
uses: shivammathur/setup-php@v2
4848
with:
49-
php-version: ${{ matrix.php-version }}
50-
coverage: xdebug
49+
php-version: '${{ matrix.php-version }}'
50+
coverage: '${{ matrix.coverage }}'
5151
tools: composer
52+
extensions: ast
5253

5354
- name: Build the Project
5455
run: make update --no-print-directory
@@ -57,12 +58,15 @@ jobs:
5758
run: make test --no-print-directory
5859

5960
- name: Uploading coverage to coveralls
61+
if: "${{ matrix.coverage == 'xdebug' }}"
62+
continue-on-error: true
6063
env:
61-
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6265
run: make report-coveralls --no-print-directory || true
6366

6467
- name: Upload Artifacts
65-
uses: actions/upload-artifact@v2
68+
uses: actions/upload-artifact@v3
69+
continue-on-error: true
6670
with:
6771
name: PHPUnit - ${{ matrix.php-version }} - ${{ matrix.coverage }}
6872
path: build/
@@ -73,17 +77,18 @@ jobs:
7377
runs-on: ubuntu-latest
7478
strategy:
7579
matrix:
76-
php-version: [ 7.4, 8.0, 8.1 ]
80+
php-version: [ 8.1, 8.2 ]
7781
steps:
7882
- name: Checkout code
79-
uses: actions/checkout@v2
83+
uses: actions/checkout@v3
8084
with:
8185
fetch-depth: 0
8286

8387
- name: Setup PHP
8488
uses: shivammathur/setup-php@v2
8589
with:
8690
php-version: ${{ matrix.php-version }}
91+
coverage: none
8792
tools: composer
8893
extensions: ast
8994

@@ -94,7 +99,8 @@ jobs:
9499
run: make codestyle --no-print-directory
95100

96101
- name: Upload Artifacts
97-
uses: actions/upload-artifact@v2
102+
uses: actions/upload-artifact@v3
103+
continue-on-error: true
98104
with:
99105
name: Linters - ${{ matrix.php-version }}
100106
path: build/
@@ -105,10 +111,10 @@ jobs:
105111
runs-on: ubuntu-latest
106112
strategy:
107113
matrix:
108-
php-version: [ 7.4, 8.0, 8.1 ]
114+
php-version: [ 8.1, 8.2 ]
109115
steps:
110116
- name: Checkout code
111-
uses: actions/checkout@v2
117+
uses: actions/checkout@v3
112118
with:
113119
fetch-depth: 0
114120

@@ -118,6 +124,7 @@ jobs:
118124
php-version: ${{ matrix.php-version }}
119125
coverage: xdebug
120126
tools: composer
127+
extensions: ast
121128

122129
- name: Build the Project
123130
run: make update --no-print-directory
@@ -126,7 +133,8 @@ jobs:
126133
run: make report-all --no-print-directory
127134

128135
- name: Upload Artifacts
129-
uses: actions/upload-artifact@v2
136+
uses: actions/upload-artifact@v3
137+
continue-on-error: true
130138
with:
131139
name: Reports - ${{ matrix.php-version }}
132140
path: build/

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#
2-
# JBZoo Toolbox - SimpleTypes
2+
# JBZoo Toolbox - SimpleTypes.
33
#
44
# This file is part of the JBZoo Toolbox project.
55
# For the full copyright and license information, please view the LICENSE
66
# file that was distributed with this source code.
77
#
8-
# @package SimpleTypes
98
# @license MIT
109
# @copyright Copyright (C) JBZoo.com, All rights reserved.
11-
# @link https://github.com/JBZoo/SimpleTypes
10+
# @see https://github.com/JBZoo/SimpleTypes
1211
#
1312

1413
.idea

.phan.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?php
22

33
/**
4-
* JBZoo Toolbox - SimpleTypes
4+
* JBZoo Toolbox - SimpleTypes.
55
*
66
* This file is part of the JBZoo Toolbox project.
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*
10-
* @package SimpleTypes
1110
* @license MIT
1211
* @copyright Copyright (C) JBZoo.com, All rights reserved.
13-
* @link https://github.com/JBZoo/SimpleTypes
12+
* @see https://github.com/JBZoo/SimpleTypes
1413
*/
1514

1615
declare(strict_types=1);
1716

18-
$default = include __DIR__ . '/vendor/jbzoo/codestyle/src/phan/default.php';
17+
$default = include __DIR__ . '/vendor/jbzoo/codestyle/src/phan.php';
1918

20-
return array_merge($default, [
19+
return \array_merge($default, [
2120
'directory_list' => [
2221
'src',
23-
]
22+
'vendor/jbzoo/utils/src',
23+
],
2424
]);

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#
2-
# JBZoo Toolbox - SimpleTypes
2+
# JBZoo Toolbox - SimpleTypes.
33
#
44
# This file is part of the JBZoo Toolbox project.
55
# For the full copyright and license information, please view the LICENSE
66
# file that was distributed with this source code.
77
#
8-
# @package SimpleTypes
98
# @license MIT
109
# @copyright Copyright (C) JBZoo.com, All rights reserved.
11-
# @link https://github.com/JBZoo/SimpleTypes
10+
# @see https://github.com/JBZoo/SimpleTypes
1211
#
1312

1413
ifneq (, $(wildcard ./vendor/jbzoo/codestyle/src/init.Makefile))

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
--------------------------------------------------------------------------------
21
# JBZoo / SimpleTypes
32

4-
[![Coverage Status](https://coveralls.io/repos/JBZoo/SimpleTypes/badge.svg)](https://coveralls.io/github/JBZoo/SimpleTypes) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/SimpleTypes/coverage.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes) [![PHP Strict Types](https://img.shields.io/badge/strict__types-%3D1-brightgreen)](https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict)
5-
[![Stable Version](https://poser.pugx.org/jbzoo/simpletypes/version)](https://packagist.org/packages/jbzoo/simpletypes) [![Latest Unstable Version](https://poser.pugx.org/jbzoo/simpletypes/v/unstable)](https://packagist.org/packages/jbzoo/simpletypes) [![Dependents](https://poser.pugx.org/jbzoo/simpletypes/dependents)](https://packagist.org/packages/jbzoo/simpletypes/dependents?order_by=downloads) [![GitHub Issues](https://img.shields.io/github/issues/jbzoo/simpletypes)](https://github.com/JBZoo/SimpleTypes/issues) [![Total Downloads](https://poser.pugx.org/jbzoo/simpletypes/downloads)](https://packagist.org/packages/jbzoo/simpletypes/stats) [![GitHub License](https://img.shields.io/github/license/jbzoo/simpletypes)](https://github.com/JBZoo/SimpleTypes/blob/master/LICENSE)
6-
3+
[![CI](https://github.com/JBZoo/SimpleTypes/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/JBZoo/SimpleTypes/actions/workflows/main.yml?query=branch%3Amaster) [![Coverage Status](https://coveralls.io/repos/github/JBZoo/SimpleTypes/badge.svg?branch=master)](https://coveralls.io/github/JBZoo/SimpleTypes?branch=master) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/SimpleTypes/coverage.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes) [![Psalm Level](https://shepherd.dev/github/JBZoo/SimpleTypes/level.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes) [![CodeFactor](https://www.codefactor.io/repository/github/jbzoo/simpletypes/badge)](https://www.codefactor.io/repository/github/jbzoo/simpletypes/issues)
4+
[![Stable Version](https://poser.pugx.org/jbzoo/simpletypes/version)](https://packagist.org/packages/jbzoo/simpletypes/) [![Total Downloads](https://poser.pugx.org/jbzoo/simpletypes/downloads)](https://packagist.org/packages/jbzoo/simpletypes/stats) [![Dependents](https://poser.pugx.org/jbzoo/simpletypes/dependents)](https://packagist.org/packages/jbzoo/simpletypes/dependents?order_by=downloads) [![Visitors](https://visitor-badge.glitch.me/badge?page_id=jbzoo.simpletypes)]() [![GitHub License](https://img.shields.io/github/license/jbzoo/simpletypes)](https://github.com/JBZoo/SimpleTypes/blob/master/LICENSE)
75

86

97
The universal PHP library to convert any values and measures - money, weight, currency coverter, length and what ever you want ;)

composer.json

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,63 @@
11
{
2-
"name" : "jbzoo/simpletypes",
3-
"type" : "library",
4-
"description" : "The universal PHP library to convert any values and measures",
5-
"license" : "MIT",
6-
"keywords" : [
7-
"converter", "acceleration", "area", "degree", "info", "length", "money", "number", "pressure", "speed",
8-
"temperature", "time", "volume", "weight"
2+
"name" : "jbzoo/simpletypes",
3+
"type" : "library",
4+
"description" : "The universal PHP library to convert any values and measures",
5+
"license" : "MIT",
6+
"keywords" : [
7+
"converter",
8+
"acceleration",
9+
"area",
10+
"degree",
11+
"info",
12+
"length",
13+
"money",
14+
"number",
15+
"pressure",
16+
"speed",
17+
"temperature",
18+
"time",
19+
"volume",
20+
"weight"
921
],
10-
"authors" : [
22+
"authors" : [
1123
{
1224
"name" : "Denis Smetannikov",
1325
"email" : "[email protected]",
1426
"role" : "lead"
1527
}
1628
],
1729

18-
"require" : {
19-
"php" : ">=7.4"
30+
"minimum-stability" : "dev",
31+
"prefer-stable" : true,
32+
33+
"require" : {
34+
"php" : "^8.1",
35+
"jbzoo/utils" : "7.x-dev"
2036
},
2137

22-
"require-dev" : {
23-
"jbzoo/toolbox-dev" : "^4.0.1"
38+
"require-dev" : {
39+
"jbzoo/toolbox-dev" : "7.x-dev"
2440
},
2541

26-
"autoload" : {
27-
"psr-4" : {
28-
"JBZoo\\SimpleTypes\\" : "src"
29-
}
42+
"autoload" : {
43+
"psr-4" : {"JBZoo\\SimpleTypes\\" : "src"}
3044
},
3145

32-
"autoload-dev" : {
33-
"classmap" : ["tests"],
34-
"files" : ["tests/phpunit-functions.php"]
46+
"autoload-dev" : {
47+
"psr-4" : {"JBZoo\\PHPUnit\\" : "tests"},
48+
"files" : [
49+
"tests/phpunit-functions.php"
50+
]
3551
},
3652

37-
"config" : {
53+
"config" : {
3854
"optimize-autoloader" : true,
39-
"allow-plugins" : {
40-
"composer/package-versions-deprecated" : true
41-
}
55+
"allow-plugins" : {"composer/package-versions-deprecated" : true}
4256
},
4357

44-
"extra" : {
58+
"extra" : {
4559
"branch-alias" : {
46-
"dev-master" : "2.x-dev"
60+
"dev-master" : "7.x-dev"
4761
}
4862
}
4963
}

demo.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
<?php
22

33
/**
4-
* JBZoo Toolbox - SimpleTypes
4+
* JBZoo Toolbox - SimpleTypes.
55
*
66
* This file is part of the JBZoo Toolbox project.
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*
10-
* @package SimpleTypes
1110
* @license MIT
1211
* @copyright Copyright (C) JBZoo.com, All rights reserved.
13-
* @link https://github.com/JBZoo/SimpleTypes
12+
* @see https://github.com/JBZoo/SimpleTypes
1413
*/
1514

1615
declare(strict_types=1);
1716

1817
require_once __DIR__ . '/vendor/autoload.php';
1918

20-
use JBZoo\SimpleTypes\Config\Config;
19+
use JBZoo\SimpleTypes\Config\AbstractConfig;
2120
use JBZoo\SimpleTypes\Config\Length as ConfigLength;
2221
use JBZoo\SimpleTypes\Config\Money as ConfigMoney;
2322
use JBZoo\SimpleTypes\Config\Weight as ConfigWeight;
@@ -26,9 +25,9 @@
2625
use JBZoo\SimpleTypes\Type\Weight;
2726

2827
// Set config object for all Money objects as default
29-
Config::registerDefault('money', new ConfigMoney());
30-
Config::registerDefault('weight', new ConfigWeight());
31-
Config::registerDefault('length', new ConfigLength());
28+
AbstractConfig::registerDefault('money', new ConfigMoney());
29+
AbstractConfig::registerDefault('weight', new ConfigWeight());
30+
AbstractConfig::registerDefault('length', new ConfigLength());
3231

3332
// Create Money object that represents 1 EUR
3433
// Some different ways
@@ -69,7 +68,7 @@
6968
->division(5) // -$2.19
7069
->multiply(10) // -$21.90
7170
->convert('eur') // -10.95€ (For easy understanding we use 1 EUR = 2 USD)
72-
->customFunc(function (Money $value) { // custom handler
71+
->customFunc(static function (Money $value): void { // custom handler
7372
$value
7473
->add(new Money('600 rub')) // 1.05€ (1 EUR = 50 RUB)
7574
->add('-500%'); // -4.2€
@@ -81,7 +80,7 @@
8180
echo $money->dump();
8281

8382
/**
84-
* You will see something like that
83+
* You will see something like that.
8584
*
8685
* Array
8786
* (

0 commit comments

Comments
 (0)