@@ -16,10 +16,10 @@ class Parameter
16
16
*/
17
17
private $ type ;
18
18
19
- public function __construct (\SimpleXMLElement $ parameter , ?PhpStanFunction $ phpStanFunction )
19
+ public function __construct (\SimpleXMLElement $ parameter , ?PhpStanFunction $ phpStanFunction, int $ position )
20
20
{
21
21
$ this ->parameter = $ parameter ;
22
- $ phpStanParam = $ phpStanFunction ? $ phpStanFunction ->getParameter ($ this ->getParameter ()) : null ;
22
+ $ phpStanParam = $ phpStanFunction ? $ phpStanFunction ->getParameter ($ this ->getParameter (), $ position ) : null ;
23
23
24
24
$ this ->type = $ phpStanParam ? $ phpStanParam ->getType () : new PhpStanType ($ this ->parameter ->type ->__toString ());
25
25
}
@@ -42,9 +42,6 @@ public function getDocBlockType(): string
42
42
43
43
public function getParameter (): string
44
44
{
45
- if ($ this ->isVariadic ()) {
46
- return 'params ' ;
47
- }
48
45
// The db2_bind_param method has parameters with a dash in it... yep... (patch submitted)
49
46
return \str_replace ('- ' , '_ ' , $ this ->parameter ->parameter ->__toString ());
50
47
}
@@ -62,7 +59,7 @@ public function isByReference(): bool
62
59
*/
63
60
public function isOptionalWithNoDefault (): bool
64
61
{
65
- if (((string )$ this ->parameter ['choice ' ]) !== 'opt ' ) {
62
+ if (((string )$ this ->parameter ['choice ' ]) !== 'opt ' && ! $ this -> isVariadic () ) {
66
63
return false ;
67
64
}
68
65
if (!$ this ->hasDefaultValue ()) {
@@ -71,15 +68,15 @@ public function isOptionalWithNoDefault(): bool
71
68
72
69
$ initializer = $ this ->getInitializer ();
73
70
// Some default value have weird values. For instance, first parameter of "mb_internal_encoding" has default value "mb_internal_encoding()"
74
- if ($ initializer !== 'array() ' && strpos ($ initializer , '( ' ) !== false ) {
71
+ if ($ initializer === ' null ' || ( $ initializer !== 'array() ' && strpos ($ initializer , '( ' ) !== false ) ) {
75
72
return true ;
76
73
}
77
74
return false ;
78
75
}
79
76
80
77
public function isVariadic (): bool
81
78
{
82
- return $ this ->parameter -> parameter -> __toString ( ) === '... ' ;
79
+ return (( string ) $ this ->parameter [ ' rep ' ] ) === 'repeat ' ;
83
80
}
84
81
85
82
public function isNullable (): bool
0 commit comments