Skip to content

Commit

Permalink
Merge pull request #1 from tr33m4n/feature/maintenance
Browse files Browse the repository at this point in the history
General maintenance
  • Loading branch information
tr33m4n authored Aug 14, 2024
2 parents 472fdf9 + 6037289 commit b20961d
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 26 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: 0 3 * * 1,3,5
workflow_dispatch:

env:
COMPOSER_MEMORY_LIMIT: -1

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 8.1, 8.2, 8.3 ]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
- name: Install dependencies
run: |
composer config --global --auth http-basic.repo.magento.com ${{ secrets.MAGENTO_REPO_USERNAME }} ${{ secrets.MAGENTO_REPO_PASSWORD }}
sudo chmod 644 ~/.composer/auth.json
composer update
- name: Run static analysis test suite
run: composer run test
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/vendor
/.php_cs.cache
/var
/composer.lock
/app
/.phpunit.cache
/.editorconfig
/.idea
/Makefile
/Brewfile
38 changes: 38 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

use AdamWojs\PhpCsFixerPhpdocForceFQCN\Fixer\Phpdoc\ForceFQCNFixer;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src');

$config = (new PhpCsFixer\Config())
->setUsingCache(false)
->registerCustomFixers([new ForceFQCNFixer()])
->setFinder($finder)
->setRules(
[
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'include' => true,
'new_with_braces' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'multiline_whitespace_before_semicolons' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'AdamWojs/phpdoc_force_fqcn_fixer' => true
]
);

return $config;
38 changes: 35 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"files": [
"src/registration.php"
Expand All @@ -19,7 +27,31 @@
}
},
"require": {
"php": "^7.2",
"magento/framework": "^100.1||^101.0||^102.0"
"php": "^8.1",
"magento/framework": "*"
},
"scripts": {
"fix": "vendor/bin/rector process && vendor/bin/php-cs-fixer fix --diff",
"test:static": "vendor/bin/phpstan analyse --no-interaction --no-progress && vendor/bin/phpcs src -s",
"test:lint": "vendor/bin/rector process --dry-run && vendor/bin/php-cs-fixer fix --dry-run --diff",
"test-static-analysis": [
"@test:static",
"@test:lint"
],
"test": [
"@test-static-analysis"
]
},
"require-dev": {
"adamwojs/php-cs-fixer-phpdoc-force-fqcn": "^2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"friendsofphp/php-cs-fixer": "^3.62",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.2"
},
"extra": {
"magento-deploystrategy": "none"
}
}
7 changes: 7 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>tr33m4n system path hints configuration</description>
<rule ref="PSR12">
<exclude name="Generic.Files.LineLength"/>
</rule>
</ruleset>
12 changes: 12 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
parameters:
paths:
- %currentWorkingDirectory%/src
excludePaths:
- *Test*
- *tests*
level: max
ignoreErrors:
- '#Method (.*) should return class-string but returns string.#'
- '#PHPDoc tag @var for constant (.*) with type class-string is incompatible with value (.*)#'
- '#Default value of the parameter (.*) of method (.*) is incompatible with type class-string.#'
- '#Default value of the parameter (.*) of method (.*) is incompatible with type array<class-string>.#'
25 changes: 25 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(SetList::DEAD_CODE);
$rectorConfig->import(SetList::NAMING);
$rectorConfig->import(SetList::EARLY_RETURN);
$rectorConfig->import(SetList::CODE_QUALITY);
$rectorConfig->import(SetList::PRIVATIZATION);
$rectorConfig->import(SetList::TYPE_DECLARATION);
$rectorConfig->import(LevelSetList::UP_TO_PHP_81);

$rectorConfig->cacheClass(MemoryCacheStorage::class);

$rectorConfig->paths([__DIR__ . '/src']);
$rectorConfig->skip([
__DIR__ . '/src/Test'
]);
};
28 changes: 5 additions & 23 deletions src/Plugin/Model/Config/Structure/Element/FieldPlugin.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,28 @@
<?php

declare(strict_types=1);

namespace tr33m4n\SystemPathHints\Plugin\Model\Config\Structure\Element;

use Magento\Config\Model\Config\Structure\Element\Field;
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* Class FieldPlugin
*
* @package tr33m4n\SystemPathHints\Plugin\Model\Config\Structure\Element
*/
class FieldPlugin
{
/**
* System path hints path
*/
const XML_ENABLE_PATH_HINTS_PATH = 'dev/debug/system_path_hints';

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $scopeConfig;
private const XML_ENABLE_PATH_HINTS_PATH = 'dev/debug/system_path_hints';

/**
* FieldPlugin constructor.
*
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
*/
public function __construct(
ScopeConfigInterface $scopeConfig
private readonly ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}

/**
* Add path to the field comment
*
* @param \Magento\Config\Model\Config\Structure\Element\Field $subject
* @param string $result
* @return string
*/
public function afterGetComment(Field $subject, string $result) : string
public function afterGetComment(Field $subject, string $result): string
{
if (!$this->scopeConfig->isSetFlag(self::XML_ENABLE_PATH_HINTS_PATH)) {
return $result;
Expand Down

0 comments on commit b20961d

Please sign in to comment.