From a55f87cd0a67e190d319684209e004ae8de0d0cc Mon Sep 17 00:00:00 2001 From: Sebastian Blank Date: Wed, 21 Dec 2022 17:14:54 +0100 Subject: [PATCH] PhpStan: Remove ignored error pattern from baseline file (#13870) * PhpStan: Remove ignored error pattern from baseline file * Fix PhpStan error --- lib/Tool/Text/Csv.php | 17 ++++++----------- phpstan-baseline.neon | 7 +------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/Tool/Text/Csv.php b/lib/Tool/Text/Csv.php index 3733a59367f..7854b7e374f 100644 --- a/lib/Tool/Text/Csv.php +++ b/lib/Tool/Text/Csv.php @@ -24,10 +24,6 @@ class Csv { /** - * @param string $data - * - * @return \stdClass - * * @throws \Exception */ public function detect(string $data): \stdClass @@ -60,10 +56,6 @@ public function detect(string $data): \stdClass } /** - * @param string $data - * - * @return string - * * @phpstan-return non-empty-string */ protected function guessLinefeed(string $data): string @@ -79,10 +71,10 @@ protected function guessLinefeed(string $data): string return "$cr$lf"; } if ($count_cr == 0 && $count_lf > 0) { - return (string)$lf; + return $lf; } if ($count_lf == 0 && $count_cr > 0) { - return (string)$cr; + return $cr; } // sane default: cr+lf @@ -98,7 +90,7 @@ protected function guessQuoteAndDelim(string $data): array $patterns[] = '/(?:^|\n)(["\']).*?(\2)(?:$|\n)/'; foreach ($patterns as $pattern) { - if ($nummatches = preg_match_all($pattern, $data, $matches)) { + if (preg_match_all($pattern, $data, $matches)) { if ($matches) { break; } @@ -125,6 +117,9 @@ protected function guessQuoteAndDelim(string $data): array return [$quote, $delim]; } + /** + * @phpstan-param non-empty-string $linefeed + */ protected function guessDelim(string $data, string $linefeed, string $quotechar): bool|string { $charcount = count_chars($data, 1); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5d9ce1af46f..46cdbaf00b0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -135,11 +135,6 @@ parameters: count: 1 path: lib/Tool/Serialize.php - - - message: "#^Parameter \\#1 \\$separator of function explode expects non\\-empty\\-string, string given\\.$#" - count: 1 - path: lib/Tool/Text/Csv.php - - message: "#^Negated boolean expression is always true\\.$#" count: 1 @@ -193,4 +188,4 @@ parameters: - message: "#^Parameter \\#1 \\$children of method Pimcore\\\\Model\\\\Document\\:\\:setChildren\\(\\) expects array\\\\|null, array\\ given\\.$#" count: 1 - path: models/Document/Hardlink/Wrapper/Snippet.php \ No newline at end of file + path: models/Document/Hardlink/Wrapper/Snippet.php