Skip to content
Merged
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
8 changes: 1 addition & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{md,html}]
indent_style = tab
indent_size = tab
tab_width = 4

[*.{js,ts}]
indent_style = space
indent_size = 2

[{*.json,.travis.yml}]
[*.{json,yaml,yml,md}]
indent_style = space
indent_size = 2
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Codesniffer"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"

jobs:
codesniffer:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@master
with:
php: "8.2"
18 changes: 18 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Coverage"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 9 * * 1"

jobs:
coverage:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master
with:
php: "8.2"
18 changes: 18 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Phpstan"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 10 * * 1"

jobs:
phpstan:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@master
with:
php: "8.2"
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Nette Tester"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 10 * * 1"

jobs:
test85:
name: "Nette Tester"
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@master
with:
php: "8.2"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@
# Composer
/vendor
/composer.lock

# Tests
/tests/tmp
/coverage.*
/tests/**/*.log
/tests/**/*.html
/tests/**/*.expected
/tests/**/*.actual
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.PHONY: install
install:
composer update

.PHONY: qa
qa: phpstan cs

.PHONY: cs
cs:
ifdef GITHUB_ACTION
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp -q --report=checkstyle src tests | cs2pr
else
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests
endif

.PHONY: csf
csf:
vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests

.PHONY: phpstan
phpstan:
vendor/bin/phpstan analyse -c phpstan.neon

.PHONY: tests
tests:
vendor/bin/tester -s -p php --colors 1 -C tests/Cases

.PHONY: coverage
coverage:
ifdef GITHUB_ACTION
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.xml --coverage-src src tests/Cases
else
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.html --coverage-src src tests/Cases
endif
31 changes: 20 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lab/dag",
"description": ":running: Dag is opinionated expression data generator written in PHP to fake your API.",
"description": "Dag is opinionated expression data generator written in PHP to fake your API.",
"keywords": [
"php",
"api",
Expand All @@ -18,27 +18,36 @@
}
],
"require": {
"php": "^7.3",
"contributte/http": "^0.3.0",
"contributte/utils": "^0.4.1",
"contributte/di": "^0.4.0",
"contributte/tracy": "^0.4.1",
"nette/routing": "^3.0.0",
"fzaninotto/faker": "^1.9.0",
"nelmio/alice": "^3.5.7"
"php": ">=8.2",
"contributte/di": "~0.6.0",
"contributte/http": "~0.5.0",
"contributte/tracy": "~0.7.0",
"contributte/utils": "~0.7.0",
"nelmio/alice": "^3.12.0",
"nette/routing": "^3.0.0"
},
"require-dev": {
"contributte/dev": "^0.1.0"
"contributte/phpstan": "~0.2.0",
"contributte/qa": "~0.4.0",
"contributte/tester": "~0.3.0"
},
"autoload": {
"psr-4": {
"Dag\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"branch-alias": {
Expand Down
127 changes: 127 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
parameters:
ignoreErrors:
-
message: '#^Class Nette\\DI\\Statement does not have a constructor and must be instantiated without any parameters\.$#'
identifier: new.noConstructor
count: 3
path: src/DI/DagExtension.php

-
message: '''
#^Instantiation of deprecated class Nette\\DI\\Statement\:
use Nette\\DI\\Definitions\\Statement$#
'''
identifier: new.deprecatedClass
count: 3
path: src/DI/DagExtension.php

-
message: '#^Parameter \#1 \$factory of method Nette\\DI\\Definitions\\ServiceDefinition\:\:setFactory\(\) expects array\|Nette\\DI\\Definitions\\Definition\|Nette\\DI\\Definitions\\Reference\|Nette\\DI\\Definitions\\Statement\|string, Nette\\DI\\Statement given\.$#'
identifier: argument.type
count: 1
path: src/DI/DagExtension.php

-
message: '#^Binary operation "\." between mixed and ''/container'' results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/Dag.php

-
message: '#^Call to an undefined method object\:\:initialize\(\)\.$#'
identifier: method.notFound
count: 1
path: src/Dag.php

-
message: '''
#^Fetching deprecated class constant DETECT of class Tracy\\Debugger\:
use Debugger\:\:Detect$#
'''
identifier: classConstant.deprecated
count: 1
path: src/Dag.php

-
message: '#^Method Dag\\Dag\:\:createContainer\(\) should return Nette\\DI\\Container but returns object\.$#'
identifier: return.type
count: 1
path: src/Dag.php

-
message: '#^Only booleans are allowed in a ternary operator condition, mixed given\.$#'
identifier: ternary.condNotBoolean
count: 1
path: src/Dag.php

-
message: '#^Parameter \#1 \$file of method Nette\\DI\\Compiler\:\:loadConfig\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Dag.php

-
message: '#^Parameter \#2 \$autoRebuild of class Nette\\DI\\ContainerLoader constructor expects bool, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Dag.php

-
message: '#^Method Dag\\Generator\\Impl\\AliceGenerator\:\:generate\(\) has parameter \$input with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: src/Generator/Impl/AliceGenerator.php

-
message: '#^Parameter \#1 \$input \(Throwable\) of method Dag\\Generator\\Impl\\ExceptionGenerator\:\:generate\(\) should be contravariant with parameter \$input \(mixed\) of method Dag\\Generator\\Impl\\IGenerator\:\:generate\(\)$#'
identifier: method.childParameterType
count: 1
path: src/Generator/Impl/ExceptionGenerator.php

-
message: '#^Method Dag\\Generator\\Impl\\FallbackGenerator\:\:generate\(\) has parameter \$input with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: src/Generator/Impl/FallbackGenerator.php

-
message: '#^Only booleans are allowed in a negated boolean, string\|null given\.$#'
identifier: booleanNot.exprNotBoolean
count: 1
path: src/Grub.php

-
message: '#^Unsafe usage of new static\(\)\.$#'
identifier: new.static
count: 1
path: src/Grub.php

-
message: '#^Parameter \#1 \$name of method Dag\\Generator\\Generator\:\:generate\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Handler/Executor.php

-
message: '#^Parameter \#2 \$value of method Nette\\Http\\Response\:\:setHeader\(\) expects string\|null, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Http/DagResponse.php

-
message: '#^Method Dag\\Router\\Router\:\:match\(\) should return array\<mixed\>\|null but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Router/Router.php

-
message: '#^Method Dag\\Utils\\Arrays\:\:toArray\(\) should return array\<mixed\> but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Utils/Arrays.php

-
message: '#^Parameter \#1 \$json of function json_decode expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: src/Utils/Arrays.php
17 changes: 17 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
includes:
- vendor/contributte/phpstan/phpstan.neon
- phpstan-baseline.neon

parameters:
level: 9
phpVersion: 80200

scanDirectories:
- src

fileExtensions:
- php

paths:
- src
- .docs
18 changes: 18 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Contributte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<!-- Rulesets -->
<rule ref="./vendor/contributte/qa/ruleset-8.2.xml"/>

<!-- Rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="Dag"/>
<element key="tests" value="Tests"/>
</property>
</properties>
</rule>

<!-- Excludes -->
<exclude-pattern>/tests/tmp</exclude-pattern>
</ruleset>
2 changes: 1 addition & 1 deletion src/DI/DagExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getConfigSchema(): Schema
]);
}

public function loadConfiguration()
public function loadConfiguration(): void
{
$builder = $this->getContainerBuilder();
$config = (array) $this->config;
Expand Down
Loading