Classes should be final
This commit is contained in:
parent
431545bfc4
commit
7dcc7a2126
4 changed files with 95 additions and 1 deletions
|
@ -135,6 +135,13 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"drupal/core-dev": "^11.1",
|
||||
"phpat/phpat": "^0.10.20",
|
||||
"phpstan/extension-installer": "^1.4",
|
||||
"weitzman/drupal-test-traits": "^2.5"
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tools\\": "tools/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
59
composer.lock
generated
59
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "acf7a5349dc6167b6a9c51b2128cd23f",
|
||||
"content-hash": "31d8c2ff0a96c6f09d7d1879afc5ad28",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asm89/stack-cors",
|
||||
|
@ -11656,6 +11656,63 @@
|
|||
},
|
||||
"time": "2024-03-15T13:55:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpat/phpat",
|
||||
"version": "0.10.20",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/carlosas/phpat.git",
|
||||
"reference": "55154db9c36d56aaae5de4bcddb7f5a1202f1910"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/carlosas/phpat/zipball/55154db9c36d56aaae5de4bcddb7f5a1202f1910",
|
||||
"reference": "55154db9c36d56aaae5de4bcddb7f5a1202f1910",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"phpstan/phpstan": "^1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "3.46",
|
||||
"kubawerlos/php-cs-fixer-custom-fixers": "3.18",
|
||||
"phpunit/phpunit": "^9.0 || ^10.0",
|
||||
"vimeo/psalm": "^5.0"
|
||||
},
|
||||
"type": "phpstan-extension",
|
||||
"extra": {
|
||||
"phpstan": {
|
||||
"includes": [
|
||||
"extension.neon"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"PHPat\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Carlos Alandete Sastre",
|
||||
"email": "carlos.alandete@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP Architecture Tester",
|
||||
"support": {
|
||||
"issues": "https://github.com/carlosas/phpat/issues",
|
||||
"source": "https://github.com/carlosas/phpat/tree/0.10.20"
|
||||
},
|
||||
"time": "2024-11-23T21:56:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "2.2.0",
|
||||
|
|
|
@ -3,3 +3,8 @@ parameters:
|
|||
paths:
|
||||
- modules
|
||||
- themes
|
||||
- tools
|
||||
services:
|
||||
- class: Tools\Phpat\ArchitectureTest
|
||||
tags:
|
||||
- phpat.test
|
||||
|
|
25
tools/Phpat/ArchitectureTest.php
Normal file
25
tools/Phpat/ArchitectureTest.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tools\Phpat;
|
||||
|
||||
use PHPat\Selector\Selector;
|
||||
use PHPat\Test\Builder\Rule;
|
||||
use PHPat\Test\PHPat;
|
||||
|
||||
final class ArchitectureTest {
|
||||
|
||||
public function test_classes_should_be_final(): Rule {
|
||||
return PHPat::rule()
|
||||
->classes(
|
||||
Selector::inNamespace(
|
||||
namespace: '/^Drupal\\\\opd_\w+/',
|
||||
regex: TRUE,
|
||||
),
|
||||
)
|
||||
->excluding(Selector::isInterface())
|
||||
->shouldBeFinal();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue