Skip to content

Commit 5886b32

Browse files
authored
Release/2.1.0 (#11)
1 parent af5a37e commit 5886b32

25 files changed

+262
-434
lines changed

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/tests export-ignore
2+
/vendor export-ignore
3+
4+
/LICENSE export-ignore
5+
/Makefile export-ignore
6+
/README.md export-ignore
7+
/phpmd.xml export-ignore
8+
/phpunit.xml export-ignore
9+
/phpstan.neon.dist export-ignore
10+
/infection.json.dist export-ignore
11+
12+
/.github export-ignore
13+
/.gitignore export-ignore
14+
/.gitattributes export-ignore

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ jobs:
1616
- name: Checkout
1717
uses: actions/checkout@v3
1818

19+
- name: Use PHP 8.2
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: '8.2'
23+
1924
- name: Install dependencies
2025
run: composer update --no-progress --optimize-autoloader
2126

@@ -33,6 +38,11 @@ jobs:
3338
- name: Checkout
3439
uses: actions/checkout@v3
3540

41+
- name: Use PHP 8.2
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: '8.2'
45+
3646
- name: Install dependencies
3747
run: composer update --no-progress --optimize-autoloader
3848

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
DOCKER_RUN = docker run --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.2
22

3-
.PHONY: configure test test-no-coverage review show-reports clean
3+
.PHONY: configure test test-file test-no-coverage review show-reports clean
44

55
configure:
66
@${DOCKER_RUN} composer update --optimize-autoloader
77

8-
test: review
8+
test:
99
@${DOCKER_RUN} composer tests
1010

11-
test-no-coverage: review
11+
test-file:
12+
@${DOCKER_RUN} composer tests-file-no-coverage ${FILE}
13+
14+
test-no-coverage:
1215
@${DOCKER_RUN} composer tests-no-coverage
1316

1417
review:
@@ -19,4 +22,4 @@ show-reports:
1922

2023
clean:
2124
@sudo chown -R ${USER}:${USER} ${PWD}
22-
@rm -rf report vendor
25+
@rm -rf report vendor .phpunit.cache

composer.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"keywords": [
1010
"vo",
1111
"psr",
12-
"psr-4",
13-
"psr-12",
1412
"tiny-blocks",
1513
"value-object"
1614
],
@@ -20,6 +18,10 @@
2018
"homepage": "https://github.com/gustavofreze"
2119
}
2220
],
21+
"support": {
22+
"issues": "https://github.com/tiny-blocks/value-object/issues",
23+
"source": "https://github.com/tiny-blocks/value-object"
24+
},
2325
"config": {
2426
"sort-packages": true,
2527
"allow-plugins": {
@@ -37,24 +39,27 @@
3739
}
3840
},
3941
"require": {
40-
"php": "^8.1||^8.2"
42+
"php": "^8.2"
4143
},
4244
"require-dev": {
43-
"infection/infection": "^0.26",
44-
"phpmd/phpmd": "^2.13",
45-
"phpunit/phpunit": "^9.6",
46-
"squizlabs/php_codesniffer": "^3.7"
45+
"phpmd/phpmd": "^2.15",
46+
"phpunit/phpunit": "^11",
47+
"phpstan/phpstan": "^1",
48+
"infection/infection": "^0.29",
49+
"squizlabs/php_codesniffer": "^3.10"
4750
},
4851
"scripts": {
4952
"phpcs": "phpcs --standard=PSR12 --extensions=php ./src",
5053
"phpmd": "phpmd ./src text phpmd.xml --suffixes php --ignore-violations-on-exit",
54+
"phpstan": "phpstan analyse -c phpstan.neon.dist --quiet --no-progress",
5155
"test": "phpunit --log-junit=report/coverage/junit.xml --coverage-xml=report/coverage/coverage-xml --coverage-html=report/coverage/coverage-html tests",
5256
"test-mutation": "infection --only-covered --logger-html=report/coverage/mutation-report.html --coverage=report/coverage --min-msi=100 --min-covered-msi=100 --threads=4",
5357
"test-no-coverage": "phpunit --no-coverage",
5458
"test-mutation-no-coverage": "infection --only-covered --min-msi=100 --threads=4",
5559
"review": [
5660
"@phpcs",
57-
"@phpmd"
61+
"@phpmd",
62+
"@phpstan"
5863
],
5964
"tests": [
6065
"@test",

infection.json.dist

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
{
22
"timeout": 10,
33
"testFramework": "phpunit",
4-
"tmpDir": "report/",
4+
"tmpDir": "report/infection/",
55
"source": {
66
"directories": [
77
"src"
88
]
99
},
1010
"logs": {
11-
"text": "report/logs/infection-text.log",
12-
"summary": "report/logs/infection-summary.log"
11+
"text": "report/infection/logs/infection-text.log",
12+
"summary": "report/infection/logs/infection-summary.log"
1313
},
1414
"mutators": {
15-
"@default": true,
16-
"PublicVisibility": false,
17-
"ProtectedVisibility": false
15+
"@default": true
1816
},
1917
"phpUnit": {
2018
"configDir": "",
2119
"customPath": "./vendor/bin/phpunit"
2220
}
23-
}
21+
}

phpstan.neon.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
parameters:
2+
paths:
3+
- src
4+
level: 9
5+
tmpDir: report/phpstan
6+
ignoreErrors:
7+
- '#return type has no value type specified in iterable type array#'
8+
reportUnmatchedIgnoredErrors: false

phpunit.xml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
bootstrap="vendor/autoload.php"
4-
cacheResultFile="report/.phpunit.result.cache"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
74
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
11-
processIsolation="false"
12-
stopOnFailure="false"
13-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
5+
bootstrap="vendor/autoload.php"
6+
failOnRisky="true"
7+
failOnWarning="true"
8+
cacheDirectory=".phpunit.cache"
9+
beStrictAboutOutputDuringTests="true">
10+
11+
<source>
12+
<include>
13+
<directory>src</directory>
14+
</include>
15+
</source>
16+
1417
<testsuites>
1518
<testsuite name="default">
16-
<directory suffix="Test.php">tests</directory>
19+
<directory>tests</directory>
1720
</testsuite>
1821
</testsuites>
1922

2023
<coverage>
21-
<include>
22-
<directory suffix=".php">src</directory>
23-
</include>
24+
<report>
25+
<text outputFile="report/coverage.txt"/>
26+
<html outputDirectory="report/html/"/>
27+
<clover outputFile="report/coverage-clover.xml"/>
28+
</report>
2429
</coverage>
30+
31+
<logging>
32+
<junit outputFile="report/execution-result.xml"/>
33+
</logging>
34+
2535
</phpunit>

src/Immutable.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TinyBlocks\Vo;
6+
7+
use TinyBlocks\Vo\Internal\Exceptions\InvalidProperty;
8+
use TinyBlocks\Vo\Internal\Exceptions\PropertyCannotBeChanged;
9+
use TinyBlocks\Vo\Internal\Exceptions\PropertyCannotBeDeactivated;
10+
11+
/**
12+
* Defines immutability by restricting property modification.
13+
*/
14+
interface Immutable
15+
{
16+
/**
17+
* Does not allow to get unknown property.
18+
* @param mixed $key
19+
* @return void
20+
* @throws InvalidProperty Get unknown property.
21+
*/
22+
public function __get(mixed $key): void;
23+
24+
/**
25+
* Does not allow injection of unknown property.
26+
* @param mixed $key
27+
* @param mixed $value
28+
* @return void
29+
* @throws PropertyCannotBeChanged If set property.
30+
*/
31+
public function __set(mixed $key, mixed $value): void;
32+
33+
/**
34+
* Does not allow properties to be disabled.
35+
* @param mixed $key
36+
* @return void
37+
* @throws PropertyCannotBeDeactivated If disable property.
38+
*/
39+
public function __unset(mixed $key): void;
40+
}

src/Internal/Exceptions/InvalidProperty.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace TinyBlocks\Vo\Internal\Exceptions;
46

57
use RuntimeException;

src/Internal/Exceptions/PropertyCannotBeChanged.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace TinyBlocks\Vo\Internal\Exceptions;
46

57
use RuntimeException;

src/Internal/Exceptions/PropertyCannotBeDeactivated.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace TinyBlocks\Vo\Internal\Exceptions;
46

57
use RuntimeException;

src/ValueObject.php

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

3-
namespace TinyBlocks\Vo;
3+
declare(strict_types=1);
44

5-
use TinyBlocks\Vo\Internal\Exceptions\InvalidProperty;
6-
use TinyBlocks\Vo\Internal\Exceptions\PropertyCannotBeChanged;
7-
use TinyBlocks\Vo\Internal\Exceptions\PropertyCannotBeDeactivated;
5+
namespace TinyBlocks\Vo;
86

97
/**
108
* A Value Object is an immutable type that is only distinguishable by the state of its properties, that is,
@@ -13,7 +11,7 @@
1311
*
1412
* @see http://martinfowler.com/bliki/ValueObject.html
1513
*/
16-
interface ValueObject
14+
interface ValueObject extends Immutable
1715
{
1816
/**
1917
* Returns object values.
@@ -27,29 +25,4 @@ public function values(): array;
2725
* @return bool
2826
*/
2927
public function equals(ValueObject $other): bool;
30-
31-
/**
32-
* Does not allow to get unknown property.
33-
* @param mixed $key
34-
* @return void
35-
* @throws InvalidProperty — Get unknown property.
36-
*/
37-
public function __get(mixed $key): void;
38-
39-
/**
40-
* Does not allow injection of unknown property.
41-
* @param mixed $key
42-
* @param mixed $value
43-
* @return void
44-
* @throws PropertyCannotBeChanged — If set property.
45-
*/
46-
public function __set(mixed $key, mixed $value): void;
47-
48-
/**
49-
* Does not allow properties to be disabled.
50-
* @param mixed $key
51-
* @return void
52-
* @throws PropertyCannotBeDeactivated — If disable property.
53-
*/
54-
public function __unset(mixed $key): void;
5528
}

src/ValueObjectAdapter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace TinyBlocks\Vo;
46

57
use TinyBlocks\Vo\Internal\Exceptions\InvalidProperty;

0 commit comments

Comments
 (0)