Example #1
0
 /**
  * 
  * @param int $size
  * @return self
  * @throws \ErrorException
  * @throws \RuntimeException
  */
 public function truncate($size = 0)
 {
     $this->checkStream();
     ErrorHandler::start();
     \ftruncate($this->stream, $size);
     ErrorHandler::stop();
     return $this;
 }
 /**
  * @test
  * @depends stopTest
  */
 public function multipleStartTest()
 {
     $called = false;
     \set_error_handler(function ($errno, $errmsg) use(&$called) {
         $called = true;
     });
     $n = \mt_rand(5, 15);
     for ($i = 0; $i < $n; $i++) {
         ErrorHandler::start();
     }
     ErrorHandler::stop();
     try {
         @\trigger_error('Notice', \E_USER_NOTICE);
         $this->assertFalse(true);
     } catch (\ErrorException $ex) {
         $this->assertFalse($called);
     }
     $n -= 2;
     for ($i = 0; $i < $n; $i++) {
         ErrorHandler::stop();
     }
     @\trigger_error('Notice', \E_USER_NOTICE);
     $this->assertTrue($called);
 }