Skip to content

Commit

Permalink
Fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Riley Aven committed Aug 30, 2024
1 parent 4475691 commit b5b293d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ parameters:
paths:
- src
- config
- database
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
2 changes: 1 addition & 1 deletion src/Parsers/EnumParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __invoke(string $attribute, FluentSchema $schema, array $validat
[$rule, $args] = $ruleArgs;

if ($rule instanceof EnumRule) {
$enumType = invade($rule)->type;
$enumType = invade($rule)->type; /** @phpstan-ignore property.protected */

$reflection = new ReflectionClass($enumType);

Expand Down
1 change: 0 additions & 1 deletion src/Parsers/MiscPropertyParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class MiscPropertyParser implements \LaravelRulesToSchema\Contracts\RuleParser
{
public function __invoke(string $attribute, FluentSchema $schema, array $validationRules, array $nestedRuleset): array|FluentSchema|null
{
/** @var JsonSchemaType[] $schemaTypes */
$schemaTypes = $schema->getSchemaDTO()->type;

foreach ($validationRules as $ruleArgs) {
Expand Down
26 changes: 14 additions & 12 deletions src/Parsers/TypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TypeParser implements RuleParser
{
public function __invoke(string $attribute, FluentSchema $schema, array $validationRules, array $nestedRuleset): array|FluentSchema|null
{
foreach ($validationRules as $ruleArgs) {
foreach($validationRules as $ruleArgs) {
[$rule, $args] = $ruleArgs;

$ruleName = is_object($rule) ? get_class($rule) : $rule;
Expand Down Expand Up @@ -54,8 +54,10 @@ public function __invoke(string $attribute, FluentSchema $schema, array $validat

protected function parseInRule(FluentSchema $schema, mixed $ruleName, ?array $args): void
{
$values = null;

if (is_string($ruleName)) {
$values = array_map(function (mixed $value) {
$values = array_map(function(mixed $value) {
if (is_numeric($value)) {
if (ctype_digit($value)) {
return intval($value);
Expand All @@ -66,32 +68,32 @@ protected function parseInRule(FluentSchema $schema, mixed $ruleName, ?array $ar

return $value;
}, $args);
} else {
$values = invade($ruleName)->values;
} elseif ($ruleName instanceof InRule) {
$values = invade($ruleName)->values; /** @phpstan-ignore property.protected */
}

if (!$values) {
return;
}

$isString = true;
$isInt = true;
$isNumeric = true;

foreach ($values as $value) {
foreach($values as $value) {
if (is_string($value)) {
$isString = $isString && true;
$isInt = false;
$isNumeric = false;
}

if (is_int($value)) {

$isString = false;
$isInt = $isInt && true;
$isNumeric = false;
}

if (is_float($value)) {
$isString = false;
$isInt = false;
$isNumeric = $isNumeric && true;
$isString = false;
$isInt = false;
}
}

Expand All @@ -108,7 +110,7 @@ protected function parseInRule(FluentSchema $schema, mixed $ruleName, ?array $ar

protected function parseEnumRule(FluentSchema $schema, EnumRule $rule): void
{
$enumType = invade($rule)->type;
$enumType = invade($rule)->type; /** @phpstan-ignore property.protected */

$reflection = new ReflectionClass($enumType);

Expand Down
2 changes: 1 addition & 1 deletion src/ValidationRuleNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getRules(): array
}

/**
* @return array<string, array<string,array>>
* @return array<int, array<string|object,array>>
*/
protected function normalizeRuleset(array $rules): array
{
Expand Down

0 comments on commit b5b293d

Please sign in to comment.