get_chain() as $link ) { $message .= "{$link}\n"; } return new self( $message, self::CIRCULAR_REFERENCE ); } /** * Create a new instance of the exception for an interface that could not * be resolved to an instantiable class. * * @since 1.6.0 * * @param string $interface_name Interface that was left unresolved. */ public static function for_unresolved_interface( string $interface_name ): self { $message = \sprintf( 'Could not resolve the interface "%s" to an instantiable class, probably forgot to bind an implementation.', $interface_name ); return new self( $message, self::UNRESOLVED_INTERFACE ); } /** * Create a new instance of the exception for an interface or class that * could not be reflected upon. * * @since 1.6.0 * * @param string $interface_or_class Interface or class that could not be * reflected upon. */ public static function for_unreflectable_class( string $interface_or_class ): self { $message = \sprintf( 'Could not reflect on the interface or class "%s", probably not a valid FQCN.', $interface_or_class ); return new self( $message, self::UNREFLECTABLE_CLASS ); } /** * Create a new instance of the exception for an argument that could not be * resolved. * * @since 1.6.0 * * @param string $argument_name Name of the argument that could not be * resolved. * @param string $class_name Class that had the argument in its * constructor. */ public static function for_unresolved_argument( string $argument_name, string $class_name ): self { $message = \sprintf( 'Could not resolve the argument "%s" while trying to instantiate the class "%s".', $argument_name, $class_name ); return new self( $message, self::UNRESOLVED_ARGUMENT ); } /** * Create a new instance of the exception for a class that was meant to be * reused but was not yet instantiated. * * @since 1.6.0 * * @param string $class_name Class that was not yet instantiated. */ public static function for_uninstantiated_shared_instance( string $class_name ): self { $message = \sprintf( 'Could not retrieve the shared instance for "%s" as it was not instantiated yet.', $class_name ); return new self( $message, self::UNINSTANTIATED_SHARED_INSTANCE ); } /** * Create a new instance of the exception for a delegate that was requested * for a class that doesn't have one. * * @since 1.6.0 * * @param string $class_name Class for which there is no delegate. */ public static function for_invalid_delegate( string $class_name ): self { $message = \sprintf( 'Could not retrieve a delegate for "%s", none was defined.', $class_name ); return new self( $message, self::INVALID_DELEGATE ); } }