Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Aug 26, 2024
1 parent 2fdef47 commit ef44f28
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
29 changes: 29 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-7341-php-84.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php // lint >= 8.4

namespace Bug7341Php84;

use function PHPStan\Testing\assertType;

final class CsvWriterTerminate extends \php_user_filter
{
/**
* @param resource $in
* @param resource $out
* @param int $consumed
* @param bool $closing
*/
public function filter($in, $out, &$consumed, $closing): int
{
while ($bucket = stream_bucket_make_writeable($in)) {
assertType('StreamBucket', $bucket);

if (isset($this->params['terminate'])) {
$bucket->data = preg_replace('/([^\r])\n/', '$1'.$this->params['terminate'], $bucket->data);
}
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}

return \PSFS_PASS_ON;
}
}
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/nsrt/bug-7341.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint < 8.4

namespace Bug7341;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public function testValidRegexPatternAfter73(): void
if (PHP_VERSION_ID >= 80200) {
$messagePart = 'alphanumeric, backslash, or NUL';
}
if (PHP_VERSION_ID >= 80400) {
$messagePart = 'alphanumeric, backslash, or NUL byte';
}

$this->analyse(
[__DIR__ . '/data/valid-regex-pattern.php'],
Expand Down

0 comments on commit ef44f28

Please sign in to comment.