Skip to content

Commit

Permalink
Apply php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzweifel authored and actions-user committed Feb 20, 2024
1 parent 699fd14 commit 5833b29
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/ClassesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function findAndLoadClasses(): Collection
ob_end_clean();

return collect(get_declared_classes())
->reject(static fn(string $className) => Str::startsWith($className, ['SwooleLibrary']));
->reject(static fn (string $className) => Str::startsWith($className, ['SwooleLibrary']));
}

/**
Expand All @@ -59,7 +59,7 @@ protected function findFilesInProjectPath(): Collection
*/
protected function isExcluded(SplFileInfo $file, Collection $excludes): bool
{
return $excludes->contains(static fn($exclude) => Str::startsWith($file->getPathname(), $exclude));
return $excludes->contains(static fn ($exclude) => Str::startsWith($file->getPathname(), $exclude));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Classifiers/MiddlewareClassifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private function getRouteMiddlewares(): array
$router = $reflection->getValue($this->httpKernel);

return collect($router->getRoutes()->getRoutes())
->map(static fn(Route $route) => $route->middleware())
->map(static fn (Route $route) => $route->middleware())
->flatten()
->unique()
->toArray();
Expand Down
6 changes: 3 additions & 3 deletions src/Classifiers/ObserverClassifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function name(): string
public function satisfies(ReflectionClass $class): bool
{
return collect($this->getEvents())
->filter(static fn($_listeners, $event) => Str::startsWith($event, 'eloquent.'))
->filter(static fn ($_listeners, $event) => Str::startsWith($event, 'eloquent.'))
->map(fn ($listeners) => collect($listeners)->map(fn ($closure) => $this->getEventListener($closure))->toArray())
->collapse()
->unique()
->filter(static fn($eventListener) => is_string($eventListener))
->filter(static fn(string $eventListenerSignature) => Str::contains($eventListenerSignature, $class->getName()))
->filter(static fn ($eventListener) => is_string($eventListener))
->filter(static fn (string $eventListenerSignature) => Str::contains($eventListenerSignature, $class->getName()))
->count() > 0;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Console/StatsListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public function handle(): void
// Remove Classes based on the RejectionStrategy
// Remove Classes based on the namespace
$reflectionClasses = $classes
->map(static fn($class) => new ReflectionClass($class))
->reject(static fn(ReflectionClass $class) => app(config('stats.rejection_strategy', RejectVendorClasses::class))
->map(static fn ($class) => new ReflectionClass($class))
->reject(static fn (ReflectionClass $class) => app(config('stats.rejection_strategy', RejectVendorClasses::class))
->shouldClassBeRejected($class))
->unique(static fn(ReflectionClass $class) => $class->getFileName())
->unique(static fn (ReflectionClass $class) => $class->getFileName())
->reject(static function (ReflectionClass $class) {
// Never discard anonymous database migrations
if (Str::contains($class->getName(), 'Migration@anonymous')) {
Expand Down
6 changes: 3 additions & 3 deletions src/Outputs/AsciiTableOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public function render(Project $project, bool $isVerbose = false, array $filterB
->setHeaders(['Name', 'Classes', 'Methods', 'Methods/Class', 'LoC', 'LLoC', 'LLoC/Method']);

// Render "Core" components
$this->renderComponents($table, $groupedByComponent->filter(static fn($_, $key) => $key !== 'Other' && ! Str::contains($key, 'Test')));
$this->renderComponents($table, $groupedByComponent->filter(static fn ($_, $key) => $key !== 'Other' && ! Str::contains($key, 'Test')));

// Render Test components
$this->renderComponents($table, $groupedByComponent->filter(static fn($_, $key) => Str::contains($key, 'Test')));
$this->renderComponents($table, $groupedByComponent->filter(static fn ($_, $key) => Str::contains($key, 'Test')));

// Render "Other" component
$this->renderComponents($table, $groupedByComponent->filter(static fn($_, $key) => $key === 'Other'));
$this->renderComponents($table, $groupedByComponent->filter(static fn ($_, $key) => $key === 'Other'));

$table->addRow(new TableSeparator);
$this->addTotalRow($table);
Expand Down
8 changes: 4 additions & 4 deletions src/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
private Collection $classes
) {
// Loop through ReflectionClasses and classify them.
$this->classifiedClasses = $this->classes->map(static fn(ReflectionClass $reflectionClass) => new ClassifiedClass(
$this->classifiedClasses = $this->classes->map(static fn (ReflectionClass $reflectionClass) => new ClassifiedClass(
$reflectionClass,
app(Classifier::class)->getClassifierForClassInstance($reflectionClass)
));
Expand All @@ -33,8 +33,8 @@ public function classifiedClasses(): Collection
public function classifiedClassesGroupedByComponentName(): Collection
{
return $this->classifiedClasses()
->groupBy(static fn(ClassifiedClass $classifiedClass) => $classifiedClass->classifier->name())
->sortBy(static fn($_, string $componentName) => $componentName);
->groupBy(static fn (ClassifiedClass $classifiedClass) => $classifiedClass->classifier->name())
->sortBy(static fn ($_, string $componentName) => $componentName);
}

public function classifiedClassesGroupedAndFilteredByComponentNames(array $componentNamesToFilter = []): Collection
Expand All @@ -44,7 +44,7 @@ public function classifiedClassesGroupedAndFilteredByComponentNames(array $compo
return $this->classifiedClassesGroupedByComponentName()
->when(
$shouldCollectionBeFiltered,
static fn(Collection $components) => $components->filter(static fn($_item, string $key) => in_array($key, $componentNamesToFilter))
static fn (Collection $components) => $components->filter(static fn ($_item, string $key) => in_array($key, $componentNamesToFilter))
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function isVendorProvided(): bool
public function usesTrait(string $name): bool
{
return collect($this->getTraits())
->contains(static fn(NativeReflectionClass $trait) => $trait->name == $name);
->contains(static fn (NativeReflectionClass $trait) => $trait->name == $name);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/Statistics/ProjectStatistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getNumberOfClasses(): int
public function getNumberOfMethods(): int
{
if ($this->numberOfMethods === null) {
$this->numberOfMethods = $this->project->classifiedClasses()->sum(static fn(ClassifiedClass $class) => $class->getNumberOfMethods());
$this->numberOfMethods = $this->project->classifiedClasses()->sum(static fn (ClassifiedClass $class) => $class->getNumberOfMethods());
}

return $this->numberOfMethods;
Expand All @@ -71,7 +71,7 @@ public function getNumberOfMethodsPerClass(): float
public function getLinesOfCode(): int
{
if ($this->linesOfCode === null) {
$this->linesOfCode = $this->project->classifiedClasses()->sum(static fn(ClassifiedClass $class) => $class->getLines());
$this->linesOfCode = $this->project->classifiedClasses()->sum(static fn (ClassifiedClass $class) => $class->getLines());
}

return $this->linesOfCode;
Expand All @@ -80,7 +80,7 @@ public function getLinesOfCode(): int
public function getLogicalLinesOfCode(): float
{
if ($this->logicalLinesOfCode === null) {
$this->logicalLinesOfCode = $this->project->classifiedClasses()->sum(static fn(ClassifiedClass $class) => $class->getLogicalLinesOfCode());
$this->logicalLinesOfCode = $this->project->classifiedClasses()->sum(static fn (ClassifiedClass $class) => $class->getLogicalLinesOfCode());
}

return $this->logicalLinesOfCode;
Expand All @@ -104,17 +104,17 @@ public function getLogicalLinesOfCodeForApplicationCode(): float
return $this
->project
->classifiedClasses()
->filter(static fn(ClassifiedClass $classifiedClass) => $classifiedClass->classifier->countsTowardsApplicationCode())
->sum(static fn(ClassifiedClass $class) => $class->getLogicalLinesOfCode());
->filter(static fn (ClassifiedClass $classifiedClass) => $classifiedClass->classifier->countsTowardsApplicationCode())
->sum(static fn (ClassifiedClass $class) => $class->getLogicalLinesOfCode());
}

public function getLogicalLinesOfCodeForTestCode(): float
{
return $this
->project
->classifiedClasses()
->filter(static fn(ClassifiedClass $classifiedClass) => $classifiedClass->classifier->countsTowardsTests())
->sum(static fn(ClassifiedClass $class) => $class->getLogicalLinesOfCode());
->filter(static fn (ClassifiedClass $classifiedClass) => $classifiedClass->classifier->countsTowardsTests())
->sum(static fn (ClassifiedClass $class) => $class->getLogicalLinesOfCode());
}

public function getApplicationCodeToTestCodeRatio(): float
Expand Down
4 changes: 2 additions & 2 deletions src/ValueObjects/ClassifiedClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getNumberOfPublicMethods(): int
{
if ($this->numberOfPublicMethods === null) {
$this->numberOfPublicMethods = $this->reflectionClass->getDefinedMethods()
->filter(static fn(ReflectionMethod $method) => $method->isPublic())->count();
->filter(static fn (ReflectionMethod $method) => $method->isPublic())->count();
}

return $this->numberOfPublicMethods;
Expand All @@ -83,7 +83,7 @@ public function getNumberOfNonPublicMethods(): int
{
if ($this->numberOfNonPublicMethods === null) {
$this->numberOfNonPublicMethods = $this->reflectionClass->getDefinedMethods()
->filter(static fn(ReflectionMethod $method) => ! $method->isPublic())->count();
->filter(static fn (ReflectionMethod $method) => ! $method->isPublic())->count();
}

return $this->numberOfNonPublicMethods;
Expand Down
10 changes: 5 additions & 5 deletions src/ValueObjects/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getNumberOfClasses(): int
public function getNumberOfMethods(): int
{
if ($this->numberOfMethods === null) {
$this->numberOfMethods = $this->classifiedClasses->sum(static fn(ClassifiedClass $class) => $class->getNumberOfMethods());
$this->numberOfMethods = $this->classifiedClasses->sum(static fn (ClassifiedClass $class) => $class->getNumberOfMethods());
}

return $this->numberOfMethods;
Expand All @@ -73,7 +73,7 @@ public function getNumberOfMethods(): int
public function getNumberOfPublicMethods(): int
{
if ($this->numberOfPublicMethods === null) {
$this->numberOfPublicMethods = $this->classifiedClasses->sum(static fn(ClassifiedClass $class) => $class->getNumberOfPublicMethods());
$this->numberOfPublicMethods = $this->classifiedClasses->sum(static fn (ClassifiedClass $class) => $class->getNumberOfPublicMethods());
}

return $this->numberOfPublicMethods;
Expand All @@ -82,7 +82,7 @@ public function getNumberOfPublicMethods(): int
public function getNumberOfNonPublicMethods(): int
{
if ($this->numberOfNonPublicMethods === null) {
$this->numberOfNonPublicMethods = $this->classifiedClasses->sum(static fn(ClassifiedClass $class) => $class->getNumberOfNonPublicMethods());
$this->numberOfNonPublicMethods = $this->classifiedClasses->sum(static fn (ClassifiedClass $class) => $class->getNumberOfNonPublicMethods());
}

return $this->numberOfNonPublicMethods;
Expand All @@ -100,7 +100,7 @@ public function getNumberOfMethodsPerClass(): float
public function getLinesOfCode(): int
{
if ($this->linesOfCode === null) {
$this->linesOfCode = $this->classifiedClasses->sum(static fn(ClassifiedClass $class) => $class->getLines());
$this->linesOfCode = $this->classifiedClasses->sum(static fn (ClassifiedClass $class) => $class->getLines());
}

return $this->linesOfCode;
Expand All @@ -109,7 +109,7 @@ public function getLinesOfCode(): int
public function getLogicalLinesOfCode(): float
{
if ($this->logicalLinesOfCode === null) {
$this->logicalLinesOfCode = $this->classifiedClasses->sum(static fn(ClassifiedClass $class) => $class->getLogicalLinesOfCode());
$this->logicalLinesOfCode = $this->classifiedClasses->sum(static fn (ClassifiedClass $class) => $class->getLogicalLinesOfCode());
}

return $this->logicalLinesOfCode;
Expand Down
2 changes: 1 addition & 1 deletion tests/Classifiers/MiddlewareClassifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MiddlewareClassifierTest extends TestCase
*/
protected function usesMiddlewareRoutes($router)
{
$router->get('/demo', static fn() => 'Hello World')->middleware(DemoMiddleware::class);
$router->get('/demo', static fn () => 'Hello World')->middleware(DemoMiddleware::class);
}

#[Test]
Expand Down
2 changes: 1 addition & 1 deletion tests/ProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function creates_a_project_object_from_a_collection_of_reflection_classes
$project = new Project($classes);

$this->assertTrue(
$project->classifiedClasses()->map(static fn($class) => $class->reflectionClass)->contains($projectModel)
$project->classifiedClasses()->map(static fn ($class) => $class->reflectionClass)->contains($projectModel)
);
$this->assertInstanceOf(ClassifiedClass::class, $project->classifiedClasses()->first());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function resolveApplicationHttpKernel($app)
public function createProjectFromClasses(array $classes = [])
{
$classes = collect($classes)
->map(static fn($class) => new ReflectionClass($class));
->map(static fn ($class) => new ReflectionClass($class));

return new Project($classes);
}
Expand Down

0 comments on commit 5833b29

Please sign in to comment.