Skip to content

Commit

Permalink
General: Fix missing phpstan data
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Feb 11, 2021
1 parent 5a3f38f commit 3bceb2f
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/PHPDraft/In/Tests/ApibFileParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public function testParseBasic(): void
*
* @covers \PHPDraft\In\ApibFileParser::set_apib_content
*/
public function testSetContent(){
public function testSetContent(): void
{
$this->class->set_apib_content('content');
$this->assertEquals('content', $this->get_reflection_property_value('full_apib'));
}
Expand Down
6 changes: 5 additions & 1 deletion src/PHPDraft/Model/Elements/ObjectStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
class ObjectStructureElement extends BasicStructureElement
{

/**
* Object representation before parsing
* @var \stdClass
*/
private $object;

/**
* Unset object function.
* @internal Only for tests
*/
public function __clearForTest()
public function __clearForTest(): void
{
$this->object = null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Elements/StructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface StructureElement
/**
* Default data types.
*
* @var array
* @var string[]
*/
public const DEFAULTS = ['boolean', 'string', 'number', 'object', 'array', 'enum'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function setUp(): void
*
* @covers \PHPDraft\Model\Elements\ArrayStructureElement::parse
*/
public function testSuccessfulParse($object, $expected)
public function testSuccessfulParse(string $object, ArrayStructureElement $expected): void
{
$dep = [];
$obj = json_decode($object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public function testSetupCorrectly(): void
* @dataProvider stringValueProvider
*
* @param mixed $value Value to set to the class
* @param string $string_value Expected string representation
* @param mixed $string_value Expected string representation
*/
public function testStringValue($value, $string_value)
public function testStringValue($value, $string_value): void
{
$this->set_reflection_property_value('value', $value);

Expand Down Expand Up @@ -119,7 +119,7 @@ public function testParseCommonDeps(): void
* @param mixed $value Value to set to the class
* @param BasicStructureElement $expected_value Expected string representation
*/
public function testParseCommon($value, $expected_value)
public function testParseCommon($value, BasicStructureElement $expected_value): void
{
$dep = [];
$method = $this->reflection->getMethod('parse_common');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function tearDown(): void
/**
* @covers \PHPDraft\Model\Elements\ElementStructureElement::parse
*/
public function testParse()
public function testParse(): void
{
$json = '{"element": "Cow", "content": "stuff", "meta": {"description": {"content": "desc"}}}';
$dep = [];
Expand All @@ -49,15 +49,15 @@ public function testParse()
/**
* @covers \PHPDraft\Model\Elements\ElementStructureElement::string_value
*/
public function testStringValue()
public function testStringValue(): void
{
$this->assertSame('<li class="list-group-item mdl-list__item"><a class="code" title="" href="#object-"></a></li>', $this->class->string_value());
}

/**
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
*/
public function testToString()
public function testToString(): void
{
$this->set_reflection_property_value('type', 'string');

Expand All @@ -67,7 +67,7 @@ public function testToString()
/**
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
*/
public function testToStringCustomType()
public function testToStringCustomType(): void
{
$this->set_reflection_property_value('type', 'Cow');

Expand All @@ -77,7 +77,7 @@ public function testToStringCustomType()
/**
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
*/
public function testToStringDescription()
public function testToStringDescription(): void
{
$this->set_reflection_property_value('type', 'Cow');
$this->set_reflection_property_value('description', 'Something');
Expand All @@ -88,7 +88,7 @@ public function testToStringDescription()
/**
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
*/
public function testToStringValue()
public function testToStringValue(): void
{
$this->set_reflection_property_value('type', 'Cow');
$this->set_reflection_property_value('value', 'stuff');
Expand All @@ -99,7 +99,7 @@ public function testToStringValue()
/**
* @covers \PHPDraft\Model\Elements\ElementStructureElement::__toString
*/
public function testToStringDescriptionAndValue()
public function testToStringDescriptionAndValue(): void
{
$this->set_reflection_property_value('type', 'Cow');
$this->set_reflection_property_value('value', 'stuff');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function testToStringWithComplexArray(): void
*
* @covers \PHPDraft\Model\Elements\EnumStructureElement::parse
*/
public function testSuccesfulParse($object, $expected)
public function testSuccesfulParse(string $object, EnumStructureElement $expected): void
{
$dep = [];
$res = $this->class->parse(json_decode($object), $dep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testNewInstance(): void
*
* @covers \PHPDraft\Model\Elements\ObjectStructureElement::parse
*/
public function testSuccesfulParse($object, $expected)
public function testSuccesfulParse(string $object, ObjectStructureElement $expected): void
{
$dep = [];
$res = $this->class->parse(json_decode($object), $dep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testPrintJsonArray(): void
*
* @covers \PHPDraft\Model\Elements\ObjectStructureElement::parse
*/
public function testSuccessfulParse($object, $expected)
public function testSuccessfulParse(string $object, ObjectStructureElement $expected): void
{
$dep = [];
$res = $this->class->parse(json_decode($object), $dep);
Expand Down
6 changes: 3 additions & 3 deletions src/PHPDraft/Out/BaseTemplateRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ abstract class BaseTemplateRenderer
/**
* CSS Files to load.
*
* @var array
* @var string[]
*/
public $css = [];
/**
* JS Files to load.
*
* @var array
* @var string[]
*/
public $js = [];
/**
Expand All @@ -56,7 +56,7 @@ abstract class BaseTemplateRenderer
/**
* The base data of the API.
*
* @var array
* @var array<mixed>
*/
protected $base_data;
/**
Expand Down
8 changes: 5 additions & 3 deletions src/PHPDraft/Out/Tests/TemplateRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function testStripSpaces(): void

/**
* Provide HTTP status codes
* @return array<int, array<int, int|string>>
*/
public function responseStatusProvider(): array
{
Expand Down Expand Up @@ -90,6 +91,7 @@ public function testResponseStatus($code, $text): void

/**
* Provide HTTP methods
* @return array<int, array<int, string>>
*/
public function requestMethodProvider(): array
{
Expand All @@ -115,14 +117,14 @@ public function requestMethodProvider(): array
*
* @dataProvider requestMethodProvider
*
* @param int $code HTTP Method
* @param string $method HTTP Method
* @param string $text Class to return
*
* @covers \PHPDraft\Out\TemplateRenderer::get_method_icon
*/
public function testRequestMethod($code, $text): void
public function testRequestMethod(string $method, string $text): void
{
$return = TemplateRenderer::get_method_icon($code);
$return = TemplateRenderer::get_method_icon($method);
$this->assertEquals($text, $return);
}

Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Out/TwigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function get(LoaderInterface $loader): Environment {
}));

$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
public function load($class) {
public function load(string $class) {
if (MarkdownRuntime::class === $class) {
return new MarkdownRuntime(new DefaultMarkdown());
}
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Parse/DrafterAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function parse(): void
*
* @param string $message API blueprint to parse
*
* @return false|resource
* @return false|resource|\CurlHandle
*/
public static function curl_init_drafter(string $message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Parse/Tests/BaseHtmlGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function tearDown(): void
/**
* * @covers \PHPDraft\Parse\BaseHtmlGenerator::init
*/
public function testInit()
public function testInit(): void
{
$data = json_decode(file_get_contents(TEST_STATICS . '/drafter/json/index.json'));
$init = $this->class->init($data);
Expand Down
7 changes: 6 additions & 1 deletion src/PHPDraft/Parse/Tests/HtmlGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ public function setUp(): void
*/
public function tearDown(): void
{
uopz_undefine('ID_STATIC');
$this->constant_undefine('ID_STATIC');
unset($this->class);
unset($this->reflection);
}

/**
* Tests if the constructor sets the property correctly
*
* @requires ext-uopz
*/
public function testSetupCorrectly(): void
{
Expand All @@ -68,6 +70,7 @@ public function testSetupCorrectly(): void

/**
* Tests if the constructor sets the property correctly
* @requires ext-uopz
*/
public function testGetHTML(): void
{
Expand All @@ -77,6 +80,7 @@ public function testGetHTML(): void

/**
* Tests if the constructor sets the property correctly
* @requires ext-uopz
*/
public function testGetHTMLMaterial(): void
{
Expand All @@ -86,6 +90,7 @@ public function testGetHTMLMaterial(): void

/**
* Tests if the constructor sets the property correctly
* @requires ext-uopz
*/
public function testGetHTMLAdvanced(): void
{
Expand Down
10 changes: 5 additions & 5 deletions src/PHPDraft/Parse/Tests/ParserFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ParserFactoryTest extends LunrBaseTest
/**
* @covers \PHPDraft\Parse\ParserFactory::getDrafter
*/
public function testGetDrafter()
public function testGetDrafter(): void
{
$this->mock_method(['\PHPDraft\Parse\Drafter', 'available'], function () {
return true;
Expand All @@ -29,7 +29,7 @@ public function testGetDrafter()
/**
* @covers \PHPDraft\Parse\ParserFactory::getDrafter
*/
public function testGetDrafterAPI()
public function testGetDrafterAPI(): void
{
$this->mock_method(['\PHPDraft\Parse\Drafter', 'available'], function () {
return false;
Expand All @@ -47,7 +47,7 @@ public function testGetDrafterAPI()
/**
* @covers \PHPDraft\Parse\ParserFactory::getDrafter
*/
public function testGetDrafterFails()
public function testGetDrafterFails(): void
{
$this->expectException('\PHPDraft\Parse\ResourceException');
$this->expectExceptionMessage('Couldn\'t get an APIB parser');
Expand All @@ -67,7 +67,7 @@ public function testGetDrafterFails()
/**
* @covers \PHPDraft\Parse\ParserFactory::getJson
*/
public function testGetJson()
public function testGetJson(): void
{
$this->mock_method(['\PHPDraft\Parse\Drafter', 'available'], function () {
return false;
Expand All @@ -85,7 +85,7 @@ public function testGetJson()
/**
* @covers \PHPDraft\Parse\ParserFactory::getJson
*/
public function testGetJsonFails()
public function testGetJsonFails(): void
{
$this->expectException('\PHPDraft\Parse\ResourceException');
$this->expectExceptionMessage('Couldn\'t get a JSON parser');
Expand Down

0 comments on commit 3bceb2f

Please sign in to comment.