Skip to content

Commit

Permalink
PHPStan fixed!
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Smet committed Mar 10, 2024
1 parent ea82d7d commit b20e4eb
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/Csv/CsvFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public function getRecords(): iterable
return $this->reader->getRecords($this->getHeader());
}

// public function getRecordsChunk(int $offset = 0, int $limit = -1): \League\Csv\ResultSet
// {
// return Statement::create(null, $offset, $limit)->process($this->reader, $this->getHeader());
// }
public function getRecordsChunk(int $offset = 0, int $limit = -1): \League\Csv\TabularDataReader
{
return Statement::create(null, $offset, $limit)->process($this->reader, $this->getHeader());
}

public function validate(bool $quickStop = false): ErrorSuite
{
Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/IsDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function validateRule(?string $cellValue): ?string

$domainPattern = '/^(?!-)[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,})$/';

if (\preg_match($domainPattern, (string)$cellValue) === false) {
if (\preg_match($domainPattern, (string)$cellValue) === 0) {
return "Value \"{$cellValue}\" is not a valid domain";
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/IsFloat.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function validateRule(?string $cellValue): ?string
return null;
}

if (\preg_match('/^-?\d+(\.\d+)?$/', (string)$cellValue) === false) {
if (\preg_match('/^-?\d+(\.\d+)?$/', (string)$cellValue) === 0) {
return "Value \"{$cellValue}\" is not a float number";
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/IsInt.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function validateRule(?string $cellValue): ?string
return null;
}

if (\preg_match('/^-?\d+$/', (string)$cellValue) === false) {
if (\preg_match('/^-?\d+$/', (string)$cellValue) === 0) {
return "Value \"{$cellValue}\" is not an integer";
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/IsLatitude.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function validateRule(?string $cellValue): ?string
}

$result = parent::validateRule($cellValue);
if ($result !== '') {
if ($result !== null) {
return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/IsLongitude.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function validateRule(?string $cellValue): ?string
}

$result = parent::validateRule($cellValue);
if ($result !== '') {
if ($result !== null) {
return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/IsUuid4.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function validateRule(?string $cellValue): ?string

$uuid4 = '/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89ABab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/';

if (\preg_match($uuid4, (string)$cellValue) === false) {
if (\preg_match($uuid4, (string)$cellValue) === 0) {
return 'Value is not a valid UUID v4';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/Max.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Max extends IsFloat
public function validateRule(?string $cellValue): ?string
{
$result = parent::validateRule($cellValue);
if ($result !== '') {
if ($result !== null) {
return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/Min.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Min extends IsFloat
public function validateRule(?string $cellValue): ?string
{
$result = parent::validateRule($cellValue);
if ($result !== '') {
if ($result !== null) {
return $result;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Validators/Rules/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ final class Regex extends AbstarctRule
public function validateRule(?string $cellValue): ?string
{
$regex = Utils::prepareRegex($this->getOptionAsString());
if (\preg_match((string)$regex, (string)$cellValue) === false) {

if (\preg_match((string)$regex, (string)$cellValue) === 0) {
return "Value \"{$cellValue}\" does not match the pattern \"{$regex}\"";
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/Rules/UsaMarketName.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function validateRule(?string $cellValue): ?string
return null;
}

if (\preg_match('/^[A-Za-z0-9\s-]+, [A-Z]{2}$/u', (string)$cellValue) === false) {
if (\preg_match('/^[A-Za-z0-9\s-]+, [A-Z]{2}$/u', (string)$cellValue) === 0) {
return 'Invalid market name format for value "' . $cellValue . '". ' .
'Market name must have format "New York, NY"';
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Blueprint/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void
public function testUndefinedRule(): void
{
$this->expectExceptionMessage(
'Rule "undefined_rule" not found. Expected class: JBZoo\CsvBlueprint\Validators\Rules\UndefinedRule',
'Rule "undefined_rule" not found. Expected class: "JBZoo\CsvBlueprint\Validators\Rules\UndefinedRule"',
);
$csv = new CsvFile(self::CSV_COMPLEX, $this->getRule('seq', 'undefined_rule', true));
$csv->validate();
Expand Down

0 comments on commit b20e4eb

Please sign in to comment.