Skip to content

Commit

Permalink
Merge branch 'master' into test-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored Nov 28, 2024
2 parents d41c519 + 238a141 commit 8cef947
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[![Latest Version](https://poser.pugx.org/thecodingmachine/safe/v/stable.svg)](https://packagist.org/packages/thecodingmachine/safe)
[![Total Downloads](https://poser.pugx.org/thecodingmachine/safe/downloads.svg)](https://packagist.org/packages/thecodingmachine/safe)
[![License](https://poser.pugx.org/thecodingmachine/safe/license.svg)](https://packagist.org/packages/thecodingmachine/safe)
[![Build Status](https://travis-ci.org/thecodingmachine/safe.svg?branch=master)](https://travis-ci.org/thecodingmachine/safe)
[![Continuous Integration](https://github.com/thecodingmachine/safe/workflows/Continuous%20Integration/badge.svg)](https://github.com/thecodingmachine/safe/actions)
[![codecov](https://codecov.io/gh/thecodingmachine/safe/branch/master/graph/badge.svg)](https://codecov.io/gh/thecodingmachine/safe)

Expand Down
1 change: 1 addition & 0 deletions generator/config/CustomPhpStanFunctionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

return [
'base64_decode' => ['string|false', 'str'=>'string', 'strict='=>'bool'], // base64_decode returns false only in strict mode https://github.com/phpstan/phpstan-src/commit/cee66721266ae05f3cc052f82391d2645d74d55f
'password_hash' => ['string|false', 'password'=>'string', 'algo'=>'int|string|null', 'options='=>'array'],
'com_load_typelib' => ['bool', 'typelib_name'=>'string', 'case_insensitive='=>'bool'], // case_insensitive is a bool
'sem_get' => ['resource|false', 'key'=>'int', 'max_acquire='=>'int', 'perm='=>'int', 'auto_release='=>'bool'], // auto_release is a bool
Expand Down
2 changes: 1 addition & 1 deletion generator/src/PhpStanFunctions/PhpStanFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PhpStanFunction
public function __construct(array $signature)
{
if (count($signature) < 1) {
throw new \RuntimeException('Invalid signoatures');
throw new \RuntimeException('Invalid signatures');
}
$this->returnType = new PhpStanType(\array_shift($signature));
foreach ($signature as $name => $type) {
Expand Down
2 changes: 1 addition & 1 deletion generator/src/WritePhpFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private function displayParamsWithType(array $params): string
$paramsAsString[] = $paramAsString;
}

return implode(', ', $paramsAsString);
return str_replace('\\\\', '\\', implode(', ', $paramsAsString));
}

private function printFunctionCall(Method $function): string
Expand Down
6 changes: 2 additions & 4 deletions generator/tests/DocPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ public function testDetectFalsyFunction()
$pregMatch = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/pcre/functions/preg-match.xml');
$implode = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/strings/functions/implode.xml');
$getCwd = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/dir/functions/getcwd.xml');
$setTime = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/datetime/settime.xml');
$createFromFormat = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/datetime/createfromformat.xml');
$filesize = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/filesystem/functions/filesize.xml');
$mcryptDecrypt = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/mcrypt/functions/mcrypt-decrypt.xml');
$fsockopen = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/network/functions/fsockopen.xml');
$arrayReplace = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/array/functions/array-replace.xml');
$date = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/functions/date.xml');
$classImplement = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/spl/functions/class-implements.xml');
$getHeaders = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/url/functions/get-headers.xml');
$gzopen = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/zlib/functions/gzopen.xml');
Expand All @@ -25,12 +24,11 @@ public function testDetectFalsyFunction()
$this->assertTrue($pregMatch->detectFalsyFunction());
$this->assertFalse($implode->detectFalsyFunction());
$this->assertTrue($getCwd->detectFalsyFunction());
$this->assertTrue($setTime->detectFalsyFunction());
$this->assertTrue($createFromFormat->detectFalsyFunction());
$this->assertTrue($filesize->detectFalsyFunction());
$this->assertTrue($mcryptDecrypt->detectFalsyFunction());
$this->assertTrue($fsockopen->detectFalsyFunction());
$this->assertFalse($arrayReplace->detectFalsyFunction());
$this->assertTrue($date->detectFalsyFunction());
$this->assertTrue($classImplement->detectFalsyFunction());
$this->assertTrue($getHeaders->detectFalsyFunction());
$this->assertTrue($gzopen->detectFalsyFunction());
Expand Down
6 changes: 3 additions & 3 deletions lib/special_cases.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Wrapper for json_decode that throws when an error occurs.
*
* @param string $json JSON data to parse
* @param bool $assoc When true, returned objects will be converted
* @param bool $associative When true, returned objects will be converted
* into associative arrays.
* @param int<1, max> $depth User specified recursion depth.
* @param int $flags Bitmask of JSON decode options.
Expand All @@ -34,9 +34,9 @@
* @throws JsonException if the JSON cannot be decoded.
* @link http://www.php.net/manual/en/function.json-decode.php
*/
function json_decode(string $json, bool $assoc = false, int $depth = 512, int $flags = 0): mixed
function json_decode(string $json, bool $associative = false, int $depth = 512, int $flags = 0): mixed
{
$data = \json_decode($json, $assoc, $depth, $flags);
$data = \json_decode($json, $associative, $depth, $flags);
if (!($flags & JSON_THROW_ON_ERROR) && JSON_ERROR_NONE !== json_last_error()) {
throw JsonException::createFromPhpError();
}
Expand Down

0 comments on commit 8cef947

Please sign in to comment.