Remove coding standard ruleset exclusion

This commit is contained in:
Zach Borboa
2023-02-26 11:00:53 -08:00
parent 54981b9a38
commit c6256e31b3
5 changed files with 25 additions and 14 deletions
+1 -1
View File
@@ -199,7 +199,7 @@ More examples are available under [/examples](https://github.com/php-curl-class/
Curl::__construct($base_url = null, $options = [])
Curl::__destruct()
Curl::__get($name)
Curl::_fastDownload($url, $filename, $connections = 4) {
Curl::_fastDownload($url, $filename, $connections = 4)
Curl::attemptRetry()
Curl::beforeSend($callback)
Curl::buildPostData($data)
+6 -3
View File
@@ -364,7 +364,8 @@ class Curl extends BaseCurl
*
* @return boolean
*/
public function _fastDownload($url, $filename, $connections = 4) {
public function _fastDownload($url, $filename, $connections = 4)
{
// First we need to retrive the 'Content-Length' header.
// Use GET because not all hosts support HEAD requests.
$this->setOpts([
@@ -2043,7 +2044,8 @@ class Curl extends BaseCurl
*
* @return callable
*/
function createHeaderCallback($header_callback_data) {
function createHeaderCallback($header_callback_data)
{
return function ($ch, $header) use ($header_callback_data) {
if (preg_match('/^Set-Cookie:\s*([^=]+)=([^;]+)/mi', $header, $cookie) === 1) {
$header_callback_data->responseCookies[$cookie[1]] = trim($cookie[2], " \n\r\t\0\x0B");
@@ -2072,7 +2074,8 @@ function createHeaderCallback($header_callback_data) {
*
* @return callable
*/
function createStopRequestFunction($header_callback_data) {
function createStopRequestFunction($header_callback_data)
{
return function (
$resource,
$download_size,
+16 -8
View File
@@ -83,7 +83,8 @@ class Test
}
}
function create_png() {
function create_png()
{
// PNG image data, 1 x 1, 1-bit colormap, non-interlaced
ob_start();
imagepng(imagecreatefromstring(base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', true)));
@@ -92,14 +93,16 @@ function create_png() {
return $raw_image;
}
function create_tmp_file($data) {
function create_tmp_file($data)
{
$tmp_file = tmpfile();
fwrite($tmp_file, $data);
rewind($tmp_file);
return $tmp_file;
}
function get_tmp_file_path() {
function get_tmp_file_path()
{
// Return temporary file path without creating file.
$tmp_file_path =
rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) .
@@ -107,20 +110,23 @@ function get_tmp_file_path() {
return $tmp_file_path;
}
function get_png() {
function get_png()
{
$tmp_filename = tempnam('/tmp', 'php-curl-class.');
file_put_contents($tmp_filename, create_png());
return $tmp_filename;
}
function mime_type($file_path) {
function mime_type($file_path)
{
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($finfo, $file_path);
finfo_close($finfo);
return $mime_type;
}
function upload_file_to_server($upload_file_path) {
function upload_file_to_server($upload_file_path)
{
$upload_test = new Test();
$upload_test->server('upload_response', 'POST', [
'image' => '@' . $upload_file_path,
@@ -136,7 +142,8 @@ function upload_file_to_server($upload_file_path) {
return $uploaded_file_path;
}
function remove_file_from_server($uploaded_file_path) {
function remove_file_from_server($uploaded_file_path)
{
$download_test = new Test();
// Ensure file successfully removed.
@@ -186,7 +193,8 @@ function get_request_stats($request_stats, $multi_curl)
return $request_stats;
}
function get_request_method($instance) {
function get_request_method($instance)
{
$request_method = $instance->getOpt(CURLOPT_CUSTOMREQUEST);
// POST requests have CURLOPT_CUSTOMREQUEST unset by default to allow
+2 -1
View File
@@ -4358,7 +4358,8 @@ class PHPCurlClassTest extends \PHPUnit\Framework\TestCase
$this->assertStringContainsString($expect, $test_5_output);
}
public function testStopRequest() {
public function testStopRequest()
{
$response_length_bytes = 1e6; // 1e6 = 1 megabyte
$stop_request_early = function ($ch, $header) {
-1
View File
@@ -11,7 +11,6 @@
<rule ref="PSR2">
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma" />
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.UseOneParamPerLine" />
<!-- TODO: Remove the following exclusion when Curl::_fastDownload() is renamed to Curl::fastDownload(). -->