Skip to content

Commit

Permalink
Code: upgrade to PHP 8, add types (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman3349 authored Dec 27, 2022
1 parent 9416d4b commit 3817ea9
Show file tree
Hide file tree
Showing 25 changed files with 93 additions and 437 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,3 @@ jobs:
phpstan:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@v1

phpstan24:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@v1
with:
php: "8.0"
makefile: "phpstan24"
composer: "composer update --prefer-lowest"
27 changes: 7 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,21 @@ on:
- cron: "0 8 * * 1"

jobs:
test81:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "8.1"

test80:
test82:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "8.0"
php: "8.2"

test74:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "7.4"

test73:
test81:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "7.3"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
php: "8.1"

test72:
test80:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "7.2"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
php: "8.0"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@ qa: phpstan cs

cs:
ifdef GITHUB_ACTION
vendor/bin/codesniffer -q --report=checkstyle src tests | cs2pr
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp -q --report=checkstyle src tests | cs2pr
else
vendor/bin/codesniffer src tests
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests
endif

csf:
vendor/bin/codefixer src tests
vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --colors -nsp src tests

phpstan:
vendor/bin/phpstan analyse -c phpstan.neon

phpstan24:
vendor/bin/phpstan analyse -c phpstan24.neon

tests:
vendor/bin/tester -s -p php --colors 1 -C tests/Cases

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For details on how to use this package, check out our [documentation](.docs).

| State | Version | Branch | Nette | PHP |
|-------------|---------|----------|-------|---------|
| dev | `^0.2` | `master` | 2.4+ | `>=7.2` |
| dev | `^0.2` | `master` | 3.1+ | `>=8.0` |
| stable | `^0.1` | `master` | 2.4+ | `>=7.2` |

## Development
Expand Down
33 changes: 17 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@
}
],
"require": {
"php": ">=7.2",
"sentry/sentry": "^3.3.7",
"guzzlehttp/guzzle": "^7.4.1",
"guzzlehttp/psr7": "^2.1.0",
"php": ">=8.0",
"sentry/sentry": "^3.12.0",
"guzzlehttp/guzzle": "^7.5.0",
"guzzlehttp/psr7": "^2.4.3",
"php-http/guzzle7-adapter": "1.0.0"
},
"require-dev": {
"mockery/mockery": "^1.3.5",
"nette/application": "^2.4.17 || ^3.0.8",
"nette/di": "^2.4.17 || ^3.0.12",
"nette/http": "^2.4.12 || ^3.0.7",
"nette/security": "^2.4.4 || ^3.0.6",
"ninjify/nunjuck": "^0.4.0",
"ninjify/qa": "^0.12.2",
"phpstan/phpstan": "^1.4.2",
"phpstan/phpstan-deprecation-rules": "^1.0.0",
"phpstan/phpstan-nette": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"tracy/tracy": "^2.6.0"
"contributte/qa": "^0.3.0",
"mockery/mockery": "^1.5.1",
"nette/application": "^3.1.0",
"nette/di": "^3.1.0",
"nette/http": "^3.2.1",
"nette/security": "^3.1.6",
"nette/tester": "^2.4.3",
"ninjify/nunjuck": "^0.3.0",
"phpstan/phpstan": "^1.9.4",
"phpstan/phpstan-deprecation-rules": "^1.1.1",
"phpstan/phpstan-nette": "^1.2.0",
"phpstan/phpstan-strict-rules": "^1.4.4",
"tracy/tracy": "^2.9.5"
},
"suggest": {
"ext-curl": "S3 upload"
Expand Down
25 changes: 0 additions & 25 deletions phpstan24.neon

This file was deleted.

2 changes: 1 addition & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/ninjify/coding-standard/contributte.xml">
<rule ref="./vendor/contributte/qa/ruleset.xml">
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Useless for yield in tests -->
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountBeforeControlStructure"/>
Expand Down
1 change: 0 additions & 1 deletion src/DI/SentryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function getConfigSchema(): Schema
]);
}


public function loadConfiguration(): void
{
$config = $this->getConfig();
Expand Down
136 changes: 0 additions & 136 deletions src/DI/SentryExtension24.php

This file was deleted.

8 changes: 2 additions & 6 deletions src/Integration/ExtraIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
class ExtraIntegration extends BaseIntegration
{

/** @var array<string, mixed> */
protected $data = [];

/** @var array<string, bool> */
protected $preset = [
protected array $preset = [
'memory' => true,
'env' => true,
'hostname' => true,
Expand All @@ -22,9 +19,8 @@ class ExtraIntegration extends BaseIntegration
/**
* @param array<string, mixed> $data
*/
public function __construct(array $data)
public function __construct(protected array $data)
{
$this->data = $data;
}

public function setPreset(string $field, bool $enable = true): void
Expand Down
2 changes: 1 addition & 1 deletion src/Integration/IgnoreErrorIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class IgnoreErrorIntegration extends BaseIntegration
{

/** @var mixed[] */
private $options;
private array $options;

/**
* @param mixed[] $options
Expand Down
11 changes: 3 additions & 8 deletions src/Integration/NetteApplicationIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,16 @@
class NetteApplicationIntegration extends BaseIntegration
{

/** @var Container */
protected $context;

public function __construct(Container $context)
public function __construct(protected Container $context)
{
$this->context = $context;
}

public function setup(HubInterface $hub, Event $event, EventHint $hint): ?Event
{
/** @var Application|null $application */
$application = $this->context->getByType(Application::class, false);

// There is no application
if ($application === null) {
if (!$application instanceof Application) {
return $event;
}

Expand All @@ -52,7 +47,7 @@ public function setup(HubInterface $hub, Event $event, EventHint $hint): ?Event
Breadcrumb::LEVEL_INFO,
Breadcrumb::TYPE_HTTP,
'nette_application_request',
sprintf('Nette Application Request #%s', intval($n) + 1),
sprintf('Nette Application Request #%s', (int) $n + 1),
$data
),
]
Expand Down
11 changes: 3 additions & 8 deletions src/Integration/NetteHttpIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@
class NetteHttpIntegration extends BaseIntegration
{

/** @var Container */
protected $context;

public function __construct(Container $context)
public function __construct(protected Container $context)
{
$this->context = $context;
}

public function setup(HubInterface $hub, Event $event, EventHint $hint): ?Event
{
/** @var IRequest|null $httpRequest */
$httpRequest = $this->context->getByType(IRequest::class);
$httpRequest = $this->context->getByType(IRequest::class, false);

// There is no http request
if ($httpRequest === null) {
if (!$httpRequest instanceof IRequest) {
return $event;
}

Expand Down
Loading

0 comments on commit 3817ea9

Please sign in to comment.