Skip to content

Commit

Permalink
Fix code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Jan 17, 2025
1 parent 4bfaba8 commit 08d66dd
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@
'CodeIgniter 4 framework',
'CodeIgniter Foundation',
'admin@codeigniter.com',
2023
2023,
);
2 changes: 1 addition & 1 deletion src/ComposerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private static function recursiveDelete(string $directory): void
/** @var SplFileInfo $file */
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(rtrim($directory, '\\/'), FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
RecursiveIteratorIterator::CHILD_FIRST,
) as $file) {
$path = $file->getPathname();

Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Classes/FrameworkExceptionInstantiationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function processNode(Node $node, Scope $scope): array

return [RuleErrorBuilder::message(sprintf(
'Instantiating %s using new is not allowed. Use one of its named constructors instead.',
$objectType->getClassReflection()->getNativeReflection()->getShortName()
$objectType->getClassReflection()->getNativeReflection()->getShortName(),
))->identifier('codeigniter.frameworkExceptionInstance')->build()];
}
}
10 changes: 5 additions & 5 deletions src/Rules/Functions/FactoriesFunctionArgumentTypeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
private readonly ReflectionProvider $reflectionProvider,
private readonly FactoriesReturnTypeHelper $factoriesReturnTypeHelper,
bool $checkArgumentTypeOfConfig,
bool $checkArgumentTypeOfModel
bool $checkArgumentTypeOfModel,
) {
$this->argumentTypeCheck = [
'config' => $checkArgumentTypeOfConfig,
Expand Down Expand Up @@ -93,7 +93,7 @@ public function processNode(Node $node, Scope $scope): array
$firstParameter = ParametersAcceptorSelector::selectFromArgs(
$scope,
$node->getArgs(),
$this->reflectionProvider->getFunction($nameNode, $scope)->getVariants()
$this->reflectionProvider->getFunction($nameNode, $scope)->getVariants(),
)->getParameters()[0];

if ($returnType->isNull()->yes()) {
Expand All @@ -102,7 +102,7 @@ public function processNode(Node $node, Scope $scope): array
$ruleErrorBuilder->addTip(sprintf(
'If %s is a valid class string, you can add its possible namespace(s) in <fg=cyan>codeigniter.additional%sNamespaces</> in your <fg=yellow>%%configurationFile%%</>.',
$constantStringType->describe(VerbosityLevel::precise()),
ucfirst($function)
ucfirst($function),
));
}

Expand All @@ -113,7 +113,7 @@ public function processNode(Node $node, Scope $scope): array
'Parameter #1 $%s of function %s expects a valid class string, %s given.',
$firstParameter->getName(),
$function,
$nameType->describe(VerbosityLevel::precise())
$nameType->describe(VerbosityLevel::precise()),
)))->identifier(sprintf('codeigniter.%sArgumentType', $function))->build()];
}

Expand All @@ -127,7 +127,7 @@ public function processNode(Node $node, Scope $scope): array
$firstParameter->getName(),
$nameType->describe(VerbosityLevel::precise()),
$function,
addcslashes($this->instanceofMap[$function], '\\')
addcslashes($this->instanceofMap[$function], '\\'),
))->identifier(sprintf('codeigniter.%sArgumentInstanceof', $function))->build()];
}

Expand Down
6 changes: 3 additions & 3 deletions src/Rules/Functions/NoClassConstFetchOnFactoriesFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class NoClassConstFetchOnFactoriesFunctions implements Rule

public function __construct(
private readonly ReflectionProvider $reflectionProvider,
private readonly FactoriesReturnTypeHelper $factoriesReturnTypeHelper
private readonly FactoriesReturnTypeHelper $factoriesReturnTypeHelper,
) {}

public function getNodeType(): string
Expand Down Expand Up @@ -120,11 +120,11 @@ public function processNode(Node $node, Scope $scope): array
RuleErrorBuilder::message(sprintf(
'Call to function %s with %s::class is discouraged.',
$function,
$reflection->getDisplayName()
$reflection->getDisplayName(),
))->tip(sprintf(
'Use %s(\'%s\') instead to allow overriding.',
$function,
$reflection->getNativeReflection()->getShortName()
$reflection->getNativeReflection()->getShortName(),
))->identifier('codeigniter.factoriesClassConstFetch')->build(),
];
}
Expand Down
8 changes: 4 additions & 4 deletions src/Rules/Functions/ServicesFunctionArgumentTypeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class ServicesFunctionArgumentTypeRule implements Rule
{
public function __construct(
private readonly ReflectionProvider $reflectionProvider,
private readonly ServicesReturnTypeHelper $servicesReturnTypeHelper
private readonly ServicesReturnTypeHelper $servicesReturnTypeHelper,
) {}

public function getNodeType(): string
Expand Down Expand Up @@ -96,14 +96,14 @@ public function processNode(Node $node, Scope $scope): array
$hasMethod = array_reduce(
$this->servicesReturnTypeHelper->getServicesReflection(),
static fn (bool $carry, ClassReflection $service): bool => $carry || $service->hasMethod($trimmedName),
false
false,
);

if (! $returnType->isNull()->yes() || $hasMethod) {
return [RuleErrorBuilder::message(sprintf(
'Service method %s expected to return a service instance, got %s instead.',
$name,
$returnType->describe(VerbosityLevel::precise())
$returnType->describe(VerbosityLevel::precise()),
))->identifier('codeigniter.serviceNonObjectReturn')->build()];
}

Expand All @@ -121,7 +121,7 @@ public function processNode(Node $node, Scope $scope): array

return [$addTip(RuleErrorBuilder::message(sprintf(
'Call to unknown service method %s.',
$nameType->describe(VerbosityLevel::precise())
$nameType->describe(VerbosityLevel::precise()),
)))->identifier('codeigniter.unknownServiceMethod')->build()];
}
}
2 changes: 1 addition & 1 deletion src/Rules/Superglobals/SuperglobalAccessRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
final class SuperglobalAccessRule implements Rule
{
public function __construct(
private readonly SuperglobalRuleHelper $superglobalRuleHelper
private readonly SuperglobalRuleHelper $superglobalRuleHelper,
) {}

public function getNodeType(): string
Expand Down
4 changes: 2 additions & 2 deletions src/Rules/Superglobals/SuperglobalAssignRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
final class SuperglobalAssignRule implements Rule
{
public function __construct(
private readonly SuperglobalRuleHelper $superglobalRuleHelper
private readonly SuperglobalRuleHelper $superglobalRuleHelper,
) {}

public function getNodeType(): string
Expand Down Expand Up @@ -108,7 +108,7 @@ private function processArrayDimFetch(Node $node, Scope $scope): array
'Use \\Config\\Services::superglobals()->%s(%s, %s) instead.',
$method,
$dimString->describe(VerbosityLevel::precise()),
$exprString->describe(VerbosityLevel::precise())
$exprString->describe(VerbosityLevel::precise()),
));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/FactoriesFunctionReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
final class FactoriesFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension
{
public function __construct(
private readonly FactoriesReturnTypeHelper $factoriesReturnTypeHelper
private readonly FactoriesReturnTypeHelper $factoriesReturnTypeHelper,
) {}

public function isFunctionSupported(FunctionReflection $functionReflection): bool
Expand All @@ -40,7 +40,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,

return $this->factoriesReturnTypeHelper->check(
$scope->getType($arguments[0]->value),
$functionReflection->getName()
$functionReflection->getName(),
);
}
}
2 changes: 1 addition & 1 deletion src/Type/FactoriesReturnTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class FactoriesReturnTypeHelper
public function __construct(
private readonly ReflectionProvider $reflectionProvider,
array $additionalConfigNamespaces,
array $additionalModelNamespaces
array $additionalModelNamespaces,
) {
$cb = static fn (string $item): string => rtrim($item, '\\') . '\\';

Expand Down
12 changes: 6 additions & 6 deletions src/Type/ModelFetchedReturnTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class ModelFetchedReturnTypeHelper
*/
public function __construct(
private readonly ReflectionProvider $reflectionProvider,
array $notStringFormattedFieldsArray
array $notStringFormattedFieldsArray,
) {
foreach ($notStringFormattedFieldsArray as $field => $type) {
if (! isset(self::$typeInterpolations[$type])) {
Expand Down Expand Up @@ -101,7 +101,7 @@ private function getArrayReturnType(ClassReflection $classReflection, Scope $sco
{
$this->fillDateFields($classReflection, $scope);
$fieldsTypes = $scope->getType(
$classReflection->getNativeProperty('allowedFields')->getNativeReflection()->getDefaultValueExpression()
$classReflection->getNativeProperty('allowedFields')->getNativeReflection()->getDefaultValueExpression(),
)->getConstantArrays();

if ($fieldsTypes === []) {
Expand All @@ -111,9 +111,9 @@ private function getArrayReturnType(ClassReflection $classReflection, Scope $sco
$fields = array_filter(
array_map(
static fn (Type $type) => current($type->getConstantStrings()),
current($fieldsTypes)->getValueTypes()
current($fieldsTypes)->getValueTypes(),
),
static fn (ConstantStringType|false $constantStringType): bool => $constantStringType !== false
static fn (ConstantStringType|false $constantStringType): bool => $constantStringType !== false,
);

return new ConstantArrayType(
Expand All @@ -135,7 +135,7 @@ private function getArrayReturnType(ClassReflection $classReflection, Scope $sco
}

return new StringType();
}, $fields)
}, $fields),
);
}

Expand All @@ -156,7 +156,7 @@ private function getNativeStringPropertyValue(ClassReflection $classReflection,

return $this->getStringValueFromExpr(
$classReflection->getNativeProperty($property)->getNativeReflection()->getDefaultValueExpression(),
$scope
$scope,
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Type/ModelFindReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
final class ModelFindReturnTypeExtension implements DynamicMethodReturnTypeExtension
{
public function __construct(
private readonly ModelFetchedReturnTypeHelper $modelFetchedReturnTypeHelper
private readonly ModelFetchedReturnTypeHelper $modelFetchedReturnTypeHelper,
) {}

public function getClass(): string
Expand Down Expand Up @@ -96,7 +96,7 @@ function (Type $idType, callable $traverse) use ($methodCall, $scope): Type {
}

return $this->getTypeFromFindAll($methodCall, $scope);
}
},
);
}

Expand All @@ -107,9 +107,9 @@ private function getTypeFromFindAll(MethodCall $methodCall, Scope $scope): Type
return TypeCombinator::intersect(
new ArrayType(
new IntegerType(),
$this->modelFetchedReturnTypeHelper->getFetchedReturnType($classReflection, $methodCall, $scope)
$this->modelFetchedReturnTypeHelper->getFetchedReturnType($classReflection, $methodCall, $scope),
),
new AccessoryArrayListType()
new AccessoryArrayListType(),
);
}
}
2 changes: 1 addition & 1 deletion src/Type/ServicesFunctionReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
final class ServicesFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension
{
public function __construct(
private readonly ServicesReturnTypeHelper $servicesReturnTypeHelper
private readonly ServicesReturnTypeHelper $servicesReturnTypeHelper,
) {}

public function isFunctionSupported(FunctionReflection $functionReflection): bool
Expand Down
4 changes: 2 additions & 2 deletions src/Type/ServicesReturnTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class ServicesReturnTypeHelper
*/
public function __construct(
private readonly ReflectionProvider $reflectionProvider,
array $additionalServices
array $additionalServices,
) {
$this->services = [
FrameworkServices::class,
Expand Down Expand Up @@ -105,7 +105,7 @@ public function check(Type $type, Scope $scope): Type
return ParametersAcceptorSelector::selectFromArgs(
$scope,
[],
$methodReflection->getVariants()
$methodReflection->getVariants(),
)->getReturnType();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function getRule(): Rule
self::createReflectionProvider(),
self::getContainer()->getByType(FactoriesReturnTypeHelper::class),
$this->checkArgumentTypeOfConfig,
$this->checkArgumentTypeOfModel
$this->checkArgumentTypeOfModel,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function getRule(): Rule
{
return new NoClassConstFetchOnFactoriesFunctions(
self::createReflectionProvider(),
self::getContainer()->getByType(FactoriesReturnTypeHelper::class)
self::getContainer()->getByType(FactoriesReturnTypeHelper::class),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function getRule(): Rule
{
return new ServicesFunctionArgumentTypeRule(
self::createReflectionProvider(),
self::getContainer()->getByType(ServicesReturnTypeHelper::class)
self::getContainer()->getByType(ServicesReturnTypeHelper::class),
);
}

Expand Down

0 comments on commit 08d66dd

Please sign in to comment.