Skip to content

Commit 885d7e9

Browse files
authored
Remove function signatures that were removed in PHP 8.0
1 parent 5e9c916 commit 885d7e9

File tree

3 files changed

+77
-4
lines changed

3 files changed

+77
-4
lines changed

resources/functionMap_php80delta.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@
158158
'xmlwriter_write_raw' => ['bool', 'xmlwriter'=>'XMLWriter', 'content'=>'string'],
159159
],
160160
'old' => [
161-
162161
'array_combine' => ['associative-array|false', 'keys'=>'string[]|int[]', 'values'=>'array'],
163162
'bcdiv' => ['?string', 'dividend'=>'string', 'divisor'=>'string', 'scale='=>'int'],
164163
'bcmod' => ['?string', 'dividend'=>'string', 'divisor'=>'string', 'scale='=>'int'],
165164
'bcpowmod' => ['?string', 'base'=>'string', 'exponent'=>'string', 'modulus'=>'string', 'scale='=>'int'],
165+
'convert_cyr_string' => ['string', 'str'=>'string', 'from'=>'string', 'to'=>'string'],
166166
'com_load_typelib' => ['bool', 'typelib_name'=>'string', 'case_insensitive='=>'bool'],
167167
'count_chars' => ['array<int,int>|false|string', 'input'=>'string', 'mode='=>'int'],
168168
'date_add' => ['DateTime|false', 'object'=>'DateTime', 'interval'=>'DateInterval'],
@@ -177,6 +177,9 @@
177177
'date_timestamp_set' => ['DateTime|false', 'object'=>'DateTime', 'unixtimestamp'=>'int'],
178178
'date_timezone_set' => ['DateTime|false', 'object'=>'DateTime', 'timezone'=>'DateTimeZone'],
179179
'each' => ['array{0:int|string,key:int|string,1:mixed,value:mixed}', '&r_arr'=>'array'],
180+
'ezmlm_hash' => ['int', 'addr'=>'string'],
181+
'fgetss' => ['string|false', 'fp'=>'resource', 'length='=>'0|positive-int', 'allowable_tags='=>'string'],
182+
'get_magic_quotes_gpc' => ['false'],
180183
'gmdate' => ['string|false', 'format'=>'string', 'timestamp='=>'int'],
181184
'gmmktime' => ['int|false', 'hour='=>'int', 'minute='=>'int', 'second='=>'int', 'month='=>'int', 'day='=>'int', 'year='=>'int'],
182185
'gmp_random' => ['GMP', 'limiter='=>'int'],
@@ -185,6 +188,7 @@
185188
'hash_hkdf' => ['non-empty-string|false', 'algo'=>'string', 'key'=>'string', 'length='=>'int', 'info='=>'string', 'salt='=>'string'],
186189
'hash_hmac' => ['non-empty-string|false', 'algo'=>'string', 'data'=>'string', 'key'=>'string', 'raw_output='=>'bool'],
187190
'hash_pbkdf2' => ['non-empty-string|false', 'algo'=>'string', 'password'=>'string', 'salt'=>'string', 'iterations'=>'int', 'length='=>'int', 'raw_output='=>'bool'],
191+
'hebrevc' => ['string', 'str'=>'string', 'max_chars_per_line='=>'int'],
188192
'image2wbmp' => ['bool', 'im'=>'resource', 'filename='=>'?string', 'threshold='=>'int'],
189193
'imageaffine' => ['resource|false', 'src'=>'resource', 'affine'=>'array', 'clip='=>'array'],
190194
'imagecreate' => ['resource|false', 'x_size'=>'int', 'y_size'=>'int'],
@@ -209,19 +213,24 @@
209213
'imagejpeg' => ['bool', 'im'=>'resource', 'filename='=>'string|resource|null', 'quality='=>'int'],
210214
'imagerotate' => ['resource|false', 'src_im'=>'resource', 'angle'=>'float', 'bgdcolor'=>'int', 'ignoretransparent='=>'int'],
211215
'imagescale' => ['resource|false', 'im'=>'resource', 'new_width'=>'int', 'new_height='=>'int', 'method='=>'int'],
216+
'imap_header' => ['stdClass|false', 'stream_id'=>'resource', 'msg_no'=>'int', 'from_length='=>'int', 'subject_length='=>'int', 'default_host='=>'string'],
212217
'implode\'1' => ['string', 'pieces'=>'array'],
213218
'jpeg2wbmp' => ['bool', 'jpegname'=>'string', 'wbmpname'=>'string', 'dest_height'=>'int', 'dest_width'=>'int', 'threshold'=>'int'],
219+
'ldap_control_paged_result' => ['bool', 'link_identifier'=>'resource', 'pagesize'=>'int', 'iscritical='=>'bool', 'cookie='=>'string'],
220+
'ldap_control_paged_result_response' => ['bool', 'link_identifier'=>'resource', 'result_identifier'=>'resource', '&w_cookie='=>'string', '&w_estimated='=>'int'],
214221
'ldap_set_rebind_proc' => ['bool', 'link_identifier'=>'resource', 'callback'=>'callable'],
215222
'ldap_sort' => ['bool', 'link_identifier'=>'resource', 'result_identifier'=>'resource', 'sortfilter'=>'string'],
216223
'mb_decode_numericentity' => ['string|false', 'string'=>'string', 'convmap'=>'array', 'encoding='=>'string', 'is_hex='=>'bool'],
217-
'mktime' => ['int|false', 'hour='=>'int', 'minute='=>'int', 'second='=>'int', 'month='=>'int', 'day='=>'int', 'year='=>'int'],
218224
'mb_strlen' => ['0|positive-int', 'str'=>'string', 'encoding='=>'string'],
225+
'mktime' => ['int|false', 'hour='=>'int', 'minute='=>'int', 'second='=>'int', 'month='=>'int', 'day='=>'int', 'year='=>'int'],
226+
'money_format' => ['string', 'format'=>'string', 'value'=>'float'],
219227
'odbc_exec' => ['resource|false', 'connection_id'=>'resource', 'query'=>'string', 'flags='=>'int'],
220228
'parse_str' => ['void', 'encoded_string'=>'string', '&w_result='=>'array'],
221229
'password_hash' => ['string|false|null', 'password'=>'string', 'algo'=>'?string|?int', 'options='=>'array'],
222230
'png2wbmp' => ['bool', 'pngname'=>'string', 'wbmpname'=>'string', 'dest_height'=>'int', 'dest_width'=>'int', 'threshold'=>'int'],
223231
'proc_get_status' => ['array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}|false', 'process'=>'resource'],
224232
'read_exif_data' => ['array', 'filename'=>'string', 'sections_needed='=>'string', 'sub_arrays='=>'bool', 'read_thumbnail='=>'bool'],
233+
'restore_include_path' => ['void'],
225234
'socket_select' => ['int|false', '&rw_read_fds'=>'resource[]|null', '&rw_write_fds'=>'resource[]|null', '&rw_except_fds'=>'resource[]|null', 'tv_sec'=>'int|null', 'tv_usec='=>'int|null'],
226235
'sodium_crypto_aead_chacha20poly1305_ietf_decrypt' => ['?string|?false', 'confidential_message'=>'string', 'public_message'=>'string', 'nonce'=>'string', 'key'=>'string'],
227236
'SplFileObject::fgetss' => ['string|false', 'allowable_tags='=>'string'],

tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php

+55-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function testCallToNonexistentFunction(): void
3535
'Function foobarNonExistentFunction not found.',
3636
5,
3737
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
38-
3938
],
4039
]);
4140
}
@@ -47,7 +46,6 @@ public function testCallToNonexistentNestedFunction(): void
4746
'Function barNonExistentFunction not found.',
4847
5,
4948
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
50-
5149
],
5250
]);
5351
}
@@ -97,6 +95,61 @@ public function testMatchExprAnalysis(): void
9795
]);
9896
}
9997

98+
public function testCallToRemovedFunctionsOnPhp8(): void
99+
{
100+
if (PHP_VERSION_ID < 80000) {
101+
$this->markTestSkipped('Test requires PHP 8.0.');
102+
}
103+
104+
$this->analyse([__DIR__ . '/data/removed-functions-from-php8.php'], [
105+
[
106+
'Function convert_cyr_string not found.',
107+
3,
108+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
109+
],
110+
[
111+
'Function ezmlm_hash not found.',
112+
4,
113+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
114+
],
115+
[
116+
'Function fgetss not found.',
117+
5,
118+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
119+
],
120+
[
121+
'Function get_magic_quotes_gpc not found.',
122+
6,
123+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
124+
],
125+
[
126+
'Function hebrevc not found.',
127+
7,
128+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
129+
],
130+
[
131+
'Function imap_header not found.',
132+
8,
133+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
134+
],
135+
[
136+
'Function ldap_control_paged_result not found.',
137+
9,
138+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
139+
],
140+
[
141+
'Function ldap_control_paged_result_response not found.',
142+
10,
143+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
144+
],
145+
[
146+
'Function restore_include_path not found.',
147+
11,
148+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
149+
],
150+
]);
151+
}
152+
100153
public function testCreateFunctionPhp8(): void
101154
{
102155
if (PHP_VERSION_ID < 80000) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
convert_cyr_string();
4+
ezmlm_hash();
5+
fgetss();
6+
get_magic_quotes_gpc();
7+
hebrevc();
8+
imap_header();
9+
ldap_control_paged_result();
10+
ldap_control_paged_result_response();
11+
restore_include_path();

0 commit comments

Comments
 (0)