Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit 09deef9

Browse files
authored
Merge pull request #42 from modulusphp/feature/exceptions-update
Feature/exceptions update
2 parents 3975da7 + 3dc160f commit 09deef9

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

Exceptions/CannotExtendClassException.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
class CannotExtendClassException extends Exception
88
{
9+
/**
10+
* __construct
11+
*
12+
* @param string $message
13+
* @return void
14+
*/
915
public function __construct(string $message)
1016
{
1117
$args = debug_backtrace()[1];
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Modulus\Framework\Exceptions;
4+
5+
use Exception;
6+
7+
class ClassDoesNotExistException extends Exception
8+
{
9+
/**
10+
* __construct
11+
*
12+
* @param string $message
13+
* @return void
14+
*/
15+
public function __construct(string $message)
16+
{
17+
$args = debug_backtrace()[1];
18+
19+
foreach ($args as $key => $value) {
20+
$this->{$key} = $value;
21+
}
22+
23+
$this->message = $message;
24+
}
25+
}

Upstart/Prototype.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use ReflectionClass;
77
use Modulus\Support\Extendable;
88
use Modulus\Framework\Exceptions\CannotExtendClassException;
9+
use Modulus\Framework\Exceptions\ClassDoesNotExistException;
910

1011
class Prototype
1112
{
@@ -19,6 +20,8 @@ class Prototype
1920
*/
2021
public function bind(string $class, string $method, Closure $closure)
2122
{
23+
if (!class_exists($class)) throw new ClassDoesNotExistException("Class {$class} does not exist");
24+
2225
if (!in_array(
2326
Extendable::class,
2427
array_keys((new ReflectionClass($class))->getTraits()))
@@ -39,6 +42,8 @@ public function bind(string $class, string $method, Closure $closure)
3942
*/
4043
public function static(string $class, string $method, Closure $closure)
4144
{
45+
if (!class_exists($class)) throw new ClassDoesNotExistException("Class {$class} does not exist");
46+
4247
if (!in_array(
4348
Extendable::class,
4449
array_keys((new ReflectionClass($class))->getTraits()))

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "modulusphp/framework",
33
"description": "Framework component for Modulus",
4-
"version": "1.9.8.10",
4+
"version": "1.9.8.11",
55
"license": "MIT",
66
"type": "package",
77
"authors": [{

0 commit comments

Comments
 (0)