Skip to content

Commit a8a0246

Browse files
authored
Merge pull request #20 from PHP-DI-Definitions/switch-to-yielding-definistion-sources
Switch to yielding definition sources
2 parents d308714 + 3ef5b6a commit a8a0246

File tree

6 files changed

+1392
-1704
lines changed

6 files changed

+1392
-1704
lines changed

Makefile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ SHELL=bash
33

44
.PHONY: *
55

6+
CONTAINER_REGISTRY_REPO="ghcr.io/wyrihaximusnet/php"
67
COMPOSER_SHOW_EXTENSION_LIST_PROD=$(shell composer show -t | grep -o "\-\-\(ext-\).\+" | sort | uniq | cut -d- -f4- | tr -d '\n' | grep . | sed '/^$$/d' | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],' | sed 's/.$$//')
78
COMPOSER_SHOW_EXTENSION_LIST_DEV=$(shell composer show -s | grep -o "\(ext-\).\+" | sort | uniq | cut -d- -f2- | cut -d" " -f1 | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],')
89
COMPOSER_SHOW_EXTENSION_LIST=$(shell echo "${COMPOSER_SHOW_EXTENSION_LIST_PROD},${COMPOSER_SHOW_EXTENSION_LIST_DEV}")
910
SLIM_DOCKER_IMAGE=$(shell php -r 'echo count(array_intersect(["gd", "vips"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}"))) > 0 ? "" : "-slim";')
1011
NTS_OR_ZTS_DOCKER_IMAGE=$(shell php -r 'echo count(array_intersect(["parallel"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}"))) > 0 ? "zts" : "nts";')
11-
PHP_VERSION:=$(shell docker run --rm -v "`pwd`:`pwd`" jess/jq jq -r -c '.config.platform.php' "`pwd`/composer.json" | php -r "echo str_replace('|', '.', explode('.', implode('|', explode('.', stream_get_contents(STDIN), 2)), 2)[0]);")
12-
CONTAINER_NAME=$(shell echo "ghcr.io/wyrihaximusnet/php:${PHP_VERSION}-${NTS_OR_ZTS_DOCKER_IMAGE}-alpine${SLIM_DOCKER_IMAGE}-dev")
12+
PHP_VERSION:=$(shell (((command -v docker >/dev/null 2>&1) && docker run --rm -v "`pwd`:`pwd`" ${CONTAINER_REGISTRY_REPO}:8.4-nts-alpine-slim php -r "echo json_decode(file_get_contents('`pwd`/composer.json'), true)['config']['platform']['php'];") || echo "8.3") | php -r "echo str_replace('|', '.', explode('.', implode('|', explode('.', stream_get_contents(STDIN), 2)), 2)[0]);")
13+
CONTAINER_NAME=$(shell echo "${CONTAINER_REGISTRY_REPO}:${PHP_VERSION}-${NTS_OR_ZTS_DOCKER_IMAGE}-alpine${SLIM_DOCKER_IMAGE}-dev")
1314
COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
14-
COMPOSER_CONTAINER_CACHE_DIR=$(shell docker run --rm -it ${CONTAINER_NAME} composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
15+
COMPOSER_CONTAINER_CACHE_DIR=$(shell ((command -v docker >/dev/null 2>&1) && docker run --rm -it ${CONTAINER_NAME} composer config --global cache-dir -q) || echo ${HOME}/.composer-php/cache)
1516

1617
ifneq ("$(wildcard /.you-are-in-a-wyrihaximus.net-php-docker-image)","")
1718
IN_DOCKER=TRUE
@@ -26,6 +27,7 @@ else
2627
-v "`pwd`:`pwd`" \
2728
-v "${COMPOSER_CACHE_DIR}:${COMPOSER_CONTAINER_CACHE_DIR}" \
2829
-w "`pwd`" \
30+
-e OTEL_PHP_FIBERS_ENABLED="true" \
2931
"${CONTAINER_NAME}"
3032
endif
3133

@@ -36,27 +38,35 @@ else
3638
endif
3739

3840
all: ## Runs everything ####
39-
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "####" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs --open-tty $(MAKE)
41+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "####" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs -o $(MAKE)
4042

41-
syntax-php: ## Lint PHP syntax ##*LH*##
43+
on-install-or-update: ## Runs everything ####
44+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -E "##\*(I|ILH)\*##" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs -o $(MAKE)
45+
46+
syntax-php: ## Lint PHP syntax ##*ILH*##
4247
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
4348

44-
cs-fix: ## Fix any automatically fixable code style issues ###
45-
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml -vvvv
49+
composer-normalize: ### Normalize composer.json ##*I*##
50+
$(DOCKER_RUN) composer normalize
51+
$(DOCKER_RUN) composer update --lock --no-scripts
52+
53+
rector-upgrade: ## Upgrade any automatically upgradable old code ##*I*##
54+
$(DOCKER_RUN) vendor/bin/rector -c ./etc/qa/rector.php
55+
56+
cs-fix: ## Fix any automatically fixable code style issues ##*I*##
57+
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml -vvvv
4658

4759
cs: ## Check the code for code style issues ##*LCH*##
48-
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml
60+
$(DOCKER_RUN) vendor/bin/phpcs --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml
4961

5062
stan: ## Run static analysis (PHPStan) ##*LCH*##
51-
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c ./etc/qa/phpstan.neon
63+
$(DOCKER_RUN) vendor/bin/phpstan analyse etc src tests --level max --ansi -c ./etc/qa/phpstan.neon
5264

5365
unit-testing: ## Run tests ##*A*##
5466
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c ./etc/qa/phpunit.xml --coverage-text --coverage-html ./var/tests-unit-coverage-html --coverage-clover ./var/tests-unit-clover-coverage.xml
55-
$(DOCKER_RUN) test -n "$(COVERALLS_REPO_TOKEN)" && test -n "$(COVERALLS_RUN_LOCALLY)" && test -f ./var/tests-unit-clover-coverage.xml && vendor/bin/php-coveralls -v --coverage_clover ./build/logs/clover.xml --json_path ./var/tests-unit-clover-coverage-upload.json || true
5667

5768
unit-testing-raw: ## Run tests ##*D*## ####
5869
php vendor/phpunit/phpunit/phpunit --colors=always -c ./etc/qa/phpunit.xml --coverage-text --coverage-html ./var/tests-unit-coverage-html --coverage-clover ./var/tests-unit-clover-coverage.xml
59-
test -n "$(COVERALLS_REPO_TOKEN)" && test -n "$(COVERALLS_RUN_LOCALLY)" && test -f ./var/tests-unit-clover-coverage.xml && ./vendor/bin/php-coveralls -v --coverage_clover ./build/logs/clover.xml --json_path ./var/tests-unit-clover-coverage-upload.json || true
6070

6171
mutation-testing: ## Run mutation testing ##*LCH*##
6272
$(DOCKER_RUN) vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --threads=$(THREADS) || (cat ./var/infection.log && false)
@@ -70,9 +80,6 @@ composer-require-checker: ## Ensure we require every package used in this packag
7080
composer-unused: ## Ensure we don't require any package we don't use in this package directly ##*C*##
7181
$(DOCKER_RUN) vendor/bin/composer-unused --ansi --configuration=./etc/qa/composer-unused.php
7282

73-
libyear: ### Calculate how many libyear this package is behind with dependencies
74-
$(DOCKER_RUN) vendor/bin/libyear
75-
7683
backward-compatibility-check: ## Check code for backwards incompatible changes ##*C*##
7784
$(MAKE) backward-compatibility-check-raw || true
7885

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
[![Total Downloads](https://poser.pugx.org/php-di-definitions/definitions-gatherer/downloads.png)](https://packagist.org/packages/php-di-definitions/definitions-gatherer)
66
[![Code Coverage](https://scrutinizer-ci.com/g/php-di-definitions/definitions-gatherer/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/php-di-definitions/definitions-gatherer/?branch=master)
77
[![License](https://poser.pugx.org/php-di-definitions/definitions-gatherer/license.png)](https://packagist.org/packages/php-di-definitions/definitions-gatherer)
8-
[![PHP 7 ready](http://php7ready.timesplinter.ch/WyriHaximus/reactphp-http-middleware-clear-body/badge.svg)](https://travis-ci.org/WyriHaximus/reactphp-http-middleware-clear-body)
98

109
# Install
1110

@@ -56,17 +55,17 @@ the same format):
5655
use DI\ContainerBuilder;
5756
use PHPDIDefinitions\DefinitionsGatherer;
5857

59-
$definitions = iterator_to_array(DefinitionsGatherer::gather());
58+
6059
$containerBuilder = new ContainerBuilder();
61-
$containerBuilder->addDefinitions($definitions);
60+
$containerBuilder->addDefinitions(...DefinitionsGatherer::gather());
6261
$container = $containerBuilder->build();
6362
```
6463

6564
# License
6665

6766
The MIT License (MIT)
6867

69-
Copyright (c) 2023 Cees-Jan Kiewiet
68+
Copyright (c) 2025 Cees-Jan Kiewiet
7069

7170
Permission is hereby granted, free of charge, to any person obtaining a copy
7271
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
}
1010
],
1111
"require": {
12-
"php": "^8.3",
12+
"php": "^8.4",
1313
"php-di-definitions/dummy": "^1.0",
14-
"wyrihaximus/get-in-packages-composer.jason": "^2"
14+
"php-di/php-di": "^7.1",
15+
"wyrihaximus/get-in-packages-composer.jason": "^2.3.0"
1516
},
1617
"require-dev": {
17-
"wyrihaximus/makefiles": "^0.3.4",
18-
"wyrihaximus/test-utilities": "^7.0.0"
18+
"wyrihaximus/makefiles": "^0.5.0",
19+
"wyrihaximus/test-utilities": "^8.5.0"
1920
},
2021
"autoload": {
2122
"psr-4": {
@@ -39,19 +40,20 @@
3940
"mindplay/composer-locator": true,
4041
"ocramius/package-versions": true,
4142
"phpstan/extension-installer": true,
42-
"wyrihaximus/makefiles": true
43+
"wyrihaximus/makefiles": true,
44+
"wyrihaximus/test-utilities": true
4345
},
4446
"platform": {
45-
"php": "8.3.13"
47+
"php": "8.4.13"
4648
},
4749
"sort-packages": true
4850
},
4951
"scripts": {
5052
"post-install-cmd": [
51-
"composer normalize"
53+
"make on-install-or-update || true"
5254
],
5355
"post-update-cmd": [
54-
"composer normalize"
56+
"make on-install-or-update || true"
5557
]
5658
}
5759
}

0 commit comments

Comments
 (0)