Skip to content

Commit

Permalink
Merge pull request #3 from Lansoweb/php-8
Browse files Browse the repository at this point in the history
Php 8
  • Loading branch information
Lansoweb authored Sep 19, 2023
2 parents 6a61718 + 86ddeca commit 279c078
Show file tree
Hide file tree
Showing 16 changed files with 297 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: Lansoweb
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_Report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug Report
about: Create a bug report to help us improve
labels: bug
assignees:
---
<!--- Provide a general summary of the issue you're having in the title above. -->

## Description
<!-- Provide a short and clear description of the bug. -->

## Steps to reproduce
<!--
Provide steps to reproduce the behavior you are experiencing. Please try to keep
this as short as possible. If able, create a reproducible script outside of any
framework you are using. This will help us to quickly debug the issue.
-->
1. Step one...
2. Step two...
3. Step three...

## Expected behavior
<!-- Provide a short and clear description of what you expect to happen. -->

## Screenshots or output
<!-- If applicable, add screenshots or program output to help explain your problem. -->

## Environment details
<!-- Provide details about the system where you're using this package. -->
- version of this package: *e.g. 1.0.0, 1.0.1, 1.1.0*
- PHP version: *e.g. 7.3.16, 7.4.4*
- OS: *e.g. Windows 10, Linux (Ubuntu 18.04.1), macOS Catalina (10.15.3)*

## Additional context
<!-- Provide any additional context that may help us debug the problem. -->
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_Request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Feature Request
about: Suggest a feature for this project
labels: enhancement
assignees:
---
<!--- Provide a general summary of your feature request in the title above. -->

<!-- Give your feature a short title here. -->
## My feature title
<!-- Provide a short and clear description of the feature. -->

## Background/problem
<!--
Provide background details to show why this feature is necessary. Is your
feature request related to a problem? If so, please describe the problem.
Provide as much detail as possible.
-->

## Proposal/solution
<!--
Provide a short and clear description of the solution you'd like. Include code
examples, if possible. Feel free to use pseudo-code to show how you think the
feature should work.
-->

## Alternatives
<!-- Describe any alternative solutions or features you've considered. -->

## Additional context
<!-- Please provide any other context or code examples that may help. -->
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/Question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Question
about: Ask a question about how to use this library
labels: question
assignees:
---
<!--- Provide a general summary of your question in the title above. -->

<!-- Write your question here. -->
## How do I... ?
<!-- Provide any additional context that may help us answer your question. -->

## Example code
<!--
If your question is about code that you've written, provide a short and clear
example of what you're trying to accomplish. Try to keep this as short as
possible. If able, please provide an example outside of any framework you are
using. This will help us to quickly respond to your question.
-->
30 changes: 30 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/Pull_Request_Template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--- Provide a general summary of your changes in the title above. -->

## Description
<!--- Describe your changes in detail. -->

## Motivation and context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How has this been tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## PR checklist
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] I have run `composer test` locally, and there were no failures or errors.
45 changes: 45 additions & 0 deletions .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Check Coding Standards"

on:
pull_request:
push:
branches:
- "master"

jobs:
coding-standards:
name: "Check Coding Standards"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "highest"
php-version:
- "8.2"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2

- uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-options }}"

- name: "phpcs"
run: "vendor/bin/phpcs"

- name: "phpstan"
run: "vendor/bin/phpstan analyze"
65 changes: 65 additions & 0 deletions .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "Automatic Releases"

on:
milestone:
types:
- "closed"

jobs:
release:
name: "GIT tag, release & create merge-up PR"
runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Release"
uses: "laminas/automatic-releases@v1"
with:
command-name: "laminas:automatic-releases:release"
env:
"GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}

- name: "Create Merge-Up Pull Request"
uses: "laminas/automatic-releases@v1"
with:
command-name: "laminas:automatic-releases:create-merge-up-pull-request"
env:
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}

- name: "Create and/or Switch to new Release Branch"
uses: "laminas/automatic-releases@v1"
with:
command-name: "laminas:automatic-releases:switch-default-branch-to-next-minor"
env:
"GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}

- name: "Bump Changelog Version On Originating Release Branch"
uses: "laminas/automatic-releases@v1"
with:
command-name: "laminas:automatic-releases:bump-changelog"
env:
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}

- name: "Create new milestones"
uses: "laminas/automatic-releases@v1"
with:
command-name: "laminas:automatic-releases:create-milestones"
env:
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
composer.lock
clover.xml
build
/build
/.phpunit.result.cache
24 changes: 14 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
}
],
"require": {
"php": "^7.4 | ^8.0",
"ext-json": "*",
"psr/http-message": "^1.0"
"php": "^8.1",
"psr/http-message": "^1.0 || ^2.0"
},
"require-dev": {
"laminas/laminas-db": "^2.9",
"squizlabs/php_codesniffer": "^3.6",
"phpstan/phpstan": "^0.12.85",
"phpunit/phpunit": "^9.5",
"laminas/laminas-diactoros": "^2.0",
"php-coveralls/php-coveralls": "^2.0",
"doctrine/coding-standard": "^9.0"
"squizlabs/php_codesniffer": "^3.7",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.3",
"laminas/laminas-diactoros": "^3.2",
"php-coveralls/php-coveralls": "^2.6",
"doctrine/coding-standard": "^12.0"
},
"autoload": {
"psr-4": {
Expand All @@ -42,9 +41,14 @@
],
"cs-check": "phpcs -s",
"cs-fix": "phpcbf",
"phpstan": "phpstan analyse -l max src",
"phpstan": "phpstan analyse",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"upload-coverage": "coveralls -v"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
24 changes: 24 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/3.5.0/phpcs.xsd"
name="Vendor">

<description>Project coding standards</description>

<arg name="extensions" value="php"/>
<arg name="colors"/>
<arg value="sp"/>

<file>./src</file>

<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix" />
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix" />
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix" />
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint" />
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint" />
</rule>
</ruleset>
9 changes: 9 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
parameters:
level: max
tmpDir: ./build/cache/phpstan
checkMissingIterableValueType: false
paths:
- ./src
ignoreErrors:
- '#mixed#'
- '#on a separate line does not do anything#'
4 changes: 1 addition & 3 deletions src/BuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ interface BuilderInterface
*/
public function fromRequest(ServerRequestInterface $request);

/**
* @return Select|array
*/
/** @return Select|array */
public function fromParams(array $query, array $hint = []);
}
10 changes: 5 additions & 5 deletions src/ElasticSearchBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@
use Psr\Http\Message\ServerRequestInterface;

use function array_merge;
use function assert;
use function in_array;
use function is_array;
use function is_string;
use function json_decode;
use function key;
use function reset;
use function str_replace;

final class ElasticSearchBuilder implements BuilderInterface
{
private string $queryName;
private string $hintName;
private array $params = [];

public function __construct(string $queryName = 'q', string $hintName = 'h')
public function __construct(private string $queryName = 'q', private string $hintName = 'h')
{
$this->queryName = $queryName;
$this->hintName = $hintName;
}

public function fromRequest(ServerRequestInterface $request): array
Expand Down Expand Up @@ -109,6 +107,8 @@ private function parseQuery(string $key, $value, bool $withoutOperator = false):
$opValue = reset($value);
$op = key($value);

assert(is_string($op));

if (in_array($op, BuilderInterface::OP_LOGIC)) {
return $this->parseLogic($key, $op, $opValue);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Exception/MalformedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

use RuntimeException;

/**
* @phpcs:disable SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix
*/
/** @phpcs:disable SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix */
class MalformedException extends RuntimeException
{
}
Loading

0 comments on commit 279c078

Please sign in to comment.