diff --git a/src/Infer/Handler/FunctionLikeHandler.php b/src/Infer/Handler/FunctionLikeHandler.php index 6b9eba90..c1dbd1c3 100644 --- a/src/Infer/Handler/FunctionLikeHandler.php +++ b/src/Infer/Handler/FunctionLikeHandler.php @@ -49,6 +49,7 @@ public function enter(FunctionLike $node, Scope $scope) $scope->context->setFunctionDefinition($fnDefinition = new FunctionLikeDefinition( type: $fnType = new FunctionType($node->name->name ?? 'anonymous'), sideEffects: [], + definingClassName: $scope->context->classDefinition?->name, isStatic: $node instanceof Node\Stmt\ClassMethod ? $node->isStatic() : false, )); $fnDefinition->isFullyAnalyzed = true; diff --git a/src/Support/OperationExtensions/ParameterExtractor/MethodCallsParametersExtractor.php b/src/Support/OperationExtensions/ParameterExtractor/MethodCallsParametersExtractor.php index 3a064551..807bce3f 100644 --- a/src/Support/OperationExtensions/ParameterExtractor/MethodCallsParametersExtractor.php +++ b/src/Support/OperationExtensions/ParameterExtractor/MethodCallsParametersExtractor.php @@ -11,14 +11,7 @@ class MethodCallsParametersExtractor implements ParameterExtractor public function handle(RouteInfo $routeInfo, array $parameterExtractionResults): array { $extractedParameters = new ParametersExtractionResult( - parameters: array_map( - function (Parameter $p) { - $p->setAttribute('isFromMethodCall', true); - - return $p; - }, - array_values($routeInfo->requestParametersFromCalls->data), - ), + parameters: array_values($routeInfo->requestParametersFromCalls->data), ); $previouslyExtractedParameters = collect($parameterExtractionResults)->flatMap->parameters->keyBy('name'); diff --git a/src/Support/Type/TypeHelper.php b/src/Support/Type/TypeHelper.php index 5cd06cc2..e27c8fb4 100644 --- a/src/Support/Type/TypeHelper.php +++ b/src/Support/Type/TypeHelper.php @@ -153,6 +153,13 @@ public static function createTypeFromValue(mixed $value) return new LiteralBooleanType($value); } + if (is_array($value)) { + return new KeyedArrayType(array_map( + fn ($key) => new ArrayItemType_($key, static::createTypeFromValue($value[$key])), + array_keys($value), + )); + } + return null; // @todo: object }