-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed trait manipulator to avoid duplicate interface calls
- Loading branch information
1 parent
9a9f237
commit 4e52397
Showing
5 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
EntityGeneratorBundle/Doctrine/EntityTrait/GetReturnHint.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace IvozDevTools\EntityGeneratorBundle\Doctrine\EntityTrait; | ||
|
||
class GetReturnHint | ||
{ | ||
private array $useStatements; | ||
|
||
public function __construct( | ||
array $useStatements | ||
) | ||
{ | ||
$this->useStatements = $useStatements; | ||
} | ||
|
||
public function execute(string $returnHint): string | ||
{ | ||
$similarInterfaces = false; | ||
|
||
foreach (array_keys($this->useStatements) as $fqdn) { | ||
$parts = explode('\\', $fqdn); | ||
$lastValue = end($parts); | ||
|
||
if ($lastValue === $returnHint) { | ||
$similarInterfaces = true; | ||
break; | ||
} | ||
} | ||
|
||
if ($similarInterfaces) { | ||
$returnHint = 'static'; | ||
} | ||
|
||
return $returnHint; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters