mageekguy\atoum\includer::includePath PHP Method

includePath() public method

public includePath ( $path, closure $closure = null )
$closure closure
    public function includePath($path, \closure $closure = null)
    {
        $this->resetErrors();
        $this->path = (string) $path;
        $errorHandler = $this->adapter->set_error_handler(array($this, 'errorHandler'));
        $closure = $closure ?: function ($path) {
            include_once $path;
        };
        $closure($this->path);
        $this->adapter->restore_error_handler();
        if (sizeof($this->errors) > 0) {
            $realpath = parse_url($this->path, PHP_URL_SCHEME) !== null ? $this->path : realpath($this->path) ?: $this->path;
            if (in_array($realpath, $this->adapter->get_included_files(), true) === false) {
                throw new includer\exception('Unable to include \'' . $this->path . '\'');
            }
            if ($errorHandler !== null) {
                foreach ($this->errors as $error) {
                    call_user_func_array($errorHandler, $error);
                }
                $this->errors = array();
            }
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 public function testGetFirstError()
 {
     $this->if($includer = new testedClass($adapter = new atoum\test\adapter()))->then->variable($includer->getFirstError())->isNull()->if($adapter->set_error_handler = function ($errorHandler) {
         set_error_handler($errorHandler);
         return null;
     })->and($fileWithError = stream::get())->and($fileWithError->file_get_contents = '<?php trigger_error(\'' . ($message = uniqid()) . '\', E_USER_WARNING); ?>')->and($includer->includePath($fileWithError))->then->array($error = $includer->getFirstError())->isNotEmpty()->integer($error[0])->isEqualTo(E_USER_WARNING)->string($error[1])->isEqualTo($message);
 }
All Usage Examples Of mageekguy\atoum\includer::includePath