c-harris /
ODataMetadata
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace AlgoWeb\ODataMetadata\Csdl\Internal\Semantics\BadElements; |
||
| 6 | |||
| 7 | use AlgoWeb\ODataMetadata\Edm\Validation\EdmError; |
||
| 8 | use AlgoWeb\ODataMetadata\Edm\Validation\EdmErrorCode; |
||
| 9 | use AlgoWeb\ODataMetadata\EdmUtil; |
||
| 10 | use AlgoWeb\ODataMetadata\Enums\SchemaElementKind; |
||
| 11 | use AlgoWeb\ODataMetadata\Helpers\SchemaElementHelpers; |
||
| 12 | use AlgoWeb\ODataMetadata\Interfaces\IFunction; |
||
| 13 | use AlgoWeb\ODataMetadata\Interfaces\IFunctionParameter; |
||
| 14 | use AlgoWeb\ODataMetadata\Interfaces\ILocation; |
||
| 15 | use AlgoWeb\ODataMetadata\Interfaces\ITypeReference; |
||
| 16 | use AlgoWeb\ODataMetadata\Library\Internal\Bad\BadElement; |
||
| 17 | use AlgoWeb\ODataMetadata\Library\Internal\Bad\BadType; |
||
| 18 | use AlgoWeb\ODataMetadata\Library\Internal\Bad\BadTypeReference; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Represents information about an EDM function that failed to resolve. |
||
| 22 | * |
||
| 23 | * @package AlgoWeb\ODataMetadata\Csdl\Internal\Semantics\BadElements |
||
| 24 | */ |
||
| 25 | class UnresolvedFunction extends BadElement implements IFunction, IUnresolvedElement |
||
| 26 | { |
||
| 27 | use SchemaElementHelpers; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | private $namespaceName; |
||
| 33 | /** |
||
| 34 | * @var string |
||
| 35 | */ |
||
| 36 | private $name; |
||
| 37 | /** |
||
| 38 | * @var ITypeReference |
||
| 39 | */ |
||
| 40 | private $returnType; |
||
| 41 | |||
| 42 | public function __construct(?string $qualifiedName, string $errorMessage, ILocation $location) |
||
| 43 | { |
||
| 44 | parent::__construct([new EdmError($location, EdmErrorCode::BadUnresolvedFunction(), $errorMessage)]); |
||
| 45 | //$this->qualifiedName = $qualifiedName ?? ''; |
||
| 46 | EdmUtil::tryGetNamespaceNameFromQualifiedName($qualifiedName, $this->namespaceName, $this->name); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 47 | $this->returnType = new BadTypeReference(new BadType($this->getErrors()), true); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return string|null gets the defining expression of this function |
||
| 52 | */ |
||
| 53 | public function getDefiningExpression(): ?string |
||
| 54 | { |
||
| 55 | return null; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Gets the return type of this function. |
||
| 60 | * |
||
| 61 | * @return ITypeReference |
||
| 62 | */ |
||
| 63 | public function getReturnType(): ITypeReference |
||
| 64 | { |
||
| 65 | return $this->returnType; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Gets the collection of parameters for this function. |
||
| 70 | * |
||
| 71 | * @return IFunctionParameter[]|null |
||
| 72 | */ |
||
| 73 | public function getParameters(): ?array |
||
| 74 | { |
||
| 75 | return []; |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Searches for a parameter with the given name, and returns null if no such parameter exists. |
||
| 80 | * |
||
| 81 | * @param string $name the name of the parameter being found |
||
| 82 | * @return IFunctionParameter|null the requested parameter or null if no such parameter exists |
||
| 83 | */ |
||
| 84 | public function findParameter(string $name): ?IFunctionParameter |
||
| 85 | { |
||
| 86 | return null; |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @return string|null gets the name of this element |
||
| 91 | */ |
||
| 92 | public function getName(): ?string |
||
| 93 | { |
||
| 94 | return $this->name; |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @return SchemaElementKind gets the kind of this schema element |
||
| 99 | */ |
||
| 100 | public function getSchemaElementKind(): SchemaElementKind |
||
| 101 | { |
||
| 102 | return SchemaElementKind::Function(); |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @return string|null gets the namespace this schema element belongs to |
||
| 107 | */ |
||
| 108 | public function getNamespace(): ?string |
||
| 109 | { |
||
| 110 | return $this->namespaceName; |
||
| 111 | } |
||
| 112 | } |
||
| 113 |