From b87ebd697f63836bfe0412ab21cb7204f010b8ee Mon Sep 17 00:00:00 2001 From: Corey Taylor Date: Sun, 6 Nov 2022 00:58:50 -0500 Subject: [PATCH] Fix assert testing callmap return types --- dictionaries/CallMap.php | 8 +-- dictionaries/CallMap_historical.php | 8 +-- .../Codebase/InternalCallMapHandlerTest.php | 60 ++----------------- 3 files changed, 14 insertions(+), 62 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index 858c659ae41..c060b68508c 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -9281,7 +9281,7 @@ 'ocigetbufferinglob' => ['bool'], 'ocisetbufferinglob' => ['bool', 'lob'=>'bool'], 'octdec' => ['int|float', 'octal_string'=>'string'], -'odbc_autocommit' => ['mixed', 'odbc'=>'resource', 'enable='=>'bool'], +'odbc_autocommit' => ['int|bool', 'odbc'=>'resource', 'enable='=>'bool'], 'odbc_binmode' => ['bool', 'statement'=>'resource', 'mode'=>'int'], 'odbc_close' => ['void', 'odbc'=>'resource'], 'odbc_close_all' => ['void'], @@ -9298,7 +9298,7 @@ 'odbc_execute' => ['bool', 'statement'=>'resource', 'params='=>'array'], 'odbc_fetch_array' => ['array|false', 'statement'=>'resource', 'row='=>'int'], 'odbc_fetch_into' => ['int', 'statement'=>'resource', '&w_array'=>'array', 'row='=>'int'], -'odbc_fetch_object' => ['object|false', 'statement'=>'resource', 'row='=>'int'], +'odbc_fetch_object' => ['stdClass|false', 'statement'=>'resource', 'row='=>'int'], 'odbc_fetch_row' => ['bool', 'statement'=>'resource', 'row='=>'int'], 'odbc_field_len' => ['int|false', 'statement'=>'resource', 'field'=>'int'], 'odbc_field_name' => ['string|false', 'statement'=>'resource', 'field'=>'int'], @@ -13683,7 +13683,7 @@ 'ssh2_exec' => ['resource|false', 'session'=>'resource', 'command'=>'string', 'pty='=>'string', 'env='=>'array', 'width='=>'int', 'height='=>'int', 'width_height_type='=>'int'], 'ssh2_fetch_stream' => ['resource|false', 'channel'=>'resource', 'streamid'=>'int'], 'ssh2_fingerprint' => ['string|false', 'session'=>'resource', 'flags='=>'int'], -'ssh2_forward_accept' => ['resource|false', 'session'=>'resource'], +'ssh2_forward_accept' => ['resource|false', 'listener'=>'resource'], 'ssh2_forward_listen' => ['resource|false', 'session'=>'resource', 'port'=>'int', 'host='=>'string', 'max_connections='=>'string'], 'ssh2_methods_negotiated' => ['array|false', 'session'=>'resource'], 'ssh2_poll' => ['int', '&polldes'=>'array', 'timeout='=>'int'], @@ -13704,7 +13704,7 @@ 'ssh2_sftp_stat' => ['array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: int, 11: int, 12: int, dev: int, ino: int, mode: int, nlink: int, uid: int, gid: int, rdev: int, size: int, atime: int, mtime: int, ctime: int, blksize: int, blocks: int}|false', 'sftp'=>'resource', 'path'=>'string'], 'ssh2_sftp_symlink' => ['bool', 'sftp'=>'resource', 'target'=>'string', 'link'=>'string'], 'ssh2_sftp_unlink' => ['bool', 'sftp'=>'resource', 'filename'=>'string'], -'ssh2_shell' => ['resource|false', 'session'=>'resource', 'term_type='=>'string', 'env='=>'array', 'width='=>'int', 'height='=>'int', 'width_height_type='=>'int'], +'ssh2_shell' => ['resource|false', 'session'=>'resource', 'termtype='=>'string', 'env='=>'array', 'width='=>'int', 'height='=>'int', 'width_height_type='=>'int'], 'ssh2_tunnel' => ['resource|false', 'session'=>'resource', 'host'=>'string', 'port'=>'int'], 'stat' => ['array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: int, 11: int, 12: int, dev: int, ino: int, mode: int, nlink: int, uid: int, gid: int, rdev: int, size: int, atime: int, mtime: int, ctime: int, blksize: int, blocks: int}|false', 'filename'=>'string'], 'stats_absolute_deviation' => ['float', 'a'=>'array'], diff --git a/dictionaries/CallMap_historical.php b/dictionaries/CallMap_historical.php index 95902245567..b127458551a 100644 --- a/dictionaries/CallMap_historical.php +++ b/dictionaries/CallMap_historical.php @@ -14056,7 +14056,7 @@ 'ocigetbufferinglob' => ['bool'], 'ocisetbufferinglob' => ['bool', 'lob'=>'bool'], 'octdec' => ['int|float', 'octal_string'=>'string'], - 'odbc_autocommit' => ['mixed', 'odbc'=>'resource', 'enable='=>'bool'], + 'odbc_autocommit' => ['int|bool', 'odbc'=>'resource', 'enable='=>'bool'], 'odbc_binmode' => ['bool', 'statement'=>'resource', 'mode'=>'int'], 'odbc_close' => ['void', 'odbc'=>'resource'], 'odbc_close_all' => ['void'], @@ -14073,7 +14073,7 @@ 'odbc_execute' => ['bool', 'statement'=>'resource', 'params='=>'array'], 'odbc_fetch_array' => ['array|false', 'statement'=>'resource', 'row='=>'int'], 'odbc_fetch_into' => ['int', 'statement'=>'resource', '&w_array'=>'array', 'row='=>'int'], - 'odbc_fetch_object' => ['object|false', 'statement'=>'resource', 'row='=>'int'], + 'odbc_fetch_object' => ['stdClass|false', 'statement'=>'resource', 'row='=>'int'], 'odbc_fetch_row' => ['bool', 'statement'=>'resource', 'row='=>'int'], 'odbc_field_len' => ['int|false', 'statement'=>'resource', 'field'=>'int'], 'odbc_field_name' => ['string|false', 'statement'=>'resource', 'field'=>'int'], @@ -15107,7 +15107,7 @@ 'ssh2_exec' => ['resource|false', 'session'=>'resource', 'command'=>'string', 'pty='=>'string', 'env='=>'array', 'width='=>'int', 'height='=>'int', 'width_height_type='=>'int'], 'ssh2_fetch_stream' => ['resource|false', 'channel'=>'resource', 'streamid'=>'int'], 'ssh2_fingerprint' => ['string|false', 'session'=>'resource', 'flags='=>'int'], - 'ssh2_forward_accept' => ['resource|false', 'session'=>'resource'], + 'ssh2_forward_accept' => ['resource|false', 'listener'=>'resource'], 'ssh2_forward_listen' => ['resource|false', 'session'=>'resource', 'port'=>'int', 'host='=>'string', 'max_connections='=>'string'], 'ssh2_methods_negotiated' => ['array|false', 'session'=>'resource'], 'ssh2_poll' => ['int', '&polldes'=>'array', 'timeout='=>'int'], @@ -15128,7 +15128,7 @@ 'ssh2_sftp_stat' => ['array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: int, 11: int, 12: int, dev: int, ino: int, mode: int, nlink: int, uid: int, gid: int, rdev: int, size: int, atime: int, mtime: int, ctime: int, blksize: int, blocks: int}|false', 'sftp'=>'resource', 'path'=>'string'], 'ssh2_sftp_symlink' => ['bool', 'sftp'=>'resource', 'target'=>'string', 'link'=>'string'], 'ssh2_sftp_unlink' => ['bool', 'sftp'=>'resource', 'filename'=>'string'], - 'ssh2_shell' => ['resource|false', 'session'=>'resource', 'term_type='=>'string', 'env='=>'array', 'width='=>'int', 'height='=>'int', 'width_height_type='=>'int'], + 'ssh2_shell' => ['resource|false', 'session'=>'resource', 'termtype='=>'string', 'env='=>'array', 'width='=>'int', 'height='=>'int', 'width_height_type='=>'int'], 'ssh2_tunnel' => ['resource|false', 'session'=>'resource', 'host'=>'string', 'port'=>'int'], 'stat' => ['array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: int, 11: int, 12: int, dev: int, ino: int, mode: int, nlink: int, uid: int, gid: int, rdev: int, size: int, atime: int, mtime: int, ctime: int, blksize: int, blocks: int}|false', 'filename'=>'string'], 'stats_absolute_deviation' => ['float', 'a'=>'array'], diff --git a/tests/Internal/Codebase/InternalCallMapHandlerTest.php b/tests/Internal/Codebase/InternalCallMapHandlerTest.php index 16eb66e9a3a..18cd54349e7 100644 --- a/tests/Internal/Codebase/InternalCallMapHandlerTest.php +++ b/tests/Internal/Codebase/InternalCallMapHandlerTest.php @@ -282,6 +282,7 @@ class InternalCallMapHandlerTest extends TestCase 'sqlsrv_prepare', 'sqlsrv_query', 'sqlsrv_server_info', + 'ssh2_forward_accept', 'stomp_abort', 'stomp_ack', 'stomp_begin', @@ -336,7 +337,6 @@ class InternalCallMapHandlerTest extends TestCase */ private static $ignoredReturnTypeOnlyFunctions = [ 'bcsqrt', - 'bzopen', 'cal_from_jd', 'collator_get_strength', 'curl_multi_init', @@ -354,25 +354,19 @@ class InternalCallMapHandlerTest extends TestCase 'date_timestamp_set', 'date_timezone_set', 'datefmt_set_lenient', - 'dba_open', - 'dba_popen', 'deflate_init', 'enchant_broker_init', 'fgetcsv', 'filter_input_array', - 'fopen', 'fpassthru', - 'fsockopen', 'ftp_get_option', 'get_declared_traits', 'gmp_export', 'gmp_hamdist', 'gmp_import', 'gzeof', - 'gzopen', 'gzpassthru', 'iconv_get_encoding', - 'igbinary_serialize', 'imagecolorclosest', 'imagecolorclosestalpha', 'imagecolorclosesthwb', @@ -402,31 +396,11 @@ class InternalCallMapHandlerTest extends TestCase 'ldap_get_attributes', 'mb_encoding_aliases', 'metaphone', - 'mongodb\\bson\\fromjson', - 'mongodb\\bson\\fromphp', - 'mongodb\\bson\\tojson', 'msg_get_queue', 'mysqli_stmt_get_warnings', 'mysqli_stmt_insert_id', 'numfmt_create', 'ob_list_handlers', - 'odbc_autocommit', - 'odbc_columnprivileges', - 'odbc_columns', - 'odbc_connect', - 'odbc_do', - 'odbc_exec', - 'odbc_fetch_object', - 'odbc_foreignkeys', - 'odbc_gettypeinfo', - 'odbc_pconnect', - 'odbc_prepare', - 'odbc_primarykeys', - 'odbc_specialcolumns', - 'odbc_statistics', - 'odbc_tableprivileges', - 'odbc_tables', - 'opendir', 'openssl_random_pseudo_bytes', 'openssl_spki_export', 'openssl_spki_export_challenge', @@ -434,58 +408,36 @@ class InternalCallMapHandlerTest extends TestCase 'parse_url', 'passthru', 'pcntl_exec', - 'pcntl_signal_get_handler', 'pcntl_strerror', - 'pfsockopen', 'pg_port', - 'pg_socket', - 'popen', - 'proc_open', 'pspell_config_create', 'pspell_new', 'pspell_new_config', 'pspell_new_personal', 'register_shutdown_function', 'rewinddir', - 'set_error_handler', - 'set_exception_handler', 'shm_attach', 'shmop_open', 'simplexml_import_dom', 'sleep', 'snmp_set_oid_numeric_print', - 'socket_export_stream', 'socket_import_stream', 'sodium_crypto_aead_chacha20poly1305_encrypt', 'sodium_crypto_aead_chacha20poly1305_ietf_encrypt', 'sodium_crypto_aead_xchacha20poly1305_ietf_encrypt', 'spl_autoload_functions', 'stream_bucket_new', - 'stream_context_create', - 'stream_context_get_default', - 'stream_context_set_default', - 'stream_filter_append', - 'stream_filter_prepend', 'stream_set_chunk_size', - 'stream_socket_accept', - 'stream_socket_client', - 'stream_socket_server', 'substr', 'substr_compare', 'timezone_abbreviations_list', 'timezone_offset_get', - 'tmpfile', 'user_error', 'xml_get_current_byte_index', 'xml_get_current_column_number', 'xml_get_current_line_number', 'xml_get_error_code', 'xml_parser_get_option', - 'yaml_parse', - 'yaml_parse_file', - 'yaml_parse_url', - 'zip_open', - 'zip_read', ]; /** @@ -767,12 +719,12 @@ public function assertEntryReturnType(ReflectionFunction $function, string $entr } else { $expectedType = $function->getReturnType(); } - if ($expectedType === null) { - $this->assertSame('', $entryReturnType, 'CallMap entry has incorrect return type'); - return; - } - $this->assertTypeValidity($expectedType, $entryReturnType, true, 'CallMap entry has incorrect return type'); + if ($expectedType !== null) { + $this->assertTypeValidity($expectedType, $entryReturnType, true, 'CallMap entry has incorrect return type'); + } else { + $this->assertNotEmpty($entryReturnType); + } } /**