Skip to content

Commit

Permalink
Add Symfony 7.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
steevanb committed May 24, 2024
1 parent 39acb86 commit 82217b4
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/actions/ci-env
- run: bin/ci/phpunit ${{ matrix.php }} ${{ matrix.symfony }}

phpunit-symfony-7:
runs-on: ubuntu-latest
strategy:
matrix:
php: [--php=8.2, --php=8.3]
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/ci-env
- run: bin/ci/phpunit ${{ matrix.php }} --symfony=7.0
2 changes: 1 addition & 1 deletion bin/ci/phpstan
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if [ "${clearCache}" == true ] && [ -d "${ROOT_DIR}"/var/ci/phpstan ]; then
fi

if [ "${phpVersion}" == "" ]; then
php8.1 "${ROOT_DIR}"/bin/ci/phpstan.php ${phpstanParameters}
php8.2 "${ROOT_DIR}"/bin/ci/phpstan.php ${phpstanParameters}
else
echo "PHP ${phpVersion}"

Expand Down
2 changes: 1 addition & 1 deletion bin/ci/phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for arg in "${@}"; do
done

if [ "${phpVersion}" == "" ] || [ "${symfonyVersion}" == "" ]; then
php8.1 "${ROOT_DIR}"/bin/ci/phpunit.php "${@}"
php8.2 "${ROOT_DIR}"/bin/ci/phpunit.php "${@}"
else
echo "PHP ${phpVersion} - Symfony ${symfonyVersion}"

Expand Down
2 changes: 1 addition & 1 deletion bin/ci/phpunit-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
echo "PHP 8.1 - Symfony 6.1"
set +e
XDEBUG_MODE=coverage \
php8.1 \
php8.2 \
"${ROOT_DIR}"/vendor/bin/phpunit \
--bootstrap "${COMPOSER_HOME_SYMFONY_6_1}"/vendor/autoload.php \
--coverage-html "${ROOT_DIR}"/var/ci/phpunit/coverage/html \
Expand Down
5 changes: 4 additions & 1 deletion bin/ci/phpunit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ function createPhpunitProcesses(string $phpVersion = null, string $symfonyVersio
{
$phpVersions = new StringCollection(is_string($phpVersion) ? [$phpVersion] : ['8.1', '8.2', '8.3']);
$symfonyVersions = new StringCollection(
is_string($symfonyVersion) ? [$symfonyVersion] : ['6.1', '6.2', '6.3', '6.4']
is_string($symfonyVersion) ? [$symfonyVersion] : ['6.1', '6.2', '6.3', '6.4', '7.0']
);

$return = new ProcessInterfaceCollection();
foreach ($phpVersions->toArray() as $loopPhpVersion) {
foreach ($symfonyVersions->toArray() as $loopSymfonyVersion) {
if ($loopSymfonyVersion === '7.0' && in_array($loopPhpVersion, ['8.2', '8.3'], true) === false) {
continue;
}
$return->add(createPhpunitProcess($loopPhpVersion, $loopSymfonyVersion));
}
}
Expand Down
2 changes: 1 addition & 1 deletion bin/ci/validate
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash

php8.1 "${ROOT_DIR}"/bin/ci/validate.php "${@}"
php8.2 "${ROOT_DIR}"/bin/ci/validate.php "${@}"
12 changes: 11 additions & 1 deletion bridge/Symfony/Normalizer/ObjectCollectionDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@ class ObjectCollectionDenormalizer implements DenormalizerInterface, Denormalize
{
use DenormalizerAwareTrait;

public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
/** @param array<mixed> $context */
public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
{
return
is_subclass_of($type, AbstractObjectCollection::class)
|| is_subclass_of($type, AbstractObjectNullableCollection::class);
}

/** @return array<class-string|'*'|'object'|string, bool|null> */
public function getSupportedTypes(?string $format): array
{
return [
AbstractObjectCollection::class => false,
AbstractObjectNullableCollection::class => false
];
}

/**
* @param array<mixed> $context
* @return AbstractObjectCollection<object>|AbstractObjectNullableCollection<object|null>
Expand Down
16 changes: 15 additions & 1 deletion bridge/Symfony/Normalizer/ScalarCollectionDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

class ScalarCollectionDenormalizer implements DenormalizerInterface
{
public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
/** @param array<mixed> $context */
public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
{
return in_array(
$type,
Expand All @@ -33,6 +34,19 @@ public function supportsDenormalization(mixed $data, string $type, string $forma
);
}

/** @return array<class-string|'*'|'object'|string, bool|null> */
public function getSupportedTypes(?string $format): array
{
return [
FloatCollection::class => false,
FloatNullableCollection::class => false,
IntegerCollection::class => false,
IntegerNullableCollection::class => false,
StringCollection::class => false,
StringNullableCollection::class => false
];
}

/**
* @param array<mixed> $context
* @return CollectionInterface<float|integer|string|null>
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### master

- Add support for Symfony `7.0`

### [6.0.1](../../compare/6.0.0...6.0.1) - 2024-05-15

- Documentation
Expand Down
8 changes: 6 additions & 2 deletions docker/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ENV COMPOSER_HOME_SYMFONY_6_1=/composer/symfony-6-1
ENV COMPOSER_HOME_SYMFONY_6_2=/composer/symfony-6-2
ENV COMPOSER_HOME_SYMFONY_6_3=/composer/symfony-6-3
ENV COMPOSER_HOME_SYMFONY_6_4=/composer/symfony-6-4
ENV COMPOSER_HOME_SYMFONY_7_0=/composer/symfony-7-0
ENV PHPSTAN_BIN_PATH=/usr/local/bin/phpstan

COPY docker/ci/composer.json ${COMPOSER_HOME}/composer.json
Expand All @@ -26,11 +27,11 @@ RUN \
php8.3-cli \
php8.3-simplexml \
# For Composer
curl zip php8.1-curl php8.1-zip \
curl zip php8.1-curl php8.1-zip php8.2-curl php8.2-zip \
# For unused-scanner and phpunit
php8.1-mbstring php8.2-mbstring php8.3-mbstring \
# For coverage
php8.1-xdebug \
php8.2-xdebug \
&& update-alternatives --set php /usr/bin/php8.1 \

# Install CI tools
Expand All @@ -47,6 +48,9 @@ RUN \
&& COMPOSER_HOME=${COMPOSER_HOME_SYMFONY_6_3} composer global require symfony/serializer:6.3.* \
&& COMPOSER_HOME=${COMPOSER_HOME_SYMFONY_6_4} composer global require symfony/serializer:6.4.* \

&& update-alternatives --set php /usr/bin/php8.2 \
&& COMPOSER_HOME=${COMPOSER_HOME_SYMFONY_7_0} composer global require symfony/serializer:7.0.* \

# Purge
&& apt-get purge -y software-properties-common \
&& apt-get autoremove -y \
Expand Down

0 comments on commit 82217b4

Please sign in to comment.