Skip to main content

MethodAssertionProvider

Trait MethodAssertionProvider 

Source
pub trait MethodAssertionProvider: Provider {
    // Required methods
    fn targets() -> &'static [MethodTarget]
       where Self: Sized;
    fn get_assertions(
        &self,
        context: &ProviderContext<'_, '_, '_>,
        class_name: &str,
        method_name: &str,
        invocation: &InvocationInfo<'_, '_, '_>,
    ) -> Option<InvocationAssertions>;
}
Expand description

Provider for getting additional assertions from method calls.

This allows plugins to specify type narrowing for method calls like:

  • $validator->isString($x) - narrows $x to string if returns true
  • Assert::assertInstanceOf(Foo::class, $x) - narrows $x to Foo

Required Methods§

Source

fn targets() -> &'static [MethodTarget]
where Self: Sized,

The methods this provider handles.

Source

fn get_assertions( &self, context: &ProviderContext<'_, '_, '_>, class_name: &str, method_name: &str, invocation: &InvocationInfo<'_, '_, '_>, ) -> Option<InvocationAssertions>

Get assertions for the method invocation.

Returns Some(assertions) if this provider has assertions to add, None otherwise.

Implementors§