Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e03bd16
Setup mago
remipelhate Jun 4, 2026
c10091c
Mago fix prefer-static-closure
remipelhate Jun 4, 2026
dd26406
Mago fix braced-string-interpolatio
remipelhate Jun 4, 2026
a020a5b
Mago fix prefer-arrow-function
remipelhate Jun 4, 2026
50cf726
Mago fix no-shorthand-ternary
remipelhate Jun 4, 2026
5d9a5b4
Mago config too-many-methods
remipelhate Jun 4, 2026
b38a447
Mago fix literal-named-argument
remipelhate Jun 4, 2026
febaf69
Mago fix readable-literal
remipelhate Jun 4, 2026
66eb8c9
Mago fix no-else-clause
remipelhate Jun 4, 2026
2a94591
Mago fix no-empty-comment
remipelhate Jun 4, 2026
1a185cf
Run mago lint in static-analysis workflow
remipelhate Jun 4, 2026
4b2d696
Mago fix formatting according to PER-CS
remipelhate Jun 4, 2026
9875a84
Dry-run formatting in static-analysis workflow
remipelhate Jun 4, 2026
b524fd0
Intentionally trigger Mago issues
remipelhate Jun 4, 2026
9852b37
Remove redudant check status step
remipelhate Jun 4, 2026
919a7d0
Re-add Mago report step to ensure the workflow fails in case of errors
remipelhate Jun 4, 2026
1da3c88
Cleanup static analysis output
remipelhate Jun 4, 2026
f785b6d
Streamline composer scripts
remipelhate Jun 4, 2026
44c7485
Intentionally trigger Mago issues
remipelhate Jun 4, 2026
a3b9300
Fix intentional errors
remipelhate Jun 4, 2026
748a819
Enable phpunit linter integration
remipelhate Jun 4, 2026
f66d87d
Setup Mago analyse
remipelhate Jun 4, 2026
d3e79d6
Run analyse:check in static-analysis workflow
remipelhate Jun 4, 2026
f8d7179
Remove php-cs-fixer and phpstan
remipelhate Jun 4, 2026
00b11e8
Fix analyzer issues
remipelhate Jun 5, 2026
c719d7e
Remove redundant HasErrorOnPath::resolveResponseUsing()
remipelhate Jun 5, 2026
3df525e
Fix last few analyzer issues
remipelhate Jun 5, 2026
e17e2cf
Fix tests
remipelhate Jun 5, 2026
cfa878e
Remove phpstan annotations
remipelhate Jun 5, 2026
d3de10f
Remove config files
remipelhate Jun 5, 2026
ef67bb2
Preserve breaking member access chain
remipelhate Jun 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
*.dist export-ignore
*.md export-ignore
*.yml export-ignore
.php-cs-fixer.dist.php export-ignore
Taskfile.yml export-ignore
41 changes: 0 additions & 41 deletions .github/actions/php-cs-fixer/action.yml

This file was deleted.

63 changes: 43 additions & 20 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,53 @@ on:
branches: ['main']

jobs:
phpstan:
mago:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
- uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # https://github.com/shivammathur/setup-php/releases/tag/2.37.1
with:
php-version: 8.4
php-version: 8.5
extensions: -pdo_mysql, -mysqli
- run: composer update --prefer-stable --prefer-dist --no-interaction
- run: composer phpstan

php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
with:
ref: ${{ github.head_ref }}
- name: 'Run PHP CS fixer'
uses: ./.github/actions/php-cs-fixer
with:
workspace: ${{ github.workspace }}
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Commit CS fixes'
uses: craftzing/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0
with:
commit_message: Fix code style violations
# Mago is installed through Composer, but the package is just a thin wrapper. By checking the version, we force
# the wrapper to download the binary before running actual checks in order not to pollute the check output...
- run: composer mago -- --version
- run: composer lint:check
id: lint
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: composer format:check
id: format
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: composer analyse:check
id: analyse
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Fail upon detected issues'
if: |
steps.lint.outcome == 'failure' ||
steps.format.outcome == 'failure' ||
steps.analyse.outcome == 'failure'
env:
LINT_OUTCOME: ${{ steps.lint.outcome }}
FORMAT_OUTCOME: ${{ steps.format.outcome }}
ANALYSE_OUTCOME: ${{ steps.analyse.outcome }}
run: |
if [ "$LINT_OUTCOME" == "failure" ]; then
echo "::error title=Lint::Linter detected issues."
fi

if [ "$FORMAT_OUTCOME" == "failure" ]; then
echo "::error title=Format::Formatter detected files needing formatting."
fi

if [ "$ANALYSE_OUTCOME" == "failure" ]; then
echo "::error title=Analyse::Analyzer detected issues."
fi

exit 1
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
coverage: pcov
extensions: -pdo_mysql, -mysqli
- run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- run: composer coverage:summary
- run: composer test:coverage
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
/vendor
/composer.lock
/.phpunit.result.cache
/.php_cs.cache
/.php-cs-fixer.cache
55 changes: 0 additions & 55 deletions .php-cs-fixer.dist.php

This file was deleted.

2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ tasks:
- for:
var: versions
split: ','
cmd: docker compose exec php-{{ .ITEM }} composer phpunit
cmd: docker compose exec php-{{ .ITEM }} composer test
34 changes: 18 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
"fakerphp/faker": "^1.24"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.75",
"carthage-software/mago": "^1.29.0",
"illuminate/collections": "^10.10|^11.0|^12.0",
"illuminate/console": "^10.10|^11.0|^12.0",
"illuminate/container": "^10.10|^11.0|^12.0",
"illuminate/contracts": "^10.10|^11.0|^12.0",
"illuminate/support": "^10.10|^11.0|^12.0",
"orchestra/testbench": "^9.9",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11.5",
"saloonphp/saloon": "^3.13"
},
Expand Down Expand Up @@ -63,26 +62,29 @@
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"cs:check": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --verbose --dry-run",
"cs:fix": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --verbose",
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2G --ansi",
"mago": "vendor/bin/mago --colors=always",
"phpunit": "vendor/bin/phpunit --colors=always --display-phpunit-deprecations --display-deprecations",
"test": [
"@composer cs:check",
"@composer phpstan",
"@composer phpunit"
"lint:check": "@composer mago -- lint --minimum-fail-level=warning --reporting-format=rich",
"lint:fix": "@composer mago -- lint --fix",
"format:check": "@composer mago -- format --dry-run",
"format:fix": "@composer mago -- format",
"analyse:check": "@composer mago -- analyse --minimum-fail-level=warning --reporting-format=rich",
"static-analysis:check": [
"@composer lint:check",
"@composer format:check",
"@composer analyse:check"
],
"coverage:summary": "@composer phpunit -- --coverage-text",
"coverage:report": "@composer phpunit -- --coverage-html=.reports/coverage"
"static-analysis:fix": [
"@composer lint:fix",
"@composer format:fix"
],
"test": "@composer phpunit",
"test:coverage": "@composer phpunit -- --coverage-text",
"test:report": "@composer phpunit -- --coverage-html=.reports/coverage"
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
},
"laravel": {
"providers": [
"Craftzing\\TestBench\\Laravel\\ServiceProvider"
]
}
}
}
41 changes: 41 additions & 0 deletions mago.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#:schema https://mago.carthage.software/1.29.0/schema.json
# For full documentation, see https://mago.carthage.software/tools/overview
version = "1"
php-version = "8.4.0"

[source]
workspace = "."
paths = ["src"]
includes = ["vendor"]
excludes = []

[source.glob]
literal-separator = true

[formatter]
preset = "psr-12"
print-width = 9999 # Horizontal limits are considered a guideline, not a requirement
space-around-assignment-in-declare = false
inline-empty-constructor-braces = true
trailing-comma = true
preserve-breaking-argument-list = true
preserve-breaking-parameter-list = true
preserve-breaking-array-like = true
preserve-breaking-attribute-list = true
preserve-breaking-member-access-chain = true

[linter]
integrations = ["phpunit"]

[linter.rules]
no-boolean-flag-parameter = { enabled = false }
too-many-methods = { exclude = ["src/**/*Test.php"] }
literal-named-argument = { exclude = ["src/**/*Test.php"] }
prefer-test-attribute = { enabled = true }

[analyzer]
excludes = ["src/**/*Test.php"]
ignore = [
"mixed-argument",
"mixed-assignment",
]
9 changes: 0 additions & 9 deletions phpstan.neon.dist

This file was deleted.

9 changes: 4 additions & 5 deletions src/Factories/ImmutableFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/**
* @template TClass of object
* @mago-expect lint:too-many-methods
*/
abstract class ImmutableFactory
{
Expand All @@ -34,7 +35,6 @@ final public function __construct(
*/
public function state(array $state): static
{
// @phpstan-ignore-next-line return.type
return new static($this->faker, [...$this->state, ...$state], $this->count);
}

Expand All @@ -43,7 +43,6 @@ public function state(array $state): static
*/
public function times(int $count): static
{
// @phpstan-ignore-next-line return.type
return new static($this->faker, $this->state, $count);
}

Expand All @@ -64,7 +63,7 @@ private function resolveValue(mixed $value): mixed
return array_map($this->resolveValue(...), iterator_to_array($value));
}

if (! $value instanceof self) {
if (!$value instanceof self) {
return $value;
}

Expand Down Expand Up @@ -102,7 +101,7 @@ public function rawMany(array $attributes = []): array
*/
public function rawCollection(array $attributes = []): Collection
{
return Collection::times($this->count, fn (): array => $this->raw($attributes));
return Collection::times($this->count, fn(): array => $this->raw($attributes));
}

/**
Expand All @@ -129,6 +128,6 @@ public function makeMany(array $attributes = []): array
*/
public function makeCollection(array $attributes = []): Collection
{
return Collection::times($this->count, fn (): mixed => $this->makeOne($attributes));
return Collection::times($this->count, fn(): mixed => $this->makeOne($attributes));
}
}
Loading