Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 0 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:

- run: composer phpunit
- run: composer pest
- run: composer inference

code-coverage:
name: Code Coverage
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"type": "library",
"homepage": "http://respect.github.io/",
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Respect/Validation Contributors",
Expand All @@ -23,7 +25,7 @@
"php": ">=8.5",
"psr/container": "^2.0",
"respect/config": "^3.0",
"respect/fluent": "^2.0",
"respect/fluent": "3.0.x-dev",
"respect/parameter": "^3.0",
"respect/string-formatter": "^1.7",
"respect/stringifier": "^3.0",
Expand All @@ -45,7 +47,7 @@
"psr/http-message": "^1.0 || ^2.0",
"ramsey/uuid": "^4",
"respect/coding-standard": "^5.0",
"respect/fluentgen": "^2.0",
"respect/fluentgen": "2.1.x-dev",
"sebastian/diff": "^7.0",
"sokil/php-isocodes": "^4.2.1",
"sokil/php-isocodes-db-only": "^4.0",
Expand Down Expand Up @@ -87,6 +89,7 @@
"phpcs": "vendor/bin/phpcs",
"phpstan": "vendor/bin/phpstan analyze",
"phpunit": "vendor/bin/phpunit --testsuite=unit",
"inference": "vendor/bin/phpunit --testsuite=inference",
"smoke-complete": "bin/console smoke-tests:check-complete",
"spdx-lint": "bin/console lint:spdx",
"qa": [
Expand All @@ -95,6 +98,7 @@
"@phpstan",
"@phpunit",
"@pest",
"@inference",
"@docs",
"@smoke-complete"
]
Expand Down
77 changes: 45 additions & 32 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<file>src-dev/</file>
<file>tests/</file>

<!-- PHPStan type-inference fixtures: intentional global functions + assertType() calls. -->
<exclude-pattern>tests/inference/assertions/*</exclude-pattern>

<rule ref="Respect" />

<!-- Exclusions -->
Expand All @@ -28,6 +31,21 @@
<exclude-pattern>src/Mixins/</exclude-pattern>
<exclude-pattern>tests/feature/</exclude-pattern>
</rule>
<!-- Generated mixin docblocks carry @template/@param/@return narrowing types whose
formatting (annotation groups, fully-qualified class names, bare iterable item
types, null ordering) is the generator's concern, not hand-maintained style. -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<exclude-pattern>src/Mixins/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName">
<exclude-pattern>src/Mixins/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification">
<exclude-pattern>src/Mixins/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition">
<exclude-pattern>src/Mixins/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure.ClosureNotStatic">
<exclude-pattern>tests/Pest.php</exclude-pattern>
<exclude-pattern>tests/feature</exclude-pattern>
Expand Down
10 changes: 10 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ parameters:
path: tests/src/Message/TestingHandler.php
- message: '/Property Respect\\Validation\\Test\\Stubs\\.+::\$[a-zA-Z]+ is never read, only written./'
path: tests/src/Stubs
-
# Why: src/Mixins/* are generated typing aids. Their @return Chain<...> carry the
# narrowing types derived from #[Assurance] (the same ones FluentAnalysis computes
# at analysis time), e.g. bare `array` or `ArrayAccess`. Fully parameterising those
# generics would only clutter the IDE-facing types without adding narrowing value.
identifier: missingType.iterableValue
path: src/Mixins/*
-
identifier: missingType.generics
path: src/Mixins/*
level: 8
treatPhpDocTypesAsCertain: false
paths:
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<testsuite name="feature">
<directory suffix="Test.php">./tests/feature</directory>
</testsuite>
<testsuite name="inference">
<directory suffix="Test.php">tests/inference/</directory>
</testsuite>
</testsuites>
<source>
<include>
Expand Down
25 changes: 25 additions & 0 deletions src-dev/Commands/LintMixinCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Respect\FluentGen\Fluent\MethodBuilder;
use Respect\FluentGen\Fluent\MixinGenerator;
use Respect\FluentGen\Fluent\PrefixConstantsGenerator;
use Respect\FluentGen\Fluent\TerminalMethod;
use Respect\FluentGen\NamespaceScanner;
use Respect\Validation\Mixins\Chain;
use Respect\Validation\Validator;
Expand Down Expand Up @@ -82,13 +83,37 @@ interfaces: [
suffix: 'Builder',
returnType: Chain::class,
static: true,
emitNarrowing: true,
),
new InterfaceConfig(
suffix: 'Chain',
returnType: Chain::class,
rootExtends: [Validator::class],
rootComment: '@mixin ValidatorBuilder',
rootUses: [ValidatorBuilder::class],
emitNarrowing: true,
templateParam: 'TSure',
terminalMethods: [
new TerminalMethod(
name: 'assert',
returnType: 'void',
parameters: ['input' => 'mixed'],
comments: ['@phpstan-assert TSure $input', '@psalm-assert TSure $input'],
optionalParameters: ['template' => 'mixed'],
),
new TerminalMethod(
name: 'check',
returnType: 'void',
parameters: ['input' => 'mixed'],
comments: ['@phpstan-assert TSure $input', '@psalm-assert TSure $input'],
optionalParameters: ['template' => 'mixed'],
),
new TerminalMethod(
name: 'isValid',
returnType: 'bool',
parameters: ['input' => 'mixed'],
),
],
),
],
);
Expand Down
Loading
Loading