Skip to content

Commit

Permalink
Don't prevent checking for curl_init() false returns
Browse files Browse the repository at this point in the history
  • Loading branch information
tscni authored Sep 6, 2024
1 parent d9b4267 commit 3592cf0
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 275 deletions.
5 changes: 0 additions & 5 deletions conf/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1360,11 +1360,6 @@ services:
tags:
- phpstan.broker.dynamicFunctionReturnTypeExtension

-
class: PHPStan\Type\Php\CurlInitReturnTypeExtension
tags:
- phpstan.broker.dynamicFunctionReturnTypeExtension

-
class: PHPStan\Type\Php\DateFunctionReturnTypeHelper

Expand Down
2 changes: 1 addition & 1 deletion resources/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@
'curl_exec' => ['bool|string', 'ch'=>'resource'],
'curl_file_create' => ['CURLFile', 'filename'=>'string', 'mimetype='=>'string', 'postfilename='=>'string'],
'curl_getinfo' => ['mixed', 'ch'=>'resource', 'option='=>'int'],
'curl_init' => ['resource|false', 'url='=>'string'],
'curl_init' => ['__benevolent<resource|false>', 'url='=>'string'],
'curl_multi_add_handle' => ['int', 'mh'=>'resource', 'ch'=>'resource'],
'curl_multi_close' => ['void', 'mh'=>'resource'],
'curl_multi_errno' => ['int', 'mh'=>'resource'],
Expand Down
2 changes: 2 additions & 0 deletions resources/functionMap_php80delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'ceil' => ['float', 'number'=>'float'],
'com_load_typelib' => ['bool', 'typelib_name'=>'string', 'case_insensitive='=>'true'],
'count_chars' => ['array<int,int>|string', 'input'=>'string', 'mode='=>'int'],
'curl_init' => ['__benevolent<CurlHandle|false>', 'url='=>'string'],
'date_add' => ['DateTime', 'object'=>'DateTime', 'interval'=>'DateInterval'],
'date_date_set' => ['DateTime', 'object'=>'DateTime', 'year'=>'int', 'month'=>'int', 'day'=>'int'],
'date_diff' => ['DateInterval', 'obj1'=>'DateTimeInterface', 'obj2'=>'DateTimeInterface', 'absolute='=>'bool'],
Expand Down Expand Up @@ -169,6 +170,7 @@
'convert_cyr_string' => ['string', 'str'=>'string', 'from'=>'string', 'to'=>'string'],
'com_load_typelib' => ['bool', 'typelib_name'=>'string', 'case_insensitive='=>'bool'],
'count_chars' => ['array<int,int>|false|string', 'input'=>'string', 'mode='=>'int'],
'curl_init' => ['__benevolent<resource|false>', 'url='=>'string'],
'date_add' => ['DateTime|false', 'object'=>'DateTime', 'interval'=>'DateInterval'],
'date_date_set' => ['DateTime|false', 'object'=>'DateTime', 'year'=>'int', 'month'=>'int', 'day'=>'int'],
'date_diff' => ['DateInterval|false', 'obj1'=>'DateTimeInterface', 'obj2'=>'DateTimeInterface', 'absolute='=>'bool'],
Expand Down
102 changes: 0 additions & 102 deletions src/Type/Php/CurlInitReturnTypeExtension.php

This file was deleted.

6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,12 @@ public function testBug11511(): void
$this->assertSame('Access to an undefined property object::$bar.', $errors[0]->getMessage());
}

public function testBug11640(): void
{
$errors = $this->runAnalyse(__DIR__ . '/data/bug-11640.php');
$this->assertNoErrors($errors);
}

/**
* @param string[]|null $allAnalysedFiles
* @return Error[]
Expand Down
9 changes: 9 additions & 0 deletions tests/PHPStan/Analyser/data/bug-11640.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php declare(strict_types = 1);

namespace Bug11640;

$ch = curl_init('https://example.com');

if (!$ch) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PHPStan\Reflection\PassedByReference;
use PHPStan\Testing\PHPStanTestCase;
use PHPStan\Type\ArrayType;
use PHPStan\Type\BenevolentUnionType;
use PHPStan\Type\BooleanType;
use PHPStan\Type\CallableType;
use PHPStan\Type\ClassStringType;
Expand Down Expand Up @@ -59,7 +60,7 @@ public function dataFunctions(): array
'variadic' => false,
],
],
new UnionType([
new BenevolentUnionType([
new ObjectType('CurlHandle'),
new ConstantBooleanType(false),
]),
Expand Down
32 changes: 0 additions & 32 deletions tests/PHPStan/Type/Php/CurlInitReturnTypeExtensionTest.php

This file was deleted.

65 changes: 0 additions & 65 deletions tests/PHPStan/Type/Php/data/curl-init-php-7.php

This file was deleted.

69 changes: 0 additions & 69 deletions tests/PHPStan/Type/Php/data/curl-init-php-8.php

This file was deleted.

0 comments on commit 3592cf0

Please sign in to comment.