Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
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
6 changes: 6 additions & 0 deletions Exceptions/CannotExtendClassException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

class CannotExtendClassException extends Exception
{
/**
* __construct
*
* @param string $message
* @return void
*/
public function __construct(string $message)
{
$args = debug_backtrace()[1];
Expand Down
25 changes: 25 additions & 0 deletions Exceptions/ClassDoesNotExistException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Modulus\Framework\Exceptions;

use Exception;

class ClassDoesNotExistException extends Exception
{
/**
* __construct
*
* @param string $message
* @return void
*/
public function __construct(string $message)
{
$args = debug_backtrace()[1];

foreach ($args as $key => $value) {
$this->{$key} = $value;
}

$this->message = $message;
}
}
5 changes: 5 additions & 0 deletions Upstart/Prototype.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use ReflectionClass;
use Modulus\Support\Extendable;
use Modulus\Framework\Exceptions\CannotExtendClassException;
use Modulus\Framework\Exceptions\ClassDoesNotExistException;

class Prototype
{
Expand All @@ -19,6 +20,8 @@ class Prototype
*/
public function bind(string $class, string $method, Closure $closure)
{
if (!class_exists($class)) throw new ClassDoesNotExistException("Class {$class} does not exist");

if (!in_array(
Extendable::class,
array_keys((new ReflectionClass($class))->getTraits()))
Expand All @@ -39,6 +42,8 @@ public function bind(string $class, string $method, Closure $closure)
*/
public function static(string $class, string $method, Closure $closure)
{
if (!class_exists($class)) throw new ClassDoesNotExistException("Class {$class} does not exist");

if (!in_array(
Extendable::class,
array_keys((new ReflectionClass($class))->getTraits()))
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modulusphp/framework",
"description": "Framework component for Modulus",
"version": "1.9.8.10",
"version": "1.9.8.11",
"license": "MIT",
"type": "package",
"authors": [{
Expand Down