Skip to content

Commit 96fb9c2

Browse files
authored
Merge pull request #40 from artemmolotov/extra-info-for-error-message-callStatic
Add extra info for message when __callStatic used
2 parents 360efcf + ef656fb commit 96fb9c2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Exception/NotCallableException.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public static function fromInvalidCallable($value, bool $containerEntry = false)
1616
$message = sprintf('Instance of %s is not a callable', get_class($value));
1717
} elseif (is_array($value) && isset($value[0], $value[1])) {
1818
$class = is_object($value[0]) ? get_class($value[0]) : $value[0];
19-
$extra = method_exists($class, '__call') ? ' A __call() method exists but magic methods are not supported.' : '';
19+
20+
$extra = method_exists($class, '__call') || method_exists($class, '__callStatic')
21+
? ' A __call() or __callStatic() method exists but magic methods are not supported.'
22+
: '';
23+
2024
$message = sprintf('%s::%s() is not a callable.%s', $class, $value[1], $extra);
2125
} elseif ($containerEntry) {
2226
$message = var_export($value, true) . ' is neither a callable nor a valid container entry';

tests/InvokerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function cannot_invoke_unknown_method()
6868
*/
6969
public function cannot_invoke_magic_method()
7070
{
71-
$this->expectExceptionMessage('Invoker\Test\InvokerTestMagicMethodFixture::foo() is not a callable. A __call() method exists but magic methods are not supported.');
71+
$this->expectExceptionMessage('Invoker\Test\InvokerTestMagicMethodFixture::foo() is not a callable. A __call() or __callStatic() method exists but magic methods are not supported.');
7272
$this->expectException(NotCallableException::class);
7373
$this->invoker->call([new InvokerTestMagicMethodFixture, 'foo']);
7474
}

0 commit comments

Comments
 (0)