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
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run test suite
run: ./vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml --exclude-group twig
run: ./vendor/phpunit/phpunit/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml --exclude-group twig

- name: PHPStan
run: ./vendor/bin/phpstan analyse --level=5 src/
run: ./vendor/phpstan/phpstan/phpstan analyse --level=5 src/

- name: PHPCS
run: phpcs --standard=tests/phpcs.xml --ignore=\*Minifier.php src/ | cs2pr
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
run: composer update --no-interaction --no-suggest

- name: Run test suite
run: ./vendor/bin/phpunit --configuration tests/phpunit.xml --exclude-group twig --coverage-clover=./var/coverage/clover.xml
run: ./vendor/phpunit/phpunit/phpunit --configuration tests/phpunit.xml --exclude-group twig --coverage-clover=./var/coverage/clover.xml

- name: Code coverage Scan
uses: codecov/codecov-action@v1
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"phpunit/phpunit": "~9.0",
"theseer/autoload": "~1.0",
"phing/phing": "~2.0",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpstan/phpstan": "^0.12.17"
"phpstan/phpstan": "^1.2.0",
"phpstan/phpstan-phpunit": "^1.0.0"
},
"scripts": {
"phar": [
Expand Down
171 changes: 85 additions & 86 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
parameters:
phpVersion: 70400
bootstrapFiles:
- tests/test.bootstrap.inc.php
excludes_analyse:
excludePaths:
- src/PHPDraft/Out/Version.php
- src/PHPDraft/Parse/Tests/BaseParserTest.php
- src/PHPDraft/Parse/Tests/DrafterTest.php
- src/PHPDraft/Parse/Tests/DrafterAPITest.php
- src/PHPDraft/**/Tests/*
ignoreErrors:
- '#Access to an undefined property object::\$[a-zA-Z0-9\\_]+#'
- '#Access to an undefined property PHPDraft\\Model\\HierarchyElement::\$[a-zA-Z0-9_]+#'
1 change: 0 additions & 1 deletion src/PHPDraft/In/Tests/ApibFileParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
class ApibFileParserTest extends LunrBaseTest
{

/**
* Set up tests.
*
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Elements/BasicStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract class BasicStructureElement implements StructureElement
/**
* Is variable.
*
* @var boolean
* @var bool
*/
public $is_variable;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/PHPDraft/Model/Elements/ObjectStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
*/
class ObjectStructureElement extends BasicStructureElement
{

/**
* Object representation before parsing
* @var \stdClass|null
* @phpstan-ignore-next-line
*/
private $object;

Expand Down Expand Up @@ -204,7 +204,7 @@ protected function construct_string_return(string $value): string

$type = $this->get_element_as_html($this->type);
$variable = '';
if ($this->is_variable === TRUE) {
if ($this->is_variable === true) {
$link_name = str_replace(' ', '-', strtolower($this->key->type));
$tooltip = 'This is a variable key of type "' . $this->key->type . '"';
$variable = '<a class="variable-key" title="' . $this->key->type . '" href="#object-' . $link_name . '"><span class="fas fa-info variable-info" data-toggle="tooltip" data-placement="top" data-tooltip="' . $tooltip . '" title="' . $tooltip . '"></span></a>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
class ArrayStructureElementTest extends LunrBaseTest
{

/**
* Set up tests
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
class BasicStructureElementTest extends LunrBaseTest
{

/**
* Set up tests
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
class ElementStructureElementTest extends LunrBaseTest
{

/**
* Set up
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
class ObjectStructureElementTest extends LunrBaseTest
{

/**
* Set up tests
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
class RequestBodyElementTest extends LunrBaseTest
{

/**
* Set up tests
* @return void
Expand Down
4 changes: 2 additions & 2 deletions src/PHPDraft/Model/HTTPRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function parse(object $object): self
$this->method = $object->attributes->method->content ?? $object->attributes->method;
$this->title = $object->meta->title->content ?? $object->meta->title ?? null;

if (isset($object->content) && $object->content !== NULL) {
if (isset($object->content) && $object->content !== null) {
foreach ($object->content as $value) {
if ($value->element === 'dataStructure') {
$this->parse_structure($value);
Expand Down Expand Up @@ -225,7 +225,7 @@ public function get_curl_command(string $base_url, array $additional = []): stri
*/
public function is_equal_to($b): bool
{
if (!($b instanceof self)){
if (!($b instanceof self)) {
return false;
}
return ($this->method === $b->method)
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/HTTPResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected function parse_structure(stdClass $object): void
*/
public function is_equal_to($b): bool
{
if (!($b instanceof self)){
if (!($b instanceof self)) {
return false;
}
return ($this->statuscode === $b->statuscode)
Expand Down
1 change: 0 additions & 1 deletion src/PHPDraft/Model/Tests/TransitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
class TransitionTest extends HierarchyElementChildTest
{

/**
* Set up
*/
Expand Down
8 changes: 6 additions & 2 deletions src/PHPDraft/Model/Transition.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,19 @@ public function parse(stdClass $object): self
$parsable = new HTTPRequest($this);
$val = $parsable->parse($item);
foreach ($this->requests as $request) {
if ($request->is_equal_to($val)) continue 3;
if ($request->is_equal_to($val)) {
continue 3;
}
}
$this->requests[] = $val;
break;
case 'httpResponse':
$parsable = new HTTPResponse($this);
$val = $parsable->parse($item);
foreach ($this->responses as $response) {
if ($response->is_equal_to($val)) continue 3;
if ($response->is_equal_to($val)) {
continue 3;
}
}
$this->responses[] = $parsable->parse($item);
break;
Expand Down
5 changes: 2 additions & 3 deletions src/PHPDraft/Out/TemplateRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

class TemplateRenderer extends BaseTemplateRenderer
{

/**
* TemplateGenerator constructor.
*
Expand Down Expand Up @@ -74,9 +73,9 @@ public function get($object): string
}

if (Sorting::sortServices($this->sorting)) {
usort($this->categories, function ($a, $b) { return strcmp($a->title, $b->title); });
usort($this->categories, fn($a, $b) => strcmp($a->title, $b->title));
foreach ($this->categories as $category) {
usort($category->children, function ($a, $b) { return strcmp($a->title, $b->title); });
usort($category->children, fn($a, $b)=> strcmp($a->title, $b->title));
}
}

Expand Down
1 change: 0 additions & 1 deletion src/PHPDraft/Out/Tests/SortingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
class SortingTest extends LunrBaseTest
{

/**
* Test if service sorting is determined correctly.
*
Expand Down
15 changes: 10 additions & 5 deletions src/PHPDraft/Out/Tests/TemplateRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ public function testIncludeFileMultiple(): void
/**
* @covers \PHPDraft\Out\TemplateRenderer::get
*/
public function testGetTemplateFailsEmpty(): void {
public function testGetTemplateFailsEmpty(): void
{
$this->expectException('PHPDraft\Parse\ExecutionException');
$this->expectExceptionMessage('Couldn\'t find template \'cow\'');
$this->set_reflection_property_value('template', 'cow');
Expand All @@ -207,7 +208,8 @@ public function testGetTemplateFailsEmpty(): void {
* @covers \PHPDraft\Out\TemplateRenderer::get
* @group twig
*/
public function testGetTemplate(): void {
public function testGetTemplate(): void
{
$json = '{"content": [{"content": "hello"}]}';

$this->assertStringEqualsFile(TEST_STATICS . '/empty_html_template', $this->class->get(json_decode($json)));
Expand All @@ -217,7 +219,8 @@ public function testGetTemplate(): void {
* @covers \PHPDraft\Out\TemplateRenderer::get
* @group twig
*/
public function testGetTemplateSorting(): void {
public function testGetTemplateSorting(): void
{
$this->set_reflection_property_value('sorting', 3);
$json = '{"content": [{"content": "hello"}]}';

Expand All @@ -228,7 +231,8 @@ public function testGetTemplateSorting(): void {
* @covers \PHPDraft\Out\TemplateRenderer::get
* @group twig
*/
public function testGetTemplateMetaData(): void {
public function testGetTemplateMetaData(): void
{
$this->set_reflection_property_value('sorting', 3);
$json = <<<'TAG'
{"content": [{"content": [], "attributes": {
Expand All @@ -246,7 +250,8 @@ public function testGetTemplateMetaData(): void {
* @covers \PHPDraft\Out\TemplateRenderer::get
* @group twig
*/
public function testGetTemplateCategories(): void {
public function testGetTemplateCategories(): void
{
$this->set_reflection_property_value('sorting', 3);
$json = <<<'TAG'
{"content": [
Expand Down
1 change: 0 additions & 1 deletion src/PHPDraft/Out/Tests/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
class VersionTest extends LunrBaseTest
{

/**
* Set up tests
*
Expand Down
11 changes: 7 additions & 4 deletions src/PHPDraft/Out/TwigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

class TwigFactory
{
public static function get(LoaderInterface $loader): Environment {
public static function get(LoaderInterface $loader): Environment
{
$twig = new Environment($loader);

$twig->addFilter(new TwigFilter('minify_css', function ($string) {
Expand All @@ -43,7 +44,8 @@ public static function get(LoaderInterface $loader): Environment {
return TemplateRenderer::get_response_status($string);
}));
$twig->addFilter(new TwigFilter('status_reason', function ($string) {
return (new Httpstatus())->getReasonPhrase($string);;
return (new Httpstatus())->getReasonPhrase($string);
;
}));
$twig->addTest(new TwigTest('enum_type', function ($object) {
return $object instanceof EnumStructureElement;
Expand All @@ -70,7 +72,8 @@ public static function get(LoaderInterface $loader): Environment {
}));

$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
public function load(string $class) {
public function load(string $class)
{
if (MarkdownRuntime::class === $class) {
return new MarkdownRuntime(new DefaultMarkdown());
}
Expand All @@ -81,4 +84,4 @@ public function load(string $class) {

return $twig;
}
}
}
1 change: 0 additions & 1 deletion src/PHPDraft/Parse/BaseHtmlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,4 @@ abstract public function build_html(string $template = 'default', ?string $image
* @return string
*/
abstract public function __toString();

}
1 change: 0 additions & 1 deletion src/PHPDraft/Parse/Tests/BaseParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
class BaseParserTest extends LunrBaseTest
{

/**
* Shared instance of the file parser.
*
Expand Down
1 change: 0 additions & 1 deletion src/PHPDraft/Parse/Tests/DrafterAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
class DrafterAPITest extends LunrBaseTest
{

/**
* Shared instance of the file parser.
*
Expand Down
1 change: 0 additions & 1 deletion src/PHPDraft/Parse/Tests/DrafterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
class DrafterTest extends LunrBaseTest
{

/**
* Shared instance of the file parser.
*
Expand Down
1 change: 0 additions & 1 deletion src/PHPDraft/Parse/Tests/ParserFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/
class ParserFactoryTest extends LunrBaseTest
{

/**
* @covers \PHPDraft\Parse\ParserFactory::getDrafter
*/
Expand Down
Loading