Skip to content

Commit d2f443c

Browse files
committed
SignatureMapParser - test required parameter after optional
1 parent 078ebaf commit d2f443c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

resources/functionMap.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -3919,7 +3919,7 @@
39193919
'hash_init' => ['HashContext', 'algo'=>'string', 'options='=>'int', 'key='=>'string'],
39203920
'hash_pbkdf2' => ['string', 'algo'=>'string', 'password'=>'string', 'salt'=>'string', 'iterations'=>'int', 'length='=>'int', 'raw_output='=>'bool'],
39213921
'hash_update' => ['bool', 'context'=>'HashContext', 'data'=>'string'],
3922-
'hash_update_file' => ['bool', 'context='=>'HashContext', 'filename'=>'string', 'scontext='=>'?HashContext'],
3922+
'hash_update_file' => ['bool', 'context'=>'HashContext', 'filename'=>'string', 'scontext='=>'?HashContext'],
39233923
'hash_update_stream' => ['int', 'context'=>'HashContext', 'handle'=>'resource', 'length='=>'int'],
39243924
'hashTableObj::clear' => ['void'],
39253925
'hashTableObj::get' => ['string', 'key'=>'string'],
@@ -5850,7 +5850,7 @@
58505850
'ldap_add' => ['bool', 'link_identifier'=>'resource', 'dn'=>'string', 'entry'=>'array', 'servercontrols='=>'array'],
58515851
'ldap_add_ext' => ['resource|false', 'link_identifier'=>'resource', 'dn'=>'string', 'entry'=>'array', 'servercontrols='=>'array'],
58525852
'ldap_bind' => ['bool', 'link_identifier'=>'resource', 'bind_rdn='=>'string|null', 'bind_password='=>'string|null', 'serverctrls=' => 'array'],
5853-
'ldap_bind_ext' => ['resource|false', 'link_identifier'=>'resource', 'bind_rdn='=>'string|null', 'bind_password='=>'string|null', 'serverctrls' => 'array'],
5853+
'ldap_bind_ext' => ['resource|false', 'link_identifier'=>'resource', 'bind_rdn='=>'string|null', 'bind_password='=>'string|null', 'serverctrls=' => 'array'],
58545854
'ldap_close' => ['bool', 'link_identifier'=>'resource'],
58555855
'ldap_compare' => ['bool', 'link_identifier'=>'resource', 'dn'=>'string', 'attr'=>'string', 'value'=>'string'],
58565856
'ldap_connect' => ['resource|false', 'host='=>'string', 'port='=>'int', 'wallet='=>'string', 'wallet_passwd='=>'string', 'authmode='=>'int'],
@@ -11861,8 +11861,8 @@
1186111861
'svn_ls' => ['array', 'repos_url'=>'string', 'revision_no='=>'int', 'recurse='=>'bool', 'peg='=>'bool'],
1186211862
'svn_mkdir' => ['bool', 'path'=>'string', 'log_message='=>'string'],
1186311863
'svn_move' => ['mixed', 'src_path'=>'string', 'dst_path'=>'string', 'force='=>'bool|false'],
11864-
'svn_propget' => ['mixed', 'path'=>'string', 'property_name'=>'string', 'recurse='=>'bool|false', 'revision'=>'int'],
11865-
'svn_proplist' => ['mixed', 'path'=>'string', 'recurse='=>'bool|false', 'revision'=>'int'],
11864+
'svn_propget' => ['mixed', 'path'=>'string', 'property_name'=>'string', 'recurse='=>'bool|false', 'revision='=>'int'],
11865+
'svn_proplist' => ['mixed', 'path'=>'string', 'recurse='=>'bool|false', 'revision='=>'int'],
1186611866
'svn_repos_create' => ['resource', 'path'=>'string', 'config='=>'array', 'fsconfig='=>'array'],
1186711867
'svn_repos_fs' => ['resource', 'repos'=>'resource'],
1186811868
'svn_repos_fs_begin_txn_for_commit' => ['resource', 'repos'=>'resource', 'rev'=>'int', 'author'=>'string', 'log_msg'=>'string'],
@@ -12657,7 +12657,7 @@
1265712657
'uopz_function\'1' => ['void', 'function'=>'string', 'handler'=>'Closure', 'modifiers='=>'int'],
1265812658
'uopz_get_exit_status' => ['mixed'],
1265912659
'uopz_get_mock' => ['mixed', 'class'=>'string'],
12660-
'uopz_get_return' => ['mixed', 'class='=>'string', 'function'=>'string'],
12660+
'uopz_get_return' => ['mixed', 'class='=>'string', 'function='=>'string'],
1266112661
'uopz_implement' => ['void', 'class'=>'string', 'interface'=>'string'],
1266212662
'uopz_overload' => ['void', 'opcode'=>'int', 'callable'=>'Callable'],
1266312663
'uopz_redefine' => ['void', 'class'=>'string', 'constant'=>'string', 'value'=>'mixed'],
@@ -12667,12 +12667,12 @@
1266712667
'uopz_restore' => ['void', 'class'=>'string', 'function'=>'string'],
1266812668
'uopz_restore\'1' => ['void', 'function'=>'string'],
1266912669
'uopz_set_mock' => ['void', 'class'=>'string', 'mock'=>'object|string'],
12670-
'uopz_set_return' => ['bool', 'class='=>'string', 'function'=>'string', 'value'=>'mixed', 'execute='=>'bool'],
12670+
'uopz_set_return' => ['bool', 'class'=>'string', 'function'=>'string', 'value'=>'mixed', 'execute='=>'bool'],
1267112671
'uopz_set_return\'1' => ['bool', 'function'=>'string', 'value'=>'mixed', 'execute='=>'bool'],
1267212672
'uopz_undefine' => ['void', 'class'=>'string', 'constant'=>'string'],
1267312673
'uopz_undefine\'1' => ['void', 'constant'=>'string'],
1267412674
'uopz_unset_mock' => ['void', 'class'=>'string'],
12675-
'uopz_unset_return' => ['bool', 'class='=>'string', 'function'=>'string'],
12675+
'uopz_unset_return' => ['bool', 'class='=>'string', 'function='=>'string'],
1267612676
'uopz_unset_return\'1' => ['bool', 'function'=>'string'],
1267712677
'urldecode' => ['string', 'str'=>'string'],
1267812678
'urlencode' => ['string', 'str'=>'string'],

tests/PHPStan/Reflection/SignatureMap/SignatureMapParserTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,13 @@ public function testParseAll(): void
403403
}
404404

405405
self::assertNotInstanceOf(ErrorType::class, $signature->getReturnType(), $functionName);
406+
$optionalOcurred = false;
406407
foreach ($signature->getParameters() as $parameter) {
408+
if ($parameter->isOptional()) {
409+
$optionalOcurred = true;
410+
} elseif ($optionalOcurred) {
411+
$this->fail(sprintf('%s contains required parameter after optional.', $functionName));
412+
}
407413
self::assertNotInstanceOf(ErrorType::class, $parameter->getType(), sprintf('%s (parameter %s)', $functionName, $parameter->getName()));
408414
}
409415
}

0 commit comments

Comments
 (0)