Skip to content

Commit

Permalink
Check all silenced errors for strict_types changes to error level
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Apr 26, 2024
1 parent 1283034 commit ebd67a5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
Binary file modified build/kint.phar
Binary file not shown.
10 changes: 8 additions & 2 deletions src/Parser/FsPathPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Kint\Zval\Representation\SplFileInfoRepresentation;
use Kint\Zval\Value;
use SplFileInfo;
use TypeError;

class FsPathPlugin extends AbstractPlugin
{
Expand Down Expand Up @@ -59,8 +60,13 @@ public function parse(&$var, Value &$o, int $trigger): void
return;
}

if (!@\file_exists($var)) {
return;
try {
if (!@\file_exists($var)) {
return;
}
} catch (TypeError $e) {// @codeCoverageIgnore
// Only possible in PHP 7
return; // @codeCoverageIgnore
}

if (\in_array($var, self::$blacklist, true)) {
Expand Down
4 changes: 3 additions & 1 deletion src/Zval/BlobValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ public static function detectEncoding(string $string)
if (\function_exists('iconv')) {
foreach (self::$legacy_encodings as $encoding) {
// Iconv detection works by triggering
// "Detected an illegal character in input string" warnings
// "Detected an illegal character in input string" notices
// This notice does not become a TypeError with strict_types
// so we don't have to wrap this in a try catch
if (@\iconv($encoding, $encoding, $string) === $string) {
return $encoding;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Parser/FsPathPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public function fsPathProvider()
'.',
false,
],
'nullinstring' => [
"/home/kint/invalid\0path/file.php",
false,
],
];
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Zval/BlobValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public function testDetectLegacyEncoding()
'UTF-8'
);
$this->assertSame('Windows-1251', BlobValue::detectEncoding($string));

$string = $string."\0".$string;
$this->assertFalse(BlobValue::detectEncoding($string));
}

/**
Expand Down

0 comments on commit ebd67a5

Please sign in to comment.