From 6d772abfd0c7f2572a01a2eb5eee08535ea23832 Mon Sep 17 00:00:00 2001 From: AI Date: Sun, 28 Dec 2025 15:18:34 +0000 Subject: [PATCH 1/2] Chore: align with Contributte standards - Add .gitattributes for proper git export - Update .gitignore with standard patterns - Update .editorconfig glob pattern syntax - Update composer.json (phpstan ^0.2, Tests\\ namespace) - Update ruleset.xml to use ruleset-8.2.xml - Update GitHub workflows to use @master and add workflow_dispatch - Add PHP 8.3 and 8.4 test jobs - Remove .kodiak.toml (not in template) - Remove tests/.coveralls.yml and tests/.gitignore - Fix deprecated addFilterLoader() call in Generator.php - Simplify TemplateFilters::description() signature --- .editorconfig | 2 +- .gitattributes | 10 ++++++++++ .github/.kodiak.toml | 10 ---------- .github/workflows/codesniffer.yml | 3 ++- .github/workflows/coverage.yml | 5 +++-- .github/workflows/phpstan.yml | 5 +++-- .github/workflows/tests.yml | 25 +++++++++++++++++++------ .gitignore | 12 ++++++++++++ composer.json | 4 ++-- ruleset.xml | 2 +- src/Generator.php | 2 +- src/TemplateFilters.php | 28 +++------------------------- tests/.coveralls.yml | 4 ---- tests/.gitignore | 10 ---------- 14 files changed, 57 insertions(+), 65 deletions(-) create mode 100644 .gitattributes delete mode 100644 .github/.kodiak.toml delete mode 100644 tests/.coveralls.yml delete mode 100644 tests/.gitignore diff --git a/.editorconfig b/.editorconfig index 2b36c40..5e5b915 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,6 @@ indent_style = tab indent_size = tab tab_width = 4 -[{*.yaml, *.yml, *.md}] +[*.{json,yaml,yml,md}] indent_style = space indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..aad8529 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +.docs export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.travis.yml export-ignore +Makefile export-ignore +README.md export-ignore +phpstan.neon export-ignore +ruleset.xml export-ignore +tests export-ignore diff --git a/.github/.kodiak.toml b/.github/.kodiak.toml deleted file mode 100644 index 60c34b6..0000000 --- a/.github/.kodiak.toml +++ /dev/null @@ -1,10 +0,0 @@ -version = 1 - -[merge] -automerge_label = "automerge" -blacklist_title_regex = "^WIP.*" -blacklist_labels = ["WIP"] -method = "rebase" -delete_branch_on_merge = true -notify_on_conflict = true -optimistic_updates = false diff --git a/.github/workflows/codesniffer.yml b/.github/workflows/codesniffer.yml index 995ab44..590394f 100644 --- a/.github/workflows/codesniffer.yml +++ b/.github/workflows/codesniffer.yml @@ -2,6 +2,7 @@ name: "Codesniffer" on: pull_request: + workflow_dispatch: push: branches: ["*"] @@ -12,6 +13,6 @@ on: jobs: codesniffer: name: "Codesniffer" - uses: contributte/.github/.github/workflows/codesniffer.yml@v1 + uses: contributte/.github/.github/workflows/codesniffer.yml@master with: php: "8.4" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 13e1568..c51c356 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -2,16 +2,17 @@ name: "Coverage" on: pull_request: + workflow_dispatch: push: branches: ["*"] schedule: - - cron: "0 8 * * 1" + - cron: "0 9 * * 1" jobs: coverage: name: "Nette Tester" - uses: contributte/.github/.github/workflows/nette-tester-coverage.yml@v1 + uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master with: php: "8.4" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 5c374a9..cd37eba 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -2,16 +2,17 @@ name: "Phpstan" on: pull_request: + workflow_dispatch: push: branches: ["*"] schedule: - - cron: "0 8 * * 1" + - cron: "0 10 * * 1" jobs: phpstan: name: "Phpstan" - uses: contributte/.github/.github/workflows/phpstan.yml@v1 + uses: contributte/.github/.github/workflows/phpstan.yml@master with: php: "8.4" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c10314..01ae1bc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,35 +2,48 @@ name: "Nette Tester" on: pull_request: + workflow_dispatch: push: branches: [ "*" ] schedule: - - cron: "0 8 * * 1" + - cron: "0 10 * * 1" jobs: - php85: + test85: name: "Nette Tester" - uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + uses: contributte/.github/.github/workflows/nette-tester.yml@master with: php: "8.5" + test84: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.4" + + test83: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.3" + test82: name: "Nette Tester" - uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + uses: contributte/.github/.github/workflows/nette-tester.yml@master with: php: "8.2" test81: name: "Nette Tester" - uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + uses: contributte/.github/.github/workflows/nette-tester.yml@master with: php: "8.1" testlower: name: "Nette Tester" - uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + uses: contributte/.github/.github/workflows/nette-tester.yml@master with: php: "8.1" composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest" diff --git a/.gitignore b/.gitignore index de4a392..f0b3670 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,14 @@ +# IDE +/.idea + +# Composer /vendor /composer.lock + +# Tests +/tests/tmp +/coverage.* +/tests/**/*.log +/tests/**/*.html +/tests/**/*.expected +/tests/**/*.actual diff --git a/composer.json b/composer.json index 80cf9c9..716a96d 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ }, "autoload-dev": { "psr-4": { - "Contributte\\ApiDocu\\Tests\\": "tests" + "Tests\\": "tests" } }, "require": { @@ -45,7 +45,7 @@ "require-dev": { "contributte/qa": "^0.4", "contributte/tester": "^0.3", - "contributte/phpstan": "^0.1", + "contributte/phpstan": "^0.2", "mockery/mockery": "^1.6.6", "tracy/tracy": "^2.10.5" }, diff --git a/ruleset.xml b/ruleset.xml index 2f9c705..9562016 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,7 +1,7 @@ - + diff --git a/src/Generator.php b/src/Generator.php index 3a2c2fc..a35537a 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -147,7 +147,7 @@ public function createTemplate(string $which): Template $template = $this->templateFactory->createTemplate(); assert($template instanceof DefaultTemplate); - $template->getLatte()->addFilterLoader('Contributte\ApiDocu\TemplateFilters::common'); + $template->getLatte()->addFilter('description', TemplateFilters::description(...)); $template->setFile(__DIR__ . '/templates/' . $which); diff --git a/src/TemplateFilters.php b/src/TemplateFilters.php index 35b79fe..4a12281 100644 --- a/src/TemplateFilters.php +++ b/src/TemplateFilters.php @@ -5,35 +5,13 @@ class TemplateFilters { - public static function common(string $filter): ?string + public static function description(string $text): string { - if (method_exists(self::class, $filter)) { - $args = func_get_args(); - array_shift($args); - - $callback = [self::class, $filter]; - - if (!is_callable($callback)) { - throw new \UnexpectedValueException(); - } - - return ($callback)($args); - } - - return null; - } - - /** - * @param array $text - */ - public static function description(array $text): string - { - $text = reset($text); - $text = nl2br($text); // @phpstan-ignore-line + $text = nl2br($text); $text = str_replace(["\n", "\n\r", "\r\n", "\r"], '', $text); $text = preg_replace_callback('/
(.*?)<\/json>/s', function ($item): string { - $s = '
' . str_replace('
', '', (string) end($item)) . '
'; + $s = '
' . str_replace('
', '', end($item)) . '
'; $s = (string) preg_replace('/(\s)"([^"]+)"/', '$1"$2"', $s); $s = (string) preg_replace('/\/\/(.*?)
/', '//$1
', $s); diff --git a/tests/.coveralls.yml b/tests/.coveralls.yml deleted file mode 100644 index a5dd742..0000000 --- a/tests/.coveralls.yml +++ /dev/null @@ -1,4 +0,0 @@ -# for php-coveralls -service_name: php-coveralls -coverage_clover: coverage.xml -json_path: coverage.json diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index f0d3402..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# Folders - recursive -*.expected -*.actual - -# Folders -/tmp - -# Files -/*.log -/*.html From 09fb8207feef56e1d5cae27c57475c369eb67dcb Mon Sep 17 00:00:00 2001 From: AI Date: Sun, 28 Dec 2025 15:20:52 +0000 Subject: [PATCH 2/2] Chore: bump minimum PHP version to 8.2 --- .github/workflows/tests.yml | 8 +------- README.md | 2 +- composer.json | 2 +- phpstan.neon | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 01ae1bc..6462f70 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,15 +35,9 @@ jobs: with: php: "8.2" - test81: - name: "Nette Tester" - uses: contributte/.github/.github/workflows/nette-tester.yml@master - with: - php: "8.1" - testlower: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.1" + php: "8.2" composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest" diff --git a/README.md b/README.md index 099c290..1e7ab2d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ For details on how to use this package, check out our [documentation](.docs). | State | Version | Branch | Nette | PHP | |--------|---------|----------|--------|---------| -| dev | `^5.1` | `master` | `4.0+` | `>=8.1` | +| dev | `^5.1` | `master` | `4.0+` | `>=8.2` | | stable | `^5.0` | `master` | `3.0+` | `>=8.1` | ## Development diff --git a/composer.json b/composer.json index 716a96d..711c72f 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ } }, "require": { - "php": ">=8.1", + "php": ">=8.2", "nette/http": "^3.2.3", "nette/application": "^3.1.14", "nette/di": "^3.1.8", diff --git a/phpstan.neon b/phpstan.neon index d20c295..cd64186 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,7 +3,7 @@ includes: parameters: level: 9 - phpVersion: 80100 + phpVersion: 80200 scanDirectories: - src