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: &[u8],
        method_name: &[u8],
        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: &[u8], method_name: &[u8], invocation: &InvocationInfo<'_, '_, '_>, ) -> Option<InvocationAssertions>

Get assertions for the method invocation.

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§