Skip to content

Commit

Permalink
Merge pull request #40 from ray-di/drop-php7
Browse files Browse the repository at this point in the history
Drop PHP 7.4 support and optimized for PHP8
  • Loading branch information
koriym committed Nov 21, 2022
2 parents 4497aef + c88e614 commit 88ae75b
Show file tree
Hide file tree
Showing 61 changed files with 253 additions and 558 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Expand Up @@ -9,5 +9,5 @@ jobs:
ci:
uses: ray-di/.github/.github/workflows/continuous-integration.yml@v1
with:
old_stable: '["7.4", "8.0", "8.1"]'
old_stable: '["8.0", "8.1"]'
current_stable: 8.2
2 changes: 2 additions & 0 deletions README.md
@@ -1,4 +1,6 @@
# Ray.MediaQuery

## Media access mapping framework
[![codecov](https://codecov.io/gh/ray-di/Ray.MediaQuery/branch/1.x/graph/badge.svg?token=QBOPCUPJQV)](https://codecov.io/gh/ray-di/Ray.MediaQuery)
[![Type Coverage](https://shepherd.dev/github/ray-di/Ray.MediaQuery/coverage.svg)](https://shepherd.dev/github/ray-di/Ray.MediaQuery)
![Continuous Integration](https://github.com/ray-di/Ray.MediaQuery/workflows/Continuous%20Integration/badge.svg)
Expand Down
3 changes: 2 additions & 1 deletion composer-require-checker.json
Expand Up @@ -4,7 +4,8 @@
"static", "self", "parent",
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "mixed", "never",
"Roave\\BetterReflection\\Reflector\\DefaultReflector",
"Roave\\BetterReflection\\Reflector\\ClassReflector"
"Roave\\BetterReflection\\Reflector\\ClassReflector",
"json_decode", "json_encode", "JSON_THROW_ON_ERROR"
],
"php-core-extensions" : [
"Core",
Expand Down
12 changes: 7 additions & 5 deletions composer.json
@@ -1,6 +1,6 @@
{
"name": "ray/media-query",
"description": "database",
"description": "Media access mapping Framework",
"license": "MIT",
"authors": [
{
Expand All @@ -9,8 +9,7 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"ext-json": "*",
"php": "^8.0",
"ext-pdo": "*",
"aura/sql": "^4.0 || ^5.0",
"doctrine/annotations": "^1.12",
Expand All @@ -25,11 +24,13 @@
"nikic/php-parser": "^4.15"
},
"require-dev": {
"phpunit/phpunit": "^9.5.5",
"doctrine/coding-standard": "^9",
"doctrine/coding-standard": "^10.0",
"phpmd/phpmd": "^2.9",
"phpmetrics/phpmetrics": "^2.7",
"phpstan/phpstan": "^1.7",
"phpunit/phpunit": "^9.5.5",
"ray/rector-ray": "^1.0",
"rector/rector": "^0.14.8",
"squizlabs/php_codesniffer": "^3.7",
"vimeo/psalm": "^4.24"
},
Expand All @@ -42,6 +43,7 @@
"psr-4": {
"Ray\\MediaQuery\\": [
"tests/",
"tests-php81/",
"tests/Fake"
]
}
Expand Down
37 changes: 19 additions & 18 deletions phpcs.xml
@@ -1,15 +1,15 @@
<?xml version="1.0"?>
<ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Ray.Aop coding standard"
xsi:noNamespaceSchemaLocation="./vendor-bin/tools/vendor/squizlabs/php_codesniffer/phpcs.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>

<!-- Compatibility with PHP 7.3.0 -->
<config name="php_version" value="70300"/>
<!-- Compatibility with PHP 8.0 -->
<config name="php_version" value="80000"/>

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
Expand All @@ -22,6 +22,9 @@
<!-- PSR12 Coding Standard -->
<rule ref="PSR12"/>

<!-- Exclude NativeTypeHintrule from interface and abstract class -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint" />
<!-- Doctrine Coding Standard -->
<rule ref="Doctrine">
<!-- Inapplicable for this project -->
Expand All @@ -31,29 +34,23 @@
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousTraitNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable"/>
<exclude name="SlevomatCodingStandard.Commenting.UselessInheritDocComment.UselessInheritDocComment"/>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.PHP.RequireExplicitAssertion.RequiredExplicitAssertion"/>
<exclude name="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants.DisallowedLateStaticBindingForConstant"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousTraitNaming.SuperfluousSuffix"/>
<!-- /Base -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn"/>
<!-- /Base -->
<!-- Option -->
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed"/>
<!-- <exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed"/>-->
<exclude name="SlevomatCodingStandard.PHP.RequireExplicitAssertion.RequiredExplicitAssertion"/>
<!-- /Option -->
<!-- Exclude Fake files form Doctrine CS -->
<exclude-pattern>*/tests/Fake/*</exclude-pattern>
</rule>

<!-- Additional Rules -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="annotationsGroups" type="array">
<element value="@param, @psalm-param, @phpstan-param"/>
<element value="@return, @psalm-return, @phpstan-return"/>
<element value="@throws"/>
</property>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
Expand All @@ -75,11 +72,15 @@
<property name="maxLinesCountBeforeWithoutComment" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing">
<exclude-pattern>src/ClassParam.php</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>

<exclude-pattern>*/Fake/*</exclude-pattern>
<exclude-pattern>*/tmp/*</exclude-pattern>
</ruleset>
25 changes: 25 additions & 0 deletions rector.php
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Ray\AnnotationBinding\Rector\ClassMethod\AnnotationBindingRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests/*/*Test.php',
__DIR__ . '/tests-php81*/*Test.php',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->rule(AnnotationBindingRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80
]);
};
31 changes: 7 additions & 24 deletions src/Annotation/DbQuery.php
Expand Up @@ -7,9 +7,6 @@
use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

use function assert;
use function class_exists;

/**
* @Annotation
* @Target("METHOD")
Expand All @@ -18,26 +15,12 @@
#[Attribute(Attribute::TARGET_METHOD)]
final class DbQuery
{
/** @var string */
public $id;

/** @var ?class-string */
public $entity;

/**
* @Enum({"row", "row_list"})
* @var 'row'|'row_list'
*/
public $type = 'row_list';

/**
* @param 'row'|'row_list' $type
*/
public function __construct(string $id, string $type = 'row_list', ?string $entity = null)
{
assert($entity === null || class_exists($entity));
$this->id = $id;
$this->entity = $entity;
$this->type = $type;
/** @param 'row'|'row_list' $type */
public function __construct(
public string $id,
public string $type = 'row_list',
/** @var ?class-string */
public string|null $entity = null,
) {
}
}
18 changes: 5 additions & 13 deletions src/Annotation/Pager.php
Expand Up @@ -15,18 +15,10 @@
#[Attribute(Attribute::TARGET_METHOD)]
final class Pager
{
/** @var int|string */
public $perPage;

/** @var string */
public $template;

/**
* @param int|string $perPage int:the number of items, string: the name of the argument of the number of items
*/
public function __construct($perPage = 10, string $template = '/{?page}')
{
$this->perPage = $perPage;
$this->template = $template;
/** @param int|string $perPage int:the number of items, string: the name of the argument of the number of items */
public function __construct(
public int|string $perPage = 10,
public string $template = '/{?page}',
) {
}
}
13 changes: 13 additions & 0 deletions src/Annotation/Qualifier/SqlDir.php
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Ray\MediaQuery\Annotation\Qualifier;

use Attribute;
use Ray\Di\Di\Qualifier;

#[Attribute(Attribute::TARGET_PARAMETER), Qualifier]
final class SqlDir
{
}
16 changes: 1 addition & 15 deletions src/Annotation/Qualifier/UriTemplateBindings.php
Expand Up @@ -5,23 +5,9 @@
namespace Ray\MediaQuery\Annotation\Qualifier;

use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Ray\Di\Di\Qualifier;

/**
* @Annotation
* @Target("METHOD")
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute(Attribute::TARGET_METHOD), Qualifier]
#[Attribute(Attribute::TARGET_PARAMETER), Qualifier]
final class UriTemplateBindings
{
/** @var string */
public $value;

public function __construct(string $value)
{
$this->value = $value;
}
}
16 changes: 1 addition & 15 deletions src/Annotation/Qualifier/WebApiList.php
Expand Up @@ -5,23 +5,9 @@
namespace Ray\MediaQuery\Annotation\Qualifier;

use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Ray\Di\Di\Qualifier;

/**
* @Annotation
* @Target("METHOD")
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute(Attribute::TARGET_METHOD), Qualifier]
#[Attribute(Attribute::TARGET_PARAMETER), Qualifier]
final class WebApiList
{
/** @var string */
public $value;

public function __construct(string $value)
{
$this->value = $value;
}
}
18 changes: 0 additions & 18 deletions src/Annotation/SqlDir.php

This file was deleted.

9 changes: 3 additions & 6 deletions src/Annotation/WebQuery.php
Expand Up @@ -15,11 +15,8 @@
#[Attribute(Attribute::TARGET_METHOD)]
final class WebQuery
{
/** @var string */
public $id;

public function __construct(string $id)
{
$this->id = $id;
public function __construct(
public string $id,
) {
}
}
5 changes: 1 addition & 4 deletions src/CamelCaseTrait.php
Expand Up @@ -10,10 +10,7 @@

trait CamelCaseTrait
{
/**
* @param mixed $value
*/
public function __set(string $name, $value): void
public function __set(string $name, mixed $value): void
{
$propName = lcfirst(str_replace('_', '', ucwords($name, '_')));
$this->{$propName} = $value;
Expand Down

0 comments on commit 88ae75b

Please sign in to comment.