Skip to content

Commit 9ded02c

Browse files
committed
Better PHP 8.0 support
1 parent 74ec5aa commit 9ded02c

File tree

9 files changed

+412
-13
lines changed

9 files changed

+412
-13
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"php": ">=7.1",
1616
"phpfui/phpfui": "^6.0",
1717
"scrivo/highlight.php": ">=9.17",
18-
"phpdocumentor/reflection-docblock": ">=4.0",
18+
"phpdocumentor/reflection-docblock": ">=3.0",
1919
"gitonomy/gitlib": "^1.2",
2020
"cebe/markdown": "^1.2"
2121
},

src/PHPFUI/InstaDoc/Section/CodeCommon.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ protected function getParameters($method) : string
334334

335335
if ($method->hasReturnType())
336336
{
337-
$info .= ' : ' . $this->getClassName($method->getReturnType()->getName());
337+
$info .= ' : ' . $this->getValueString($method->getReturnType());
338338
}
339339

340340
$info .= $this->getComments($docBlock, $method instanceof \ReflectionMethod ? $method : null);
@@ -380,6 +380,17 @@ protected function getValueString($value) : string
380380
{
381381
$value = ($value->allowsNull() ? '?' : '') . $this->getClassName($value->getName());
382382
}
383+
elseif ('ReflectionUnionType' == $class)
384+
{
385+
$types = $value->getTypes();
386+
$value = $bar = '';
387+
foreach ($types as $type)
388+
{
389+
$value .= $bar;
390+
$bar = '|';
391+
$value .= $this->getClassName($type->getName());
392+
}
393+
}
383394
else
384395
{
385396
$value = $this->getClassName($class);

src/PHPFUI/InstaDoc/TestClass.php renamed to src/PHPFUI/InstaDoc/Tests/Test71.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace PHPFUI\InstaDoc;
3+
namespace PHPFUI\InstaDoc\Tests;
44

55
/**
66
* A test class with no functionality.
@@ -9,7 +9,7 @@
99
*
1010
* @author bruce (1/3/2020)
1111
*/
12-
class TestClass
12+
class Test71
1313
{
1414
public const CONST_PUBLIC_STRING = 'Default';
1515
protected const CONST_PROTECTED_INT = 42;
@@ -21,9 +21,13 @@ class TestClass
2121
public $public_float = 3.14;
2222
protected $protected_string = 'whatever';
2323

24-
private $private_array = ['fred', 1, false, 9.9, ['nested', self::CONST_PRIVATE_ARRAY]];
24+
private $private_array = ['fred', 1, false, 9.9, ['nested', self::CONST_PRIVATE_ARRAY, ]];
2525

26-
public function public_function_returning_and_taking_array(array $array = ['tom', 2 => 'Dick', 'harry' => 'reasoner']) : array
26+
public function __construct(?Test80 $test = null)
27+
{
28+
}
29+
30+
public final function public_function_returning_and_taking_array(array $array = ['tom', 2 => 'Dick', 'harry' => 'reasoner', ]) : array
2731
{
2832
return [];
2933
}
@@ -70,17 +74,17 @@ protected function protected_function_no_return(string $fred, $unknown = 3.14) :
7074
*
7175
* @throw //garbage dfsadfsfd
7276
*/
73-
private function private_function_no_return(string $fred = 'Eythel') : void {}
77+
private function private_function_no_return(?string $fred = 'Eythel') : void {}
7478

7579
/**
7680
* Testing method sorting
7781
*/
78-
private function theLowerTest() : void {}
82+
private static function theLowerTest() : self { return new static(); }
7983

8084
/**
8185
* Testing method sorting
8286
*/
83-
private function UpperCaseMethodName() : void {}
87+
private function UpperCaseMethodName() : void { }
8488

8589
/**
8690
* Testing method sorting

src/PHPFUI/InstaDoc/Tests/Test72.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
namespace PHPFUI\InstaDoc\Tests;
4+
5+
/**
6+
* A test class with no functionality.
7+
*
8+
* It is just to test InstaDoc
9+
*
10+
* @author bruce (1/3/2020)
11+
*/
12+
class Test72
13+
{
14+
public const CONST_PUBLIC_STRING = 'Default';
15+
protected const CONST_PROTECTED_INT = 42;
16+
private const CONST_PRIVATE_ARRAY = ['.Git', 0, true, 0.2, ];
17+
18+
/**
19+
* @var float
20+
*/
21+
public $public_float = 3.14;
22+
protected $protected_string = 'whatever';
23+
24+
private $private_array = ['fred', 1, false, 9.9, ['nested', self::CONST_PRIVATE_ARRAY, ]];
25+
26+
public function __construct(?Test80 $test = null)
27+
{
28+
}
29+
30+
public final function public_function_returning_and_taking_array(array $array = ['tom', 2 => 'Dick', 'harry' => 'reasoner', ]) : array
31+
{
32+
return [];
33+
}
34+
35+
/**
36+
* This function does nothing. But it has a very long
37+
* meaningless description that just seems to go on and on and
38+
* on but does not really say anything except for being very
39+
* long and completely unreadable, but such is the nature of
40+
* long meaningless comments that really say nothing of any
41+
* importance that just seem to meander and never get to the
42+
* point and be concise and to the point, but that is the point,
43+
* that there is no point. Pointless really.
44+
*
45+
* @param string $fred nothing to note here
46+
* @param float $unknown is pi
47+
*
48+
* @api declares that elements are suitable for consumption by third parties.
49+
* @example shows the code of a specified example file or, optionally, just a portion of it.
50+
* @ignore tells phpDocumentor that the associated element is not to be included in the documentation.
51+
* @internal denotes that the associated elements is internal to this application or library and hides it by default.
52+
* @source shows the source code of the associated element.
53+
* @throws \Fred this is the text
54+
* @todo indicates whether any development activity should still be executed on the associated element.
55+
* @uses indicates a reference to (and from) a single associated element.
56+
* @var $Properties This the explaination of the var
57+
* @return string this is the return text
58+
*
59+
* @category CategoryName
60+
* @package PackageName
61+
* @author Original Author <[email protected]>
62+
* @author Another Author <[email protected]>
63+
* @copyright 1997-2005 The PHP Group
64+
* @license http://www.php.net/license/3_01.txt PHP License 3.01
65+
* @version SVN: $Id$
66+
* @link http://pear.php.net/package/PackageName
67+
* @since File available since Release 1.2.0
68+
* @deprecated File deprecated in Release 2.0.0
69+
*/
70+
protected function protected_function_no_return(string $fred, $unknown = 3.14) : void {}
71+
72+
/**
73+
* This function does nothing.
74+
*
75+
* @throw //garbage dfsadfsfd
76+
*/
77+
private function private_function_no_return(?string $fred = 'Eythel') : void {}
78+
79+
/**
80+
* Testing method sorting
81+
*/
82+
private static function theLowerTest() : self { return new static(); }
83+
84+
/**
85+
* Testing method sorting
86+
*/
87+
private function UpperCaseMethodName() : void { }
88+
89+
/**
90+
* Testing method sorting
91+
*/
92+
private function upperTest() : void {}
93+
94+
}

src/PHPFUI/InstaDoc/Tests/Test73.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
namespace PHPFUI\InstaDoc\Tests;
4+
5+
/**
6+
* A test class with no functionality.
7+
*
8+
* It is just to test InstaDoc
9+
*
10+
* @author bruce (1/3/2020)
11+
*/
12+
class Test73
13+
{
14+
public const CONST_PUBLIC_STRING = 'Default';
15+
protected const CONST_PROTECTED_INT = 42;
16+
private const CONST_PRIVATE_ARRAY = ['.Git', 0, true, 0.2, ];
17+
18+
/**
19+
* @var float
20+
*/
21+
public $public_float = 3.14;
22+
protected $protected_string = 'whatever';
23+
24+
private $private_array = ['fred', 1, false, 9.9, ['nested', self::CONST_PRIVATE_ARRAY, ]];
25+
26+
public function __construct(?Test80 $test = null)
27+
{
28+
}
29+
30+
public final function public_function_returning_and_taking_array(array $array = ['tom', 2 => 'Dick', 'harry' => 'reasoner', ]) : array
31+
{
32+
return [];
33+
}
34+
35+
/**
36+
* This function does nothing. But it has a very long
37+
* meaningless description that just seems to go on and on and
38+
* on but does not really say anything except for being very
39+
* long and completely unreadable, but such is the nature of
40+
* long meaningless comments that really say nothing of any
41+
* importance that just seem to meander and never get to the
42+
* point and be concise and to the point, but that is the point,
43+
* that there is no point. Pointless really.
44+
*
45+
* @param string $fred nothing to note here
46+
* @param float $unknown is pi
47+
*
48+
* @api declares that elements are suitable for consumption by third parties.
49+
* @example shows the code of a specified example file or, optionally, just a portion of it.
50+
* @ignore tells phpDocumentor that the associated element is not to be included in the documentation.
51+
* @internal denotes that the associated elements is internal to this application or library and hides it by default.
52+
* @source shows the source code of the associated element.
53+
* @throws \Fred this is the text
54+
* @todo indicates whether any development activity should still be executed on the associated element.
55+
* @uses indicates a reference to (and from) a single associated element.
56+
* @var $Properties This the explaination of the var
57+
* @return string this is the return text
58+
*
59+
* @category CategoryName
60+
* @package PackageName
61+
* @author Original Author <[email protected]>
62+
* @author Another Author <[email protected]>
63+
* @copyright 1997-2005 The PHP Group
64+
* @license http://www.php.net/license/3_01.txt PHP License 3.01
65+
* @version SVN: $Id$
66+
* @link http://pear.php.net/package/PackageName
67+
* @since File available since Release 1.2.0
68+
* @deprecated File deprecated in Release 2.0.0
69+
*/
70+
protected function protected_function_no_return(string $fred, $unknown = 3.14) : void {}
71+
72+
/**
73+
* This function does nothing.
74+
*
75+
* @throw //garbage dfsadfsfd
76+
*/
77+
private function private_function_no_return(?string $fred = 'Eythel') : void {}
78+
79+
/**
80+
* Testing method sorting
81+
*/
82+
private static function theLowerTest() : self { return new static(); }
83+
84+
/**
85+
* Testing method sorting
86+
*/
87+
private function UpperCaseMethodName() : void { }
88+
89+
/**
90+
* Testing method sorting
91+
*/
92+
private function upperTest() : void {}
93+
94+
}

src/PHPFUI/InstaDoc/Tests/Test74.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
namespace PHPFUI\InstaDoc\Tests;
4+
5+
/**
6+
* A test class with no functionality.
7+
*
8+
* It is just to test InstaDoc
9+
*
10+
* @author bruce (1/3/2020)
11+
*/
12+
class Test74
13+
{
14+
public const CONST_PUBLIC_STRING = 'Default';
15+
protected const CONST_PROTECTED_INT = 42;
16+
private const CONST_PRIVATE_ARRAY = ['.Git', 0, true, 0.2, ];
17+
18+
/**
19+
* @var float
20+
*/
21+
public float $public_float = 3.14;
22+
protected string $protected_string = 'whatever';
23+
24+
private array $private_array = ['fred', 1, false, 9.9, ['nested', self::CONST_PRIVATE_ARRAY]];
25+
26+
public function __construct(?Test80 $test = null)
27+
{
28+
}
29+
30+
public final function public_function_returning_and_taking_array(array $array = ['tom', 2 => 'Dick', 'harry' => 'reasoner', ]) : array
31+
{
32+
return [];
33+
}
34+
35+
/**
36+
* This function does nothing. But it has a very long
37+
* meaningless description that just seems to go on and on and
38+
* on but does not really say anything except for being very
39+
* long and completely unreadable, but such is the nature of
40+
* long meaningless comments that really say nothing of any
41+
* importance that just seem to meander and never get to the
42+
* point and be concise and to the point, but that is the point,
43+
* that there is no point. Pointless really.
44+
*
45+
* @param string $fred nothing to note here
46+
* @param float $unknown is pi
47+
*
48+
* @api declares that elements are suitable for consumption by third parties.
49+
* @example shows the code of a specified example file or, optionally, just a portion of it.
50+
* @ignore tells phpDocumentor that the associated element is not to be included in the documentation.
51+
* @internal denotes that the associated elements is internal to this application or library and hides it by default.
52+
* @source shows the source code of the associated element.
53+
* @throws \Fred this is the text
54+
* @todo indicates whether any development activity should still be executed on the associated element.
55+
* @uses indicates a reference to (and from) a single associated element.
56+
* @var $Properties This the explaination of the var
57+
* @return string this is the return text
58+
*
59+
* @category CategoryName
60+
* @package PackageName
61+
* @author Original Author <[email protected]>
62+
* @author Another Author <[email protected]>
63+
* @copyright 1997-2005 The PHP Group
64+
* @license http://www.php.net/license/3_01.txt PHP License 3.01
65+
* @version SVN: $Id$
66+
* @link http://pear.php.net/package/PackageName
67+
* @since File available since Release 1.2.0
68+
* @deprecated File deprecated in Release 2.0.0
69+
*/
70+
protected function protected_function_no_return(string $fred, $unknown = 3.14) : void {}
71+
72+
/**
73+
* This function does nothing.
74+
*
75+
* @throw //garbage dfsadfsfd
76+
*/
77+
private function private_function_no_return(?string $fred = 'Eythel') : void {}
78+
79+
/**
80+
* Testing method sorting
81+
*/
82+
private static function theLowerTest() : self { return new static(); }
83+
84+
/**
85+
* Testing method sorting
86+
*/
87+
private function UpperCaseMethodName() : void { }
88+
89+
/**
90+
* Testing method sorting
91+
*/
92+
private function upperTest() : void {}
93+
94+
}

0 commit comments

Comments
 (0)