Skip to content

Commit

Permalink
php 8.4 and phpunit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Dec 8, 2024
1 parent 6c61bd1 commit 6f357af
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 67 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@ on:
- cron: '0 0 * * *'

jobs:
php81:
name: PHP 8.1
runs-on: ubuntu-22.04
php82:
name: PHP 8.2
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v4
- name: composer test
uses: docker://ghcr.io/chubbyphp/ci-php81:latest
uses: docker://ghcr.io/chubbyphp/ci-php82:latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
php82:
name: PHP 8.2
runs-on: ubuntu-22.04
php83:
name: PHP 8.3
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v4
- name: composer test
uses: docker://ghcr.io/chubbyphp/ci-php82:latest
uses: docker://ghcr.io/chubbyphp/ci-php83:latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
php83:
name: PHP 8.3
runs-on: ubuntu-22.04
php84:
name: PHP 8.4
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v4
- name: composer test
uses: docker://ghcr.io/chubbyphp/ci-php83:latest
uses: docker://ghcr.io/chubbyphp/ci-php84:latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
- name: sonarcloud.io
uses: sonarsource/sonarcloud-github-action@master
uses: sonarsource/sonarqube-scan-action@v4.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ A simple deserialization.

## Requirements

* php: ^8.1
* php: ^8.2
* chubbyphp/chubbyphp-decode-encode: ^1.1
* psr/http-message: ^1.1|^2.0
* psr/log: ^2.0|^3.0
* psr/log: ^2.0|^3.0.2

## Suggest

* chubbyphp/chubbyphp-container: ^2.2
* pimple/pimple: ^3.5
* psr/container: ^2.0.2
* symfony/config: ^5.4.31|^6.3.8|^7.0 (symfony integration)
* symfony/dependency-injection: ^5.4.31|^6.3.8|^7.0 (symfony integration)
* symfony/config: ^5.4.46|^6.4.14|^7.2 (symfony integration)
* symfony/dependency-injection: ^5.4.46|^6.4.14|^7.2 (symfony integration)

## Installation

Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-deserialization][1].

```sh
composer require chubbyphp/chubbyphp-deserialization "^4.1"
composer require chubbyphp/chubbyphp-deserialization "^4.2"
```

## Usage
Expand Down
28 changes: 14 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-dom": "*",
"ext-json": "*",
"ext-mbstring": "*",
"chubbyphp/chubbyphp-decode-encode": "^1.1",
"psr/http-message": "^1.1|^2.0",
"psr/log": "^2.0|^3.0"
"psr/log": "^2.0|^3.0.2"
},
"require-dev": {
"chubbyphp/chubbyphp-container": "^2.2",
"chubbyphp/chubbyphp-dev-helper": "dev-master",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.3",
"chubbyphp/chubbyphp-mock": "^1.7.0",
"doctrine/collections": "^2.1.4",
"doctrine/persistence": "^3.2",
"infection/infection": "^0.27.8",
"chubbyphp/chubbyphp-mock": "^1.8",
"doctrine/collections": "^2.2.2",
"doctrine/persistence": "^4.0",
"infection/infection": "^0.29.8",
"php-coveralls/php-coveralls": "^2.7.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.45",
"phpunit/phpunit": "^10.4.2",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^2.0.3",
"phpunit/phpunit": "^11.5.0",
"pimple/pimple": "^3.5",
"psr/container": "^2.0.2",
"symfony/config": "^5.4.31|^6.3.8|^7.0",
"symfony/dependency-injection": "^5.4.31|^6.3.8|^7.0"
"symfony/config": "^5.4.46|^6.4.14|^7.2",
"symfony/dependency-injection": "^5.4.46|^6.4.14|^7.2"
},
"autoload": {
"psr-4": { "Chubbyphp\\Deserialization\\": "src/" }
Expand All @@ -50,7 +50,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
"dev-master": "4.2-dev"
}
},
"scripts": {
Expand All @@ -65,9 +65,9 @@
],
"test:cs": "mkdir -p build && PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --cache-file=build/phpcs.cache",
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=93 --verbose --coverage=build/phpunit",
"test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-result-file=build/phpunit/result.cache",
"test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-directory=build/phpunit",
"test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log",
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=8 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'",
"test:unit": "vendor/bin/phpunit --testsuite=Unit --coverage-text --coverage-clover=build/phpunit/clover.xml --coverage-html=build/phpunit/coverage-html --coverage-xml=build/phpunit/coverage-xml --log-junit=build/phpunit/junit.xml --cache-result-file=build/phpunit/result.cache"
"test:unit": "vendor/bin/phpunit --testsuite=Unit --coverage-text --coverage-clover=build/phpunit/clover.xml --coverage-html=build/phpunit/coverage-html --coverage-xml=build/phpunit/coverage-xml --log-junit=build/phpunit/junit.xml --cache-directory=build/phpunit"
}
}
9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ parameters:
-
message: '/supplied for foreach, only iterables are supported/'
path: %currentWorkingDirectory%/src/Denormalizer/Relation/EmbedManyFieldDenormalizer.php
-
message: '/Call to function is_array\(\) with array will always evaluate to true./'
path: %currentWorkingDirectory%/src/Denormalizer/Relation/EmbedManyFieldDenormalizer.php
-
message: '/supplied for foreach, only iterables are supported/'
path: %currentWorkingDirectory%/src/Denormalizer/Relation/ReferenceManyFieldDenormalizer.php
-
message: '/Call to function is_string\(\) with string will always evaluate to true./'
path: %currentWorkingDirectory%/src/Denormalizer/Relation/ReferenceManyFieldDenormalizer.php
-
message: '/Parameter .*relatedObjects.*/'
path: %currentWorkingDirectory%/src/Denormalizer/Relation/ReferenceManyFieldDenormalizer.php
3 changes: 3 additions & 0 deletions src/Accessor/PropertyAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function getValue(object $object)
return $getter($this->property);
}

/**
* @return class-string<object>
*/
private function getClass(object $object): string
{
if (interface_exists('Doctrine\Persistence\Proxy') && $object instanceof Proxy) {
Expand Down
4 changes: 0 additions & 4 deletions src/Denormalizer/FieldDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
namespace Chubbyphp\Deserialization\Denormalizer;

use Chubbyphp\Deserialization\Accessor\AccessorInterface;
use Chubbyphp\Deserialization\DeserializerRuntimeException;

final class FieldDenormalizer implements FieldDenormalizerInterface
{
public function __construct(private AccessorInterface $accessor, private bool $emptyToNull = false) {}

/**
* @throws DeserializerRuntimeException
*/
public function denormalizeField(
string $path,
object $object,
Expand Down
14 changes: 7 additions & 7 deletions src/DeserializerLogicException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ final class DeserializerLogicException extends \LogicException
{
public static function createMissingContentType(string $contentType): self
{
return new self(sprintf('There is no decoder for content-type: "%s"', $contentType));
return new self(\sprintf('There is no decoder for content-type: "%s"', $contentType));
}

public static function createMissingDenormalizer(string $path): self
{
return new self(sprintf('There is no denormalizer at path: "%s"', $path));
return new self(\sprintf('There is no denormalizer at path: "%s"', $path));
}

public static function createMissingMapping(string $class): self
{
return new self(sprintf('There is no mapping for class: "%s"', $class));
return new self(\sprintf('There is no mapping for class: "%s"', $class));
}

/**
Expand All @@ -27,22 +27,22 @@ public static function createMissingMapping(string $class): self
public static function createMissingMethod(string $class, array $methods): self
{
return new self(
sprintf('There are no accessible method(s) "%s", within class: "%s"', implode('", "', $methods), $class)
\sprintf('There are no accessible method(s) "%s", within class: "%s"', implode('", "', $methods), $class)
);
}

public static function createMissingProperty(string $class, string $property): self
{
return new self(sprintf('There is no property "%s" within class: "%s"', $property, $class));
return new self(\sprintf('There is no property "%s" within class: "%s"', $property, $class));
}

public static function createFactoryDoesNotReturnObject(string $path, string $dataType): self
{
return new self(sprintf('Factory does not return object, "%s" given at path: "%s"', $dataType, $path));
return new self(\sprintf('Factory does not return object, "%s" given at path: "%s"', $dataType, $path));
}

public static function createConvertTypeDoesNotExists(string $convertType): self
{
return new self(sprintf('Convert type "%s" is not supported', $convertType));
return new self(\sprintf('Convert type "%s" is not supported', $convertType));
}
}
14 changes: 7 additions & 7 deletions src/DeserializerRuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ final class DeserializerRuntimeException extends \RuntimeException
public static function createInvalidDataType(string $path, string $givenType, string $wishedType): self
{
return new self(
sprintf('There is an invalid data type "%s", needed "%s" at path: "%s"', $givenType, $wishedType, $path)
\sprintf('There is an invalid data type "%s", needed "%s" at path: "%s"', $givenType, $wishedType, $path)
);
}

public static function createNotParsable(string $contentType, ?string $error = null): self
{
$message = sprintf('Data is not parsable with content-type: "%s"', $contentType);
$message = \sprintf('Data is not parsable with content-type: "%s"', $contentType);
if (null !== $error) {
$message .= sprintf(', error: "%s"', $error);
$message .= \sprintf(', error: "%s"', $error);
}

return new self($message);
Expand All @@ -28,15 +28,15 @@ public static function createNotParsable(string $contentType, ?string $error = n
*/
public static function createNotAllowedAdditionalFields(array $paths): self
{
return new self(sprintf('There are additional field(s) at paths: "%s"', implode('", "', $paths)));
return new self(\sprintf('There are additional field(s) at paths: "%s"', implode('", "', $paths)));
}

/**
* @param array<int, string> $supportedTypes
*/
public static function createMissingObjectType(string $path, array $supportedTypes): self
{
return new self(sprintf(
return new self(\sprintf(
'Missing object type, supported are "%s" at path: "%s"',
implode('", "', $supportedTypes),
$path
Expand All @@ -48,7 +48,7 @@ public static function createMissingObjectType(string $path, array $supportedTyp
*/
public static function createInvalidObjectType(string $path, string $type, array $supportedTypes): self
{
return new self(sprintf(
return new self(\sprintf(
'Unsupported object type "%s", supported are "%s" at path: "%s"',
$type,
implode('", "', $supportedTypes),
Expand All @@ -58,6 +58,6 @@ public static function createInvalidObjectType(string $path, string $type, array

public static function createTypeIsNotAString(string $path, string $dataType): self
{
return new self(sprintf('Type is not a string, "%s" given at path: "%s"', $dataType, $path));
return new self(\sprintf('Type is not a string, "%s" given at path: "%s"', $dataType, $path));
}
}
2 changes: 1 addition & 1 deletion tests/Integration/DeserializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public function testDenormalizeWithAllowedAdditionalFields(): void

private function getLogger(): AbstractLogger
{
return new class() extends AbstractLogger {
return new class extends AbstractLogger {
private array $entries = [];

public function log($level, $message, array $context = []): void
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Accessor/MethodAccessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class MethodAccessorTest extends TestCase
{
public function testSetValue(): void
{
$object = new class() {
$object = new class {
private ?string $name = null;

public function getName(): string
Expand All @@ -41,15 +41,15 @@ public function testMissingSet(): void
{
$this->expectException(DeserializerLogicException::class);

$object = new class() {};
$object = new class {};

$accessor = new MethodAccessor('name');
$accessor->setValue($object, 'Name');
}

public function testGetValue(): void
{
$object = new class() {
$object = new class {
private ?string $name = null;

public function getName(): string
Expand All @@ -72,7 +72,7 @@ public function setName(string $name): void

public function testHasValue(): void
{
$object = new class() {
$object = new class {
private ?string $name = null;

public function hasName(): bool
Expand All @@ -95,7 +95,7 @@ public function setName(string $name): void

public function testIsValue(): void
{
$object = new class() {
$object = new class {
private ?string $name = null;

public function isName(): bool
Expand All @@ -120,7 +120,7 @@ public function testMissingGet(): void
{
$this->expectException(DeserializerLogicException::class);

$object = new class() {};
$object = new class {};

$accessor = new MethodAccessor('name');
$accessor->getValue($object);
Expand Down
Loading

0 comments on commit 6f357af

Please sign in to comment.