Skip to content

Commit 73e32bd

Browse files
authored
Merge pull request #91 from Chris53897/feature/modernise
feat: modernise, drop support for php < 7.4, migrate tests and config…
2 parents 03ead79 + 98654fd commit 73e32bd

29 files changed

+238
-219
lines changed

.github/workflows/ci.yaml

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
1-
name: PHP Composer
1+
# .github/workflows/code_checks.yaml
2+
name: Code_Checks
23

3-
on:
4-
push:
5-
pull_request:
6-
branches: [ "master" ]
7-
8-
permissions:
9-
contents: read
4+
on: ["push", "pull_request"]
105

116
jobs:
12-
run:
13-
runs-on: ${{ matrix.operating-system }}
7+
tests:
8+
runs-on: ubuntu-latest
149
strategy:
1510
fail-fast: false
1611
matrix:
17-
operating-system: [ubuntu-latest]
18-
php-versions:
19-
- '7.4'
20-
# - '8.0'
21-
# - '8.1'
22-
# - '8.2'
23-
# - '8.3'
24-
# - '8.4'
25-
26-
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
27-
12+
php: ['7.4']
13+
stability: [ prefer-stable ]
14+
experimental: [false]
15+
include:
16+
- php: '7.4'
17+
stability: prefer-lowest
18+
- php: '8.0'
19+
- php: '8.1'
20+
- php: '8.2'
21+
- php: '8.3'
22+
23+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }} tests
2824
steps:
29-
- name: Checkout
30-
uses: actions/checkout@v4
31-
32-
- name: Install PHP
33-
uses: shivammathur/setup-php@v2
34-
with:
35-
php-version: ${{ matrix.php-versions }}
36-
37-
- name: Check PHP Version
38-
run: php -v
39-
40-
- name: Validate composer.json and composer.lock
41-
run: composer validate --strict
42-
43-
- name: Install dependencies
44-
run: composer install --prefer-dist --no-progress
45-
46-
- name: Run lint check
47-
run: composer run-script lint
48-
49-
- name: Run test suite
50-
run: composer run-script test
25+
# basically git clone
26+
- uses: actions/checkout@v4
27+
28+
- name: Cache dependencies
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.composer/cache/files
32+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
33+
34+
# use PHP of specific version
35+
- uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: ${{ matrix.php }}
38+
extensions: pcov
39+
coverage: pcov
40+
41+
- name: Install dependencies
42+
run: |
43+
composer install --verbose --prefer-dist --no-interaction -o
44+
45+
- name: Execute tests
46+
run: composer run-script test
47+
48+
cs:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: shivammathur/setup-php@v2
53+
with:
54+
php-version: 8.2
55+
coverage: none # disable xdebug, pcov
56+
- run: composer install --no-progress
57+
- run: composer run-script lint

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ Desktop.ini
2222
## From https://github.com/github/gitignore
2323
### SASS Ignores - "Sassy CSS" http://sass-lang.com/
2424
*.sass-cache
25+
26+
.phpunit.result.cache
27+
tests/clover.xml

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v2.2.0 (xxx)
2+
3+
- Drop support of php < 7.4
4+
15
## v2.1.0 (July 24th, 2016)
26
- Added getUnitDefinitions() method to PhysicalQuantity classes, to get a raw list of UnitofMeasure objects defined on that quantity
37
- Added UPPERCASE templating support for autogenerated metric units to support names like MEGA_METERS, for example.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ isTooTallToRideThisTrain( new Length(2, 'm') );
4343
```
4444

4545
## Installation
46-
This library is best included in your projects via Composer. See the [Composer website](http://getcomposer.org/) for more details, and see the [Packagist.org site for this library](https://packagist.org/packages/php-units-of-measure/php-units-of-measure).
46+
This library is best included in your projects via Composer. See the [Composer website](https://getcomposer.org/) for more details, and see the [Packagist.org site for this library](https://packagist.org/packages/php-units-of-measure/php-units-of-measure).
4747

48-
If you'd prefer to manually include this library as a dependency in your project, then it is recommended that you use a [PSR-4](http://www.php-fig.org/psr/psr-4/) compliant PHP autoloader. The mapping between this project's root namespace and its base directory is:
48+
If you'd prefer to manually include this library as a dependency in your project, then it is recommended that you use a [PSR-4](https://www.php-fig.org/psr/psr-4/) compliant PHP autoloader. The mapping between this project's root namespace and its base directory is:
4949
- vendor namespace 'PhpUnitsOfMeasure\' maps to the library's base directory 'source/'
5050

5151
See the documentation of your autoloader for further instructions.
5252

5353
### Project Tags and Versions
54-
This project follows the guidelines set out in [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html). In general, versions are of the form 'X.Y.Z', and increments to X denote backward-incompatible major changes.
54+
This project follows the guidelines set out in [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html). In general, versions are of the form 'X.Y.Z', and increments to X denote backward-incompatible major changes.
5555

56-
It is recommended that if your project includes this project as a dependency and you are using an automated dependency management tool such as [Composer](http://getcomposer.org/), then you should 'pin' the major version (X) and allow only variations in 'Y' (minor changes) and 'Z' (bugfixes). See the documentation of your dependency manager for more details.
56+
It is recommended that if your project includes this project as a dependency and you are using an automated dependency management tool such as [Composer](https://getcomposer.org/), then you should 'pin' the major version (X) and allow only variations in 'Y' (minor changes) and 'Z' (bugfixes). See the documentation of your dependency manager for more details.
5757

5858

5959
## Use
@@ -239,7 +239,7 @@ class Length extends AbstractPhysicalQuantity
239239
Now any program which uses `Length` will start with the cubits unit already built in. Note that here we used the more concise linear unit factory method, but the result is equivalent to the expanded form calling the `UnitOfMeasure` constructor, as used above. Also, notice that the `static` keyword was used instead of the class name, though either would be acceptable in this case.
240240

241241
### Adding New Physical Quantities
242-
[Physical quantities](http://en.wikipedia.org/wiki/Physical_quantity) are categories of measurable values, like mass, length, force, etc.
242+
[Physical quantities](https://en.wikipedia.org/wiki/Physical_quantity) are categories of measurable values, like mass, length, force, etc.
243243

244244
For physical quantities that are not already present in this library, it will be necessary to write a class to support a new one. All physical quantities implement the `\PhpUnitsOfMeasure\PhysicalQuantityInterface` interface, typically extend the `\PhpUnitsOfMeasure\AbstractPhysicalQuantity` class, and typically have only an `initialize()` method which creates the quantity's units of measure. See above for typical examples of physical quantity classes and of how to add new units to a quantity class.
245245

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
"source": "https://github.com/PhpUnitsOfMeasure/php-units-of-measure"
2020
},
2121
"require": {
22-
"php": ">=7.4.0"
22+
"php": ">=7.4"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "5.*",
26-
"squizlabs/php_codesniffer": "3.7.2"
25+
"phpunit/phpunit": "^9.5",
26+
"squizlabs/php_codesniffer": "^3.7"
2727
},
2828
"replace": {
2929
"triplepoint/php-units-of-measure": "*"

0 commit comments

Comments
 (0)