Add methods and args from inherited classes/interfaces

@return void
178409
protected function mergeInheritedDependencies()
    {
        $reflection = new \ReflectionClass($this->class);

        $inheritance = $reflection->getInterfaceNames();
        $class = $reflection;

        while ($parent = $class->getParentClass()) {
            $inheritance[] = $parent->getName();
            $class = $parent;
        }

        foreach ($inheritance as $interface) {
            $interface = $this->container->getRaw($interface);
            if ($interface instanceof static and $interface->inherit()) {
                $this->addArgs($interface->getArgs());
                $this->withMethods($interface->getMethods());
            }
        }
    }
1323969
protected function _inherit() {

		$inherited = array_fill_keys($this->_inherited(), []);

		foreach (static::_parents() as $parent) {
			$parentConfig = get_class_vars($parent);

			foreach ($inherited as $key => $value) {
				if (isset($parentConfig["{$key}"])) {
					$val = $parentConfig["{$key}"];
					if (is_array($val)) {
						$inherited[$key] += $val;
					}
				}
			}

			if ($parent === __CLASS__) {
				break;
			}
		}

		foreach ($inherited as $key => $value) {
			if (is_array($this->{$key})) {
				$this->{$key} += $value;
			}
		}
	}
548637
private void addArrayMethods(List<MethodNode> methods, ClassNode receiver, String name, ClassNode[] args) {
        if (args.length!=1) return;
        if (!receiver.isArray()) return;
        if (!isIntCategory(getUnwrapper(args[0]))) return;
        if ("getAt".equals(name)) {
            MethodNode node = new MethodNode(name, Opcodes.ACC_PUBLIC, receiver.getComponentType(), new Parameter[]{new Parameter(args[0],"arg")}, null, null);
            node.setDeclaringClass(receiver.redirect());
            methods.add(node);
        } else if ("setAt".equals(name)) {
            MethodNode node = new MethodNode(name, Opcodes.ACC_PUBLIC, VOID_TYPE, new Parameter[]{new Parameter(args[0],"arg")}, null, null);
            node.setDeclaringClass(receiver.redirect());
            methods.add(node);
        }
    }
1026315
public function addInterface($interface, $extends = [])
    {
        $interfaceId = $this->registerInterface($interface);
        if (!empty($extends)) {
            $interfaceIds = [];
            foreach ($extends as $name) {
                $interfaceIds[] = $this->registerInterface($name);
            }
            $this->interfaceExtends[$interfaceId] = $interfaceIds;
        }
    }
1083348
private function addMethod(string $method): void
    {
        if (!HttpMethod::isValid($method)) {
            throw new \InvalidArgumentException("Invalid HTTP request method '$method'");
        }

        $this->methods[] = $method;
    }
261846
protected function DefineInterface()
    {
        parent::DefineInterface();
        $this->methodCallAllowed[] = 'ExecuteStep';
        $this->methodCallAllowed[] = 'PostProcessExternalPaymentHandlerHook';
        $this->methodCallAllowed[] = 'JumpSelectPaymentMethod';
        $this->methodCallAllowed[] = 'GetStepAsAjax';
    }
985376
public function addMethods($object, array $method_aliases = [])
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('$object must be an object');
        }
        foreach ($method_aliases as $alias => $method) {
            $callable = [$object, $method];
            if (!is_callable($callable)) {
                $class = get_class($object);
                throw new \InvalidArgumentException("Method {$method} not found in class {$class}");
            }
            if (is_int($alias)) {
                $alias = $method;
            }
            $this->plugins[$alias] = $callable;
        }
    }
1196731
protected function setupMethods() {
		//PARAMETERS
		$parameterPrimary = new ParameterGenerator();
		$parameterPrimary->setName($this->getNames()->primary);
		
		$paramTagPrimary = new ParamTag();
		$paramTagPrimary->setTypes([$this->getNames()->properties[$this->getNames()->primary]['type']]);
		$paramTagPrimary->setVariableName($this->getNames()->primary);

		$parameterEntity = new ParameterGenerator();
		$parameterEntity->setName($this->getNames()->entityVariable);
		$parameterEntity->setType($this->getNames()->namespace_entity . '\\' . $this->getNames()->entityName);
		
		$parameterEvent = new ParameterGenerator();
		$parameterEvent->setName('events');
		$parameterEvent->setType('Zend\EventManager\EventManagerInterface');
		
		$parameterPaginator = new ParameterGenerator('paginated');
		$parameterPaginator->setDefaultValue(false);

		//===============================================

		//METHODS
		// METHOD:enableEvents
		$method = $this->buildMethod('enableEvents');
		$body = <<<MBODY
\$this->eventsEnabled = true;
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator('Enable Events');
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:disableEvents
		$method = $this->buildMethod('disableEvents');
		$body = <<<MBODY
\$this->eventsEnabled = false;
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator('Disable Events');
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:setEventManager
		$method = $this->buildMethod('setEventManager');
		$method->setParameter($parameterEvent);
		$body = <<<MBODY
\$events->setIdentifiers([
    __CLASS__,
    array_pop(explode('\\\\', __CLASS__))
]);
\$this->events = \$events;
return \$this;
MBODY;
		$method->setBody($body);
		$paramTag = new ParamTag();
		$paramTag->setTypes('\Zend\EventManager\EventManagerInterface');
		$paramTag->setVariableName('events');
		$tag = new ReturnTag();
		$tag->setTypes("{$this->getNames()->modelName}");
		$docBlock = new DocBlockGenerator();
		$docBlock->setShortDescription('Set the event manager instance used by this context');
		$docBlock->setTag($paramTag);
		$docBlock->setTag($tag);
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:getEventManager
		$method = $this->buildMethod('getEventManager');
		$body = <<<MBODY
if (null === \$this->events) {
    \$this->setEventManager(new EventManager(new SharedEventManager()));
}
return \$this->events;
MBODY;
		$method->setBody($body);
		$tag = new ReturnTag();
		$tag->setTypes('\Zend\EventManager\EventManagerInterface');
		$docBlock = new DocBlockGenerator();
		$docBlock->setShortDescription(<<<MBODY
Retrieve the event manager

Lazy-loads an EventManager instance if none registered.
MBODY
);
		$docBlock->setTag($tag);
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);
		
		//===============================================
		
		// METHOD:getPrimaryKeyField
		$method = $this->buildMethod('getPrimaryKeyField');
		$body = <<<MBODY
return \$this->primaryKeyField;
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator();
		$docBlock->setShortDescription(<<<MBODY
Get PrimaryKey Field
MBODY
				);
		$docBlock->setTag(new ReturnTag(['string']));
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:trigger
		$method = $this->buildMethod('trigger', MethodGenerator::FLAG_PRIVATE);
		$method->setParameter(new ParameterGenerator('task'));
		$method->setParameter(new ParameterGenerator('state'));
		$method->setParameter(new ParameterGenerator('data', null, []));
		$body = <<<MBODY
if (\$this->eventsEnabled) {
	\$table = \$this->table;
    \$info = compact('table', 'task', 'state', 'data');

    if (\$state == 'post') {
        \$this->getEventManager()->trigger('commit', \$this, \$info);
    }
    \$this->getEventManager()->trigger(\$task.'.'.\$state, \$this, \$info);
}
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator('Trigger an event');
		$docBlock->setTag(new ParamTag('task', 'string'));
		$docBlock->setTag(new ParamTag('state', 'string'));
		$docBlock->setTag(new ParamTag('data', 'array|object'));
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:__construct
		$method = $this->buildMethod('__construct');
		$body = <<<MBODY
\$this->table = '{$this->getNames()->tableName}';
\$this->featureSet = new Feature\FeatureSet();
\$this->featureSet->addFeature(new Feature\GlobalAdapterFeature());
\$this->featureSet->addFeature(new Feature\MetadataFeature());

\$this->resultSetPrototype = new HydratingResultSet(new Reflection(), new {$this->getNames()->entityName}());

\$this->initialize();
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator('Create DataTable Object');
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:getEntity
		$method = $this->buildMethod('getEntity');
		$body = <<<MBODY
return new \\{$this->getNames()->namespace_entity}\\{$this->getNames()->entityName}();
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator();
		$docBlock->setShortDescription(<<<MBODY
Get Empty Entity
MBODY
		);
		$docBlock->setTag(new ReturnTag(['\\'.$this->getNames()->namespace_entity."\\{$this->getNames()->entityName}"]));
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:getColumnDefaults
		$method = $this->buildMethod('getColumnDefaults');
		$body = <<<MBODY
return \$this->columnDefaults;
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator();
		$docBlock->setShortDescription(<<<MBODY
Get Column Default
MBODY
		);
		$docBlock->setTag(new ReturnTag(['Array']));
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:fetchAll
		$method = $this->buildMethod('fetchAll');
		$method->setParameter($parameterPaginator);
		$body = <<<MBODY
if (\$paginated) {
	// create a new pagination adapter object
	\$paginatorAdapter = new DbSelect(
		// our configured select object
		\$this->sql->select(),
		// the adapter to run it against
		\$this->getAdapter(),
		// the result set to hydrate
		\$this->resultSetPrototype
	);
	\$paginator = new Paginator(\$paginatorAdapter);
	return \$paginator;
}
\$resultSet = \$this->select();
return \$resultSet;
MBODY;
		$method->setBody($body);
		$tag = new ReturnTag();
		$tag->setTypes("\\Zend\\Db\\ResultSet\\HydratingResultSet");
		$docBlock = new DocBlockGenerator('Fetch all entities');
		$docBlock->setTag(new ParamTag('paginated', ['boolean'], 'True: use paginator'));
		$docBlock->setTag($tag);
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:selectUsing
		$method = $this->buildMethod('selectUsing');
		$method->setParameter(new ParameterGenerator('order', null, false));
		$method->setParameter(new ParameterGenerator('where', null, false));
		$method->setParameter(new ParameterGenerator('limit', null, false));
		$body = <<<MBODY
\$select = new Select(\$this->table);
if (\$order) \$select->order(\$order);
if (\$where) \$select->where(\$where);
if (\$limit) \$select->limit(\$limit);

return \$this->selectWith(\$select);
MBODY;
		$method->setBody($body);
		$tag = new ReturnTag();
		$tag->setTypes("\\Zend\\Db\\ResultSet\\HydratingResultSet");
		$docBlock = new DocBlockGenerator('Select Using Where/Order');
		$docBlock->setTag(new ParamTag('order', ['string', 'array'], 'Sort Order'));
		$docBlock->setTag(new ParamTag('where', ['string', 'array', '\Closure', 'Where'], 'Where'));
		$docBlock->setTag(new ParamTag('limit', ['int'], 'Limit'));
		$docBlock->setTag($tag);
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:get
		$method = $this->buildMethod("get{$this->getNames()->entityName}");
		$method->setParameter($parameterPrimary);
		$body = <<<MBODY
\$rowset = \$this->select([\$this->getPrimaryKeyField() => \${$this->getNames()->primary}]);
\$row = \$rowset->current();
return \$row;
MBODY;
		$method->setBody($body);
		$tag = new ReturnTag();
		$tag->setTypes("\\{$this->getNames()->namespace_entity}\\{$this->getNames()->entityName}");
		$docBlock = new DocBlockGenerator('Get by primaryId');
		$docBlock->setTag($paramTagPrimary);
		$docBlock->setTag($tag);
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:save
		$method = $this->buildMethod("save{$this->getNames()->entityName}");
		$method->setParameter($parameterEntity);

		$body = <<<MBODY
\$data = \${$this->getNames()->entityVariable}->getArrayCopy(true);
\${$this->getNames()->primary} = \${$this->getNames()->entityVariable}->{$this->getNames()->primary};
\$row = \$this->get{$this->getNames()->entityName}(\${$this->getNames()->primary});
if (\$row) {
	\$data = array_diff_assoc(\$data, \$row->getArrayCopy());
	if (count(\$data) > 0) {
		\$this->trigger('update', 'pre', \${$this->getNames()->primary});
		\$this->update(\$data, [\$this->getPrimaryKeyField() => \${$this->getNames()->primary}]);
		\$this->trigger('update', 'post', \${$this->getNames()->primary});
	}
} else {
	if ((\$this->isSequence && !\${$this->getNames()->primary}) || (!\$this->isSequence && \${$this->getNames()->primary})) {
		\$data['{$this->getNames()->primary}'] = \${$this->getNames()->primary};
		\$this->trigger('insert', 'pre', \$data);
		\$this->insert(array_filter(\$data));
		if (\$this->isSequence) {
			\${$this->getNames()->entityVariable}->{$this->getNames()->primary} = \$this->lastInsertValue;
		}
		\$this->trigger('insert', 'post', \${$this->getNames()->entityVariable}->{$this->getNames()->primary});
	} else {
		throw new \Exception('{$this->getNames()->entityName} {$this->getNames()->primary} error with insert/update');
	}
}
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator('Save entity to database');
		$docBlock->setTag(new ParamTag($this->getNames()->entityVariable, $this->getNames()->entityName));
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);

		//===============================================

		// METHOD:delete
		$method = $this->buildMethod("delete{$this->getNames()->entityName}");
		$method->setParameter($parameterPrimary);
		$body = <<<MBODY
\$this->trigger('delete', 'pre', \${$this->getNames()->primary});
\$this->delete([\$this->getPrimaryKeyField() => \${$this->getNames()->primary}]);
\$this->trigger('delete', 'post', \${$this->getNames()->primary});
MBODY;
		$method->setBody($body);
		$docBlock = new DocBlockGenerator('Delete entity');
		$docBlock->setTag(new ParamTag($this->getNames()->primary));
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);
	}
1189552
protected function addErrorClass()
    {
        $errors = $this->parent->getRequest()->session()->get('errors');
        $errorBag = $this->parent->getErrorBag();

        if ($errors && $errors->hasBag($errorBag) && $errors->getBag($errorBag)->has($this->getNameKey())) {
            $fieldErrorClass = $this->getConfig('defaults.field_error_class');
            $fieldClass = $this->getOption('attr.class');

            if ($fieldErrorClass && !str_contains($fieldClass, $fieldErrorClass)) {
                $fieldClass .= ' ' . $fieldErrorClass;
                $this->setOption('attr.class', $fieldClass);
            }

            $wrapperErrorClass = $this->getConfig('defaults.wrapper_error_class');
            $wrapperClass = $this->getOption('wrapper.class');

            if ($wrapperErrorClass && $this->getOption('wrapper') && !str_contains($wrapperClass, $wrapperErrorClass)) {
                $wrapperClass .= ' ' . $wrapperErrorClass;
                $this->setOption('wrapper.class', $wrapperClass);
            }
        }
    }
960734
public function add($method)
    {
        if (!$method instanceof MethodInterface) {
            throw new \InvalidArgumentException('This Method must be a instance of \ClassGeneration\MethodInterface');
        }
        if ($method->getName() === null) {
            $method->setName('method' . ($this->count() + 1));
        }

        parent::set($method->getName(), $method);
        return true;
    }
503055
public function addClass($classes)
    {
        $classes = (array)$classes;
        foreach ($classes as $class) {
            if (class_exists($class) || interface_exists($class)) {
                $this->classes[] = $class;
            } else {
                echo "Class not exists: $class\r\n";
            }
        }
    }
118711
protected function DefineInterface()
    {
        parent::DefineInterface();
        $this->methodCallAllowed[] = 'WriteReview';
        $this->methodCallAllowed[] = 'RateReview';
        $this->methodCallAllowed[] = 'ReportReview';
        $this->methodCallAllowed[] = 'DeleteReview';
        $this->methodCallAllowed[] = 'UnlockReview';
        $this->methodCallAllowed[] = 'EditReview';
        $this->methodCallAllowed[] = 'ChangeReviewReportNotificationState';
        // pkgComment functions
        $this->methodCallAllowed[] = 'WriteComment';
        $this->methodCallAllowed[] = 'ReportComment';
        $this->methodCallAllowed[] = 'RespondToComment';
        $this->methodCallAllowed[] = 'EditComment';
        $this->methodCallAllowed[] = 'DeleteComment';
    }
507632
protected function registerRenderMethodArguments()
    {
        foreach (static::getRenderMethodArgumentDefinitions($this->objectManager) as $argumentName => $definition) {
            $this->argumentDefinitions[$argumentName] = new ArgumentDefinition($definition[0], $definition[1], $definition[2], $definition[3], $definition[4], $definition[5]);
        }
    }
926116
protected function registerTraits(): void
	{
		if(!isset(static::$traitHooks[static::class]))
		{
			static::$traitHooks[static::class] = [];
			static::$traitCasts[static::class] = [];

			foreach(ClassInspector::getTraits(static::class) as $trait)
			{
				if(method_exists($this, $getter = 'get' . $this->getClassShortName($trait) . 'Hooks'))
				{
					static::$traitHooks[static::class] = array_merge_recursive(static::$traitHooks[static::class], $this->$getter());
				}

				if(method_exists($this, $getter = 'get' . $this->getClassShortName($trait) . 'Casts'))
				{
					static::$traitCasts[static::class] += $this->$getter();
				}
			}
		}

		$this->cast += static::$traitCasts[static::class];
	}
1290930
protected function __overloadMethods($method, $args)
	{
		$_method = strtolower($method);

		if (in_array($_method, ['prefix', 'suffix'])) {
			return call_user_func_array(array($this, 'affix'), array_merge([$_method], $args));
		}

		if ($_method == 'length') {
			return call_user_func_array(array($this, 'length'), $args);
		}

		throw new BadMethodCallException(sprintf("Call to unknown method %s::%s()", get_called_class(), $method));
	}
674036
public void addInterface(Class<?> newInterface) {
        if (!newInterface.isInterface()) {
            throw new IllegalArgumentException(newInterface + " is not an interface");
        }
        additionalInterfaces.add(newInterface);
    }
1341429
protected function buildMethods()
    {
        $refl = new \ReflectionClass($this);
        $enterMethods = [];
        $leaveMethods = [];

        foreach ($refl->getMethods() as $method) {
            $name = $method->getName();
            if (preg_match('/^(enter|leave).+/', $name) && !preg_match('/^(enter|leave)Node$/', $name)) {
                $params = $method->getParameters();
                if ($params && $params[0]->getClass()) {
                    $nodeType = $params[0]->getClass()->getName();
                    if (Text::startsWith($name, 'enter')) {
                        $enterMethods[$nodeType][] = $name;
                    } else {
                        $leaveMethods[$nodeType][] = $name;
                    }
                }
            }
        }
        self::$enterMethods[get_class($this)] = $enterMethods;
        self::$leaveMethods[get_class($this)] = $leaveMethods;
    }