Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .github/workflows/grumphp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.3', '7.4', '8.0']
php-versions: ['8.0', '8.1']
composer-options: ['', '--prefer-lowest']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }} with ${{ matrix.composer-options }}
Expand All @@ -34,20 +34,14 @@ jobs:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies <PHP8
if: matrix.php-versions != '8.0'
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }}
#
# Currently php-cs-fixer is nog PHP 8 compatible yet!
#
- name: Install dependencies PHP8
if: matrix.php-versions == '8.0'
- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }} --ignore-platform-reqs
- name: Set git variables
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
- name: Run the tests
run: php vendor/bin/grumphp run --no-interaction
continue-on-error: ${{ matrix.php-versions == '8.1' && matrix.composer-options == '--prefer-lowest' }}
env:
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.php-versions == '8.0'}}
PHP_CS_FIXER_IGNORE_ENV: 1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/vendor/
composer.lock
.php_cs.cache
.php-cs-fixer.cache
.php_cs
grumphp.yml
phpspec.yml
25 changes: 17 additions & 8 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setFinder(
\Symfony\Component\Finder\Finder::create()
PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/spec',
Expand All @@ -15,7 +15,7 @@
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'backtick_to_shell_exec' => true,
'blank_line_before_statement' => true,
'blank_line_before_statement' => ['statements' => ['return']],
'class_keyword_remove' => false,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
Expand All @@ -30,13 +30,13 @@
'escape_implicit_backslashes' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'final_internal_class' => false,
'final_internal_class' => true,
'fully_qualified_strict_types' => true,
'general_phpdoc_annotation_remove' => false,
'header_comment' => false,
'heredoc_to_nowdoc' => false,
'linebreak_after_opening_tag' => true,
'list_syntax' => true,
'list_syntax' => ['syntax' => 'short'],
'mb_str_functions' => true,
'method_chaining_indentation' => true,
'multiline_comment_opening_closing' => true,
Expand All @@ -46,7 +46,7 @@
'no_blank_lines_before_namespace' => false,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_echo_tag' => false,
'echo_tag_syntax' => ['format'=> 'long'],
'no_superfluous_elseif' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
Expand All @@ -60,16 +60,17 @@
'php_unit_mock' => false,
'php_unit_namespaced' => false,
'php_unit_no_expectation_annotation' => false,
'php_unit_ordered_covers' => true,
'phpdoc_order_by_value' => ['annotations' => ['covers']],
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_strict' => false,
'php_unit_test_annotation' => false,
'php_unit_test_class_requires_covers' => false,
'php_unit_method_casing' => ['case' => 'snake_case'],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
'pow_to_exponentiation' => true,
'psr0' => true,
'psr_autoloading' => ['dir' => 'src'],
'random_api_migration' => false,
'simplified_null_return' => true,
'static_lambda' => false,
Expand All @@ -79,5 +80,13 @@
'ternary_to_null_coalescing' => true,
'void_return' => true,
'yoda_style' => true,
'single_line_throw' => false,
'phpdoc_align' => ['align' => 'left'],
'phpdoc_to_comment' => false,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
])
;
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"description": "RFC7807 Problem details implementation",
"type": "library",
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16.7",
"phpro/grumphp-shim": "^1.2",
"phpspec/phpspec": "^6.3",
"symfony/validator": "^4.4",
"sebastian/comparator": "^1.2.4"
"friendsofphp/php-cs-fixer": "^3.3",
"phpro/grumphp-shim": "^1.6",
"phpspec/phpspec": "^7.0",
"symfony/validator": "^5.3 || ^6.0",
"sebastian/comparator": "^4.0"
},
"license": "MIT",
"authors": [
Expand All @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^7.3 || ^8.0"
"php": "^8.0"
},
"config": {
"sort-packages": true
Expand Down
2 changes: 1 addition & 1 deletion grumphp.yml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
grumphp:
tasks:
phpcsfixer2:
config: ".php_cs.dist"
config: ".php-cs-fixer.dist.php"
config_contains_finder: true
phpspec:
format: dot
Expand Down
3 changes: 2 additions & 1 deletion spec/Exception/ApiProblemExceptionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace spec\Phpro\ApiProblem\Exception;

use Exception;
use Phpro\ApiProblem\ApiProblemInterface;
use Phpro\ApiProblem\Exception\ApiProblemException;
use PhpSpec\ObjectBehavior;
Expand All @@ -23,7 +24,7 @@ public function it_is_initializable(): void

public function it_is_an_excpetion(): void
{
$this->shouldHaveType(\Exception::class);
$this->shouldHaveType(Exception::class);
}

public function it_contains_an_api_problem(ApiProblemInterface $apiProblem): void
Expand Down
3 changes: 2 additions & 1 deletion spec/Http/ExceptionApiProblemSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace spec\Phpro\ApiProblem\Http;

use Exception;
use InvalidArgumentException;
use Phpro\ApiProblem\DebuggableApiProblemInterface;
use Phpro\ApiProblem\Http\ExceptionApiProblem;
use Phpro\ApiProblem\Http\HttpApiProblem;
Expand Down Expand Up @@ -148,7 +149,7 @@ public function it_should_deal_with_string_exception_codes(): void
public function it_should_use_code_as_status_code_when_valid_http_status_code_error(): void
{
$message = 'an honest error';
$this->beConstructedWith(new \InvalidArgumentException($message, 400));
$this->beConstructedWith(new InvalidArgumentException($message, 400));

$this->toArray()->shouldBe([
'status' => 400,
Expand Down
3 changes: 2 additions & 1 deletion src/Exception/ApiProblemException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

namespace Phpro\ApiProblem\Exception;

use Exception;
use Phpro\ApiProblem\ApiProblemInterface;

class ApiProblemException extends \Exception
class ApiProblemException extends Exception
{
/**
* @var ApiProblemInterface
Expand Down
5 changes: 3 additions & 2 deletions src/Http/ExceptionApiProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Phpro\ApiProblem\Http;

use function get_class;
use Phpro\ApiProblem\DebuggableApiProblemInterface;
use Throwable;

Expand All @@ -23,7 +24,7 @@ public function __construct(Throwable $exception)
: 500;

parent::__construct($statusCode, [
'detail' => $exception->getMessage() ?: \get_class($exception),
'detail' => $exception->getMessage() ?: get_class($exception),
]);
}

Expand Down Expand Up @@ -51,7 +52,7 @@ public function toDebuggableArray(): array
private function serializeException(Throwable $throwable): array
{
return [
'type' => \get_class($throwable),
'type' => get_class($throwable),
'message' => $throwable->getMessage(),
'code' => $throwable->getCode(),
'line' => $throwable->getLine(),
Expand Down