Skip to content

Commit 3cc28e5

Browse files
committed
FIX: removed get_headers from the ignore list
1 parent 5df7dbd commit 3cc28e5

File tree

7 files changed

+91
-69
lines changed

7 files changed

+91
-69
lines changed

generated/functionsList.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@
245245
'getprotobynumber',
246246
'getrusage',
247247
'getservbyport',
248+
'get_headers',
248249
'get_include_path',
249250
'get_meta_tags',
250251
'glob',

generated/pgsql.php

Lines changed: 57 additions & 66 deletions
Large diffs are not rendered by default.

generated/url.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,35 @@ function base64_decode(string $string, bool $strict = false): string
2828
}
2929

3030

31+
/**
32+
* get_headers returns an array with the headers sent
33+
* by the server in response to a HTTP request.
34+
*
35+
* @param string $url The target URL.
36+
* @param bool $associative If the optional associative parameter is set to true,
37+
* get_headers parses the response and sets the
38+
* array's keys.
39+
* @param resource $context A valid context resource created with
40+
* stream_context_create.
41+
* @return array Returns an indexed or associative array with the headers.
42+
* @throws UrlException
43+
*
44+
*/
45+
function get_headers(string $url, bool $associative = false, $context = null): array
46+
{
47+
error_clear_last();
48+
if ($context !== null) {
49+
$result = \get_headers($url, $associative, $context);
50+
} else {
51+
$result = \get_headers($url, $associative);
52+
}
53+
if ($result === false) {
54+
throw UrlException::createFromPhpError();
55+
}
56+
return $result;
57+
}
58+
59+
3160
/**
3261
* Opens filename and parses it line by line for
3362
* <meta> tags in the file. The parsing stops at

generator/config/ignoredFunctions.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@
1717
'filter_has_var', // this function is meant to return a boolean
1818
'array_multisort', // this function is too buggy, see PR #113 on GitHub
1919
'imagegrabwindow',
20-
'get_headers',
2120
];

generator/src/PhpStanFunctions/CustomPhpStanFunctionMap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
'imap_open' => ['resource|false', 'mailbox'=>'string', 'user'=>'string', 'password'=>'string', 'flags='=>'int', 'retries='=>'int', 'options=' => 'array'], //the last 3 parameters were renamed
1313
'imagerotate' => ['resource|false', 'src_im'=>'resource', 'angle'=>'float', 'bgdcolor'=>'int', 'ignoretransparent='=>'bool'], //ignoretransparent is a bool instead of a int
1414
'pg_pconnect' => ['resource|false', 'connection_string'=>'string', 'flags' => 'int'], //flags is an int instead of a string
15+
'get_headers' => ['array|false', 'url'=>'string', 'format='=>'bool', 'context='=>'resource'], // format is a bool instead of int
1516
];

generator/tests/DocPageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testDetectFalsyFunction()
2020
$date = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/functions/date.xml');
2121
$classImplement = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/spl/functions/class-implements.xml');
2222
$getHeaders = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/url/functions/get-headers.xml');
23-
$ldapSearch = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/ldap/functions/ldap-search.xml');
23+
//$ldapSearch = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/ldap/functions/ldap-search.xml');
2424

2525
$this->assertTrue($pregMatch->detectFalsyFunction());
2626
$this->assertFalse($implode->detectFalsyFunction());
@@ -34,7 +34,7 @@ public function testDetectFalsyFunction()
3434
$this->assertTrue($date->detectFalsyFunction());
3535
$this->assertTrue($classImplement->detectFalsyFunction());
3636
$this->assertTrue($getHeaders->detectFalsyFunction());
37-
$this->assertTrue($ldapSearch->detectFalsyFunction());
37+
//$this->assertTrue($ldapSearch->detectFalsyFunction());
3838
}
3939

4040
public function testDetectNullsyFunction()

rector-migrate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@
255255
'getprotobynumber' => 'Safe\getprotobynumber',
256256
'getrusage' => 'Safe\getrusage',
257257
'getservbyport' => 'Safe\getservbyport',
258+
'get_headers' => 'Safe\get_headers',
258259
'get_include_path' => 'Safe\get_include_path',
259260
'get_meta_tags' => 'Safe\get_meta_tags',
260261
'glob' => 'Safe\glob',

0 commit comments

Comments
 (0)