Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Sep 29, 2024
1 parent 60b7a7d commit b50a053
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions src/MethodCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public function compile(Expression $expr, CompilationContext $compilationContext
);
}

/*
/**
* Try to produce an exception if a method is called with a wrong number of parameters
* We only check extension parameters if methods are extension methods
* Internal methods may have invalid Reflection information
Expand Down Expand Up @@ -448,7 +448,7 @@ public function compile(Expression $expr, CompilationContext $compilationContext
}
}

/*
/**
* The method is checked in the first class that implements the method
* We could probably have collisions here
*/
Expand Down Expand Up @@ -497,45 +497,43 @@ public function compile(Expression $expr, CompilationContext $compilationContext
$this->reflection = $method;
}

/*
/**
* Transfer the return type-hint to the returned variable
*/
if ($isExpecting) {
if (isset($method)) {
if ($method instanceof Method) {
if ($method->isVoid()) {
throw new CompilerException(
sprintf(
"Method '%s::%s' is marked as '%s' and it does not return anything",
$classDefinition->getCompleteName(),
$expression['name'],
Types::T_VOID
),
$expression
);
}
if ($isExpecting && isset($method)) {
if ($method instanceof Method) {
if ($method->isVoid()) {
throw new CompilerException(
sprintf(
"Method '%s::%s' is marked as '%s' and it does not return anything",
$classDefinition->getCompleteName(),
$expression['name'],
Types::T_VOID
),
$expression
);
}

$returnClassTypes = $method->getReturnClassTypes();
$returnClassTypes = $method->getReturnClassTypes();

if (null !== $returnClassTypes) {
$symbolVariable->setDynamicTypes('object');
foreach ($returnClassTypes as &$returnClassType) {
$returnClassType = $compilationContext->getFullName($returnClassType);
}
$symbolVariable->setClassTypes($returnClassTypes);
if (null !== $returnClassTypes) {
$symbolVariable->setDynamicTypes('object');
foreach ($returnClassTypes as &$returnClassType) {
$returnClassType = $compilationContext->getFullName($returnClassType);
}
$symbolVariable->setClassTypes($returnClassTypes);
}

$returnTypes = $method->getReturnTypes();
if (null !== $returnTypes) {
foreach ($returnTypes as $dataType => $returnType) {
$symbolVariable->setDynamicTypes($dataType);
}
$returnTypes = $method->getReturnTypes();
if (null !== $returnTypes) {
foreach ($returnTypes as $dataType => $returnType) {
$symbolVariable->setDynamicTypes($dataType);
}
}
}
}

/*
/**
* Some parameters in internal methods receive parameters as references
*/
if (isset($expression['parameters'])) {
Expand All @@ -555,17 +553,17 @@ public function compile(Expression $expr, CompilationContext $compilationContext
}
}

/*
/**
* Include fcall header
*/
$compilationContext->headersManager->add('kernel/fcall');

/*
/**
* Call methods must grown the stack
*/
$compilationContext->symbolTable->mustGrownStack(true);

/*
/**
* Mark references
*/
$params = [];
Expand Down Expand Up @@ -597,7 +595,7 @@ public function compile(Expression $expr, CompilationContext $compilationContext
continue;
}

/*
/**
* If the passed parameter is different to the expected type we show a warning
*/
if ($resolvedTypes[$n] != $parameter['data-type']) {
Expand Down

0 comments on commit b50a053

Please sign in to comment.