Skip to content

Commit

Permalink
ci(chglog): update filters and title maps in .chglog/config.yml
Browse files Browse the repository at this point in the history
- Add 'build', 'ci', 'docs', 'style', and 'test' to commit type filters.
- Update title maps for 'chore', 'feat', 'fix', 'perf', 'refactor', and 'test'.
- Remove commented out lines from the file.

- Update .editorconfig indentation settings for '*.vue', '*.js', and '*.scss' files.
- Update .editorconfig 'insert_final_newline' setting for all files except '*.vue', '*.js', and '*.scss'.

- Update .gitattributes to ignore additional files and directories.
- Add '.editorconfig', '.php_cs', and '.github' to the ignored files.

- Add phpstan.yml workflow file.

- Update tests.yml workflow file to include PHP 8.4 in the matrix.

- Update .lintmdrc to exclude './CHANGELOG.md' from linting.

- Update README files to reflect the minimum required PHP version of 7.4.

- Add error ignore rules to phpstan.neon.

- Update phpunit.xml.dist to exclude 'src/Support/helpers.php' from coverage.
- Add exclusion of 'vendor/' to the testsuite in phpunit.xml.dist.

- Update psalm.xml.dist to enable finding unused code and resolve from config file.
  • Loading branch information
guanguans committed Jan 16, 2025
1 parent 54e7c79 commit 0660a5e
Show file tree
Hide file tree
Showing 37 changed files with 836 additions and 238 deletions.
19 changes: 12 additions & 7 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@ options:
commits:
filters:
Type:
- build
# - chore
- ci
- docs
- feat
- fix
- perf
- refactor
- docs
- test
- ci
- revert
- style
- test
commit_groups:
title_maps:
chore: Chores
ci: CI
# feat: Features
# fix: Bug Fixes
# perf: Performance Improvements
# refactor: Code Refactoring
feat: Features
fix: Bug Fixes
perf: Performance Improvements
refactor: Code Refactoring
test: Tests
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
Expand Down
14 changes: 9 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

[*.{vue,js,scss}]
indent_size = 2
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml,xml,xml.dist}]
indent_size = 2
indent_size = 2
22 changes: 12 additions & 10 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
* text=auto
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
phpunit.php export-ignore
phpunit.xml.dist export-ignore
phpunit.xml export-ignore
.php_cs export-ignore
# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.php_cs export-ignore
/.github export-ignore
/psalm.xml export-ignore
38 changes: 38 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: phpstan

on:
workflow_dispatch:
push:
paths:
- '**.php'
- '*.neon'
- '*.xml'
- '*.xml.dist'
- '.github/**.yaml'
- '.github/**.yml'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}

- name: Run composer install
run: composer install --no-interaction --prefer-dist --ansi -v

- name: Run phpstan
run: composer phpstan
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: true
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
php: [ 7.4, 8.3 ]
php: [ 7.4, 8.4 ]
dependency-version: [ prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
Expand Down
5 changes: 3 additions & 2 deletions .lintmdrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"excludeFiles": [
"src/",
"tests/",
"vendor/"
"vendor/",
"./CHANGELOG.md"
],
"rules": {
"space-around-alphabet": 2,
Expand Down Expand Up @@ -30,4 +31,4 @@
}
]
}
}
}
2 changes: 1 addition & 1 deletion README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

## 环境要求

* PHP >= 7.3
* PHP >= 7.4
* ext-json
* ext-mbstring

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

## Requirements

* PHP >= 7.3
* PHP >= 7.4
* ext-json
* ext-mbstring

Expand Down
38 changes: 29 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
"ergebnis/rector-rules": "^1.3",
"guanguans/ai-commit": "dev-main",
"guanguans/monorepo-builder-worker": "^1.4",
"icanhazstring/composer-unused": "^0.8",
"jetbrains/phpstorm-attributes": "^1.2",
"maglnet/composer-require-checker": "^3.8 || ^4.0",
"mockery/mockery": "^1.6",
"pestphp/pest": "^1.23 || ^2.0 || ^3.0",
"pestphp/pest-plugin-faker": "^1.0 || ^2.0 || ^3.0",
Expand All @@ -53,12 +55,15 @@
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-deprecation-rules": "^2.0",
"povils/phpmnd": "^3.5",
"rector/rector": "^2.0",
"spatie/pest-plugin-snapshots": "^1.1 || ^2.0",
"spatie/phpunit-snapshot-assertions": "^4.2 || ^5.0",
"spaze/phpstan-disallowed-calls": "^4.1",
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0",
"vimeo/psalm": "^4.30"
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true,
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -99,7 +104,7 @@
"target-directory": "vendor-bin"
},
"branch-alias": {
"dev-master": "4.x-dev"
"dev-master": "5.x-dev"
},
"hooks": {
"post-merge": [
Expand Down Expand Up @@ -141,16 +146,17 @@
"@style-lint",
"@test",
"@psalm",
"@phpstan",
"@rector-dry-run"
],
"composer-bin-all-update": "@composer bin all update --ansi -v",
"composer-check-platform-reqs": "@composer check-platform-reqs --lock --ansi -v",
"composer-normalize": "@composer normalize --dry-run --diff --ansi -v",
"composer-require-checker": "@php ./vendor/bin/composer-require-checker check --config-file=composer-require-checker.json composer.json --ansi -v",
"composer-require-checker-json": "@php ./vendor/bin/composer-require-checker check --config-file=composer-require-checker.json composer.json --ansi -v --output=json | jq",
"composer-unused": "@php ./vendor/bin/composer-unused --ansi -v",
"composer-updater": [
"Composer\\Config::disableProcessTimeout",
"@php ./composer-updater --highest-php-binary=/opt/homebrew/opt/php@8.4/bin/php --ansi"
],
"composer-updater": "@php ./composer-updater --highest-php-binary=/opt/homebrew/opt/php@8.4/bin/php --except-packages=pestphp/pest-plugin-laravel --ansi",
"composer-updater-dry-run": "@composer-updater --dry-run",
"composer-validate": "@composer validate --check-lock --strict --ansi -v",
"dump-soar": [
"@dump-soar-docblock",
Expand All @@ -162,32 +168,46 @@
"dump-soar-yaml-config": "./bin/soar.darwin-amd64 -print-config -verbose > examples/soar.options.example.yaml",
"json-lint": "@php ./vendor/bin/jsonlint *.json .*rc",
"lint": [
"for DIR in .; do find $DIR -maxdepth 1 -type f -name '*.php' -type f ! -name 'xxx.php' -exec php -l {} \\; 2>&1 | (! grep -v '^No syntax errors detected'); done",
"for DIR in ./src ./tests; do find $DIR -type f -name '*.php' -type f ! -name 'xxx.php' -exec php -l {} \\; 2>&1 | (! grep -v '^No syntax errors detected'); done"
"@putenvs",
"for DIR in .; do find $DIR -maxdepth 1 -type f -name '*.php' -type f ! -name 'xxx.php' -exec $PHP74 -l {} \\; 2>&1 | (! grep -v '^No syntax errors detected'); done",
"for DIR in ./src ./tests; do find $DIR -type f -name '*.php' -type f ! -name 'xxx.php' -exec $PHP74 -l {} \\; 2>&1 | (! grep -v '^No syntax errors detected'); done"
],
"mark-finish": "printf '\\n!\\n!\\t\\033[0;32m%s\\033[0m\\n!\\n\\n' \"Finished\"",
"mark-separate": "printf '\\n!\\n!\\t\\033[0;33m%s\\033[0m\\n!\\n\\n' \"----------------\"",
"mark-start": "printf '\\n!\\n!\\t\\033[0;36m%s\\033[0m\\n!\\n\\n' \"Started\"",
"md-fix": "@md-lint --fix",
"md-lint": "lint-md --config .lintmdrc ./*.md ./.github/ ./docs/",
"peck": "/opt/homebrew/opt/php@8.3/bin/php ./vendor/bin/peck --ansi -v",
"pest": "@php ./vendor/bin/pest --coverage",
"pest-coverage": "@pest --coverage-html=./.build/phpunit/ --coverage-clover=./clover.xml",
"pest-coverage": "@pest --coverage-html=./.build/phpunit/ --coverage-clover=./.build/phpunit/clover.xml --coverage",
"pest-migrate-configuration": "@pest --migrate-configuration",
"pest-update-snapshots": "@pest -d --update-snapshots",
"phpmnd": "@php ./vendor/bin/phpmnd src --exclude-path=Support/Utils.php --hint --progress --ansi -v",
"phpstan": "@php ./vendor/bin/phpstan analyse --ansi -v",
"phpstan-baseline": "@phpstan --generate-baseline --allow-empty-baseline",
"post-merge": [
"composer install --ansi -v"
],
"psalm": "@php ./vendor/bin/psalm",
"psalm-baseline": "@psalm --update-baseline",
"putenvs": [
"@putenv PHP73=/opt/homebrew/opt/php@7.3/bin/php",
"@putenv PHP74=/opt/homebrew/opt/php@7.4/bin/php",
"@putenv PHP80=/opt/homebrew/opt/php@8.0/bin/php",
"@putenv PHP81=/opt/homebrew/opt/php@8.1/bin/php",
"@putenv PHP82=/opt/homebrew/opt/php@8.2/bin/php",
"@putenv PHP83=/opt/homebrew/opt/php@8.3/bin/php",
"@putenv PHP83=/opt/homebrew/opt/php@8.4/bin/php"
],
"rector": "@php ./vendor/bin/rector --ansi -v",
"rector-custom-rule": "@rector custom-rule",
"rector-detect-node": "@rector detect-node --loop",
"rector-dry-run": "@rector --dry-run",
"rector-list-rules": "@rector list-rules",
"rector-setup-ci": "@rector setup-ci",
"release": "@php ./vendor/bin/monorepo-builder release --ansi -v",
"release-1.0.0-BETA1": "@release 1.0.0-BETA1",
"release-1.0.0-BETA1-dry-run": "@release-1.0.0-BETA1 --dry-run",
"release-major": "@release major",
"release-major-dry-run": "@release-major --dry-run",
"release-minor": "@release minor",
Expand Down
62 changes: 55 additions & 7 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,31 +1,79 @@
parameters:
ignoreErrors:
-
message: "#^Call to method onlyHelp\\(\\) on an unknown class Guanguans\\\\SoarPHP\\\\Concerns\\\\HasOptions\\.$#"
message: '#^Call to function function_exists\(\) with callable\-string will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: src/Soar.php

-
message: "#^Call to method onlyVersion\\(\\) on an unknown class Guanguans\\\\SoarPHP\\\\Concerns\\\\HasOptions\\.$#"
message: '#^Call to function is_array\(\) with list\<string\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 2
path: src/Soar.php

-
message: '#^Call to method onlyHelp\(\) on an unknown class Guanguans\\SoarPHP\\Concerns\\HasOptions\.$#'
identifier: class.notFound
count: 1
path: src/Soar.php

-
message: "#^Call to method run\\(\\) on an unknown class Guanguans\\\\SoarPHP\\\\Concerns\\\\HasOptions\\.$#"
message: '#^Call to method onlyVersion\(\) on an unknown class Guanguans\\SoarPHP\\Concerns\\HasOptions\.$#'
identifier: class.notFound
count: 1
path: src/Soar.php

-
message: '#^Call to method run\(\) on an unknown class Guanguans\\SoarPHP\\Concerns\\HasOptions\.$#'
identifier: class.notFound
count: 3
path: src/Soar.php

-
message: "#^Call to method scores\\(\\) on an unknown class Guanguans\\\\SoarPHP\\\\Concerns\\\\HasOptions\\.$#"
message: '#^Call to method scores\(\) on an unknown class Guanguans\\SoarPHP\\Concerns\\HasOptions\.$#'
identifier: class.notFound
count: 3
path: src/Soar.php

-
message: "#^Result of && is always false\\.$#"
count: 2
message: '#^Calling var_dump\(\) is forbidden, use some logger instead\.$#'
identifier: disallowed.function
count: 1
path: src/Soar.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
message: '#^Result of && is always false\.$#'
identifier: booleanAnd.alwaysFalse
count: 2
path: src/Soar.php

-
message: '#^Unused result of "and" operator\.$#'
identifier: logicalAnd.resultUnused
count: 3
path: src/Soar.php

-
message: '#^Unused result of "and" operator\.$#'
identifier: logicalAnd.resultUnused
count: 1
path: src/Support/ComposerScript.php

-
message: '#^Method Guanguans\\SoarPHP\\Support\\Rectors\\ToInternalExceptionRector\:\:refactor\(\) never returns array\<PhpParser\\Node\> so it can be removed from the return type\.$#'
identifier: return.unusedType
count: 1
path: src/Support/Rectors/ToInternalExceptionRector.php

-
message: '#^Method Guanguans\\SoarPHP\\Support\\Rectors\\ToInternalExceptionRector\:\:refactor\(\) never returns null so it can be removed from the return type\.$#'
identifier: return.unusedType
count: 1
path: src/Support/Rectors/ToInternalExceptionRector.php

-
message: '#^Call to function method_exists\(\) with ''Symfony\\\\Component\\\\Process\\\\Process'' and ''escapeArgument'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: src/Support/helpers.php
16 changes: 14 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
includes:
- phpstan-baseline.neon
# - vendor/roave/no-floaters/rules.neon
# - vendor-bin/larastan/vendor/larastan/larastan/extension.neon
# - vendor/roavcome/no-floaters/rules.neon
# - vendor/phpstan/phpstan-strict-rules/rules.neon
# - vendor/ergebnis/phpstan-rules/rules.neon
# - vendor/ekino/phpstan-banned-code/extension.neon
- vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon
- vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon
- vendor/spaze/phpstan-disallowed-calls/disallowed-insecure-calls.neon
- vendor/spaze/phpstan-disallowed-calls/disallowed-loose-calls.neon

parameters:
level: 5
Expand All @@ -12,7 +17,7 @@ parameters:
tmpDir: .build/phpstan
# checkOctaneCompatibility: true
# checkModelProperties: true
checkMissingIterableValueType: true
# checkMissingIterableValueType: true
# disallowFloatsEverywhere: true

# strictRules:
Expand All @@ -28,3 +33,10 @@ parameters:
# strictCalls: false
# switchConditionsMatchingType: false
# noVariableVariables: false
ignoreErrors:
- "#^Unsafe usage of new static\\(\\)\\.$#"
- '#^Method Guanguans\\SoarPHP\\Support\\Rectors\\ToInternalExceptionRector\:\:refactor\(\) never returns \d so it can be removed from the return type\.$#'
- '#^Method Guanguans\\SoarPHP\\Support\\Rectors\\ToInternalExceptionRector\:\:refactor\(\) should return 1\|2\|3\|4\|array\<PhpParser\\Node\>\|PhpParser\\Node\|null but empty return statement found\.$#'
# -
# message: "#^Calling env\\(\\) is forbidden, use config\\(\\) instead\\.$#"
# path: src/Support/helpers.php
Loading

0 comments on commit 0660a5e

Please sign in to comment.