当前位置: 首页>>代码示例>>PHP>>正文


PHP ErrorHandler::start方法代码示例

本文整理汇总了PHP中Zend\Stdlib\ErrorHandler::start方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::start方法的具体用法?PHP ErrorHandler::start怎么用?PHP ErrorHandler::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Stdlib\ErrorHandler的用法示例。


在下文中一共展示了ErrorHandler::start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 /**
  * Load a CSV file content
  *
  * {@inheritdoc}
  * @return TextDomain|false
  */
 public function load($locale, $filename)
 {
     //$filename .= $this->fileExtension;
     $messages = array();
     ErrorHandler::start();
     $file = fopen($filename, 'rb');
     $error = ErrorHandler::stop();
     if (false === $file) {
         return false;
     }
     while (($data = fgetcsv($file, $this->options['length'], $this->options['delimiter'], $this->options['enclosure'])) !== false) {
         if (substr($data[0], 0, 1) === '#') {
             continue;
         }
         if (!isset($data[1])) {
             continue;
         }
         if (count($data) == 2) {
             $messages[$data[0]] = $data[1];
         } else {
             $singular = array_shift($data);
             $messages[$singular] = $data;
         }
     }
     $textDomain = new TextDomain($messages);
     return $textDomain;
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:33,代码来源:Csv.php

示例2: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $cacheDir = $this->config['directory'];
     if (!is_writable($cacheDir)) {
         throw new \RuntimeException("Unable to write to the {$cacheDir} directory");
     }
     $output->writeln('<info>Clearing the cache</info>');
     $dirIterator = new \RecursiveDirectoryIterator($cacheDir, \FilesystemIterator::SKIP_DOTS);
     /** @var \DirectoryIterator[] $items */
     $items = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($items as $item) {
         if (substr($item->getFileName(), 0, 1) == '.') {
             continue;
         }
         if ($item->isFile()) {
             ErrorHandler::start();
             unlink($item->getPathName());
             ErrorHandler::stop(true);
             if (file_exists($item->getPathname())) {
                 throw new \RuntimeException('Could not delete file ' . $item->getPathname());
             }
         } else {
             ErrorHandler::start();
             rmdir($item->getPathName());
             ErrorHandler::stop(true);
             if (file_exists($item->getPathname())) {
                 throw new \RuntimeException('Could not delete directory ' . $item->getPathname());
             }
         }
     }
     $output->writeln('Successfully deleted all cache files');
 }
开发者ID:radnan,项目名称:rdn-console,代码行数:32,代码来源:CacheClear.php

示例3: __construct

 /**
  * Constructor
  *
  * @param  string|resource|array|Traversable $streamOrUrl Stream or URL to open as a stream
  * @param  string|null $mode Mode, only applicable if a URL is given
  * @param  null|string $logSeparator Log separator string
  * @return Stream
  * @throws Exception\InvalidArgumentException
  * @throws Exception\RuntimeException
  */
 public function __construct($streamOrUrl, $mode = null, $logSeparator = null)
 {
     if ($streamOrUrl instanceof Traversable) {
         $streamOrUrl = iterator_to_array($streamOrUrl);
     }
     if (is_array($streamOrUrl)) {
         $mode = isset($streamOrUrl['mode']) ? $streamOrUrl['mode'] : null;
         $logSeparator = isset($streamOrUrl['log_separator']) ? $streamOrUrl['log_separator'] : null;
         $streamOrUrl = isset($streamOrUrl['stream']) ? $streamOrUrl['stream'] : null;
     }
     // Setting the default mode
     if (null === $mode) {
         $mode = 'a';
     }
     if (is_resource($streamOrUrl)) {
         if ('stream' != get_resource_type($streamOrUrl)) {
             throw new Exception\InvalidArgumentException(sprintf('Resource is not a stream; received "%s', get_resource_type($streamOrUrl)));
         }
         if ('a' != $mode) {
             throw new Exception\InvalidArgumentException(sprintf('Mode must be "a" on existing streams; received "%s"', $mode));
         }
         $this->stream = $streamOrUrl;
     } else {
         ErrorHandler::start();
         $this->stream = fopen($streamOrUrl, $mode, false);
         $error = ErrorHandler::stop();
         if (!$this->stream) {
             throw new Exception\RuntimeException(sprintf('"%s" cannot be opened with mode "%s"', $streamOrUrl, $mode), 0, $error);
         }
     }
     if (null !== $logSeparator) {
         $this->setLogSeparator($logSeparator);
     }
     $this->formatter = new SimpleFormatter();
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:45,代码来源:Stream.php

示例4: connect

    /**
     * Open connection to IMAP server
     *
     * @param  string      $host  hostname or IP address of IMAP server
     * @param  int|null    $port  of IMAP server, default is 143 (993 for ssl)
     * @param  string|bool $ssl   use 'SSL', 'TLS' or false
     * @throws Exception\RuntimeException
     * @return string welcome message
     */
    public function connect($host, $port = null, $ssl = false)
    {
        if ($ssl == 'SSL') {
            $host = 'ssl://' . $host;
        }

        if ($port === null) {
            $port = $ssl === 'SSL' ? 993 : 143;
        }

        ErrorHandler::start();
        $this->socket = fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION);
        $error = ErrorHandler::stop();
        if (!$this->socket) {
            throw new Exception\RuntimeException(sprintf(
                'cannot connect to host%s',
                ($error ? sprintf('; error = %s (errno = %d )', $error->getMessage(), $error->getCode()) : '')
            ), 0, $error);
        }

        if (!$this->_assumedNextLine('* OK')) {
            throw new Exception\RuntimeException('host doesn\'t allow connection');
        }

        if ($ssl === 'TLS') {
            $result = $this->requestAndResponse('STARTTLS');
            $result = $result && stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
            if (!$result) {
                throw new Exception\RuntimeException('cannot enable TLS');
            }
        }
    }
开发者ID:ramol,项目名称:zf2,代码行数:41,代码来源:Imap.php

示例5: pharAction

 public function pharAction()
 {
     $client = $this->serviceLocator->get('zendServerClient');
     $client = new Client();
     if (defined('PHAR')) {
         // the file from which the application was started is the phar file to replace
         $file = $_SERVER['SCRIPT_FILENAME'];
     } else {
         $file = dirname($_SERVER['SCRIPT_FILENAME']) . '/zs-client.phar';
     }
     $request = new Request();
     $request->setMethod(Request::METHOD_GET);
     $request->setHeaders(Headers::fromString('If-Modified-Since: ' . gmdate('D, d M Y H:i:s T', filemtime($file))));
     $request->setUri('https://github.com/zendtech/ZendServerSDK/raw/master/bin/zs-client.phar');
     //$client->getAdapter()->setOptions(array('sslcapath' => __DIR__.'/../../../certs/'));
     $client->setAdapter(new Curl());
     $response = $client->send($request);
     if ($response->getStatusCode() == 304) {
         return 'Already up-to-date.';
     } else {
         ErrorHandler::start();
         rename($file, $file . '.' . date('YmdHi') . '.backup');
         $handler = fopen($file, 'w');
         fwrite($handler, $response->getBody());
         fclose($handler);
         ErrorHandler::stop(true);
         return 'The phar file was updated successfully.';
     }
 }
开发者ID:alexb-uk,项目名称:ZendServerSDK,代码行数:29,代码来源:UpdateController.php

示例6: normalize

 /**
  * Normalize all non-scalar data types (except null) in a string value
  *
  * @param mixed $value
  * @return mixed
  */
 protected function normalize($value)
 {
     if (is_scalar($value) || null === $value) {
         return $value;
     }
     // better readable JSON
     static $jsonFlags;
     if ($jsonFlags === null) {
         $jsonFlags = 0;
         $jsonFlags |= defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0;
         $jsonFlags |= defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0;
     }
     ErrorHandler::start();
     if ($value instanceof DateTime) {
         $value = $value->format($this->getDateTimeFormat());
     } elseif ($value instanceof Traversable) {
         $value = json_encode(iterator_to_array($value), $jsonFlags);
     } elseif (is_array($value)) {
         $value = json_encode($value, $jsonFlags);
     } elseif (is_object($value) && !method_exists($value, '__toString')) {
         $value = sprintf('object(%s) %s', get_class($value), json_encode($value));
     } elseif (is_resource($value)) {
         $value = sprintf('resource(%s)', get_resource_type($value));
     } elseif (!is_object($value)) {
         $value = gettype($value);
     }
     ErrorHandler::stop();
     return (string) $value;
 }
开发者ID:leonardovn86,项目名称:zf2_basic2013,代码行数:35,代码来源:Base.php

示例7: onRun

 public function onRun(RunEvent $e)
 {
     /* @var $test \ZFTool\Diagnostics\Test\TestInterface */
     $test = $e->getTarget();
     try {
         ErrorHandler::start($this->getCatchErrorSeverity());
         $result = $test->run();
         ErrorHandler::stop(true);
     } catch (ErrorException $e) {
         return new Failure('PHP ' . static::getSeverityDescription($e->getSeverity()) . ': ' . $e->getMessage(), $e);
     } catch (\Exception $e) {
         ErrorHandler::stop(false);
         return new Failure('Uncaught ' . get_class($e) . ': ' . $e->getMessage(), $e);
     }
     // Check if we've received a Result object
     if (is_object($result)) {
         if (!$result instanceof ResultInterface) {
             return new Failure('Test returned unknown object ' . get_class($result), $result);
         }
         return $result;
         // Interpret boolean as a failure or success
     } elseif (is_bool($result)) {
         if ($result) {
             return new Success();
         } else {
             return new Failure();
         }
         // Convert scalars to a warning
     } elseif (is_scalar($result)) {
         return new Warning('Test returned unexpected ' . gettype($result), $result);
         // Otherwise interpret as failure
     } else {
         return new Failure('Test returned unknown result of type ' . gettype($result), $result);
     }
 }
开发者ID:ralfeggert,项目名称:zftool,代码行数:35,代码来源:RunListener.php

示例8: filter

 /**
  * Returns the result of filtering $value
  *
  * @param mixed $value
  * @return mixed
  */
 public function filter($value)
 {
     $unfilteredValue = $value;
     if (is_float($value) && !is_nan($value) && !is_infinite($value)) {
         ErrorHandler::start();
         $formatter = $this->getFormatter();
         $currencyCode = $this->setupCurrencyCode();
         $result = $formatter->formatCurrency($value, $currencyCode);
         ErrorHandler::stop();
         // FIXME: verify that this, given the initial IF condition, never happens
         // if ($result === false) {
         // return $unfilteredValue;
         // }
         // Retrieve the precision internally used by the formatter (i.e., depends from locale and currency code)
         $precision = $formatter->getAttribute(\NumberFormatter::FRACTION_DIGITS);
         // $result is considered valid if the currency's fraction digits can accomodate the $value decimal precision
         // i.e. EUR (fraction digits = 2) must NOT allow double(1.23432423432)
         $isFloatScalePrecise = $this->isFloatScalePrecise($value, $precision, $this->formatter->getAttribute(\NumberFormatter::ROUNDING_MODE));
         if ($this->getScaleCorrectness() && !$isFloatScalePrecise) {
             return $unfilteredValue;
         }
         return $result;
     }
     return $unfilteredValue;
 }
开发者ID:leodido,项目名称:moneylaundry,代码行数:31,代码来源:Currency.php

示例9: initializeFromDist

 /**
  * @param string $fileName
  * @return \Application\SharedKernel\SqliteDbFile
  */
 public static function initializeFromDist($fileName)
 {
     $dist = new self($fileName . '.dist');
     ErrorHandler::start();
     copy($dist->toString(), $fileName);
     ErrorHandler::stop(true);
     return new self($fileName);
 }
开发者ID:prooph,项目名称:link-app-core,代码行数:12,代码来源:SqliteDbFile.php

示例10: __destruct

 /**
  * Object destructor.
  *
  * Closes the file if it had been successfully opened.
  */
 public function __destruct()
 {
     if (is_resource($this->_fileResource)) {
         ErrorHandler::start(E_WARNING);
         fclose($this->_fileResource);
         ErrorHandler::stop();
     }
 }
开发者ID:marcyniu,项目名称:vendors,代码行数:13,代码来源:File.php

示例11: testSetByValueException

 public function testSetByValueException()
 {
     /* @var $style \ZfcDatagrid\Column\Style\AbstractStyle */
     $style = $this->getMockForAbstractClass('ZfcDatagrid\\Column\\Style\\AbstractStyle');
     ErrorHandler::start(E_USER_DEPRECATED);
     $style->setByValue($this->column, 'test');
     $err = ErrorHandler::stop();
     $this->assertInstanceOf('ErrorException', $err);
 }
开发者ID:rezix,项目名称:ZfcDatagrid,代码行数:9,代码来源:AbstractStyleTest.php

示例12: __construct

 /**
  * Object constructor
  *
  * @throws \ZendSearch\Lucene\Exception\RuntimeException
  */
 public function __construct()
 {
     ErrorHandler::start(E_WARNING);
     $result = preg_match('/\\pL/u', 'a');
     ErrorHandler::stop();
     if ($result != 1) {
         // PCRE unicode support is turned off
         throw new RuntimeException('Utf8 analyzer needs PCRE unicode support to be enabled.');
     }
 }
开发者ID:avbrugen,项目名称:uace-laravel,代码行数:15,代码来源:Utf8.php

示例13: download

 /**
  * @inheritdoc
  * @throws \RuntimeException
  */
 public function download($id, FileInterface $output)
 {
     $source = new GFile($id, $this->filesystem);
     ErrorHandler::start();
     $flag = file_put_contents($output->getPath(), $source->getContent());
     ErrorHandler::stop(true);
     if ($flag === false) {
         throw new \RuntimeException("Could not download file ({$id})");
     }
 }
开发者ID:radnan,项目名称:rdn-upload,代码行数:14,代码来源:Gaufrette.php

示例14: remove

 /**
  * {@inheritDoc}
  */
 public function remove($key)
 {
     ErrorHandler::start(\E_WARNING);
     $success = unlink($this->cachedFile());
     ErrorHandler::stop();
     if (false === $success) {
         throw new RuntimeException(sprintf('Could not remove key "%s"', $this->cachedFile()));
     }
     return $success;
 }
开发者ID:jguittard,项目名称:AssetManager,代码行数:13,代码来源:FilePathCache.php

示例15: testGetConstantsReturnsConstantNames

 /**
  * @todo Remove error handling once we remove deprecation warning from getConstants method
  */
 public function testGetConstantsReturnsConstantNames()
 {
     $file = new FileScanner(__DIR__ . '/../TestAsset/FooClass.php');
     $class = $file->getClass('ZendTest\\Code\\TestAsset\\FooClass');
     ErrorHandler::start(E_USER_DEPRECATED);
     $constants = $class->getConstants();
     $error = ErrorHandler::stop();
     $this->assertInstanceOf('ErrorException', $error);
     $this->assertContains('FOO', $constants);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:13,代码来源:ClassScannerTest.php


注:本文中的Zend\Stdlib\ErrorHandler::start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。