PHP Classes

File: src/SternTrait.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  Stern PHP Type Safety  >  src/SternTrait.php  >  Download  
File: src/SternTrait.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Stern PHP Type Safety
Make class function calls invoke strict versions
Author: By
Last change:
Date: 1 year ago
Size: 594 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);
namespace
ParagonIE\Stern;

/**
 * Trait SternTrait
 * @package ParagonIE\Stern
 */
trait SternTrait
{
   
/**
     * @param string $name
     * @param mixed $arguments
     * @return mixed
     * @throws \Error
     */
   
public function __call($name, $arguments)
    {
        if (\
method_exists($this, 'strict' . $name)) {
            return
$this->{'strict' . $name}(...$arguments);
        }
       
        throw new \
Error(
            \
sprintf('Destination proxy method %s not found on class %s', 'strict' . $name, \get_class($this))
        );
    }
}

For more information send a message to info at phpclasses dot org.