Skip to content

Commit 1b69a44

Browse files
Drop Support for Laravel Versions below 11 and below PHP 8.2 (#227)
* Drop Support for Laravel Versions below 11 * Update GitHub Actions Workflow * Bump PHP Version to 8.2 * Remove guards for previous Laravel Versions * Update Versions Constraints * Run tests on phpunit v11 on GitHub Actions * Drop Pest v1 * Exclude Phpunit 11 on PHP 8.2 * Only test with PhpUnit 10 * Run Rector for PHP 8.2 features * Ignore FirstClassCallableRector * Update README.md * Upgrade Tests to use PhpUnit 10 Format * Upgrade phpunit.xml
1 parent d2782aa commit 1b69a44

File tree

57 files changed

+205
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+205
-195
lines changed

.github/workflows/tests.yml

+5-17
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,16 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
php: [8.0, 8.1, 8.2, 8.3]
13-
laravel: [9.*, 10.*, 11.*]
14-
phpunit: [9.*, 10.*]
12+
php: [8.2, 8.3]
13+
laravel: [11.*]
14+
phpunit: [10.*]
1515
stability: [prefer-lowest, prefer-stable]
1616
include:
17-
- laravel: 9.*
18-
testbench: 7.*
19-
- laravel: 10.*
20-
testbench: 8.*
2117
- laravel: 11.*
2218
testbench: 9.*
2319
exclude:
24-
- laravel: 11.*
25-
php: 8.0
26-
- laravel: 11.*
27-
phpunit: 9.*
28-
- laravel: 11.*
29-
php: 8.1
30-
- laravel: 10.*
31-
php: 8.0
32-
- laravel: 9.*
33-
phpunit: 10.*
20+
- php: 8.2
21+
phpunit: 11.*
3422

3523
name: P${{ matrix.php }} - L${{ matrix.laravel }} PU${{ matrix.phpunit }} - ${{ matrix.stability }}
3624

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
### Installing
2828

29-
The easiest way to install the package is by using composer. The package requires PHP 8.0, Laravel 9.0 or higher or Lumen 9.0 or higher.
29+
The easiest way to install the package is by using composer.
3030

3131
```shell
3232
composer require "wnx/laravel-stats" --dev

composer.json

+12-14
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,23 @@
1313
}
1414
],
1515
"require": {
16-
"php": "^8.0",
16+
"php": "^8.2",
1717
"ext-json": "*",
18-
"illuminate/console": "^9.0 | ^10.0 | ^11.0",
19-
"illuminate/support": "^9.0 | ^10.0| ^11.0",
18+
"illuminate/console": "^11.0",
19+
"illuminate/support": "^11.0",
2020
"stefanzweifel/laravel-stats-phploc": "^7.0 | ^8.0",
21-
"symfony/finder": "^6.0 | ^7.0",
22-
"symfony/process": "^6.0 | ^7.0"
21+
"symfony/finder": "^7.0",
22+
"symfony/process": " ^7.0"
2323
},
2424
"require-dev": {
2525
"friendsofphp/php-cs-fixer": "^3.2",
26-
"laravel/browser-kit-testing": "^6.0 | ^7.0 | ^8.0",
27-
"laravel/dusk": "^6.0 | ^7.0 | ^8.0",
28-
"livewire/livewire": "^2.0 | ^3.0",
29-
"orchestra/testbench": "^7.0 | ^8.0 | ^9.0",
30-
"pestphp/pest": "^1 || ^2",
31-
"phpunit/phpunit": "^9.0 | ^10.0 | ^11.0",
32-
"rector/rector": "^0.15|^1.0",
33-
"vimeo/psalm": "^5.0"
26+
"laravel/browser-kit-testing": "^7.1 | ^8.0",
27+
"laravel/dusk": "^8.0",
28+
"livewire/livewire": "^3.0",
29+
"orchestra/testbench": "^9.0",
30+
"pestphp/pest": "^2",
31+
"phpunit/phpunit": "^10.0 | ^11.0",
32+
"rector/rector": "^1.0"
3433
},
3534
"autoload": {
3635
"psr-4": {
@@ -45,7 +44,6 @@
4544
},
4645
"scripts": {
4746
"format": "php-cs-fixer fix",
48-
"psalm": "vendor/bin/psalm",
4947
"test": "vendor/bin/phpunit"
5048
},
5149
"config": {

phpunit.xml

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
83
<testsuites>
94
<testsuite name="Test Suite">
105
<directory>tests</directory>
11-
<exclude>./tests/Stubs/Tests/DemoBrowserKit.php</exclude>
12-
<exclude>./tests/Stubs/Tests/DemoDuskTest.php</exclude>
13-
<exclude>./tests/Stubs/Tests/DemoUnitTest.php</exclude>
6+
<exclude>./tests/Stubs/Tests/DemoBrowserKit.php</exclude>
7+
<exclude>./tests/Stubs/Tests/DemoDuskTest.php</exclude>
8+
<exclude>./tests/Stubs/Tests/DemoUnitTest.php</exclude>
149
</testsuite>
1510
</testsuites>
11+
<source>
12+
<include>
13+
<directory suffix=".php">src/</directory>
14+
</include>
15+
</source>
1616
</phpunit>

psalm.xml

-26
This file was deleted.

rector.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6+
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
7+
use Rector\PHPUnit\Set\PHPUnitSetList;
68
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
79

810
return RectorConfig::configure()
@@ -11,8 +13,16 @@
1113
__DIR__ . '/tests',
1214
])
1315
// uncomment to reach your current PHP version
14-
->withPhpSets(php80: true)
16+
->withPhpSets(php82: true)
1517
->withPreparedSets(deadCode: true, codingStyle: true)
18+
->withSets([
19+
PHPUnitSetList::PHPUNIT_100,
20+
])
1621
->withRules([
1722
AddVoidReturnTypeWhereNoReturnRector::class,
23+
])
24+
->withSkip([
25+
FirstClassCallableRector::class => [
26+
__DIR__ . '/tests/Stubs/EventListeners/UserEventSubscriber.php',
27+
],
1828
]);

src/Classifiers/ControllerClassifier.php

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function satisfies(ReflectionClass $class): bool
2323
// Laravel
2424
return $route->getActionName() === 'Closure';
2525
}
26+
2627
// Lumen
2728
return data_get($route, 'action.uses') === null;
2829
})
@@ -35,6 +36,7 @@ public function satisfies(ReflectionClass $class): bool
3536
return;
3637
}
3738
}
39+
3840
// Lumen
3941
return Str::before(data_get($route, 'action.uses'), '@');
4042
})

src/Classifiers/CustomCastClassifier.php

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ public function name(): string
1616

1717
public function satisfies(ReflectionClass $class): bool
1818
{
19-
if ((float) app()->version() < 7) {
20-
return false;
21-
}
22-
2319
return $class->implementsInterface(CastsAttributes::class) ||
2420
$class->implementsInterface(CastsInboundAttributes::class);
2521
}

src/Classifiers/DatabaseFactoryClassifier.php

-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ public function name(): string
1515

1616
public function satisfies(ReflectionClass $class): bool
1717
{
18-
if ((float) app()->version() < 8) {
19-
return false;
20-
}
21-
2218
return $class->isSubclassOf(Factory::class);
2319
}
2420

src/Console/StatsListCommand.php

+2
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ public function handle(): void
5252
if (Str::contains($class->getName(), 'Migration@anonymous')) {
5353
return false;
5454
}
55+
5556
foreach (config('stats.ignored_namespaces', []) as $namespace) {
5657
if (Str::startsWith($class->getNamespaceName(), $namespace)) {
5758
return true;
5859
}
5960
}
61+
6062
return false;
6163
});
6264

src/Project.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Project
1616
private $classifiedClasses;
1717

1818
public function __construct(
19-
private Collection $classes
19+
private readonly Collection $classes
2020
) {
2121
// Loop through ReflectionClasses and classify them.
2222
$this->classifiedClasses = $this->classes->map(static fn (ReflectionClass $reflectionClass) => new ClassifiedClass(

src/Statistics/ProjectStatistic.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ProjectStatistic
3737
*/
3838
private $logicalLinesOfCodePerMethod;
3939

40-
public function __construct(private Project $project)
40+
public function __construct(private readonly Project $project)
4141
{
4242
}
4343

src/ValueObjects/Component.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Component
4848

4949
public function __construct(
5050
public string $name,
51-
private Collection $classifiedClasses
51+
private readonly Collection $classifiedClasses
5252
) {
5353
}
5454

tests/ClassesFinderTest.php

+20-19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Wnx\LaravelStats\Tests;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use Wnx\LaravelStats\ClassesFinder;
67

78
class ClassesFinderTest extends TestCase
@@ -26,117 +27,117 @@ protected function setUp() : void
2627
$this->classes = app(ClassesFinder::class)->findAndLoadClasses();
2728
}
2829

29-
/** @test */
30+
#[Test]
3031
public function it_finds_controllers(): void
3132
{
3233
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Controllers\ProjectsController::class));
3334
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Controllers\Controller::class));
3435
}
3536

36-
/** @test */
37+
#[Test]
3738
public function it_finds_commands(): void
3839
{
3940
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Commands\DemoCommand::class));
4041
}
4142

42-
/** @test */
43+
#[Test]
4344
public function it_finds_events(): void
4445
{
4546
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Events\DemoEvent::class));
4647
}
4748

48-
/** @test */
49+
#[Test]
4950
public function it_finds_jobs(): void
5051
{
5152
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Jobs\DemoJob::class));
5253
}
5354

54-
/** @test */
55+
#[Test]
5556
public function it_finds_mails(): void
5657
{
5758
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Mails\DemoMail::class));
5859
}
5960

60-
/** @test */
61+
#[Test]
6162
public function it_finds_middleware(): void
6263
{
6364
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Middleware\DemoMiddleware::class));
6465
}
6566

66-
/** @test */
67+
#[Test]
6768
public function it_finds_route_middleware(): void
6869
{
6970
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Middleware\RouteMiddleware::class));
7071
}
7172

72-
/** @test */
73+
#[Test]
7374
public function it_finds_migrations(): void
7475
{
7576
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Migrations\CreatePasswordResetsTable::class));
7677
}
7778

78-
/** @test */
79+
#[Test]
7980
public function it_finds_models(): void
8081
{
8182
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Models\Project::class));
8283
}
8384

84-
/** @test */
85+
#[Test]
8586
public function it_finds_notifications(): void
8687
{
8788
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Notifications\ServerDownNotification::class));
8889
}
8990

90-
/** @test */
91+
#[Test]
9192
public function it_finds_policies(): void
9293
{
9394
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Policies\DemoPolicy::class));
9495
}
9596

96-
/** @test */
97+
#[Test]
9798
public function it_finds_request(): void
9899
{
99100
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Requests\UserRequest::class));
100101
}
101102

102-
/** @test */
103+
#[Test]
103104
public function it_finds_resources(): void
104105
{
105106
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Resources\DemoResource::class));
106107
}
107108

108-
/** @test */
109+
#[Test]
109110
public function it_finds_rules(): void
110111
{
111112
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Rules\DemoRule::class));
112113
}
113114

114-
/** @test */
115+
#[Test]
115116
public function it_finds_seeders(): void
116117
{
117118
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\Seeders\DemoSeeder::class));
118119
}
119120

120-
/** @test */
121+
#[Test]
121122
public function it_finds_service_providers(): void
122123
{
123124
$this->assertTrue($this->classes->contains(\Wnx\LaravelStats\Tests\Stubs\ServiceProviders\DemoProvider::class));
124125
}
125126

126-
/** @test */
127+
#[Test]
127128
public function it_includes_native_php_classes(): void
128129
{
129130
$this->assertTrue($this->classes->contains('stdClass'));
130131
$this->assertTrue($this->classes->contains('Exception'));
131132
}
132133

133-
/** @test */
134+
#[Test]
134135
public function it_ignores_exluded_file(): void
135136
{
136137
$this->assertFalse($this->classes->contains('ExcludedFile'));
137138
}
138139

139-
/** @test */
140+
#[Test]
140141
public function it_includes_vendored_classes(): void
141142
{
142143
$this->assertTrue($this->classes->contains(\Symfony\Component\Finder\Finder::class));

0 commit comments

Comments
 (0)