Skip to content

Commit df2b6e6

Browse files
Fix invalid condition in Typo3ClassNamingUtilityTrait (#59)
There have been multiple issues in the condition that does check if the given class does implement the RepositoryInterface when converting the repository name to a model name. 1. The condition was not negated 2. The attributes passed to "is_a()" where in the wrong or order. So the condition was totally broken and did not do what it should do.
1 parent df8c48a commit df2b6e6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Helpers/Typo3ClassNamingUtilityTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ trait Typo3ClassNamingUtilityTrait
1919
*/
2020
protected function translateRepositoryNameToModelName(string $repositoryClassName): string
2121
{
22-
if (is_a(RepositoryInterface::class, $repositoryClassName, true)) {
23-
throw new \PHPStan\ShouldNotHappenException('Repository class must implement RepositoryInterface');
22+
if (!is_a($repositoryClassName, RepositoryInterface::class, true)) {
23+
throw new \PHPStan\ShouldNotHappenException(
24+
sprintf('Repository class "%s" must implement "%s"', $repositoryClassName, RepositoryInterface::class)
25+
);
2426
}
25-
/** @var class-string<RepositoryInterface> $repositoryClassName */
26-
27-
/** @var class-string $modelName */
28-
$modelName = ClassNamingUtility::translateRepositoryNameToModelName($repositoryClassName);
29-
return $modelName;
27+
/** @var class-string $modelClass */
28+
$modelClass = ClassNamingUtility::translateRepositoryNameToModelName($repositoryClassName);
29+
return $modelClass;
3030
}
3131

3232
}

0 commit comments

Comments
 (0)