/** * Simple protected method * * @param $a * @return mixed */ protected function protectedMethod($a) { if ($a === 0) { return next::caller(); } return $a + 10; }
public function ___get($name) { if ($name == 'foobar') { return 'test'; } return next::parent($name); }
/** * @param \PHPUnit_Framework_MockObject_Invocation $invocation * * @return mixed * @throws \Exception */ public function invoke(\PHPUnit_Framework_MockObject_Invocation $invocation) { $exception = null; $hasReturnValue = false; $returnValue = next::caller(); foreach ($this->matchers as $match) { try { if ($match->matches($invocation)) { $value = $match->invoked($invocation); if (!$hasReturnValue) { $returnValue = $value; $hasReturnValue = true; } } } catch (\Exception $e) { $exception = $e; } } if ($exception !== null) { throw $exception; } return $returnValue; }
/** * Set/Get attribute wrapper * * @param string $method * @param array $args * @return mixed */ public function ___call($method, $args) { switch (substr($method, 0, 3)) { case 'get': //Varien_Profiler::start('GETTER: '.get_class($this).'::'.$method); $key = $this->_underscore(substr($method, 3)); $data = $this->getData($key, isset($args[0]) ? $args[0] : null); //Varien_Profiler::stop('GETTER: '.get_class($this).'::'.$method); return $data; case 'set': //Varien_Profiler::start('SETTER: '.get_class($this).'::'.$method); $key = $this->_underscore(substr($method, 3)); $result = $this->setData($key, isset($args[0]) ? $args[0] : null); //Varien_Profiler::stop('SETTER: '.get_class($this).'::'.$method); return $result; case 'uns': //Varien_Profiler::start('UNS: '.get_class($this).'::'.$method); $key = $this->_underscore(substr($method, 3)); $result = $this->unsetData($key); //Varien_Profiler::stop('UNS: '.get_class($this).'::'.$method); return $result; case 'has': //Varien_Profiler::start('HAS: '.get_class($this).'::'.$method); $key = $this->_underscore(substr($method, 3)); //Varien_Profiler::stop('HAS: '.get_class($this).'::'.$method); return isset($this->_data[$key]); } return next::parent(); }
protected function ___init() { next::parent(); $this->output .= "!!!"; }
/** * Allow call to protected methods by using the 'PROTECTED_' prefix * and the __callProtectedMethod * * @return void * @test */ public function testProtectedMethodCall() { $dummy = new DummyClass(); $this->assertNull($dummy->protectedMethod(10)); $this->assertNull($dummy->privateMethod(10)); $this->assertEquals(20, $dummy->publicMethod(10)); $this->assertEquals(20, $dummy->__callProtectedMethod('protectedMethod', [10])); $this->assertEquals(20, $dummy->__callProtectedMethod('privateMethod', [10])); $this->assertEquals(20, $dummy->__callProtectedMethod('publicMethod', [10])); $this->assertNull($dummy->protectedMethod(10)); $this->assertNull($dummy->privateMethod(10)); $this->assertEquals(20, $dummy->publicMethod(10)); $this->assertSame(next::caller(), $dummy->__callProtectedMethod('notExist')); $this->assertNull($dummy->PROTECTED_notExist()); }
protected function ___init() { next::parent("World"); }
/** * @param string $name * @param $value */ public function __set($name, $value) { $result = $this->__callTraitMethods(self::SETTER, func_get_args()); if (!next::isNot($result)) { $this->__properties[$name] = $value; } }