diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..37cfad7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index bf57097..f3f99cf 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -5,11 +5,9 @@ on: push: branches: - main - - master pull_request: branches: - main - - master jobs: ecs-check: @@ -26,11 +24,10 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php_version }} - ini-values: short_open_tag=On coverage: none - name: install dependencies - run: composer install + run: composer install --no-progress --no-suggest --no-interaction - name: check code style - run: php vendor/bin/ecs check + run: ./vendor/bin/ecs check diff --git a/composer.json b/composer.json index dc9306f..b6b416a 100644 --- a/composer.json +++ b/composer.json @@ -1,52 +1,64 @@ { - "name": "elnadrion/tools.twig", - "description": "Модуль подключения шаблонизатора twig к битриксу", - "keywords": ["bitrix", "1С Битрикс", "twig", "шаблонизатор"], - "license": "MIT", - "support": { - "source": "https://github.com/Elnadrion/tools.twig.git" - }, - "authors": [ - { - "name": "Журов Михаил", - "email": "m.zhurov@maximaster.ru" + "name": "elnadrion/tools.twig", + "description": "Модуль подключения шаблонизатора twig к битриксу", + "keywords": [ + "bitrix", + "1С Битрикс", + "twig", + "шаблонизатор" + ], + "license": "MIT", + "support": { + "source": "https://github.com/Elnadrion/tools.twig.git" }, - { - "name": "Лавриненко Максим", - "email": "maxim.lavrinenko@maximaster.ru" + "authors": [ + { + "name": "Журов Михаил", + "email": "m.zhurov@maximaster.ru" + }, + { + "name": "Лавриненко Максим", + "email": "maxim.lavrinenko@maximaster.ru" + }, + { + "name": "Elnadrion", + "email": "elnadrion.dev@yandex.ru" + } + ], + "require": { + "php": ">=7.2.5", + "twig/twig": "~3.0" }, - { - "name": "Elnadrion", - "email": "elnadrion.dev@yandex.ru" - } - ], - "require": { - "php": ">=7.2.5", - "twig/twig": "~3.0", - "symfony/var-dumper": "^5.0|^6.0|^7.0" - }, - "autoload": { - "psr-4": { - "Maximaster\\": "src/Maximaster/", - "Maximaster\\Tools\\Twig\\Test\\": "tests/" + "require-dev": { + "phpunit/phpunit": "^5.7", + "goaop/framework": "dev-autoload_unregister_bugfix", + "symfony/var-dumper": "^5.0|^6.0|^7.0", + "symplify/easy-coding-standard": "^12.1.14" + }, + "autoload": { + "psr-4": { + "Maximaster\\": "src/Maximaster/", + "Maximaster\\Tools\\Twig\\Test\\": "tests/" + }, + "files": [ + "src/Maximaster/functions.php" + ] + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/mlavrinenko/framework" + } + ], + "suggest": { + "goaop/framework": "Для того чтобы использовать twig-шаблоны для стандартных компонент работающих в ajax-режиме, необходимо подключить доп. зависимость. Требуется специальная исправленная версия (https://github.com/mlavrinenko/framework#dev-autoload_unregister_bugfix) и php 5.6+" + }, + "scripts": { + "test": "vendor/bin/phpunit" }, - "files": ["src/Maximaster/functions.php"] - }, - "require-dev": { - "phpunit/phpunit": "^5.7", - "goaop/framework": "dev-autoload_unregister_bugfix", - "symplify/easy-coding-standard": "^11.0" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/mlavrinenko/framework" + "config": { + "platform": { + "php": "7.4" + } } - ], - "suggest": { - "goaop/framework": "Для того чтобы использовать twig-шаблоны для стандартных компонент работающих в ajax-режиме, необходимо подключить доп. зависимость. Требуется специальная исправленная версия (https://github.com/mlavrinenko/framework#dev-autoload_unregister_bugfix) и php 5.6+" - }, - "scripts": { - "test": "vendor/bin/phpunit" - } } diff --git a/ecs.php b/ecs.php index d74c870..05c1147 100644 --- a/ecs.php +++ b/ecs.php @@ -12,27 +12,21 @@ use Symplify\EasyCodingStandard\ValueObject\Set\SetList; return static function (ECSConfig $ecsConfig): void { - $services = $ecsConfig->services(); - - $services->set(OrderedTraitsFixer::class); - $services->set(SingleQuoteFixer::class); - $services->set(NoExtraBlankLinesFixer::class); - $services->set(SingleTraitInsertPerStatementFixer::class); + $ecsConfig->rules([ + OrderedTraitsFixer::class, + SingleQuoteFixer::class, + NoExtraBlankLinesFixer::class, + SingleTraitInsertPerStatementFixer::class, + ]); - $services->set(YodaStyleFixer::class) - ->call('configure', [ - [ - 'equal' => false, - 'identical' => false, - 'less_and_greater' => false, - ], - ]); - $services->set(TrailingCommaInMultilineFixer::class) - ->call('configure', [ - [ - 'elements' => ['arrays'], - ], - ]); + $ecsConfig->ruleWithConfiguration(YodaStyleFixer::class, [ + 'equal' => false, + 'identical' => false, + 'less_and_greater' => false, + ]); + $ecsConfig->ruleWithConfiguration(TrailingCommaInMultilineFixer::class, [ + 'elements' => ['arrays'], + ]); $ecsConfig->paths([ __DIR__ . '/src', diff --git a/src/Maximaster/Tools/Twig/BitrixLoader.php b/src/Maximaster/Tools/Twig/BitrixLoader.php index 96067c8..df3f480 100755 --- a/src/Maximaster/Tools/Twig/BitrixLoader.php +++ b/src/Maximaster/Tools/Twig/BitrixLoader.php @@ -130,7 +130,7 @@ private function getComponentTemplatePath(string $name): string return $_SERVER['DOCUMENT_ROOT'] . ( $isRelative ? ($obTemplate->GetFolder() . DIRECTORY_SEPARATOR . $page) : $obTemplate->GetFile() - ); + ); } /** diff --git a/src/Maximaster/Tools/Twig/Extensions/DDExtension.php b/src/Maximaster/Tools/Twig/Extensions/DDExtension.php index ffe0316..1e53e98 100644 --- a/src/Maximaster/Tools/Twig/Extensions/DDExtension.php +++ b/src/Maximaster/Tools/Twig/Extensions/DDExtension.php @@ -25,8 +25,10 @@ public function getFunctions(): array ]; } - public static function dd($data): void + public static function dd(mixed ...$data): void { - dd($data); + if (function_exists('dd')) { + dd($data); + } } } diff --git a/src/Maximaster/Tools/Twig/Extensions/DumpExtension.php b/src/Maximaster/Tools/Twig/Extensions/DumpExtension.php index 0a53784..56fe8be 100644 --- a/src/Maximaster/Tools/Twig/Extensions/DumpExtension.php +++ b/src/Maximaster/Tools/Twig/Extensions/DumpExtension.php @@ -25,8 +25,10 @@ public function getFunctions(): array ]; } - public static function dump($data): void + public static function dump(mixed ...$data): void { - dump($data); + if (!function_exists('dd')) { + dump($data); + } } }