Skip to content

Commit d7ff567

Browse files
authored
Merge pull request #2 from koriym/spike
Update meta files and templates
2 parents 7459dbc + 96900ca commit d7ff567

File tree

10 files changed

+71
-168
lines changed

10 files changed

+71
-168
lines changed

demo/tests/Integration/DemoTest.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

demo/tests/Workflow/DemoTest.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

phpcs.xml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<ruleset name="PHP_CodeSniffer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
4-
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
5-
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
6-
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
7-
<rule ref="PSR2">
8-
<exclude name="Generic.Files.LineLength"/>
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
3+
<description></description>
4+
<arg name="basepath" value="."/>
5+
<arg name="extensions" value="php"/>
6+
<arg name="parallel" value="80"/>
7+
<arg name="cache" value=".phpcs-cache"/>
8+
<arg name="colors"/>
9+
10+
<!-- Ignore warnings, show progress of the run and show sniff names -->
11+
<arg value="nps"/>
12+
13+
<!-- Directories to be checked -->
14+
<file>src</file>
15+
<file>tests</file>
16+
17+
<!-- Doctrine Coding Standard (Based on PSR-12) -->
18+
<rule ref="Doctrine">
19+
<!-- Exclude rules for BEAR.Sunday -->
20+
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame"/>
21+
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
22+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
23+
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectOrderOfAnnotationsGroup"/>
24+
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException"/>
25+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
26+
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint"/>
27+
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
28+
"/>
929
</rule>
10-
<rule ref="PEAR.Commenting.FunctionComment">
11-
<exclude name="PEAR.Commenting.FunctionComment.MissingReturn"/>
12-
<exclude name="PEAR.Commenting.FunctionComment.MissingParamComment"/>
13-
<exclude name="PEAR.Commenting.FunctionComment.SpacingBeforeTags"/>
14-
<exclude name="PEAR.Commenting.FunctionComment.MissingParamTag"/>
15-
<exclude name="PEAR.Commenting.FunctionComment.Missing"/>
16-
<exclude name="PEAR.Commenting.FunctionComment.ParameterCommentsNotAligned"/>
17-
</rule>
18-
</ruleset>
30+
</ruleset>

phpmd.xml

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,27 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<ruleset name="PHPMD rule set"
3-
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6-
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
1+
<ruleset
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
5+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
76
<!--codesize-->
87
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
98
<properties>
10-
<property name="reportLevel" value="20"/>
11-
</properties>
12-
</rule>
13-
<rule ref="rulesets/codesize.xml/NPathComplexity">
14-
<properties>
15-
<property name="minimum" value="200"/>
16-
</properties>
17-
</rule>
18-
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
19-
<properties>
20-
<property name="maximum" value="100"/>
9+
<property name="reportLevel" description="The Cyclomatic Complexity reporting threshold" value="10"/>
2110
</properties>
2211
</rule>
12+
<rule ref="rulesets/codesize.xml/NPathComplexity" />
13+
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity"/>
2314
<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>
2415
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>
2516
<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
2617
<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>
2718
<rule ref="rulesets/codesize.xml/TooManyFields"/>
2819
<rule ref="rulesets/codesize.xml/TooManyMethods"/>
2920
<!--design-->
30-
<rule ref="rulesets/design.xml/EvalExpression"/>
31-
<rule ref="rulesets/design.xml/ExitExpression"/>
32-
<rule ref="rulesets/design.xml/GotoStatement" />
3321
<rule ref="rulesets/design.xml/NumberOfChildren"/>
3422
<rule ref="rulesets/design.xml/DepthOfInheritance"/>
35-
<!-- <rule ref="rulesets/design.xml/CouplingBetweenObjects" /> -->
23+
<rule ref="rulesets/design.xml/CouplingBetweenObjects" />
24+
<rule ref="rulesets/design.xml/CountInLoopExpression" />
3625
<!--naming-->
3726
<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
3827
<rule ref="rulesets/naming.xml/BooleanGetMethodName"/>
@@ -41,11 +30,9 @@
4130
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
4231
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
4332
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
44-
<!--controversial-->
45-
<rule ref="rulesets/controversial.xml/CamelCaseClassName"/>
46-
<rule ref="rulesets/controversial.xml/CamelCasePropertyName"/>
47-
<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>
4833
<!--cleancode-->
4934
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag"/>
50-
<!-- <rule ref="rulesets/cleancode.xml/ElseExpression" /> -->
35+
<rule ref="rulesets/cleancode.xml/ElseExpression" />
36+
<rule ref="rulesets/cleancode.xml/IfStatementAssignment" />
37+
<rule ref="rulesets/cleancode.xml/DuplicatedArrayKey" />
5138
</ruleset>

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ parameters:
33
paths:
44
- src
55
- tests
6-
checkMissingIterableValueType: false
6+
ignoreErrors:

phpunit.xml.dist

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php">
55
<testsuites>
6-
<testsuite name="all">
7-
<directory>tests</directory>
6+
<testsuite name="Resource">
7+
<directory suffix="Test.php">tests/Resource</directory>
8+
</testsuite>
9+
<testsuite name="Hypermedia">
10+
<directory suffix="Test.php">tests/Hypermedia</directory>
11+
</testsuite>
12+
<testsuite name="HTTP">
13+
<directory suffix="Test.php">tests/Http</directory>
814
</testsuite>
915
</testsuites>
10-
<php>
11-
<ini name="error_reporting" value="-1" />
12-
</php>
1316
<filter>
14-
<whitelist processUncoveredFilesFromWhitelist="true">
17+
<whitelist processUncoveredFilesFromWhitelist="true" addUncoveredFilesFromWhitelist="false">
1518
<directory suffix=".php">src</directory>
19+
<exclude>
20+
<file>src/Bootstrap.php</file>
21+
</exclude>
1622
</whitelist>
1723
</filter>
1824
</phpunit>

template/tests/Http/HypermediaTest.php renamed to template/tests/Http/WorkflowTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
use BEAR\Dev\Http\BuiltinServerStartTrait;
88
use BEAR\Resource\ResourceObject;
9-
use BEAR\Skeleton\Hypermedia\HypermediaTest as Workflow;
9+
use BEAR\Skeleton\Hypermedia\WorkflowTest as Workflow;
1010
use BEAR\Skeleton\Injector;
1111

12-
class HypermediaTest extends Workflow
12+
class WorkflowTest extends Workflow
1313
{
1414
use BuiltinServerStartTrait;
1515

16-
protected function setUp() : void
16+
protected function setUp(): void
1717
{
1818
$_SERVER['Authorization'] = '_secret_token_';
19-
$this->resource = $this->getHttpResourceClient(Injector::getInstance('app'), __CLASS__);
19+
$this->resource = $this->getHttpResourceClient(Injector::getInstance('app'), self::class);
2020
}
2121

22-
public function testIndex() : ResourceObject
22+
public function testIndex(): ResourceObject
2323
{
2424
$index = $this->resource->get($this->httpHost . '/');
2525
$this->assertSame(200, $index->code);

template/tests/Http/index.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
2-
/**
3-
* HTTP test buitin server script
4-
*/
2+
3+
declare(strict_types=1);
4+
5+
use BEAR\Skeleton\Bootstrap;
6+
57
require dirname(__DIR__, 2) . '/vendor/autoload.php';
6-
exit((require dirname(__DIR__, 2) . '/bootstrap.php')('prod-hal-app', $GLOBALS, $_SERVER));
8+
exit((new Bootstrap())('hal-app', $GLOBALS, $_SERVER));

template/tests/Hypermedia/HypermediaTest.php renamed to template/tests/Hypermedia/WorkflowTest.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,27 @@
44

55
namespace BEAR\Skeleton\Hypermedia;
66

7-
use BEAR\Dev\Db\DbProfile;
87
use BEAR\Resource\ResourceInterface;
98
use BEAR\Resource\ResourceObject;
109
use BEAR\Skeleton\Injector;
1110
use PHPUnit\Framework\TestCase;
1211
use Ray\Di\InjectorInterface;
1312

14-
class HypermediaTest extends TestCase
13+
class WorkflowTest extends TestCase
1514
{
16-
/**
17-
* @var ResourceInterface
18-
*/
15+
/** @var ResourceInterface */
1916
protected $resource;
2017

21-
/**
22-
* @var InjectorInterface
23-
*/
18+
/** @var InjectorInterface */
2419
protected $injector;
2520

26-
/**
27-
* @var DbProfile
28-
*/
29-
private $dbProfile;
30-
31-
protected function setUp() : void
21+
protected function setUp(): void
3222
{
3323
$this->injector = Injector::getInstance('app');
3424
$this->resource = $this->injector->getInstance(ResourceInterface::class);
3525
}
3626

37-
public function testIndex() : ResourceObject
27+
public function testIndex(): ResourceObject
3828
{
3929
$index = $this->resource->get('/index');
4030
$this->assertSame(200, $index->code);

0 commit comments

Comments
 (0)