Skip to content

Commit

Permalink
php 8.0 min version
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Mar 6, 2022
1 parent 4046436 commit 1bb11a5
Show file tree
Hide file tree
Showing 40 changed files with 93 additions and 239 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ on:
- cron: '0 0 * * *'

jobs:
php74:
name: PHP 7.4
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
- name: composer test
uses: docker://chubbyphp/ci-php74:latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
php80:
name: PHP 8.0
runs-on: ubuntu-20.04
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 Dominik Zogg
Copyright (c) 2022 Dominik Zogg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ A simple serialization.

## Requirements

* php: ^7.4|^8.0
* doctrine/inflector: ^1.0|^2.0
* php: ^8.0
* doctrine/inflector: ^1.4.4|^2.0.4
* psr/http-message: ^1.0.1
* psr/link: ^1.0
* psr/log: ^1.1.3
* psr/log: ^1.1.4|^2.0|^3.0

## Suggest

* chubbyphp/chubbyphp-container: ^1.1
* pimple/pimple: ^3.3
* psr/container: ^1.0
* symfony/dependency-injection: ^4.4.34|^5.3.11|^6.0.0 (symfony integration)
* symfony/yaml: ^4.4.34|^5.3.11|^6.0.0 (application/x-yaml support)
* chubbyphp/chubbyphp-container: ^2.1
* pimple/pimple: ^3.5
* psr/container: ^1.1.2|^2.0.2
* symfony/dependency-injection: ^4.4.38|^5.4.5|^6.0 (symfony integration)
* symfony/yaml: ^4.4.38|^5.4.5|^6.0 (application/x-yaml support)

## Installation

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

```sh
composer require chubbyphp/chubbyphp-serialization "^3.1"
composer require chubbyphp/chubbyphp-serialization "^3.2"
```

## Usage
Expand Down Expand Up @@ -225,7 +225,7 @@ echo $serializer->encode(

## Copyright

Dominik Zogg 2021
Dominik Zogg 2022


[1]: https://packagist.org/packages/chubbyphp/chubbyphp-serialization
Expand Down
38 changes: 21 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.0",
"ext-dom": "*",
"ext-json": "*",
"doctrine/inflector": "^1.0|^2.0",
"doctrine/inflector": "^1.4.4|^2.0.4",
"psr/http-message": "^1.0.1",
"psr/link": "^1.0",
"psr/log": "^1.1.3",
"symfony/yaml": "^4.4.34|^5.3.11|^6.0.0"
"psr/log": "^1.1.4|^2.0|^3.0",
"symfony/yaml": "^4.4.38|^5.4.5|^6.0"
},
"require-dev": {
"chubbyphp/chubbyphp-container": "^1.1|^2.0",
"chubbyphp/chubbyphp-container": "^2.1",
"chubbyphp/chubbyphp-dev-helper": "dev-master",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.0",
"chubbyphp/chubbyphp-laminas-config-factory": "^1.2",
"chubbyphp/chubbyphp-mock": "^1.6.1",
"doctrine/persistence": "^1.3|^2.0",
"infection/infection": "^0.25.3",
"php-coveralls/php-coveralls": "^2.5.1",
"doctrine/persistence": "^2.3",
"infection/infection": "^0.26.5",
"php-coveralls/php-coveralls": "^2.5.2",
"phploc/phploc": "^7.0.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.1.2",
"phpunit/phpunit": "^9.5.10",
"pimple/pimple": "^3.3",
"psr/container": "^1.0|^2.0",
"symfony/config": "^4.4.34|^5.3.11|^6.0.0",
"symfony/dependency-injection": "^4.4.34|^5.3.11|^6.0.0"
"phpstan/phpstan": "^1.4.8",
"phpunit/phpunit": "^9.5.17",
"pimple/pimple": "^3.5",
"psr/container": "^1.1.2|^2.0.2",
"symfony/config": "^4.4.38|^5.4.5|^6.0",
"symfony/dependency-injection": "^4.4.38|^5.4.5|^6.0"
},
"autoload": {
"psr-4": { "Chubbyphp\\Serialization\\": "src/" }
Expand All @@ -43,11 +43,15 @@
"psr-4": { "Chubbyphp\\Tests\\Serialization\\": "tests/" }
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true,
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
"dev-master": "3.2-dev"
}
},
"scripts": {
Expand Down
9 changes: 6 additions & 3 deletions infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
},
"timeout": 10,
"logs": {
"text": "build/phpinfection.log",
"badge": {
"branch": "master"
"text": "build/phpinfection/infection.log",
"html": "build/phpinfection/infection.html",
"json": "build/phpinfection/infection.json",
"summary": "build/phpinfection/summary.log",
"stryker": {
"report": "master"
}
},
"mutators": {
Expand Down
3 changes: 0 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ parameters:
-
message: '//'
path: %currentWorkingDirectory%/src/Encoder/JsonxTypeEncoder.php
-
message: '/Unreachable statement - code above always terminates\./'
path: %currentWorkingDirectory%/src/Encoder/UrlEncodedTypeEncoder.php
-
message: '/PHPDoc tag @var for variable \$parentReflectionClass contains generic class ReflectionClass but does not specify its types\: T/'
path: %currentWorkingDirectory%/src/Normalizer/NormalizerObjectMappingRegistry.php
7 changes: 2 additions & 5 deletions src/Accessor/MethodAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

final class MethodAccessor implements AccessorInterface
{
private string $property;

public function __construct(string $property)
public function __construct(private string $property)
{
$this->property = $property;
}

/**
Expand All @@ -38,6 +35,6 @@ public function getValue(object $object)
return $object->{$is}();
}

throw SerializerLogicException::createMissingMethod(\get_class($object), [$get, $has, $is]);
throw SerializerLogicException::createMissingMethod($object::class, [$get, $has, $is]);
}
}
7 changes: 2 additions & 5 deletions src/Accessor/PropertyAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@

final class PropertyAccessor implements AccessorInterface
{
private string $property;

public function __construct(string $property)
public function __construct(private string $property)
{
$this->property = $property;
}

/**
Expand Down Expand Up @@ -49,6 +46,6 @@ private function getClass(object $object): string
}
}

return \get_class($object);
return $object::class;
}
}
4 changes: 2 additions & 2 deletions src/DependencyInjection/SerializationCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function process(ContainerBuilder $container): void
private function registerObjectmappingRegistry(ContainerBuilder $container): void
{
$normalizerObjectMappingReferences = [];
foreach ($container->findTaggedServiceIds('chubbyphp.serializer.normalizer.objectmapping') as $id => $tags) {
foreach (array_keys($container->findTaggedServiceIds('chubbyphp.serializer.normalizer.objectmapping')) as $id) {
$normalizerObjectMappingReferences[] = new Reference($id);
}

Expand All @@ -55,7 +55,7 @@ private function registerObjectmappingRegistry(ContainerBuilder $container): voi
private function registerEncoder(ContainerBuilder $container): void
{
$encoderTypeReferences = [];
foreach ($container->findTaggedServiceIds('chubbyphp.serializer.encoder.type') as $id => $tags) {
foreach (array_keys($container->findTaggedServiceIds('chubbyphp.serializer.encoder.type')) as $id) {
$encoderTypeReferences[] = new Reference($id);
}

Expand Down
5 changes: 1 addition & 4 deletions src/Encoder/JsonTypeEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

final class JsonTypeEncoder implements TypeEncoderInterface
{
private bool $prettyPrint;

public function __construct(bool $prettyPrint = false)
public function __construct(private bool $prettyPrint = false)
{
$this->prettyPrint = $prettyPrint;
}

public function getContentType(): string
Expand Down
12 changes: 3 additions & 9 deletions src/Encoder/JsonxTypeEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ final class JsonxTypeEncoder implements TypeEncoderInterface
public const DATATYPE_NUMBER = 'number';
public const DATATYPE_NULL = 'null';

private bool $prettyPrint;

public function __construct(bool $prettyPrint = false)
public function __construct(private bool $prettyPrint = false)
{
$this->prettyPrint = $prettyPrint;
}

public function getContentType(): string
Expand Down Expand Up @@ -139,10 +136,7 @@ private function createStringNode(\DOMDocument $document, string $value, ?string
return $node;
}

/**
* @param float|int $value
*/
private function createNumberNode(\DOMDocument $document, $value, ?string $name = null): \DOMElement
private function createNumberNode(\DOMDocument $document, float|int $value, ?string $name = null): \DOMElement
{
$node = $document->createElement('json:number', (string) $value);

Expand Down Expand Up @@ -196,7 +190,7 @@ private function getType($value): string
throw new \InvalidArgumentException(
sprintf(
'Value needs to be of type array|bool|string|int|float|null, %s given',
\is_object($value) ? \get_class($value) : \gettype($value)
get_debug_type($value)
)
);
}
Expand Down
6 changes: 2 additions & 4 deletions src/Encoder/UrlEncodedTypeEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ private function buildQuery(array $data, string $path = ''): string
}

/**
* @param bool|float|int|string $value
*
* @throws \InvalidArgumentException
*/
private function getValueAsString($value): string
private function getValueAsString(\stdClass|bool|float|int|string $value): string
{
if (\is_string($value)) {
return $value;
Expand All @@ -61,7 +59,7 @@ private function getValueAsString($value): string

if (\is_float($value)) {
$value = (string) $value;
if (false === strpos($value, '.')) {
if (!str_contains($value, '.')) {
$value .= '.0';
}

Expand Down
19 changes: 2 additions & 17 deletions src/Link/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,12 @@

final class Link implements LinkInterface
{
private string $href;

/**
* @var array<int, string>
*/
private array $rels;

/**
* @var array<string, mixed>
*/
private array $attributes;

/**
* @param array<int, string> $rels
* @param array<string, mixed> $attributes
*/
public function __construct(string $href, array $rels, array $attributes)
public function __construct(private string $href, private array $rels, private array $attributes)
{
$this->href = $href;
$this->rels = $rels;
$this->attributes = $attributes;
}

public function getHref(): string
Expand All @@ -38,7 +23,7 @@ public function getHref(): string

public function isTemplated(): bool
{
return false !== strpos($this->href, '{');
return str_contains($this->href, '{');
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Mapping/CallableNormalizationObjectMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@

final class CallableNormalizationObjectMapping implements NormalizationObjectMappingInterface
{
private string $class;

/**
* @var callable
*/
private $callable;

private ?NormalizationObjectMappingInterface $mapping = null;

public function __construct(string $class, callable $callable)
public function __construct(private string $class, callable $callable)
{
$this->class = $class;
$this->callable = $callable;
}

Expand Down
11 changes: 1 addition & 10 deletions src/Mapping/LazyNormalizationObjectMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,8 @@

final class LazyNormalizationObjectMapping implements NormalizationObjectMappingInterface
{
private ContainerInterface $container;

private string $serviceId;

private string $class;

public function __construct(ContainerInterface $container, string $serviceId, string $class)
public function __construct(private ContainerInterface $container, private string $serviceId, private string $class)
{
$this->container = $container;
$this->serviceId = $serviceId;
$this->class = $class;
}

public function getClass(): string
Expand Down
10 changes: 2 additions & 8 deletions src/Mapping/NormalizationFieldMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@

final class NormalizationFieldMapping implements NormalizationFieldMappingInterface
{
private string $name;

private FieldNormalizerInterface $fieldNormalizer;

private PolicyInterface $policy;

public function __construct(
string $name,
FieldNormalizerInterface $fieldNormalizer,
private string $name,
private FieldNormalizerInterface $fieldNormalizer,
?PolicyInterface $policy = null
) {
$this->name = $name;
$this->fieldNormalizer = $fieldNormalizer;
$this->policy = $policy ?? new NullPolicy();
}

Expand Down
Loading

0 comments on commit 1bb11a5

Please sign in to comment.