Skip to content

Commit

Permalink
PhpStan: Remove ignored error pattern from baseline file (pimcore#13870)
Browse files Browse the repository at this point in the history
* PhpStan: Remove ignored error pattern from baseline file

* Fix PhpStan error
  • Loading branch information
blankse authored Dec 21, 2022
1 parent 51c29d5 commit a55f87c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
17 changes: 6 additions & 11 deletions lib/Tool/Text/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
class Csv
{
/**
* @param string $data
*
* @return \stdClass
*
* @throws \Exception
*/
public function detect(string $data): \stdClass
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -193,4 +188,4 @@ parameters:
-
message: "#^Parameter \\#1 \\$children of method Pimcore\\\\Model\\\\Document\\:\\:setChildren\\(\\) expects array\\<Pimcore\\\\Model\\\\Document\\>\\|null, array\\<int, Pimcore\\\\Model\\\\Document\\\\Hardlink\\\\Wrapper\\\\WrapperInterface\\> given\\.$#"
count: 1
path: models/Document/Hardlink/Wrapper/Snippet.php
path: models/Document/Hardlink/Wrapper/Snippet.php

0 comments on commit a55f87c

Please sign in to comment.