diff --git a/Dockerfile b/Dockerfile index 760d6ef..7045925 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ ARG PHP_VERSION=8.3 ARG DEBIAN_VERSION=bookworm +ARG COMPOSER_VERSION=2.7.6 -FROM composer:2.7.1 as composer +FROM composer:${COMPOSER_VERSION} as composer FROM php:${PHP_VERSION}-cli-${DEBIAN_VERSION} diff --git a/Makefile b/Makefile index e0ec19f..6c2d841 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,22 @@ ARGS_PHPUNIT ?= DOCKER := $(if $(LRN_SDK_NO_DOCKER),,$(shell which docker)) -PHP_VERSION = 8.3 -DEBIAN_VERSION = bookworm -IMAGE = php-cli-composer:$(PHP_VERSION) + +# PHP Evolution +SUPPORTED_PHP_VERSIONS = 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 +PHP_VERSION = $(lastword ${SUPPORTED_PHP_VERSIONS}) +DEBIAN_VERSION-7.1 = buster +DEBIAN_VERSION-7.2 = buster +DEBIAN_VERSION-7.3 = bullseye +DEBIAN_VERSION-7.4 = bullseye +DEBIAN_VERSION-8.0 = bullseye +DEBIAN_VERSION-def = bookworm +DEBIAN_VERSION = $(or $(DEBIAN_VERSION-$(PHP_VERSION)),$(DEBIAN_VERSION-def)) +COMPOSER_VERSION-7.1 = 2.2 +COMPOSER_VERSION-def = 2.7.6 +COMPOSER_VERSION = $(or $(COMPOSER_VERSION-$(PHP_VERSION)),$(COMPOSER_VERSION-def)) + +IMAGE = php-cli-composer:$(PHP_VERSION)-$(DEBIAN_VERSION)-$(COMPOSER_VERSION) TARGETS = all build devbuild prodbuild \ quickstart check-quickstart install-vendor \ @@ -28,8 +41,14 @@ $(TARGETS): $(if $(shell docker image ls -q --filter reference=$(IMAGE)),,docker $(DKR) make -e MAKEFLAGS="$(MAKEFLAGS)" $@ docker-build: - docker image build --progress plain --build-arg PHP_VERSION=$(PHP_VERSION) --build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) -t $(IMAGE) . -.PHONY: docker-build + docker image build \ + --progress plain \ + --build-arg PHP_VERSION=$(PHP_VERSION) \ + --build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) \ + --build-arg COMPOSER_VERSION=$(COMPOSER_VERSION) \ + -t $(IMAGE) . +.PHONY: docker-build lrn-test-all lrn-test-clean + else DIST_PREFIX = learnosity_sdk- @@ -64,19 +83,19 @@ prodbuild: install-vendor release: @./release.sh -lint: install-vendor +lint: build $(PHPCS) src -test: install-vendor - $(PHPUNIT) --do-not-cache-result $(ARGS_PHPUNIT) +test: build + $(PHPUNIT) $(if $(subst 7.1,,$(PHP_TARGET)),--do-not-cache-result) $(ARGS_PHPUNIT) -test-coverage: install-vendor +test-coverage: build XDEBUG_MODE=coverage $(PHPUNIT) --do-not-cache-result $(ARGS_PHPUNIT) -test-unit: install-vendor +test-unit: build $(PHPUNIT) --do-not-cache-result --testsuite unit $(ARGS_PHPUNIT) -test-integration-env: install-vendor +test-integration-env: build $(PHPUNIT) --do-not-cache-result --testsuite integration $(ARGS_PHPUNIT) ### @@ -104,8 +123,8 @@ dist-test: dist-zip install-vendor ### # install vendor rules ### -install-vendor: vendor/autoload.php -vendor/autoload.php: composer.json +install-vendor: composer.lock +composer.lock: composer.json $(COMPOSER) install $(COMPOSER_INSTALL_FLAGS) $(VENDOR_FLAGS) clean: clean-dist clean-test clean-vendor diff --git a/src/Services/PreHashStringFactory.php b/src/Services/PreHashStringFactory.php index b5ae08f..5642e71 100644 --- a/src/Services/PreHashStringFactory.php +++ b/src/Services/PreHashStringFactory.php @@ -13,7 +13,10 @@ class PreHashStringFactory LegacyPreHashString::class, ]; - protected array $validServices; + /** + * @var array + */ + protected /* array */ $validServices; public function __construct() { diff --git a/src/Services/PreHashStrings/LegacyPreHashString.php b/src/Services/PreHashStrings/LegacyPreHashString.php index dd36839..c5d76bd 100644 --- a/src/Services/PreHashStrings/LegacyPreHashString.php +++ b/src/Services/PreHashStrings/LegacyPreHashString.php @@ -94,11 +94,15 @@ class LegacyPreHashString implements PreHashStringInterface 'domain', ]; - /** Service name to generate a pre-hash string for */ - protected string $service; + /** Service name to generate a pre-hash string for + * @var string + */ + protected /* string */ $service; - /** V1-compat strings need the secret to be part of the pre-hash string */ - protected bool $v1Compat; + /** V1-compat strings need the secret to be part of the pre-hash string + * @var bool + */ + protected /* bool */ $v1Compat; public function __construct(string $service, bool $v1Compat = false) { diff --git a/tests/Request/InitTest.php b/tests/Request/InitTest.php index b25cf7c..aaf496a 100644 --- a/tests/Request/InitTest.php +++ b/tests/Request/InitTest.php @@ -153,6 +153,9 @@ public function testNullRequestPacketAndActionGeneratesValidInit() $this->assertInstanceOf(Init::class, $initObject); } + /** + * @requires PHPUnit >= 9.6 + */ public function testMetaWithTelemetryOnlyAddsSdkProp() { list($service, $security, $secret, $request, $action) = ParamsFixture::getWorkingQuestionsApiParams(); @@ -170,6 +173,9 @@ public function testMetaWithTelemetryOnlyAddsSdkProp() $this->assertEquals(1, count((array) $generatedObject->meta)); } + /** + * @requires PHPUnit >= 9.6 + */ public function testRequestWithTelemetryPreservesOtherMetaProps() { list($service, $security, $secret, $request, $action) = ParamsFixture::getWorkingQuestionsApiParams(); @@ -195,6 +201,9 @@ public function testRequestWithTelemetryPreservesOtherMetaProps() $this->assertObjectHasProperty('sdk', $generatedObject->meta); } + /** + * @requires PHPUnit >= 9.6 + */ public function testRequestWithoutTelemetryPreservesEmptyMeta() { // We disable telemetry to be able to reliably test signature generation. Added telemetry @@ -210,6 +219,9 @@ public function testRequestWithoutTelemetryPreservesEmptyMeta() $this->assertObjectNotHasProperty('meta', $generatedObject); } + /** + * @requires PHPUnit >= 9.6 + */ public function testRequestWithoutTelemetryPreservesFilledMeta() { // We disable telemetry to be able to reliably test signature generation. Added telemetry diff --git a/tests/Services/LegacySignaturesTest.php b/tests/Services/LegacySignaturesTest.php index e6b1064..0d8ebe3 100644 --- a/tests/Services/LegacySignaturesTest.php +++ b/tests/Services/LegacySignaturesTest.php @@ -11,7 +11,10 @@ class LegacySignaturesTest extends AbstractTestCase { - private SignatureFactory $signatureFactory; + /** + * @var SignatureFactory + */ + private /* SignatureFactory */ $signatureFactory; public function setUp(): void {