Skip to content

Commit fb4f00b

Browse files
authored
Merge branch 'steevanb:master' into feat-datetime_collection
2 parents c3ce9f0 + bedf5b5 commit fb4f00b

File tree

108 files changed

+1548
-88
lines changed

Some content is hidden

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

108 files changed

+1548
-88
lines changed

.github/workflows/ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- uses: actions/checkout@v2
5050
- run: bin/ci/unused-scanner
5151

52-
phpunit:
52+
phpunit-symfony-6:
5353
runs-on: ubuntu-latest
5454
strategy:
5555
matrix:
@@ -65,7 +65,8 @@ jobs:
6565
strategy:
6666
matrix:
6767
php: [--php=8.2, --php=8.3]
68+
symfony: [--symfony=7.0, --symfony=7.1]
6869
steps:
6970
- uses: actions/checkout@v2
7071
- uses: ./.github/actions/ci-env
71-
- run: bin/ci/phpunit ${{ matrix.php }} --symfony=7.0
72+
- run: bin/ci/phpunit ${{ matrix.php }} ${{ matrix.symfony }}

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
[![Version](https://img.shields.io/badge/version-6.1.0-blueviolet.svg)](https://github.com/steevanb/php-collection/tree/6.1.0)
1+
[![Version](https://img.shields.io/badge/version-6.2.0-blueviolet.svg)](https://github.com/steevanb/php-collection/tree/6.2.0)
22
[![PHP](https://img.shields.io/badge/php-^8.1-blue.svg)](https://php.net)
3-
![Lines](https://img.shields.io/badge/code%20lines-3,622-blue.svg)
3+
![Lines](https://img.shields.io/badge/code%20lines-3,714-blue.svg)
44
![Downloads](https://poser.pugx.org/steevanb/php-typed-array/downloads)
55
![GitHub workflow status](https://img.shields.io/github/actions/workflow/status/steevanb/php-collection/ci.yml?branch=master)
6-
![Coverage](https://img.shields.io/badge/coverage-88%25-success.svg)
6+
![Coverage](https://img.shields.io/badge/coverage-89%25-success.svg)
77

88
## php-collection
99

bin/ci/composer-require-checker

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

99
composer-require-checker \
1010
--ansi \
11-
--config-file="${ROOT_DIR}"/config/ci/composerRequireChecker.json \
11+
--config-file="${ROOT_PATH}"/config/ci/composerRequireChecker.json \
1212
"${@}"

bin/ci/composer-validate

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

99
composer validate --ansi --strict

bin/ci/docker

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
source "${ROOT_DIR}"/bin/common.inc.sh
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
source "${ROOT_PATH}"/bin/common.inc.sh
77

88
DOCKER_IMAGE_NAME="${CI_DOCKER_IMAGE_NAME}" \
9-
DOCKER_FILE_PATH="${ROOT_DIR}"/docker/ci/Dockerfile \
10-
source "${ROOT_DIR}"/bin/docker-build.inc.bash
9+
DOCKER_FILE_PATH="${ROOT_PATH}"/docker/ci/Dockerfile \
10+
source "${ROOT_PATH}"/bin/docker-build.inc.bash

bin/ci/env

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

9-
"${ROOT_DIR}"/bin/composer install
9+
"${ROOT_PATH}"/bin/composer install

bin/ci/phpcs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

9-
if [ ! -d "${ROOT_DIR}"/var/ci/phpcs ]; then
10-
mkdir -p "${ROOT_DIR}"/var/ci/phpcs
9+
if [ ! -d "${ROOT_PATH}"/var/ci/phpcs ]; then
10+
mkdir -p "${ROOT_PATH}"/var/ci/phpcs
1111
fi
1212

1313
phpcs \
@@ -17,6 +17,6 @@ phpcs \
1717
--bootstrap=config/ci/phpcs.php \
1818
--standard="${COMPOSER_HOME}"/vendor/steevanb/php-code-sniffs/src/Steevanb/ruleset.xml \
1919
--report=steevanb\\PhpCodeSniffs\\Reports\\Steevanb \
20-
--cache="${ROOT_DIR}"/var/ci/phpcs/cache \
20+
--cache="${ROOT_PATH}"/var/ci/phpcs/cache \
2121
. \
2222
"${@}"

bin/ci/phpdd

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

99
ls -lah ${COMPOSER_HOME}/vendor/bin
1010
ls -lah ${COMPOSER_HOME}/vendor/wapmorgan/php-deprecation-detector/bin

bin/ci/phpstan

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
66

7-
source "${ROOT_DIR}"/bin/common.inc.sh
8-
source "${ROOT_DIR}"/bin/dockerise.inc.bash
7+
source "${ROOT_PATH}"/bin/common.inc.sh
8+
source "${ROOT_PATH}"/bin/dockerise.inc.bash
99

1010
phpVersion=
1111
phpstanParameters=
@@ -20,13 +20,13 @@ for arg in "${@}"; do
2020
fi
2121
done
2222

23-
if [ "${clearCache}" == true ] && [ -d "${ROOT_DIR}"/var/ci/phpstan ]; then
23+
if [ "${clearCache}" == true ] && [ -d "${ROOT_PATH}"/var/ci/phpstan ]; then
2424
echo "Clear cache"
25-
rm -rf "${ROOT_DIR}"/var/ci/phpstan
25+
rm -rf "${ROOT_PATH}"/var/ci/phpstan
2626
fi
2727

2828
if [ "${phpVersion}" == "" ]; then
29-
php8.2 "${ROOT_DIR}"/bin/ci/phpstan.php ${phpstanParameters}
29+
php8.3 "${ROOT_PATH}"/bin/ci/phpstan.php ${phpstanParameters}
3030
else
3131
echo "PHP ${phpVersion}"
3232

bin/ci/phpunit

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

99
phpVersion=
1010
symfonyVersion=
@@ -20,7 +20,7 @@ for arg in "${@}"; do
2020
done
2121

2222
if [ "${phpVersion}" == "" ] || [ "${symfonyVersion}" == "" ]; then
23-
php8.2 "${ROOT_DIR}"/bin/ci/phpunit.php "${@}"
23+
php8.2 "${ROOT_PATH}"/bin/ci/phpunit.php "${@}"
2424
else
2525
echo "PHP ${phpVersion} - Symfony ${symfonyVersion}"
2626

bin/ci/phpunit-coverage

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

99
echo "PHP 8.1 - Symfony 6.1"
1010
set +e
1111
XDEBUG_MODE=coverage \
1212
php8.2 \
13-
"${ROOT_DIR}"/vendor/bin/phpunit \
13+
"${ROOT_PATH}"/vendor/bin/phpunit \
1414
--bootstrap "${COMPOSER_HOME_SYMFONY_6_1}"/vendor/autoload.php \
15-
--coverage-html "${ROOT_DIR}"/var/ci/phpunit/coverage/html \
16-
--configuration "${ROOT_DIR}"/config/ci/phpunit.php-8.1.xml \
15+
--coverage-html "${ROOT_PATH}"/var/ci/phpunit/coverage/html \
16+
--configuration "${ROOT_PATH}"/config/ci/phpunit.php-8.1.xml \
1717
"${@}"
1818
set -e
1919

bin/ci/phpunit.inc.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ function createPhpunitProcesses(string $phpVersion = null, string $symfonyVersio
1212
{
1313
$phpVersions = new StringCollection(is_string($phpVersion) ? [$phpVersion] : ['8.1', '8.2', '8.3']);
1414
$symfonyVersions = new StringCollection(
15-
is_string($symfonyVersion) ? [$symfonyVersion] : ['6.1', '6.2', '6.3', '6.4', '7.0']
15+
is_string($symfonyVersion) ? [$symfonyVersion] : ['6.1', '6.2', '6.3', '6.4', '7.0', '7.1']
1616
);
1717

1818
$return = new ProcessInterfaceCollection();
1919
foreach ($phpVersions->toArray() as $loopPhpVersion) {
2020
foreach ($symfonyVersions->toArray() as $loopSymfonyVersion) {
21-
if ($loopSymfonyVersion === '7.0' && in_array($loopPhpVersion, ['8.2', '8.3'], true) === false) {
21+
if (
22+
in_array($loopSymfonyVersion, ['7.0', '7.1'])
23+
&& in_array($loopPhpVersion, ['8.2', '8.3'], true) === false
24+
) {
2225
continue;
2326
}
27+
2428
$return->add(createPhpunitProcess($loopPhpVersion, $loopSymfonyVersion));
2529
}
2630
}

bin/ci/shellcheck

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
source "${ROOT_DIR}"/bin/common.inc.sh
7-
source "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
source "${ROOT_PATH}"/bin/common.inc.sh
7+
source "${ROOT_PATH}"/bin/dockerise.inc.bash
88

99
filesToCheck=()
10-
files=$(find "${ROOT_DIR}"/bin)
10+
files=$(find "${ROOT_PATH}"/bin)
1111
for file in ${files}; do
1212
if [ -f "${file}" ] && [ "${file:(-4)}" != ".php" ]; then
1313
filesToCheck+=("${file}")

bin/ci/unused-scanner

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

9-
unused-scanner "${ROOT_DIR}"/config/ci/unused-scanner.php
9+
unused-scanner "${ROOT_PATH}"/config/ci/unused-scanner.php

bin/ci/validate

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
. "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
. "${ROOT_PATH}"/bin/dockerise.inc.bash
88

9-
php8.2 "${ROOT_DIR}"/bin/ci/validate.php "${@}"
9+
php8.2 "${ROOT_PATH}"/bin/ci/validate.php "${@}"

bin/composer

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/..")"
6-
. "${ROOT_DIR}"/bin/common.inc.sh
7-
BIN_DIR=bin COMPOSER_HOME=/app/var/composer . "${ROOT_DIR}"/bin/dockerise.inc.bash
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/..")"
6+
. "${ROOT_PATH}"/bin/common.inc.sh
7+
BIN_DIR=bin COMPOSER_HOME=/app/var/composer . "${ROOT_PATH}"/bin/dockerise.inc.bash
88

99
php /usr/local/bin/composer "${@}"

bin/dev/generate-php-collections

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
source "${ROOT_PATH}"/bin/common.inc.sh
7+
BIN_DIR=bin/dev COMPOSER_HOME=/app/var/composer source "${ROOT_PATH}"/bin/dockerise.inc.bash
8+
9+
php /app/bin/dev/generate-php-collections.php

bin/dev/generate-php-collections.php

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Steevanb\PhpCollection\{
6+
Maker\ObjectCollectionMaker,
7+
Maker\ObjectNullableCollectionMaker
8+
};
9+
10+
$rootPath = dirname(__DIR__, 2);
11+
12+
require $rootPath . '/vendor/autoload.php';
13+
14+
$maker = new ObjectCollectionMaker();
15+
$nullableMaker = new ObjectNullableCollectionMaker();
16+
$collectionPath = $rootPath . '/src/ObjectCollection';
17+
$collectionNamespace = 'Steevanb\\PhpCollection\\ObjectCollection';
18+
19+
$interfaces = [
20+
'\\' . BackedEnum::class,
21+
'\\' . Countable::class,
22+
'\\' . DateTimeInterface::class,
23+
'\\' . JsonSerializable::class,
24+
'\\' . Serializable::class,
25+
'\\' . Stringable::class,
26+
'\\' . UnitEnum::class
27+
];
28+
29+
foreach ($interfaces as $interface) {
30+
echo 'Generate collection for ' . $interface . '.' . "\n";
31+
$maker->make($interface, $collectionPath, $collectionNamespace);
32+
33+
echo 'Generate nullable collection for ' . $interface . '.' . "\n";
34+
$nullableMaker->make($interface, $collectionPath, $collectionNamespace);
35+
}
36+
37+
$classes = [
38+
'\\' . DateInterval::class,
39+
'\\' . DatePeriod::class,
40+
'\\' . DateTime::class,
41+
'\\' . DateTimeImmutable::class,
42+
'\\' . DateTimeZone::class,
43+
'\\' . Reflection::class,
44+
'\\' . ReflectionAttribute::class,
45+
'\\' . ReflectionClass::class,
46+
'\\' . ReflectionClassConstant::class,
47+
'\\' . ReflectionEnum::class,
48+
'\\' . ReflectionEnumBackedCase::class,
49+
'\\' . ReflectionEnumUnitCase::class,
50+
'\\' . ReflectionExtension::class,
51+
'\\' . ReflectionFiber::class,
52+
'\\' . ReflectionFunction::class,
53+
'\\' . ReflectionFunctionAbstract::class,
54+
'\\' . ReflectionGenerator::class,
55+
'\\' . ReflectionIntersectionType::class,
56+
'\\' . ReflectionMethod::class,
57+
'\\' . ReflectionNamedType::class,
58+
'\\' . ReflectionObject::class,
59+
'\\' . ReflectionParameter::class,
60+
'\\' . ReflectionProperty::class,
61+
'\\' . ReflectionReference::class,
62+
'\\' . ReflectionType::class,
63+
'\\' . ReflectionUnionType::class,
64+
'\\' . SplFileInfo::class,
65+
'\\' . SplFileObject::class,
66+
'\\' . stdClass::class
67+
];
68+
69+
foreach ($classes as $class) {
70+
echo 'Generate collection for ' . $class . '.' . "\n";
71+
$maker->make($class, $collectionPath, $collectionNamespace);
72+
73+
echo 'Generate nullable collection for ' . $class . '.' . "\n";
74+
$nullableMaker->make($class, $collectionPath, $collectionNamespace);
75+
}

bin/dev/start

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -eu
44

5-
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6-
source "${ROOT_DIR}"/bin/common.inc.sh
5+
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
6+
source "${ROOT_PATH}"/bin/common.inc.sh
77

88
docker pull "${CI_DOCKER_IMAGE_NAME}"
9-
"${ROOT_DIR}"/bin/composer up
9+
"${ROOT_PATH}"/bin/composer up

bin/docker-build.inc.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function buildDockerImage() {
2020
--build-arg DOCKER_UID="$(id -u)" \
2121
--build-arg DOCKER_GID="$(id -g)" \
2222
${refreshArguments} \
23-
"${ROOT_DIR}"
23+
"${ROOT_PATH}"
2424
}
2525

2626
function pushDockerImage() {

bin/dockerise.inc.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if ! ${isInDocker}; then
3232
--rm \
3333
--tty \
3434
${interactiveParameter} \
35-
--volume "${ROOT_DIR}":/app \
35+
--volume "${ROOT_PATH}":/app \
3636
--user "$(id -u)":"$(id -g)" \
3737
--entrypoint "${BIN_DIR}"/"$(basename "${0}")" \
3838
--workdir /app \

0 commit comments

Comments
 (0)