Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/main/php/lang/FunctionType.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php namespace lang;

use Throwable as Any;

/**
* Represents function types
*
Expand Down Expand Up @@ -79,7 +81,7 @@ public function literal(): string {
*/
protected function verify($r, $signature, $false, $class= null) {
if ($class) {
$details= XPClass::detailsForMethod($class, $r->getName());
$details= XPClass::detailsForClass(XPClass::nameOf($class->name))[1][$r->name] ?? null;
$resolve= [
'static' => function() use($class) { return new XPClass($class); },
'self' => function() use($class) { return new XPClass($class); },
Expand Down Expand Up @@ -303,7 +305,7 @@ public function isAssignableFrom($type): bool {
* @param var[] $args
* @return var
* @throws lang.IllegalArgumentException in case the passed function is not an instance of this type
* @throws lang.reflect.TargetInvocationException for any exception raised from the invoked function
* @throws lang.Throwable for any exception raised from the invoked function
*/
public function invoke($func, $args= []) {
$closure= $this->verified($func, function($m) use($func) { throw new IllegalArgumentException(sprintf(
Expand All @@ -314,8 +316,8 @@ public function invoke($func, $args= []) {
)); });
try {
return $closure(...$args);
} catch (Throwable $e) {
throw new \lang\reflect\TargetInvocationException($this->getName(), $e);
} catch (Any $e) {
throw Throwable::wrap($e);
}
}
}
3 changes: 2 additions & 1 deletion src/main/php/lang/GenericTypes.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function newType(XPClass $base, array $arguments) {
public function newType0($base, $arguments) {

// Verify
$annotations= $base->getAnnotations();
$details= XPClass::detailsForClass($base->getName());
$annotations= $details ? $details['class'][DETAIL_ANNOTATIONS] : [];
if (!isset($annotations['generic']['self'])) {
throw new IllegalStateException('Class '.$base->name.' is not a generic definition');
}
Expand Down
Loading