@inheritdoc

@SuppressWarnings(PHPMD.StaticAccess)
433470
public static function configureRoutes(GroupInterface $routes): void
    {
        $routes->group('', function (GroupInterface $routes): void {

            $routes->addContainerConfigurators([
                L10nContainerConfigurator::CONFIGURATOR,
            ]);

            for ($i = 0; $i < 10 + 10 * 5; ++$i) {
                $routes->post("/posts$i/create", [PostsController::class, PostsController::METHOD_CREATE]);
            }

        });
    }
74149
public function resolve($resource, $attribute = null)
    {
        $attribute = $attribute ?? $this->attribute;

        $value = $resource->{$attribute} ?? null;

        $value = is_object($value) || is_array($value) ? $value : json_decode($value);

        $fields = $this->fields->whereInstanceOf(Resolvable::class)->reduce(function ($values, $field) {
            return $values->map(function ($row) use ($field) {
                $key = $field->attribute;
                $cb = $field->resolveCallback;

                if (isset($row->{$key})) {
                    $row->{$key} = $cb ? call_user_func($cb, $row->{$key}) : $row->{$key};
                }

                if (property_exists($field, 'computeCallback') && $field->computeCallback) {
                    $row->{$key} = call_user_func($field->computeCallback, $row);
                }

                return $row;
            });
        }, collect($value));

        if (!$this->resolveCallback) {
            $this->resolveCallback = function () use ($fields) {
                return $fields->toArray();
            };
        }

        $this->withMeta(['fields' => $this->fields]);

        parent::resolve($resource, $attribute);
    }
1271236
public function setData($property, $value = null)
    {
        if (is_array($property)) {
            $description = $this->getEntityDescription();
            $properties = $property;
            $access = pick($value, AnDomain::ACCESS_PUBLIC);

            foreach ($properties as $key => $value) {
                $property = $description->getProperty($key);
                if ($property && $property->getWriteAccess() >= $access) {
                    //ignore any type related exceptions
                      try {
                          $this->setData($property->getName(), $value);
                      } catch (AnDomainExceptionType $e) {
                          print $e->getMessage();
                          die;
                      }
                } elseif (!$property) {
                    $this->$key = $value;
                }
            }

            return $this;
        } else {
            $name = $property;
            $description = $this->getEntityDescription();
            $property = $description->getProperty($property);

            if (!$property instanceof AnDomainPropertyAbstract) {
                $this->set($name, $value);

                return $this;
            }

            $name = $property->getName();
            $method = 'set'.ucfirst($name);

            if ($this->methodExists($method)) {
                $this->$method($value);
            } else {
                //only set the property if it's not write proteced (write != private )
                if ($property->getWriteAccess() < AnDomain::ACCESS_PROTECTED) {
                    throw new AnException(get_class($this).'::$'.$name.' is write protected');
                }

                $this->set($name, $value);
            }

            return $this;
        }
    }
936248
public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);

        parent::execute($request);

        /** @var OrderPaymentInterface $payment */
        $payment = $request->getSource();
        /** @var array $model */
        $model = $request->getResult();

        $model['NOSHIPPING'] = 1;
        $model['LANDINGPAGE'] = 'Billing';
        $model['SOLUTIONTYPE'] = 'Sole';

        $order = $payment->getOrder();
        $orderTotal = $this->calculator->calculateOrderTotal($order, true);
        $paymentAmount = $payment->getAmount();

        // Add item details only if this is a full order payement.
        if (0 == bccomp($orderTotal, $paymentAmount, 2)) {
            $m = 0;
            foreach($order->getItems() as $item) {
                $model['L_PAYMENTREQUEST_0_NAME'.$m] = $item->getDesignation();
                $model['L_PAYMENTREQUEST_0_AMT'.$m] = round($item->getPrice(), 2);
                $model['L_PAYMENTREQUEST_0_QTY'.$m] = $item->getQuantity();
                $m++;
            }
            $model['PAYMENTREQUEST_0_ITEMAMT'] = round($this->calculator->calculateOrderItemsTotal($order), 2);

            $model['PAYMENTREQUEST_0_SHIPPINGAMT'] = round($this->calculator->calculateOrderShipmentTotal($order), 2);

            $taxes = $this->calculator->calculateOrderTaxesAmounts($order);
            $model['PAYMENTREQUEST_0_TAXAMT'] = round($taxes->getTotal(), 2);
        }

        $request->setResult((array) $model);
    }
394814
public static function runtime($context) {
        $class = new \ReflectionClass($context['runtime']);
        $ret = '';
        $methods = static::getClassMethods($context, $class);

        $exports = array_keys($context['usedCount']['runtime']);

        while (true) {
            if (array_sum(array_map(function ($name) use (&$exports, $methods) {
                $n = 0;
                foreach ($methods[$name][1] as $child => $count) {
                    if (!in_array($child, $exports)) {
                       $exports[] = $child;
                       $n++;
                    }
                }
                return $n;
            }, $exports)) == 0) {
                break;
            }
        }

        foreach ($exports as $export) {
            $ret .= ($methods[$export][0] . "\n");
        }

        return $ret;
    }
1241581
public function canAccess(?ResourceAccessCheckerInterface $resourceAccessChecker, ResourceMetadata $resourceMetadata, string $resourceClass, ResolveInfo $info, $object = null, string $operationName = null): void
    {
        if (null === $resourceAccessChecker) {
            return;
        }

        $isGranted = $resourceMetadata->getGraphqlAttribute($operationName ?? '', 'access_control', null, true);
        if (null === $isGranted || $resourceAccessChecker->isGranted($resourceClass, $isGranted, ['object' => $object])) {
            return;
        }

        throw Error::createLocatedError($resourceMetadata->getGraphqlAttribute($operationName ?? '', 'access_control_message', 'Access Denied.'), $info->fieldNodes, $info->path);
    }
285299
protected function query($value)
    {
        $conditions = [$this->field => $value];
        /** @var MapperInterface $mapper */
        $mapper = $this->mapperManager->get($this->getEntity());
        if (!empty($this->exclude)) {
            $field = $this->exclude['field'] ?? '';
            $excludedValue = $this->exclude['value'] ?? '';
            $operator = $this->exclude['operator'] ?? '!=';

            if (!empty($field) && !empty($excludedValue)) {
                $conditions[] = $mapper->quoteIdentifier($field) . $operator . $mapper->quoteValue($excludedValue);
            }
        }
        $result = $mapper->find('all', [
            'conditions' => $conditions
        ]);

        return $result;
    }
928898
function &parse()
    {

        $rootDoc =& new rootDoc($this);
        $ii = 0;
        foreach ($this->_files as $path => $files) {
            $this->_sourceIndex = $ii++;
            if (isset($this->_options['overview'])) $this->_overview = $this->makeAbsolutePath($this->_options['overview'], $this->sourcePath());
            if (isset($this->_options['package_comment_dir'])) $this->_packageCommentDir = $this->makeAbsolutePath($this->_options['package_comment_dir'], $this->sourcePath());

            foreach ($files as $filename) {
                if ($filename) {
                    $this->message('Reading file "'.$filename.'"');
                    $fileString = @file_get_contents($filename);
                    if ($fileString !== FALSE) {
                        $fileString = str_replace( "\r\n", "\n", $fileString ); // fix Windows line endings
                        $fileString = str_replace( "\r", "\n", $fileString ); // fix ancient Mac line endings

                        $this->_currentFilename = $filename;

                        $tokens = token_get_all($fileString);

                        if (!$this->_verbose) echo 'Parsing tokens';

                        /* This array holds data gathered before the type of element is
                        discovered and an object is created for it, including doc comment
                        data. This data is stored in the object once it has been created and
                        then merged into the objects data fields upon object completion. */
                        $currentData = array();

                        $currentPackage = $this->_defaultPackage; // the current package
                        if ($this->_useClassPathAsPackage) { // magic up package name from filepath
                            $currentPackage .= '\\'.str_replace(' ', '\\', ucwords(str_replace(DIRECTORY_SEPARATOR, ' ', substr(dirname($filename), strlen($this->sourcePath()) + 1))));
                        }
                        $defaultPackage = $oldDefaultPackage = $currentPackage;
                        $fileData = array();

                        $currentElement = array(); // stack of element family, current at top of stack
                        $ce =& $rootDoc; // reference to element at top of stack

                        $open_curly_braces = FALSE;
                        $in_parsed_string = FALSE;

                        $counter = 0;
                        $lineNumber = 1;
                        $commentNumber = 0;

                        $numOfTokens = count($tokens);
                        for ($key = 0; $key < $numOfTokens; $key++) {
                            $token = $tokens[$key];
                            if (!$in_parsed_string && is_array($token)) {

                                $lineNumber += substr_count($token[1], "\n");

                                if ($commentNumber == 1 && (
                                    $token[0] == T_CLASS ||
                                    $token[0] == T_INTERFACE ||
                                    $token[0] == T_FUNCTION ||
                                    $token[0] == T_VARIABLE
                                )) { // we have a code block after the 1st comment, so it is not a file level comment
                                    $defaultPackage = $oldDefaultPackage;
                                    $fileData = array();
                                }

                                switch ($token[0]) {

                                case T_COMMENT: // read comment
                                case T_ML_COMMENT: // and multiline comment (deprecated in newer versions)
                                case T_DOC_COMMENT: // and catch PHP5 doc comment token too
                                    $currentData = array_merge($currentData, $this->processDocComment($token[1], $rootDoc));
                                    if ($currentData) {
                                        $commentNumber++;
                                        if ($commentNumber == 1) {
                                            if (isset($currentData['package'])) { // store 1st comment incase it is a file level comment
                                                $oldDefaultPackage = $defaultPackage;
                                                $defaultPackage = $currentData['package'];
                                            }
                                            $fileData = $currentData;
                                        }
                                    }
                                    break;

                                case T_CLASS:
                                // read class
                                    $class =& new classDoc($this->_getProgramElementName($tokens, $key), $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create class object
                                    $this->verbose('+ Entering '.get_class($class).': '.$class->name());
                                    if (isset($currentData['docComment'])) { // set doc comment
                                        $class->set('docComment', $currentData['docComment']);
                                    }
                                    $class->set('data', $currentData); // set data
                                    if (isset($currentData['package']) && $currentData['package'] != NULL) { // set package
                                        $currentPackage = $currentData['package'];
                                    }
                                    $class->set('package', $currentPackage);

                                    $parentPackage =& $rootDoc->packageNamed($class->packageName(), TRUE); // get parent package
                                    $parentPackage->addClass($class); // add class to package
                                    $class->setByRef('parent', $parentPackage); // set parent reference
                                    $currentData = array(); // empty data store
                                    if ($this->_includeElements($class)) {
                                        $currentElement[count($currentElement)] =& $class; // re-assign current element
                                    }
                                    $ce =& $class;
                                    break;

                                case T_INTERFACE:
                                // read interface
                                    $interface =& new classDoc($this->_getProgramElementName($tokens, $key), $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create interface object
                                    $this->verbose('+ Entering '.get_class($interface).': '.$interface->name());
                                    if (isset($currentData['docComment'])) { // set doc comment
                                        $interface->set('docComment', $currentData['docComment']);
                                    }
                                    $interface->set('data', $currentData); // set data
                                    $interface->set('interface', TRUE); // this element is an interface
                                    if (isset($currentData['package']) && $currentData['package'] != NULL) { // set package
                                        $currentPackage = $currentData['package'];
                                    }
                                    $interface->set('package', $currentPackage);

                                    $parentPackage =& $rootDoc->packageNamed($interface->packageName(), TRUE); // get parent package
                                    $parentPackage->addClass($interface); // add class to package
                                    $interface->setByRef('parent', $parentPackage); // set parent reference
                                    $currentData = array(); // empty data store
                                    if ($this->_includeElements($interface)) {
                                        $currentElement[count($currentElement)] =& $interface; // re-assign current element
                                    }
                                    $ce =& $interface;
                                    break;

                                case T_TRAIT:
                                // read trait
                                    $trait =& new classDoc($this->_getProgramElementName($tokens, $key), $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create trait object
                                    $this->verbose('+ Entering '.get_class($trait).': '.$trait->name());
                                    if (isset($currentData['docComment'])) { // set doc comment
                                        $trait->set('docComment', $currentData['docComment']);
                                    }
                                    $trait->set('data', $currentData); // set data
                                    $trait->set('trait', TRUE); // this element is a trait
                                    if (isset($currentData['package']) && $currentData['package'] != NULL) { // set package
                                        $currentPackage = $currentData['package'];
                                    }
                                    $trait->set('package', $currentPackage);

                                    $parentPackage =& $rootDoc->packageNamed($trait->packageName(), TRUE); // get parent package
                                    $parentPackage->addClass($trait); // add class to package
                                    $trait->setByRef('parent', $parentPackage); // set parent reference
                                    $currentData = array(); // empty data store
                                    if ($this->_includeElements($trait)) {
                                        $currentElement[count($currentElement)] =& $trait; // re-assign current element
                                    }
                                    $ce =& $trait;
                                    break;

                                case T_EXTENDS:
                                // get extends clause
                                    $superClassName = $this->_getProgramElementName($tokens, $key);
                                    $ce->set('superclass', $superClassName);
                                    if ($superClass =& $rootDoc->classNamed($superClassName) && $commentTag =& $superClass->tags('@text')) {
                                        $ce->setTag('@text', $commentTag);
                                    }
                                    break;

                                case T_IMPLEMENTS:
                                // get implements clause
                                    $interfaceName = $this->_getProgramElementName($tokens, $key);
                                    $interface =& $rootDoc->classNamed($interfaceName);
                                    if ($interface) {
                                        $ce->set('interfaces', $interface);
                                    }
                                    break;

                                case T_THROW:
                                // throws exception
                                    $className = $this->_getNext($tokens, $key, T_STRING);
                                    $class =& $rootDoc->classNamed($className);
                                    if ($class) {
                                        $ce->setByRef('throws', $class);
                                    } else {
                                        $ce->set('throws', $className);
                                    }
                                    break;

                                case T_PRIVATE:
                                    $currentData['access'] = 'private';
                                    break;

                                case T_PROTECTED:
                                    $currentData['access'] = 'protected';
                                    break;

                                case T_PUBLIC:
                                    $currentData['access'] = 'public';
                                    break;

                                case T_ABSTRACT:
                                    $currentData['abstract'] = TRUE;
                                    break;

                                case T_FINAL:
                                    $currentData['final'] = TRUE;
                                    break;

                                case T_STATIC:
                                    $currentData['static'] = TRUE;
                                    break;

                                case T_VAR:
                                    $currentData['var'] = 'var';
                                    break;

                                case T_CONST:
                                    $currentData['var'] = 'const';
                                    break;

                                case T_USE:
                                    if (strtolower(get_class($ce)) == 'classdoc') {
                                        while ($tokens[++$key][0] != ';') {
                                            if ($tokens[$key][0] == T_STRING) {
                                                $className = $tokens[$key][1];
                                                $class =& $rootDoc->classNamed($className);
                                                if ($class) {
                                                    $ce->setByRef('traits', $class);
                                                } else {
                                                    $ce->set('traits', $className);
                                                }
                                            }
                                        }
                                    }
                                    break;

                                case T_NAMESPACE:
                                case T_NS_C:
                                    $namespace = '';
                                    while ($tokens[++$key][0] != T_STRING);
                                    $namespace = $tokens[$key++][1];
                                    while ($tokens[$key][0] == T_NS_SEPARATOR) {
                                        $namespace .= $tokens[$key++][1] . $tokens[$key++][1];
                                    }
                                    $currentPackage = $defaultPackage = $oldDefaultPackage = $namespace;
                                    $key--;
                                    break;

                                case T_FUNCTION:
                                // read function
                                    $name = $this->_getProgramElementName($tokens, $key);
                                    $method =& new methodDoc($name, $ce, $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create method object
                                    $this->verbose('+ Entering '.get_class($method).': '.$method->name());
                                    if (isset($currentData['docComment'])) { // set doc comment
                                        $method->set('docComment', $currentData['docComment']); // set doc comment
                                    }
                                    $method->set('data', $currentData); // set data
                                    $ceClass = strtolower(get_class($ce));
                                    if ($ceClass == 'rootdoc') { // global function, add to package
                                        $this->verbose(' is a global function');
                                        if (isset($currentData['access']) && $currentData['access'] == 'private') $method->makePrivate();
                                        if (isset($currentData['package']) && $currentData['package'] != NULL) { // set package
                                            $method->set('package', $currentData['package']);
                                        } else {
                                            $method->set('package', $currentPackage);
                                        }
                                        $method->mergeData();
                                        $parentPackage =& $rootDoc->packageNamed($method->packageName(), TRUE); // get parent package
                                        if ($this->_includeElements($method)) {
                                            $parentPackage->addFunction($method); // add method to package
                                        }
                                    } elseif ($ceClass == 'classdoc' || $ceClass == 'methoddoc') { // class method, add to class
                                        $method->set('package', $ce->packageName()); // set package
                                        if ($method->name() == '__construct' || strtolower($method->name()) == strtolower($ce->name())) { // constructor
                                            $this->verbose(' is a constructor of '.get_class($ce).' '.$ce->name());
                                            $method->set("name", "__construct");
                                            $ce->addMethod($method);
                                        } else {
                                            if ($this->_hasPrivateName($method->name())) $method->makePrivate();
                                            if (isset($currentData['access']) && $currentData['access'] == 'private') $method->makePrivate();
                                            $this->verbose(' is a method of '.get_class($ce).' '.$ce->name());
                                            if ($this->_includeElements($method)) {
                                                $method->mergeData();
                                                $ce->addMethod($method);
                                            }
                                            /*
                                            if ($name == 'exec') {
                                                echo "\n", $name, "\n";
                                                foreach ($method->_parameters as $tagName => $tag) {
                                                    echo $tagName;
                                                }
                                                echo "\n";
                                                #die;
                                            }
                                            //*/
                                        }
                                    }
                                    $currentData = array(); // empty data store
                                    $currentElement[count($currentElement)] =& $method; // re-assign current element
                                    $ce =& $method;
                                    break;

                                case T_STRING:

                                    if ($token[1] == 'define') {
                                        $const =& new fieldDoc($this->_getNext($tokens, $key, T_CONSTANT_ENCAPSED_STRING), $ce, $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create constant object

                                        $this->verbose('Found '.get_class($const).': global constant '.$const->name());
                                        $const->set('final', TRUE); // is constant
                                        $value = '';
                                        do {
                                            $key++;
                                        } while (isset($tokens[$key]) && $tokens[$key] != ',');
                                        $key++;
                                        while (isset($tokens[$key]) && $tokens[$key] != ')') {
                                            if (is_array($tokens[$key])) {
                                                $value .= $tokens[$key][1];
                                            } else {
                                                $value .= $tokens[$key];
                                            }
                                            $key++;
                                        }
                                        $value = trim($value);
                                        if (substr($value, 0, 5) == 'array') {
                                            $value = 'array(...)';
                                        }
                                        $const->set('value', $value);
                                        if (is_numeric($value)) {
                                            $const->set('type', new type('int', $rootDoc));
                                        } elseif (strtolower($value) == 'true' || strtolower($value) == 'false') {
                                            $const->set('type', new type('bool', $rootDoc));
                                        } elseif (
                                            substr($value, 0, 1) == '"' && substr($value, -1, 1) == '"' ||
                                            substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'"
                                        ) {
                                            $const->set('type', new type('str', $rootDoc));
                                        }
                                        unset($value);
                                        if (isset($currentData['docComment'])) { // set doc comment
                                            $const->set('docComment', $currentData['docComment']);
                                        }
                                        $const->set('data', $currentData); // set data
                                        if (isset($currentData['package'])) { // set package
                                            $const->set('package', $currentData['package']);
                                        } else {
                                            $const->set('package', $currentPackage);
                                        }
                                        $const->mergeData();
                                        $parentPackage =& $rootDoc->packageNamed($const->packageName(), TRUE); // get parent package
                                        if ($this->_includeElements($const)) {
                                            $parentPackage->addGlobal($const); // add constant to package
                                        }
                                        $currentData = array(); // empty data store

                                    // member constant
                                    } elseif (isset($currentData['var']) && $currentData['var'] == 'const') {
                                        do {
                                            $key++;
                                            if ($tokens[$key] == '=') {
                                                $name = $this->_getPrev($tokens, $key, array(T_VARIABLE, T_STRING));
                                                $value = '';
                                            } elseif (isset($value) && $tokens[$key] != ',' && $tokens[$key] != ';') { // set value
                                                if (is_array($tokens[$key])) {
                                                    $value .= $tokens[$key][1];
                                                } else {
                                                    $value .= $tokens[$key];
                                                }
                                            } elseif ($tokens[$key] == ',' || $tokens[$key] == ';') {
                                                if (!isset($name)) {
                                                    $name = $this->_getPrev($tokens, $key, array(T_VARIABLE, T_STRING));
                                                }
                                                $const =& new fieldDoc($name, $ce, $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create field object
                                                $this->verbose('Found '.get_class($const).': '.$const->name());
                                                if ($this->_hasPrivateName($const->name())) $const->makePrivate();
                                                $const->set('final', TRUE);
                                                if (isset($value)) { // set value
                                                    $value = trim($value);
                                                    if (strlen($value) > 30 && substr($value, 0, 5) == 'array') {
                                                        $value = 'array(...)';
                                                    }
                                                    $const->set('value', $value);
                                                    if (is_numeric($value)) {
                                                        $const->set('type', new type('int', $rootDoc));
                                                    } elseif (strtolower($value) == 'true' || strtolower($value) == 'false') {
                                                        $const->set('type', new type('bool', $rootDoc));
                                                    } elseif (
                                                        substr($value, 0, 1) == '"' && substr($value, -1, 1) == '"' ||
                                                        substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'"
                                                    ) {
                                                        $const->set('type', new type('str', $rootDoc));
                                                    }
                                                }
                                                if (isset($currentData['docComment'])) { // set doc comment
                                                    $const->set('docComment', $currentData['docComment']);
                                                }
                                                $const->set('data', $currentData); // set data
                                                $const->set('package', $ce->packageName()); // set package
                                                $const->set('static', TRUE);
                                                $this->verbose(' is a member constant of '.get_class($ce).' '.$ce->name());
                                                $const->mergeData();
                                                if ($this->_includeElements($const)) {
                                                    $ce->addConstant($const);
                                                }
                                                unset($name);
                                                unset($value);
                                            }
                                        } while (isset($tokens[$key]) && $tokens[$key] != ';');
                                        $currentData = array(); // empty data store

                                    // function parameter
                                    } elseif (strtolower(get_class($ce)) == 'methoddoc' && $ce->inBody == 0) {
                                        $typehint = NULL;
                                        do {
                                            $key++;
                                            if (!isset($tokens[$key])) break;
                                            if ($tokens[$key] == ',' || $tokens[$key] == ')') {
                                                unset($param);
                                            } elseif (is_array($tokens[$key])) {
                                                if ($tokens[$key][0] == T_STRING && !isset($param)) { // type hint
                                                    $typehint = $tokens[$key][1];
                                                } elseif ($tokens[$key][0] == T_VARIABLE && !isset($param)) {
                                                    $param =& new fieldDoc($tokens[$key][1], $ce, $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create constant object
                                                    $this->verbose('Found '.get_class($param).': '.$param->name());
                                                    if (isset($currentData['docComment'])) { // set doc comment
                                                        $param->set('docComment', $currentData['docComment']);
                                                    }
                                                    if ($typehint) {
                                                        $param->set('type', new type($typehint, $rootDoc));
                                                        $this->verbose(' has a typehint of '.$typehint);
                                                    }
                                                    $param->set('data', $currentData); // set data
                                                    $param->set('package', $ce->packageName()); // set package
                                                    $this->verbose(' is a parameter of '.get_class($ce).' '.$ce->name());
                                                    $param->mergeData();
                                                    $ce->addParameter($param);
                                                    $typehint = NULL;
                                                } elseif (isset($param) && ($tokens[$key][0] == T_STRING || $tokens[$key][0] == T_CONSTANT_ENCAPSED_STRING || $tokens[$key][0] == T_LNUMBER)) { // set value
                                                    $value = $tokens[$key][1];
                                                    $param->set('value', $value);
                                                    if (!$typehint) {
                                                        if (is_numeric($value)) {
                                                            $param->set('type', new type('int', $rootDoc));
                                                        } elseif (strtolower($value) == 'true' || strtolower($value) == 'false') {
                                                            $param->set('type', new type('bool', $rootDoc));
                                                        } elseif (
                                                            substr($value, 0, 1) == '"' && substr($value, -1, 1) == '"' ||
                                                            substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'"
                                                        ) {
                                                            $param->set('type', new type('str', $rootDoc));
                                                        }
                                                    }
                                                }
                                            }
                                        } while (isset($tokens[$key]) && $tokens[$key] != ')');
                                        $currentData = array(); // empty data store
                                    }
                                    break;

                                case T_VARIABLE:
                                    // read global variable
                                    if (strtolower(get_class($ce)) == 'rootdoc') { // global var, add to package
                                        $global =& new fieldDoc($tokens[$key][1], $ce, $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create constant object
                                        $this->verbose('Found '.get_class($global).': global variable '.$global->name());
                                        if (isset($tokens[$key - 1][0]) && isset($tokens[$key - 2][0]) && $tokens[$key - 2][0] == T_STRING && $tokens[$key - 1][0] == T_WHITESPACE) {
                                            $global->set('type', new type($tokens[$key - 2][1], $rootDoc));
                                        } while (isset($tokens[$key]) && $tokens[$key] != '=' && $tokens[$key] != ';') {
                                            $key++;
                                        }
                                        if (isset($tokens[$key]) && $tokens[$key] == '=') {
                                            $default = '';
                                            $key2 = $key + 1;
                                            do {
                                                if (is_array($tokens[$key2])) {
                                                    if ($tokens[$key2][1] != '=') $default .= $tokens[$key2][1];
                                                } else {
                                                    if ($tokens[$key2] != '=') $default .= $tokens[$key2];
                                                }
                                                $key2++;
                                            } while (isset($tokens[$key2]) && $tokens[$key2] != ';' && $tokens[$key2] != ',' && $tokens[$key2] != ')');
                                            $global->set('value', trim($default, ' ()')); // set value
                                        }
                                        if (isset($currentData['docComment'])) { // set doc comment
                                            $global->set('docComment', $currentData['docComment']);
                                        }
                                        $global->set('data', $currentData); // set data
                                        if (isset($currentData['package'])) { // set package
                                            $global->set('package', $currentData['package']);
                                        } else {
                                            $global->set('package', $currentPackage);
                                        }
                                        $global->mergeData();
                                        $parentPackage =& $rootDoc->packageNamed($global->packageName(), TRUE); // get parent package
                                        if ($this->_includeElements($global)) {
                                            $parentPackage->addGlobal($global); // add constant to package
                                        }
                                        $currentData = array(); // empty data store

                                // read member variable
                                    } elseif (
                                        (isset($currentData['var']) && $currentData['var'] == 'var') ||
                                        (isset($currentData['access']) && ($currentData['access'] == 'public' || $currentData['access'] == 'protected' || $currentData['access'] == 'private'))
                                    ) {
                                        unset($name);
                                        do {
                                            $key++;
                                            if ($tokens[$key] == '=') { // start value
                                                $name = $this->_getPrev($tokens, $key, T_VARIABLE);
                                                $value = '';
                                                $bracketCount = 0;
                                            } elseif (isset($value) && ($tokens[$key] != ',' || $bracketCount > 0) && $tokens[$key] != ';') { // set value
                                                if ($tokens[$key] == '(') {
                                                    $bracketCount++;
                                                } elseif ($tokens[$key] == ')') {
                                                    $bracketCount--;
                                                }
                                                if (is_array($tokens[$key])) {
                                                    $value .= $tokens[$key][1];
                                                } else {
                                                    $value .= $tokens[$key];
                                                }
                                            } elseif ($tokens[$key] == ',' || $tokens[$key] == ';') {
                                                if (!isset($name)) {
                                                    $name = $this->_getPrev($tokens, $key, T_VARIABLE);
                                                }
                                                $field =& new fieldDoc($name, $ce, $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create field object
                                                $this->verbose('Found '.get_class($field).': '.$field->name());
                                                if ($this->_hasPrivateName($field->name())) $field->makePrivate();
                                                if (isset($value)) { // set value
                                                    $value = trim($value);
                                                    if (strlen($value) > 30 && substr($value, 0, 5) == 'array') {
                                                        $value = 'array(...)';
                                                    }
                                                    $field->set('value', $value);
                                                }
                                                if (isset($currentData['docComment'])) { // set doc comment
                                                    $field->set('docComment', $currentData['docComment']);
                                                }
                                                $field->set('data', $currentData); // set data
                                                $field->set('package', $ce->packageName()); // set package
                                                $this->verbose(' is a member variable of '.get_class($ce).' '.$ce->name());
                                                $field->mergeData();
                                                if ($this->_includeElements($field)) {
                                                    $ce->addField($field);
                                                }
                                                unset($name);
                                                unset($value);
                                            }
                                        } while (isset($tokens[$key]) && $tokens[$key] != ';');
                                        $currentData = array(); // empty data store

                                    }
                                    break;

                                case T_CURLY_OPEN:
                                case T_DOLLAR_OPEN_CURLY_BRACES: // we must catch this so we don't accidently step out of the current block
                                    $open_curly_braces = TRUE;
                                    break;
                                }

                            } else { // primitive tokens

                                switch ($token) {
                                case '{':
                                    if (!$in_parsed_string) {
                                        $ce->inBody++;
                                    }
                                    break;
                                case '}':
                                    if (!$in_parsed_string) {
                                        if ($open_curly_braces) { // end of var curly brace syntax
                                            $open_curly_braces = FALSE;
                                        } else {
                                            $ce->inBody--;
                                            if ($ce->inBody == 0 && count($currentElement) > 0) {
                                                $ce->mergeData();
                                                $this->verbose('- Leaving '.get_class($ce).': '.$ce->name());
                                                array_pop($currentElement); // re-assign current element
                                                if (count($currentElement) > 0) {
                                                    $ce =& $currentElement[count($currentElement) - 1];
                                                } else {
                                                    unset($ce);
                                                    $ce =& $rootDoc;
                                                }
                                                $currentPackage = $defaultPackage;
                                            }
                                        }
                                    }
                                    break;
                                case ';': // case for closing abstract functions
                                    if (!$in_parsed_string && $ce->inBody == 0 && count($currentElement) > 0) {
                                        $ce->mergeData();
                                        $this->verbose('- Leaving empty '.get_class($ce).': '.$ce->name());
                                        array_pop($currentElement); // re-assign current element
                                        if (count($currentElement) > 0) {
                                            $ce =& $currentElement[count($currentElement) - 1];
                                        } else {
                                            unset($ce);
                                            $ce =& $rootDoc;
                                        }
                                    }
                                    break;
                                case '"': // catch parsed strings so as to ignore tokens within
                                    $in_parsed_string = !$in_parsed_string;
                                    break;
                                }
                            }

                            $counter++;
                            if ($counter > 99) {
                                if (!$this->_verbose) echo '.';
                                $counter = 0;
                            }
                        }
                        if (!$this->_verbose) echo "\n";

                        $rootDoc->addSource($filename, $fileString, $fileData);

                    } else {
                        $this->error('Could not read file "'.$filename.'"');
                        exit;
                    }
                }
            }
        }

        // add parent data to child elements
        $this->message('Merging superclass data');
        $this->_mergeSuperClassData($rootDoc);

        return $rootDoc;
    }
1349885
protected function _throw($object)
    {
        $error = $object->errorInfo();
        throw new \RuntimeException(
            sprintf(
                'PDO operation returned SQLSTATE %s: Error %s (%s)',
                $error[0],
                $error[1],
                $error[2]
            )
        );
    }
355347
public function getStmt()
    {
        // Make sure there are no nested arrays
        if (ArrayUtils::hasAtLeastOneArrayValue($this->bindings)) {
            throw new RuntimeException('PDO bindings can not contain nested arrays');
        }

        // Build target query before bindings are cleared purely for logging purpose
        $log = str_replace(array_keys($this->bindings), array_values($this->bindings), $this->queryBuilder->getQueryString());

        // Execute it
        $stmt = $this->pdo->prepare($this->queryBuilder->getQueryString());
        $stmt->execute($this->bindings);

        // Log target query
        $this->queryLogger->add($log);

        // Clear the buffer
        $this->clear();

        return $stmt;
    }
1079710
protected function doExtract($object)
    {
        $originalFieldNames = $this->metadata->getOriginalFieldNames();

        /*
        $filter = $object instanceof FilterProviderInterface
            ? $object->getFilter()
            : $this->filterComposite;
        */

        $data = [];
        if (! $this->metadata->hasCustomHydrator()) {

            $this->executeMethods($object, $this->metadata->getPreExtractListeners());

            foreach ($originalFieldNames as $originalFieldName) {
                $mappedFieldName = $this->metadata->getMappedFieldName($originalFieldName);

                if ($this->metadata->isNotManaged($mappedFieldName)) {
                    continue;
                }

                if ($this->metadata->isValueObject($mappedFieldName)) {
                    continue;
                }

                /*if ($filter && !$filter->filter($mappedFieldName)) {
                    continue;
                }*/

                try {
                    $value = $this->memberAccessStrategy->getValue($object, $mappedFieldName);             
                } catch (NotFoundMemberException $e) {
                    continue;
                }

                if (null === $value) {
                    $data[$originalFieldName] = null;
                    continue;
                }

                if ($fieldClass = $this->metadata->getClassOfMappedField($mappedFieldName)) {
                    $fieldHydrator = $this->objectManager->createHydratorFor($fieldClass);
                    $fieldValue = $value;

                    /*if (! is_array($fieldValue)) {
                        throw new ObjectMappingException(
                            sprintf(
                                'Cannot hydrate field "%s" of class "%s" from raw data.'
                                . ' Raw data should be an array but got "%s".', 
                                $mappedFieldName,
                                $fieldClass,
                                is_object($fieldValue) ? get_class($fieldValue) : gettype($fieldValue)
                                )
                        );
                    }   */
                    
                    reset($fieldValue);
                    if (0 !== count($fieldValue) && ! is_numeric(key($fieldValue))) {
                        $fieldRawData = $fieldHydrator->extract($fieldValue);
                        $data[$originalFieldName] = $fieldRawData;                              
                    } else {

                        $fieldRawData = [];
                        foreach ($fieldValue as $itemFieldValue) {              
                            $fieldRawData[] = $fieldHydrator->extract($itemFieldValue);                
                        }
                        $data[$originalFieldName] = $fieldRawData;
                    }   
                } else {
                    $value = $this->extractValue($mappedFieldName, $value, $object, $data);
                    $data[$originalFieldName] = $value;    
                }
            }
        } else {
            list($customHydratorClass, , $customExtractMethod) = $this->metadata->getCustomHydratorInfo();            
            $this->executeMethod($object, new ClassMetadata\Model\Method($customHydratorClass, $customExtractMethod, [$object]));
        }

        //Value objects extraction.
        foreach ($this->metadata->getFieldsWithValueObjects() as $mappedFieldName) {

            if ($this->metadata->isNotManaged($mappedFieldName)) {
                continue;
            }

            $info = $this->metadata->getValueObjectInfo($mappedFieldName);
            list($voClassName, $voResource, $voResourceType) = $info;

            $valueObjectHydrator = $this->objectManager->createHydratorFor($voClassName);
            $objectKey = $this->pushRuntimeConfiguration($mappedFieldName, $object, $voClassName, $voResourceType, $voResource);

            $valueObject = $this->memberAccessStrategy->getValue($object, $mappedFieldName);
            $valueObjectData = $valueObjectHydrator->extract($valueObject, $objectKey);
            $this->popRuntimeConfiguration();

            $data = array_merge($data, $valueObjectData);
        }

        $this->executeMethods($object, $this->metadata->getPostExtractListeners());

        return $data;
    }
332161
function bindAndExecute() {
		$conn = $this->connection;

		if ($conn === null) {
			throw new RuntimeException('bindAndExecute cannot be called on a QueryStatement without a connection.');
		}
		if ($conn instanceof DBMSSQL && $conn->getDriver() === 'dblib' && function_exists('mb_detect_encoding')) {
			return $conn->query($this->__toString());
		}
		if ($conn instanceof DBSQLite) {
			return $conn->query($this->__toString());
		}

		$string = self::embedIdentifiers($this->getString(), array_values($this->identifiers), $conn);

		$result = $conn->prepare($string);
		foreach ($this->getParams() as $key => $value) {
			$pdo_type = PDO::PARAM_STR;
			if (is_int($value)) {
				$pdo_type = PDO::PARAM_INT;
			} elseif (is_null($value)) {
				$pdo_type = PDO::PARAM_NULL;
			} elseif (is_bool($value)) {
				$value = $value ? 1 : 0;
				$pdo_type = PDO::PARAM_INT;
			}
			$result->bindValue($key + 1, $value, $pdo_type);
		}
		$result->execute();
		return $result;
	}
600742
public function execute($response) {

        $ok = $this->check_tool_proxy(null, $response->get_request_data());
        if ($ok) {
            $toolproxy = $this->get_service()->get_tool_proxy();
        } else {
            $toolproxy = null;
            $response->set_code(401);
        }
        $tools = array();

        // Ensure all required elements are present in the Tool Proxy.
        if ($ok) {
            $toolproxyjson = json_decode($response->get_request_data());
            $ok = !empty($toolproxyjson);
            if (!$ok) {
                debugging('Tool proxy is not properly formed JSON');
            } else {
                $ok = isset($toolproxyjson->tool_profile->product_instance->product_info->product_family->vendor->code);
                $ok = $ok && isset($toolproxyjson->security_contract->shared_secret);
                $ok = $ok && isset($toolproxyjson->tool_profile->resource_handler);
                if (!$ok) {
                    debugging('One or more missing elements from tool proxy: vendor code, shared secret or resource handlers');
                }
            }
        }

        // Check all capabilities requested were offered.
        if ($ok) {
            $offeredcapabilities = explode("\n", $toolproxy->capabilityoffered);
            $resources = $toolproxyjson->tool_profile->resource_handler;
            $errors = array();
            foreach ($resources as $resource) {
                if (isset($resource->message)) {
                    foreach ($resource->message as $message) {
                        if (!in_array($message->message_type, $offeredcapabilities)) {
                            $errors[] = $message->message_type;
                        } else if (isset($resource->parameter)) {
                            foreach ($message->parameter as $parameter) {
                                if (isset($parameter->variable) && !in_array($parameter->variable, $offeredcapabilities)) {
                                    $errors[] = $parameter->variable;
                                }
                            }
                        }
                    }
                }
            }
            if (count($errors) > 0) {
                $ok = false;
                debugging('Tool proxy contains capabilities which were not offered: ' . implode(', ', $errors));
            }
        }

        // Check all services requested were offered (only tool services currently supported).
        if ($ok && isset($toolproxyjson->security_contract->tool_service)) {
            $contexts = lti_get_contexts($toolproxyjson);
            $profileservice = lti_get_service_by_name('profile');
            $profileservice->set_tool_proxy($toolproxy);
            $context = $profileservice->get_service_path() . $profileservice->get_resources()[0]->get_path() . '#';
            $offeredservices = explode("\n", $toolproxy->serviceoffered);
            $services = lti_get_services();
            $tpservices = $toolproxyjson->security_contract->tool_service;
            $errors = array();
            foreach ($tpservices as $service) {
                $fqid = lti_get_fqid($contexts, $service->service);
                if (substr($fqid, 0, strlen($context)) !== $context) {
                    $errors[] = $service->service;
                } else {
                    $id = explode('#', $fqid, 2);
                    $aservice = lti_get_service_by_resource_id($services, $id[1]);
                    $classname = explode('\\', get_class($aservice));
                    if (empty($aservice) || !in_array($classname[count($classname) - 1], $offeredservices)) {
                        $errors[] = $service->service;
                    }
                }
            }
            if (count($errors) > 0) {
                $ok = false;
                debugging('Tool proxy contains services which were not offered: ' . implode(', ', $errors));
            }
        }

        // Extract all launchable tools from the resource handlers.
        if ($ok) {
            $resources = $toolproxyjson->tool_profile->resource_handler;
            $messagetypes = [
                'basic-lti-launch-request',
                'ContentItemSelectionRequest',
            ];
            foreach ($resources as $resource) {
                $launchable = false;
                $messages = array();
                $tool = new \stdClass();

                $iconinfo = null;
                if (is_array($resource->icon_info)) {
                    $iconinfo = $resource->icon_info[0];
                } else {
                    $iconinfo = $resource->icon_info;
                }
                if (isset($iconinfo) && isset($iconinfo->default_location) && isset($iconinfo->default_location->path)) {
                    $tool->iconpath = $iconinfo->default_location->path;
                }

                foreach ($resource->message as $message) {
                    if (in_array($message->message_type, $messagetypes)) {
                        $launchable = $launchable || ($message->message_type === 'basic-lti-launch-request');
                        $messages[$message->message_type] = $message;
                    }
                }
                if (!$launchable) {
                    continue;
                }
                $tool->name = $resource->resource_name->default_value;
                $tool->messages = $messages;
                $tools[] = $tool;
            }
            $ok = count($tools) > 0;
            if (!$ok) {
                debugging('No launchable messages found in tool proxy');
            }
        }

        // Add tools and custom parameters.
        if ($ok) {
            $baseurl = '';
            if (isset($toolproxyjson->tool_profile->base_url_choice[0]->default_base_url)) {
                $baseurl = $toolproxyjson->tool_profile->base_url_choice[0]->default_base_url;
            }
            $securebaseurl = '';
            if (isset($toolproxyjson->tool_profile->base_url_choice[0]->secure_base_url)) {
                $securebaseurl = $toolproxyjson->tool_profile->base_url_choice[0]->secure_base_url;
            }
            foreach ($tools as $tool) {
                $messages = $tool->messages;
                $launchrequest = $messages['basic-lti-launch-request'];
                $config = new \stdClass();
                $config->lti_toolurl = "{$baseurl}{$launchrequest->path}";
                $config->lti_typename = $tool->name;
                $config->lti_coursevisible = 1;
                $config->lti_forcessl = 0;
                if (isset($messages['ContentItemSelectionRequest'])) {
                    $contentitemrequest = $messages['ContentItemSelectionRequest'];
                    $config->lti_contentitem = 1;
                    if ($launchrequest->path !== $contentitemrequest->path) {
                        $config->lti_toolurl_ContentItemSelectionRequest = $baseurl . $contentitemrequest->path;
                    }
                    $contentitemcapabilities = implode("\n", $contentitemrequest->enabled_capability);
                    $config->lti_enabledcapability_ContentItemSelectionRequest = $contentitemcapabilities;
                    $contentitemparams = self::lti_extract_parameters($contentitemrequest->parameter);
                    $config->lti_parameter_ContentItemSelectionRequest = $contentitemparams;
                }

                $type = new \stdClass();
                $type->state = LTI_TOOL_STATE_PENDING;
                $type->toolproxyid = $toolproxy->id;
                $type->enabledcapability = implode("\n", $launchrequest->enabled_capability);
                $type->parameter = self::lti_extract_parameters($launchrequest->parameter);

                if (!empty($tool->iconpath)) {
                    $type->icon = "{$baseurl}{$tool->iconpath}";
                    if (!empty($securebaseurl)) {
                        $type->secureicon = "{$securebaseurl}{$tool->iconpath}";
                    }
                }

                $ok = $ok && (lti_add_type($type, $config) !== false);
            }
            if (isset($toolproxyjson->custom)) {
                lti_set_tool_settings($toolproxyjson->custom, $toolproxy->id);
            }
        }

        if (!empty($toolproxy)) {
            if ($ok) {
                // If all went OK accept the tool proxy.
                $toolproxy->state = LTI_TOOL_PROXY_STATE_ACCEPTED;
                $toolproxy->toolproxy = $response->get_request_data();
                $toolproxy->secret = $toolproxyjson->security_contract->shared_secret;
                $toolproxy->vendorcode = $toolproxyjson->tool_profile->product_instance->product_info->product_family->vendor->code;

                $url = $this->get_endpoint();
                $body = <<< EOD
{
  "@context" : "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId",
  "@type" : "ToolProxy",
  "@id" : "{$url}",
  "tool_proxy_guid" : "{$toolproxy->guid}"
}
EOD;
                $response->set_code(201);
                $response->set_content_type('application/vnd.ims.lti.v2.toolproxy.id+json');
                $response->set_body($body);
            } else {
                // Otherwise reject the tool proxy.
                $toolproxy->state = LTI_TOOL_PROXY_STATE_REJECTED;
                $response->set_code(400);
            }
            lti_update_tool_proxy($toolproxy);
        } else {
            $response->set_code(400);
        }
    }
21659
static function validateInputHandlers( &$module, &$class, $object, &$version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage, $validationParameters )
    {
        $result = array( 'validated' => true, 'warnings' => array() );
        $validated =& $result['validated'];
        $warnings =& $result['warnings'];

        $http = eZHTTPTool::instance();

        $functionName = 'validateInput';
        $params = array( $http,
                         &$module,
                         &$class,
                         $object,
                         &$version,
                         $contentObjectAttributes,
                         $editVersion,
                         $editLanguage,
                         $fromLanguage,
                         $validationParameters );

        $validationResults = self::executeHandlerFunction( $functionName, $params );

        foreach( $validationResults as $validationResult )
        {
            $value = $validationResult['function']['value'];

            if ( $value['is_valid'] == false )
            {
                if ( $value['warnings'] )
                    $warnings = array_merge( $warnings, $value['warnings'] );

                $validated = false;
            }
        }

        return $result;
    }
145193
public function execute($object)
    {
        $callable = array($object, $this->methodName);

        if (!is_callable($callable)) {
            $className = get_class($object);

            throw new RuntimeException("Method '$this->methodName' does not exist in object of class '$className'");
        }

        return call_user_func_array($callable, $this->params);
    }
753101
public function php($baseIndent = 0) {
    $php = $this->phpDocBlock($baseIndent);
    
    $php .= str_repeat(' ',$baseIndent);
    $ms = array(
                self::MODIFIER_PUBLIC => 'public',
                self::MODIFIER_PRIVATE => 'private',
                self::MODIFIER_PROTECTED => 'protected',
                self::MODIFIER_STATIC => 'static',
                // self::MODIFIER_FINAL => 'final' // kein final für properties?
               );
    
    foreach ($ms as $const => $modifier) {
      if (($const & $this->modifiers) == $const)
        $php .= $modifier.' ';
    }
    
    $php .= '$'.$this->name;
    
    if ($this->hasDefaultValue() && $this->getDefaultValue() !== NULL) {
      $php .= ' = '.$this->exportPropertyValue($this->getDefaultValue());
    }
    
    return $php;
  }
152433
public function getData($entity = array())
    {
        if ($this->accessor == null) {
            $this->accessor = new PropertyAccessor;
        }

        foreach ($this->getFields() as $name => $field) {
            if ($mapping = $field->getMappingName()) {
                if (is_array($entity)) {
                    $entity[$mapping] = $field->getMappingValue();
                } else {
                    $this->accessor->setValue($entity, $mapping, $field->getMappingValue());
                }
            }
        }

        return $entity;
    }