Skip to content

Commit

Permalink
Require parameters to have type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
tlmcclatchey committed Feb 17, 2024
1 parent d886e27 commit 97e6c27
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Exceptions/ParameterTypeRequiredException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* Thrown when a method parameter lacks a type declaration, essential for DI resolution.
*
* This exception is raised to highlight missing type declarations for parameters in method signatures,
* which are required for the dependency injection system to accurately resolve and inject dependencies.
* Ensures that method parameters within classes conform to type declaration standards necessary for
* effective dependency management.
*
* @package CommonPHP
* @subpackage DependencyInjection\Exceptions
* @author Timothy McClatchey <[email protected]>
* @copyright 2024 CommonPHP.org
* @license http://opensource.org/licenses/MIT MIT License
* @noinspection PhpUnused
*/

namespace CommonPHP\DependencyInjection\Exceptions;

use Throwable;

class ParameterTypeRequiredException extends DependencyInjectionException
{
public function __construct(string $class, string $method, string $parameter, ?Throwable $previous = null)
{
parent::__construct("Parameters must have a type on parameter $parameter for method $method in class $class.", $previous);
$this->code = 1512;
}
}

0 comments on commit 97e6c27

Please sign in to comment.