Skip to content

Commit 3bceb2f

Browse files
committed
General: Fix missing phpstan data
1 parent 5a3f38f commit 3bceb2f

16 files changed

+44
-32
lines changed

src/PHPDraft/In/Tests/ApibFileParserTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public function testParseBasic(): void
108108
*
109109
* @covers \PHPDraft\In\ApibFileParser::set_apib_content
110110
*/
111-
public function testSetContent(){
111+
public function testSetContent(): void
112+
{
112113
$this->class->set_apib_content('content');
113114
$this->assertEquals('content', $this->get_reflection_property_value('full_apib'));
114115
}

src/PHPDraft/Model/Elements/ObjectStructureElement.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818
class ObjectStructureElement extends BasicStructureElement
1919
{
2020

21+
/**
22+
* Object representation before parsing
23+
* @var \stdClass
24+
*/
2125
private $object;
2226

2327
/**
2428
* Unset object function.
2529
* @internal Only for tests
2630
*/
27-
public function __clearForTest()
31+
public function __clearForTest(): void
2832
{
2933
$this->object = null;
3034
}

src/PHPDraft/Model/Elements/StructureElement.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface StructureElement
1717
/**
1818
* Default data types.
1919
*
20-
* @var array
20+
* @var string[]
2121
*/
2222
public const DEFAULTS = ['boolean', 'string', 'number', 'object', 'array', 'enum'];
2323

src/PHPDraft/Model/Elements/Tests/ArrayStructureElementTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function setUp(): void
4141
*
4242
* @covers \PHPDraft\Model\Elements\ArrayStructureElement::parse
4343
*/
44-
public function testSuccessfulParse($object, $expected)
44+
public function testSuccessfulParse(string $object, ArrayStructureElement $expected): void
4545
{
4646
$dep = [];
4747
$obj = json_decode($object);

src/PHPDraft/Model/Elements/Tests/BasicStructureElementTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public function testSetupCorrectly(): void
5353
* @dataProvider stringValueProvider
5454
*
5555
* @param mixed $value Value to set to the class
56-
* @param string $string_value Expected string representation
56+
* @param mixed $string_value Expected string representation
5757
*/
58-
public function testStringValue($value, $string_value)
58+
public function testStringValue($value, $string_value): void
5959
{
6060
$this->set_reflection_property_value('value', $value);
6161

@@ -119,7 +119,7 @@ public function testParseCommonDeps(): void
119119
* @param mixed $value Value to set to the class
120120
* @param BasicStructureElement $expected_value Expected string representation
121121
*/
122-
public function testParseCommon($value, $expected_value)
122+
public function testParseCommon($value, BasicStructureElement $expected_value): void
123123
{
124124
$dep = [];
125125
$method = $this->reflection->getMethod('parse_common');

src/PHPDraft/Model/Elements/Tests/ElementStructureElementTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function tearDown(): void
3434
/**
3535
* @covers \PHPDraft\Model\Elements\ElementStructureElement::parse
3636
*/
37-
public function testParse()
37+
public function testParse(): void
3838
{
3939
$json = '{"element": "Cow", "content": "stuff", "meta": {"description": {"content": "desc"}}}';
4040
$dep = [];
@@ -49,15 +49,15 @@ public function testParse()
4949
/**
5050
* @covers \PHPDraft\Model\Elements\ElementStructureElement::string_value
5151
*/
52-
public function testStringValue()
52+
public function testStringValue(): void
5353
{
5454
$this->assertSame('<li class="list-group-item mdl-list__item"><a class="code" title="" href="#object-"></a></li>', $this->class->string_value());
5555
}
5656

5757
/**
5858
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
5959
*/
60-
public function testToString()
60+
public function testToString(): void
6161
{
6262
$this->set_reflection_property_value('type', 'string');
6363

@@ -67,7 +67,7 @@ public function testToString()
6767
/**
6868
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
6969
*/
70-
public function testToStringCustomType()
70+
public function testToStringCustomType(): void
7171
{
7272
$this->set_reflection_property_value('type', 'Cow');
7373

@@ -77,7 +77,7 @@ public function testToStringCustomType()
7777
/**
7878
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
7979
*/
80-
public function testToStringDescription()
80+
public function testToStringDescription(): void
8181
{
8282
$this->set_reflection_property_value('type', 'Cow');
8383
$this->set_reflection_property_value('description', 'Something');
@@ -88,7 +88,7 @@ public function testToStringDescription()
8888
/**
8989
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
9090
*/
91-
public function testToStringValue()
91+
public function testToStringValue(): void
9292
{
9393
$this->set_reflection_property_value('type', 'Cow');
9494
$this->set_reflection_property_value('value', 'stuff');
@@ -99,7 +99,7 @@ public function testToStringValue()
9999
/**
100100
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
101101
*/
102-
public function testToStringDescriptionAndValue()
102+
public function testToStringDescriptionAndValue(): void
103103
{
104104
$this->set_reflection_property_value('type', 'Cow');
105105
$this->set_reflection_property_value('value', 'stuff');

src/PHPDraft/Model/Elements/Tests/EnumStructureElementTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function testToStringWithComplexArray(): void
120120
*
121121
* @covers \PHPDraft\Model\Elements\EnumStructureElement::parse
122122
*/
123-
public function testSuccesfulParse($object, $expected)
123+
public function testSuccesfulParse(string $object, EnumStructureElement $expected): void
124124
{
125125
$dep = [];
126126
$res = $this->class->parse(json_decode($object), $dep);

src/PHPDraft/Model/Elements/Tests/ObjectStructureElementTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testNewInstance(): void
5858
*
5959
* @covers \PHPDraft\Model\Elements\ObjectStructureElement::parse
6060
*/
61-
public function testSuccesfulParse($object, $expected)
61+
public function testSuccesfulParse(string $object, ObjectStructureElement $expected): void
6262
{
6363
$dep = [];
6464
$res = $this->class->parse(json_decode($object), $dep);

src/PHPDraft/Model/Elements/Tests/RequestBodyElementTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function testPrintJsonArray(): void
112112
*
113113
* @covers \PHPDraft\Model\Elements\ObjectStructureElement::parse
114114
*/
115-
public function testSuccessfulParse($object, $expected)
115+
public function testSuccessfulParse(string $object, ObjectStructureElement $expected): void
116116
{
117117
$dep = [];
118118
$res = $this->class->parse(json_decode($object), $dep);

src/PHPDraft/Out/BaseTemplateRenderer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ abstract class BaseTemplateRenderer
2626
/**
2727
* CSS Files to load.
2828
*
29-
* @var array
29+
* @var string[]
3030
*/
3131
public $css = [];
3232
/**
3333
* JS Files to load.
3434
*
35-
* @var array
35+
* @var string[]
3636
*/
3737
public $js = [];
3838
/**
@@ -56,7 +56,7 @@ abstract class BaseTemplateRenderer
5656
/**
5757
* The base data of the API.
5858
*
59-
* @var array
59+
* @var array<mixed>
6060
*/
6161
protected $base_data;
6262
/**

src/PHPDraft/Out/Tests/TemplateRendererTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function testStripSpaces(): void
5858

5959
/**
6060
* Provide HTTP status codes
61+
* @return array<int, array<int, int|string>>
6162
*/
6263
public function responseStatusProvider(): array
6364
{
@@ -90,6 +91,7 @@ public function testResponseStatus($code, $text): void
9091

9192
/**
9293
* Provide HTTP methods
94+
* @return array<int, array<int, string>>
9395
*/
9496
public function requestMethodProvider(): array
9597
{
@@ -115,14 +117,14 @@ public function requestMethodProvider(): array
115117
*
116118
* @dataProvider requestMethodProvider
117119
*
118-
* @param int $code HTTP Method
120+
* @param string $method HTTP Method
119121
* @param string $text Class to return
120122
*
121123
* @covers \PHPDraft\Out\TemplateRenderer::get_method_icon
122124
*/
123-
public function testRequestMethod($code, $text): void
125+
public function testRequestMethod(string $method, string $text): void
124126
{
125-
$return = TemplateRenderer::get_method_icon($code);
127+
$return = TemplateRenderer::get_method_icon($method);
126128
$this->assertEquals($text, $return);
127129
}
128130

src/PHPDraft/Out/TwigFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function get(LoaderInterface $loader): Environment {
7272
}));
7373

7474
$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
75-
public function load($class) {
75+
public function load(string $class) {
7676
if (MarkdownRuntime::class === $class) {
7777
return new MarkdownRuntime(new DefaultMarkdown());
7878
}

src/PHPDraft/Parse/DrafterAPI.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function parse(): void
5353
*
5454
* @param string $message API blueprint to parse
5555
*
56-
* @return false|resource
56+
* @return false|resource|\CurlHandle
5757
*/
5858
public static function curl_init_drafter(string $message)
5959
{

src/PHPDraft/Parse/Tests/BaseHtmlGeneratorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function tearDown(): void
3535
/**
3636
* * @covers \PHPDraft\Parse\BaseHtmlGenerator::init
3737
*/
38-
public function testInit()
38+
public function testInit(): void
3939
{
4040
$data = json_decode(file_get_contents(TEST_STATICS . '/drafter/json/index.json'));
4141
$init = $this->class->init($data);

src/PHPDraft/Parse/Tests/HtmlGeneratorTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ public function setUp(): void
5151
*/
5252
public function tearDown(): void
5353
{
54-
uopz_undefine('ID_STATIC');
54+
$this->constant_undefine('ID_STATIC');
5555
unset($this->class);
5656
unset($this->reflection);
5757
}
5858

5959
/**
6060
* Tests if the constructor sets the property correctly
61+
*
62+
* @requires ext-uopz
6163
*/
6264
public function testSetupCorrectly(): void
6365
{
@@ -68,6 +70,7 @@ public function testSetupCorrectly(): void
6870

6971
/**
7072
* Tests if the constructor sets the property correctly
73+
* @requires ext-uopz
7174
*/
7275
public function testGetHTML(): void
7376
{
@@ -77,6 +80,7 @@ public function testGetHTML(): void
7780

7881
/**
7982
* Tests if the constructor sets the property correctly
83+
* @requires ext-uopz
8084
*/
8185
public function testGetHTMLMaterial(): void
8286
{
@@ -86,6 +90,7 @@ public function testGetHTMLMaterial(): void
8690

8791
/**
8892
* Tests if the constructor sets the property correctly
93+
* @requires ext-uopz
8994
*/
9095
public function testGetHTMLAdvanced(): void
9196
{

src/PHPDraft/Parse/Tests/ParserFactoryTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ParserFactoryTest extends LunrBaseTest
1515
/**
1616
* @covers \PHPDraft\Parse\ParserFactory::getDrafter
1717
*/
18-
public function testGetDrafter()
18+
public function testGetDrafter(): void
1919
{
2020
$this->mock_method(['\PHPDraft\Parse\Drafter', 'available'], function () {
2121
return true;
@@ -29,7 +29,7 @@ public function testGetDrafter()
2929
/**
3030
* @covers \PHPDraft\Parse\ParserFactory::getDrafter
3131
*/
32-
public function testGetDrafterAPI()
32+
public function testGetDrafterAPI(): void
3333
{
3434
$this->mock_method(['\PHPDraft\Parse\Drafter', 'available'], function () {
3535
return false;
@@ -47,7 +47,7 @@ public function testGetDrafterAPI()
4747
/**
4848
* @covers \PHPDraft\Parse\ParserFactory::getDrafter
4949
*/
50-
public function testGetDrafterFails()
50+
public function testGetDrafterFails(): void
5151
{
5252
$this->expectException('\PHPDraft\Parse\ResourceException');
5353
$this->expectExceptionMessage('Couldn\'t get an APIB parser');
@@ -67,7 +67,7 @@ public function testGetDrafterFails()
6767
/**
6868
* @covers \PHPDraft\Parse\ParserFactory::getJson
6969
*/
70-
public function testGetJson()
70+
public function testGetJson(): void
7171
{
7272
$this->mock_method(['\PHPDraft\Parse\Drafter', 'available'], function () {
7373
return false;
@@ -85,7 +85,7 @@ public function testGetJson()
8585
/**
8686
* @covers \PHPDraft\Parse\ParserFactory::getJson
8787
*/
88-
public function testGetJsonFails()
88+
public function testGetJsonFails(): void
8989
{
9090
$this->expectException('\PHPDraft\Parse\ResourceException');
9191
$this->expectExceptionMessage('Couldn\'t get a JSON parser');

0 commit comments

Comments
 (0)