|
| 1 | +<?php declare(strict_types = 1); |
| 2 | + |
| 3 | +namespace CurlInitReturnTypeExtensionTestPhp8; |
| 4 | + |
| 5 | +use function PHPStan\Testing\assertType; |
| 6 | + |
| 7 | +function (string $unknownString) { |
| 8 | + assertType('CurlHandle', curl_init()); |
| 9 | + assertType('CurlHandle', curl_init('https://phpstan.org')); |
| 10 | + assertType('CurlHandle|false', curl_init($unknownString)); |
| 11 | + assertType('CurlHandle', curl_init(null)); |
| 12 | + assertType('CurlHandle', curl_init('')); |
| 13 | + assertType('CurlHandle', curl_init(':')); |
| 14 | + assertType('CurlHandle', curl_init('file://host/text.txt')); |
| 15 | + assertType('CurlHandle', curl_init('FIle://host/text.txt')); |
| 16 | + assertType('CurlHandle', curl_init('host/text.txt')); |
| 17 | + assertType('*NEVER*', curl_init("\0")); |
| 18 | + assertType('*NEVER*', curl_init("https://phpstan.org\0")); |
| 19 | + |
| 20 | + $url = 'https://phpstan.org'; |
| 21 | + if (rand(0,1)) $url = null; |
| 22 | + assertType('CurlHandle', curl_init($url)); |
| 23 | + |
| 24 | + $url = 'https://phpstan.org'; |
| 25 | + if (rand(0,1)) $url = 'https://phpstan.org/try'; |
| 26 | + assertType('CurlHandle', curl_init($url)); |
| 27 | + |
| 28 | + $url = 'https://phpstan.org'; |
| 29 | + if (rand(0,1)) $url = "\0"; |
| 30 | + assertType('CurlHandle', curl_init($url)); |
| 31 | + |
| 32 | + $url = 'https://phpstan.org'; |
| 33 | + if (rand(0,1)) $url = "https://phpstan.org\0"; |
| 34 | + assertType('CurlHandle', curl_init($url)); |
| 35 | + |
| 36 | + $url = 'https://phpstan.org'; |
| 37 | + if (rand(0,1)) $url = $unknownString; |
| 38 | + assertType('CurlHandle|false', curl_init($url)); |
| 39 | + |
| 40 | + $url = 'https://phpstan.org'; |
| 41 | + if (rand(0,1)) $url .= $unknownString; |
| 42 | + assertType('CurlHandle|false', curl_init($url)); |
| 43 | + |
| 44 | + $url = 'https://phpstan.org'; |
| 45 | + if (rand(0,1)) $url = ':'; |
| 46 | + assertType('CurlHandle', curl_init($url)); |
| 47 | + |
| 48 | + $url = 'https://phpstan.org'; |
| 49 | + if (rand(0,1)) $url = 'file://host/text.txt'; |
| 50 | + assertType('CurlHandle', curl_init($url)); |
| 51 | + |
| 52 | + $url = 'https://phpstan.org'; |
| 53 | + if (rand(0,1)) $url = 'FIle://host/text.txt'; |
| 54 | + assertType('CurlHandle', curl_init($url)); |
| 55 | + |
| 56 | + $url = 'https://phpstan.org'; |
| 57 | + if (rand(0,1)) $url = 'host/text.txt'; |
| 58 | + assertType('CurlHandle', curl_init($url)); |
| 59 | + |
| 60 | + $url = 'https://phpstan.org'; |
| 61 | + if (rand(0,1)) $url = 'file://host/text.txt'; |
| 62 | + if (rand(0,1)) $url = null; |
| 63 | + assertType('CurlHandle', curl_init($url)); |
| 64 | + |
| 65 | + $url = 'https://phpstan.org'; |
| 66 | + if (rand(0,1)) $url = null; |
| 67 | + if (rand(0,1)) $url = $unknownString; |
| 68 | + assertType('CurlHandle|false', curl_init($url)); |
| 69 | +}; |
0 commit comments