generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improved index builders * string type roll back * implemented setter calls analysis * added more stuff * upd formatting * remove unused var
- Loading branch information
1 parent
57bc523
commit 9e947b3
Showing
16 changed files
with
455 additions
and
31 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
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,33 @@ | ||
<?php | ||
|
||
namespace Dedoc\Scramble\Infer\Extensions; | ||
|
||
use Dedoc\Scramble\Support\IndexBuilders\Bag; | ||
use Dedoc\Scramble\Support\IndexBuilders\IndexBuilder; | ||
|
||
class IndexBuildingBroker | ||
{ | ||
public function __construct( | ||
public readonly array $indexBuilders = [], | ||
) {} | ||
|
||
public function getIndex(string $builderClassName): Bag | ||
{ | ||
foreach ($this->indexBuilders as $indexBuilder) { | ||
if (is_a($indexBuilder, $builderClassName)) { | ||
return $indexBuilder->bag; | ||
} | ||
} | ||
|
||
return new Bag; | ||
} | ||
|
||
public function handleEvent($event) | ||
{ | ||
foreach ($this->indexBuilders as $indexBuilder) { | ||
if ($indexBuilder instanceof IndexBuilder) { | ||
$indexBuilder->handleEvent($event); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Dedoc\Scramble\Infer\Services; | ||
|
||
use Dedoc\Scramble\Infer\Scope\Scope; | ||
use Dedoc\Scramble\Support\Type\Literal\LiteralStringType; | ||
use Dedoc\Scramble\Support\Type\TypeHelper; | ||
use Dedoc\Scramble\Support\Type\UnknownType; | ||
|
||
class ConstFetchTypeGetter | ||
{ | ||
public function __invoke(Scope $scope, string $className, string $constName) | ||
{ | ||
if ($constName === 'class') { | ||
return new LiteralStringType($className); | ||
} | ||
|
||
try { | ||
$constantReflection = new \ReflectionClassConstant($className, $constName); | ||
$constantValue = $constantReflection->getValue(); | ||
|
||
$type = TypeHelper::createTypeFromValue($constantValue); | ||
|
||
if ($type) { | ||
return $type; | ||
} | ||
} catch (\ReflectionException $e) { | ||
return new UnknownType('Cannot get const value'); | ||
} | ||
|
||
return new UnknownType('ConstFetchTypeGetter is not yet implemented fully for non-class const fetches.'); | ||
} | ||
} |
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
Oops, something went wrong.