Skip to content

Commit

Permalink
Merge pull request #19 from fruitl00p/feature/L11-strict-standards
Browse files Browse the repository at this point in the history
Feature/l11 strict standards
  • Loading branch information
jackwh authored May 10, 2024
2 parents 10ec38f + 858e5b7 commit e74e554
Show file tree
Hide file tree
Showing 21 changed files with 392 additions and 292 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
/UPGRADING.md export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
/rector.php export-ignore
/pint.json export-ignore
23 changes: 0 additions & 23 deletions .github/workflows/php-cs-fixer.yml

This file was deleted.

5 changes: 2 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none
php-version: '8.1'

- name: Install composer dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
24 changes: 24 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PHP Linting (Pint)
on:
workflow_dispatch:
push:
branches-ignore:
- 'dependabot/npm_and_yarn/*'
jobs:
phplint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: "laravel-pint"
uses: aglipanci/[email protected]
with:
preset: psr12
verboseMode: true

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: PHP Linting (Pint)
skip_fetch: true
221 changes: 116 additions & 105 deletions .idea/laravel-new-relic.iml

Large diffs are not rendered by default.

40 changes: 0 additions & 40 deletions .php_cs.dist.php

This file was deleted.

28 changes: 16 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@
],
"require": {
"php": "^8.1",
"illuminate/contracts": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0"
"illuminate/contracts": "^9.0|^10.0|^11.0",
"illuminate/support": "^9.0|^10.0|^11.0"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"nunomaduro/collision": "^6.0",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^7.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"phpstan/extension-installer": "^1.1",
"driftingly/rector-laravel": "^1.2",
"larastan/larastan": "^2.9.0",
"laravel/pint": "^1.15",
"nunomaduro/collision": "^6.0|^8.0",
"orchestra/testbench": "^7.0|^9.0",
"pestphp/pest": "^1.21|^2.34",
"pestphp/pest-plugin-laravel": "^1.1|^2.3",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5",
"spatie/laravel-ray": "^1.26"
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5|^10.5",
"rector/rector": "^1.0",
"roave/security-advisories": "dev-latest",
"spatie/laravel-ray": "^1.26"
},
"autoload": {
"psr-4": {
Expand All @@ -48,6 +51,7 @@
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse",
"lint": "vendor/bin/pint",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage"
},
Expand Down
32 changes: 17 additions & 15 deletions config/new-relic.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

return [

/*
Expand Down Expand Up @@ -28,7 +30,7 @@
| api_key: Optional, but required to use the New Relic deployments feature.
|
*/
'app_name' => ini_get('newrelic.appname') ?: env('APP_NAME', 'laravel'),
'app_name' => ini_get('newrelic.appname') ?: env('APP_NAME', 'laravel'),

/*
|--------------------------------------------------------------------------
Expand All @@ -49,7 +51,7 @@
'environments' => [
'production',
],
'loggable' => [
'loggable' => [
'local',
],

Expand Down Expand Up @@ -88,17 +90,17 @@
| ignore: Set which HTTP requests should be ignored by New Relic.
|
*/
'http' => [
'http' => [
'middleware' => \JackWH\LaravelNewRelic\Middleware\NewRelicMiddleware::class,

'visitors' => [
'record_user_id' => true,
'record_user_id' => true,
'record_ip_address' => false,
'guest_label' => 'Guest',
'guest_label' => 'Guest',
],

'rewrite' => [
'/livewire/livewire.js' => 'livewire.js',
'/livewire/livewire.js' => 'livewire.js',
'/livewire/livewire.js.map' => 'livewire.js.map',
],

Expand Down Expand Up @@ -128,7 +130,7 @@
| runtime stats for background, noisy, or long-running processes.
|
*/
'artisan' => [
'artisan' => [
'prefix' => '',

'ignore' => [
Expand Down Expand Up @@ -164,13 +166,13 @@
| connections, queue names, or job classes, enter them here.
|
*/
'queue' => [
'queue' => [
'prefix' => '',

'ignore' => [
'connections' => ['sync'],
'queues' => [],
'jobs' => [],
'queues' => [],
'jobs' => [],
],
],

Expand All @@ -196,7 +198,7 @@
| ignored in the Artisan or Queue configuration sections.
|
*/
'scheduler' => [
'scheduler' => [
'prefix' => '',

'ignore' => [
Expand All @@ -220,12 +222,12 @@
| detect_hash: If true, and no git commit hash is passed to the command,
| the package will attempt to auto-detect the revision.
*/
'deployments' => [
'api_key' => env('NEW_RELIC_API_KEY'),
'app_id' => env('NEW_RELIC_APP_ID'),
'deployments' => [
'api_key' => env('NEW_RELIC_API_KEY'),
'app_id' => env('NEW_RELIC_APP_ID'),
'endpoint' => env('NEW_RELIC_API_ENDPOINT', 'https://api.newrelic.com/v2/'),

'user' => '[email protected]',
'user' => '[email protected]',

'detect_hash' => true,
],
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 4
level: 6
paths:
- src
- config
Expand Down
3 changes: 3 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "psr12"
}
30 changes: 30 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;

return RectorConfig::configure()
->withPaths([
__DIR__.'/config',
__DIR__.'/src',
__DIR__.'/tests',
])
// uncomment to reach your current PHP version
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
naming: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true
)
->withPhpSets(php81: true)
->withRules([
\Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector::class,
AddVoidReturnTypeWhereNoReturnRector::class,
]);
5 changes: 4 additions & 1 deletion src/Commands/NewRelicDeployCommand.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

declare(strict_types=1);

namespace JackWH\LaravelNewRelic\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Throwable;

class NewRelicDeployCommand extends Command
{
Expand Down Expand Up @@ -59,7 +62,7 @@ public function detectRevision(): ?string

try {
return trim(exec('git log --pretty="%H" -n1 HEAD'));
} catch (\Throwable $throwable) {
} catch (Throwable $throwable) {
$this->warn('Could not auto-detect revision hash: ' . $throwable->getMessage());
}

Expand Down
2 changes: 2 additions & 0 deletions src/Facades/NewRelicTransaction.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JackWH\LaravelNewRelic\Facades;

use Illuminate\Support\Facades\Facade;
Expand Down
2 changes: 2 additions & 0 deletions src/Helpers/LoggableNewRelicFunctions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
|--------------------------------------------------------------------------
| Loggable New Relic Functions
Expand Down
6 changes: 4 additions & 2 deletions src/LaravelNewRelicServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JackWH\LaravelNewRelic;

use Illuminate\Support\ServiceProvider;
Expand All @@ -21,8 +23,8 @@ public function register(): void
// Bind the transaction and handler classes to the container.
// We bind them as scoped singletons, meaning they will be
// automatically reset at the end of each lifecycle request.
$this->app->scoped(NewRelicTransaction::class, fn ($app) => new NewRelicTransaction());
$this->app->scoped(NewRelicTransactionHandler::class, fn ($app) => new NewRelicTransactionHandler());
$this->app->scoped(NewRelicTransaction::class, static fn ($app): NewRelicTransaction => new NewRelicTransaction());
$this->app->scoped(NewRelicTransactionHandler::class, static fn ($app): NewRelicTransactionHandler => new NewRelicTransactionHandler());
}

/**
Expand Down
Loading

0 comments on commit e74e554

Please sign in to comment.