[ Index ] |
PHP Cross Reference of phpBB-3.3.9-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 * 15 * This software consists of voluntary contributions made by many individuals 16 * and is licensed under the MIT license. 17 */ 18 19 declare(strict_types=1); 20 21 namespace ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator; 22 23 use ProxyManager\Generator\MagicMethodGenerator; 24 use Zend\Code\Generator\ParameterGenerator; 25 use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; 26 use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator; 27 use ReflectionClass; 28 use Zend\Code\Generator\PropertyGenerator; 29 30 /** 31 * Magic `__set` for lazy loading value holder objects 32 * 33 * @author Marco Pivetta <ocramius@gmail.com> 34 * @license MIT 35 */ 36 class MagicSet extends MagicMethodGenerator 37 { 38 /** 39 * Constructor 40 * 41 * @param ReflectionClass $originalClass 42 * @param PropertyGenerator $initializerProperty 43 * @param PropertyGenerator $valueHolderProperty 44 * @param PublicPropertiesMap $publicProperties 45 * 46 * @throws \Zend\Code\Generator\Exception\InvalidArgumentException 47 * @throws \InvalidArgumentException 48 */ 49 public function __construct( 50 ReflectionClass $originalClass, 51 PropertyGenerator $initializerProperty, 52 PropertyGenerator $valueHolderProperty, 53 PublicPropertiesMap $publicProperties 54 ) { 55 parent::__construct( 56 $originalClass, 57 '__set', 58 [new ParameterGenerator('name'), new ParameterGenerator('value')] 59 ); 60 61 $hasParent = $originalClass->hasMethod('__set'); 62 $initializer = $initializerProperty->getName(); 63 $valueHolder = $valueHolderProperty->getName(); 64 $callParent = ''; 65 66 $this->setDocBlock(($hasParent ? "{@inheritDoc}\n" : '') . "@param string \$name\n@param mixed \$value"); 67 68 if (! $publicProperties->isEmpty()) { 69 $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" 70 . ' return ($this->' . $valueHolder . '->$name = $value);' 71 . "\n}\n\n"; 72 } 73 74 $callParent .= $hasParent 75 ? 'return $this->' . $valueHolder . '->__set($name, $value);' 76 : PublicScopeSimulator::getPublicAccessSimulationCode( 77 PublicScopeSimulator::OPERATION_SET, 78 'name', 79 'value', 80 $valueHolderProperty 81 ); 82 83 $this->setBody( 84 '$this->' . $initializer . ' && $this->' . $initializer 85 . '->__invoke($this->' . $valueHolder . ', $this, ' 86 . '\'__set\', array(\'name\' => $name, \'value\' => $value), $this->' . $initializer . ');' 87 . "\n\n" . $callParent 88 ); 89 } 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 7 15:09:22 2022 | Cross-referenced by PHPXref 0.7.1 |