{@inheritDoc}

@SuppressWarnings(PHPMD.UnusedFormalParameter)
339291
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!($this->project && $this->getApi())) {
            $this->writelnAlways($output, '<error>No project set or no API received, exiting.</error>');

            return;
        }

        $project = new Project($this->getApi());

        $project->setSlug($this->project);

        $resources = $project->getResources();

        $files = $this->getAllTxFiles($this->baselanguage);

        foreach ($files as $file => $basename) {
            $noext = basename($basename, '.xlf');
            if (array_key_exists($this->prefix . $noext, $resources)) {
                // already present, update.
                $this->writeln($output, sprintf('Updating ressource <info>%s</info>', $this->prefix . $noext));
                /** @var \CyberSpectrum\Transifex\TranslationResource $resource */
                $resource = $resources[$this->prefix . $noext];
                $resource->setContent(file_get_contents($file));
                $resource->updateContent();
            } else {
                $this->writeln($output, sprintf('Creating new ressource <info>%s</info>', $this->prefix . $noext));
                // upload new.
                $resource = new TranslationResource($this->getApi());
                $resource->setProject($this->project);
                $resource->setSlug($this->prefix . $noext);
                $resource->setName($resource->getSlug());
                $resource->setSourceLanguageCode($this->baselanguage);

                $resource->setContent(file_get_contents($file));

                $resource->create();
            }
        }
    }
894263
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$value, $namedParameters, $placement )
    {
        if ( isset( $this->PHPNameMap[$operatorName] ) )
        {
            $typeFunction = $this->PHPNameMap[$operatorName];
            $this->checkType( $typeFunction, $tpl, $value, $operatorParameters, $rootNamespace, $currentNamespace, $placement );
            return;
        }
        switch ( $operatorName )
        {
            case $this->IsClassName:
            {
                if ( count( $operatorParameters ) == 1 )
                {
                    $className = $tpl->elementValue( $operatorParameters[0], $rootNamespace, $currentNamespace, $placement );
                    $value = strtolower( get_class( $value ) ) == strtolower( $className );
                }
                else
                {
                    $className = $tpl->elementValue( $operatorParameters[0], $rootNamespace, $currentNamespace, $placement );
                    $value = strtolower( get_class( $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace, $placement ) ) ) == strtolower( $className );
                }
            } break;
            case $this->IsSetName:
            {
                if ( count( $operatorParameters ) > 0 )
                {
                    if ( count( $operatorParameters ) > 1 )
                    {
                        $tpl->extraParameters( $operatorName, count( $operatorParameters ), 1 );
                    }

                    $operand = $tpl->elementValue( $operatorParameters[0], $rootNamespace, $currentNamespace, $placement, true );
                    $value = $operand !== null;


                }
                else
                    $tpl->missingParameter( $operatorName, 'input' );

            } break;
            case $this->IsUnsetName:
            {
                if ( count( $operatorParameters ) > 0 )
                {
                    if ( count( $operatorParameters ) > 1 )
                        $tpl->extraParameters( $operatorName,
                                               count( $operatorParameters ),
                                               1 );
                    $operand = $tpl->elementValue( $operatorParameters[0], $rootNamespace, $currentNamespace, $placement, true );
                    $value = $operand === null;
                }
                else
                    $tpl->missingParameter( $operatorName, 'input' );
            } break;
            case $this->GetTypeName:
            {
                if ( count( $operatorParameters ) > 0 )
                {
                    if ( count( $operatorParameters ) > 1 )
                        $tpl->extraParameters( $operatorName,
                                               count( $operatorParameters ),
                                               1 );
                    $operand = $tpl->elementValue( $operatorParameters[0], $rootNamespace, $currentNamespace, $placement );
                }
                else
                    $operand =& $value;
                if ( $operand === null )
                    $value = 'null';
                else if ( is_bool( $operand ) )
                    $value = 'boolean[' . ( $operand ? 'true' : 'false' ) . ']';
                else if ( is_object( $operand ) )
                    $value = 'object[' . get_class( $operand ) . ']';
                else if ( is_array( $operand ) )
                    $value = 'array[' . count( $operand ) . ']';
                else if ( is_string( $operand ) )
                    $value = 'string[' . strlen( $operand ) . ']';
                else
                    $value = gettype( $operand );
            } break;
            case $this->GetClassName:
            {
                if ( count( $operatorParameters ) > 0 )
                {
                    if ( count( $operatorParameters ) > 1 )
                        $tpl->extraParameters( $operatorName,
                                               count( $operatorParameters ),
                                               1 );
                    $operand = $tpl->elementValue( $operatorParameters[0], $rootNamespace, $currentNamespace, $placement );
                    $value = strtolower( get_class( $operand ) );
                }
                else
                {
                    $value = strtolower( get_class( $value ) );
                }
            } break;
        }
    }
267231
function select($fields,$filter=NULL,array $options=NULL,$ttl=0) {
		list($sql,$args)=$this->stringify($fields,$filter,$options);
		$result=$this->db->exec($sql,$args,$ttl);
		$out=[];
		foreach ($result as &$row) {
			foreach ($row as $field=>&$val) {
				if (array_key_exists($field,$this->fields)) {
					if (!is_null($val) || !$this->fields[$field]['nullable'])
						$val=$this->db->value(
							$this->fields[$field]['pdo_type'],$val);
				}
				unset($val);
			}
			$out[]=$this->factory($row);
			unset($row);
		}
		return $out;
	}
107062
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
    {
        $dom = $namedParameters['dom'];
        if ( $dom instanceof eZContentObjectAttribute )
        {
            $this->ObjectAttributeId = $dom->attribute( 'id' );
            $content = $dom->attribute( 'content' );
            $xmlData = $content->attribute( 'xml_data' );

            $domTree = new DOMDocument( '1.0', 'utf-8' );
            $domTree->preserveWhiteSpace = false;
            $success = $domTree->loadXML( $xmlData );

            $tocText = '';
            if ( $success )
            {
                $this->HeaderCounter = array();
                $this->LastHeaderLevel = 0;

                $rootNode = $domTree->documentElement;
                $tocText .= $this->handleSection( $rootNode );

                while ( $this->LastHeaderLevel > 0 )
                {
                    $tocText .= "</li>\n</ul>\n";
                    $this->LastHeaderLevel--;
                }
            }
        }
        $operatorValue = $tocText;
    }
289509
public function execute($input_parameters = null)
    {
        $debug = $this->pdo->getDebugSnapshot();
        $return = parent::execute($input_parameters);

        $sql = $this->getExecutedQueryString($input_parameters?$input_parameters:array());
        $this->pdo->log($sql, null, __METHOD__, $debug);
        $this->pdo->setLastExecutedQuery($sql);
        $this->pdo->incrementQueryCount();

        return $return;
    }
229039
function apply($value, $instance = null, $attribute = null)
    {
        if(!$instance->$attribute) {
            return null;
        }

        if($instance->$attribute() instanceof MorphMany) {
            // We are handling a list of uploads
            return $instance->$attribute->map(function($upload) {
                $array = $this->transformUpload($upload);

                $file = array_only($array, ["name", "thumbnail", "size"]);

                return [
                    "file" => sizeof($file) ? $file : null,
                ] + array_except($array, ["name", "thumbnail", "size"]);
            })->all();
        };

        return $this->transformUpload($instance->$attribute);
    }
272992
static function checkRequiredParametersAreSet(array $given, array $required)
    {
        foreach ($required as $key) {
            if (empty($given[$key])) {
                throw new MissingRequiredParameterException(
                        "Missing required parameter '$key'"
                );
            }
        }
    }
522366
public function execute($parameters = null)
    {
        if ($parameters !== null) {
            $parameters = array_intersect_key($parameters, $this->types);
            foreach ($this->placeholders as $i => $name) {
                $value = & $parameters[$name];
                if ($value === null) {
                    $this->bindValue($i + 1, null, Connection::PARAM_NULL);
                } else {
                    $type = & $this->types[$name];
                    if ($type === Connection::PARAM_INT) {
                        $value = (int)$value;
                    } elseif ($type === Connection::PARAM_DATE_TIME) {
                        $value = $this->grammar->buildDateTime($value);
                        $type = Connection::PARAM_STR;
                    } elseif ($type === Connection::PARAM_TIME) {
                        $value = $this->grammar->buildTime($value);
                        $type = Connection::PARAM_STR;
                    }
                    $this->bindValue($i + 1, $value, $type);
                }
            }
        }
        parent::execute();

        return $this;
    }
1161300
public function serialize($includePrivate=false, $includeInternal=true, $removeNullValues=false,
                              $dateAsISO8601=false)
    {
        $answer = array();
        $schema = $this->_jsonSchema;

        foreach ($schema['definition'] as $property => $definition) {
            $method = 'get' . ucfirst($property);

            //Checking special types
            if ($definition['private'] == true && !$includePrivate) {
                continue;
            }

            if ($definition['internal'] == true && !$includeInternal) {
                continue;
            }

            $valueFromMethod = $this->$method();

            if (isset($definition['type'])) {
                switch ($definition['type']) {
                    case "datetime":
                        if ($dateAsISO8601 && !is_null($valueFromMethod)) {
                            $valueFromMethod = $valueFromMethod->format("c");
                        } else {
                            $valueFromMethod = $this->$property; //Integer value
                        }
                        break;
                }
            }
            $value = StoreHelper::serialize($valueFromMethod, $includePrivate, $includeInternal, $removeNullValues, $dateAsISO8601);

            if (is_null($value)
                && $removeNullValues
                && array_key_exists('validationConstraints', $definition)
                && !$definition['keepIfNull']
                && !(in_array('NotBlank', $definition['validationConstraints']))) {

                continue;
            }

            $answer[$property] = $value;

            /**
             * Add aliases
             */
            if ($definition['alias']) {
                $alias = $definition['alias'];
                $method = 'get' . ucfirst($alias);
                if (method_exists($this, $method)) {
                    $answer[$alias] = $this->$method();
                } else {
                    $answer[$alias] = $answer[$property];
                }
            }
        }

        return (object) $answer;
    }
526940
function execute($m, $params=null, $paramtypes=null, $msgID=null)
		{
			if (is_object($m))
			{
				// watch out: if $m is an xmlrpcmsg obj, this will raise a warning: no id memeber...
				$methName = $m->method();
				$msgID = $m->id;
			}
			else
			{
				$methName = $m;
			}
			$sysCall = $this->allow_system_funcs && strpos($methName, "system.") === 0;
			$dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap;

			if(!isset($dmap[$methName]['function']))
			{
				// No such method
				return new jsonrpcresp(0,
					$GLOBALS['xmlrpcerr']['unknown_method'],
					$GLOBALS['xmlrpcstr']['unknown_method']);
			}

			// Check signature
			if(isset($dmap[$methName]['signature']))
			{
				$sig = $dmap[$methName]['signature'];
				if (is_object($m))
				{
					list($ok, $errstr) = $this->verifySignature($m, $sig);
				}
				else
				{
					list($ok, $errstr) = $this->verifySignature($paramtypes, $sig);
				}
				if(!$ok)
				{
					// Didn't match.
					return new jsonrpcresp(
						0,
						$GLOBALS['xmlrpcerr']['incorrect_params'],
						$GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}"
					);
				}
			}

			$func = $dmap[$methName]['function'];
			// let the 'class::function' syntax be accepted in dispatch maps
			if(is_string($func) && strpos($func, '::'))
			{
				$func = explode('::', $func);
			}
			// verify that function to be invoked is in fact callable
			if(!is_callable($func))
			{
				error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler is not callable");
				return new jsonrpcresp(
					0,
					$GLOBALS['xmlrpcerr']['server_error'],
					$GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method"
				);
			}

			// If debug level is 3, we should catch all errors generated during
			// processing of user function, and log them as part of response
			if($this->debug > 2)
			{
				$GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler');
			}
			try
			{
				if (is_object($m))
				{
					if($sysCall)
					{
						$r = call_user_func($func, $this, $m);
					}
					else
					{
						$r = call_user_func($func, $m);
					}
					if (!is_a($r, 'xmlrpcresp'))
					{
						error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler does not return an xmlrpcresp object");
						if (is_a($r, 'xmlrpcval'))
						{
							$r = new jsonrpcresp($r);
						}
						else
						{
							$r = new jsonrpcresp(
								0,
								$GLOBALS['xmlrpcerr']['server_error'],
								$GLOBALS['xmlrpcstr']['server_error'] . ": function does not return jsonrpcresp or xmlrpcresp object"
							);
						}
					}
				}
				else
				{
					// call a 'plain php' function
					if($sysCall)
					{
						array_unshift($params, $this);
						$r = call_user_func_array($func,$params);
					}
					else
					{
						// 3rd API convention for method-handling functions: EPI-style
						if ($this->functions_parameters_type == 'epivals')
						{
							$r = call_user_func_array($func, array($methName, $params, $this->user_data));
							// mimic EPI behaviour: if we get an array that looks like an error, make it
							// an eror response
							if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r))
							{
								$r = new jsonrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']);
							}
							else
							{
								// functions using EPI api should NOT return resp objects,
								// so make sure we encode the return type correctly
								$r = new jsonrpcresp(php_xmlrpc_encode($r, array('extension_api')));
							}
						}
						else
						{
							$r = call_user_func_array($func, $params);
						}
					}
					// the return type can be either an xmlrpcresp object or a plain php value...
					if (!is_a($r, 'xmlrpcresp'))
					{
						// what should we assume here about automatic encoding of datetimes
						// and php classes instances???
						$r = new jsonrpcresp(php_jsonrpc_encode($r, $this->phpvals_encoding_options));
					}
				}
				// here $r is either an xmlrpcresp or jsonrpcresp
				if (!is_a($r, 'jsonrpcresp'))
				{

					// dirty trick: user has given us back an xmlrpc response,
					// since he had an existing xmlrpc server with boatloads of code.
					// Be nice to him, and serialize the xmlrpc stuff into JSON.
					// We also override the content_type of the xmlrpc response,
					// but lack knoweledge of intented response charset...
					$r->content_type = 'application/json';
					$r->payload = serialize_jsonrpcresp($r, $msgID);
				}
				else
				{
					$r->id = $msgID;
				}
			}
			catch(Exception $e)
			{
			// (barring errors in the lib) an uncatched exception happened
				// in the called function, we wrap it in a proper error-response
				switch($this->exception_handling)
				{
					case 2:
						throw $e;
						break;
					case 1:
						$r = new jsonrpcresp(0, $e->getCode(), $e->getMessage());
						break;
					default:
						$r = new jsonrpcresp(0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error']);
				}
			}
			if($this->debug > 2)
			{
				// note: restore the error handler we found before calling the
				// user func, even if it has been changed inside the func itself
				if($GLOBALS['_xmlrpcs_prev_ehandler'])
				{
					set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']);
				}
				else
				{
					restore_error_handler();
				}
			}
			return $r;
		}
124027
public static function resolve(array $parameters, $context = null)
    {
        $params = [];
        foreach ($parameters as $key => $value) {
            if ($value instanceof Reference) {
                $val = $value->getValue();
                if (isset($context[$val])) {
                    $params[$key] = $context[$val];
                } else {
                    throw new RuntimeException('Reference invalid context key "' . $val . '"');
                }
            } else {
                $params[$key] = $value;
            }
        }

        return $params;
    }
5365
public function filter($value)
    {
        // Formats are applied exclusively and supersed filters
        if ($this->format) {
            if (!$this->serviceDescription) {
                throw new \RuntimeException('No service description was set so '
                    . 'the value cannot be formatted.');
            }
            return $this->serviceDescription->format($this->format, $value);
        }

        // Convert Boolean values
        if ($this->type == 'boolean' && !is_bool($value)) {
            $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
        }

        // Apply filters to the value
        if ($this->filters) {
            foreach ($this->filters as $filter) {
                if (is_array($filter)) {
                    // Convert complex filters that hold value place holders
                    foreach ($filter['args'] as &$data) {
                        if ($data == '@value') {
                            $data = $value;
                        } elseif ($data == '@api') {
                            $data = $this;
                        }
                    }
                    $value = call_user_func_array(
                        $filter['method'],
                        $filter['args']
                    );
                } else {
                    $value = call_user_func($filter, $value);
                }
            }
        }

        return $value;
    }
1048020
public function bindParam($paramno, &$param, $type = null, $maxlen = null, $driverdata = null)
    {
        $log = 'Binding Parameters: ' . $paramno . '=' . $param;
        if (!is_null($type)) {
            $log .= '| Type: ' . $type;
        }
        if (!is_null($maxlen)) {
            $log .= '| Maxlen: ' . $maxlen;
        }

        if (!is_null($driverdata)) {
            $log .= '| DriverData: ' . $driverdata;
        }
        $this->connection->writeToLog($log);

        if (!empty($type)) {
            return parent::bindParam($paramno, $param, $type, $maxlen, $driverdata);
        }

        return parent::bindParam($key, $val);
    }
608848
function exportValues($elementList = null){
        $unfiltered = array();
        if (null === $elementList) {
            // iterate over all elements, calling their exportValue() methods
            foreach (array_keys($this->_elements) as $key) {
                if ($this->_elements[$key]->isFrozen() && !$this->_elements[$key]->_persistantFreeze) {
                    $varname = $this->_elements[$key]->_attributes['name'];
                    $value = '';
                    // If we have a default value then export it.
                    if (isset($this->_defaultValues[$varname])) {
                        $value = $this->prepare_fixed_value($varname, $this->_defaultValues[$varname]);
                    }
                } else {
                    $value = $this->_elements[$key]->exportValue($this->_submitValues, true);
                }

                if (is_array($value)) {
                    // This shit throws a bogus warning in PHP 4.3.x
                    $unfiltered = HTML_QuickForm::arrayMerge($unfiltered, $value);
                }
            }
        } else {
            if (!is_array($elementList)) {
                $elementList = array_map('trim', explode(',', $elementList));
            }
            foreach ($elementList as $elementName) {
                $value = $this->exportValue($elementName);
                if (@PEAR::isError($value)) {
                    return $value;
                }
                //oh, stock QuickFOrm was returning array of arrays!
                $unfiltered = HTML_QuickForm::arrayMerge($unfiltered, $value);
            }
        }

        if (is_array($this->_constantValues)) {
            $unfiltered = HTML_QuickForm::arrayMerge($unfiltered, $this->_constantValues);
        }
        return $unfiltered;
    }
1143634
private function bindParameters()
    {
        $bindedParameterReferences = array(implode('', $this->bindedTypes));
        $lobParameters = array();
        $null = null;

        foreach ($this->bindedParameters as $key => &$parameter) {
            if (isset($this->bindedTypes[$key - 1])
                && ($this->bindedTypes[$key - 1] === self::$mappedTypes[\PDO::PARAM_LOB])) {
                $lobParameters[$key - 1] = $parameter;
                $bindedParameterReferences[$key] = &$null;
            } else {
                $bindedParameterReferences[$key] = &$parameter;
            }
        }

        call_user_func_array(array($this->mysqliStatement, 'bind_param'), $bindedParameterReferences);

        foreach ($lobParameters as $key => $lobParameter) {
            rewind($lobParameter);

            while (!feof($lobParameter)) {
                $this->mysqliStatement->send_long_data(
                    $key,
                    fread($lobParameter, $this->connection->getMaxAllowedPacket())
                );
            }
        }
    }
866478
public function resolve(
        Parameter $parameter,
        ParameterBag $unresolvedParameters,
        ParameterBag $resolvedParameters,
        ResolvingContext $context = null
    ): ParameterBag {
        $context = ResolvingContext::createFrom($context, $parameter->getKey());

        $self = $this;
        $value = preg_replace_callback(
            self::PATTERN,
            function ($match) use ($self, $context, $unresolvedParameters, &$resolvedParameters, $parameter) {
                $key = $match['parameter'];
                $resolvedParameters = $self->resolveStringKey(
                    $self->resolver,
                    $parameter,
                    $key,
                    $unresolvedParameters,
                    $resolvedParameters,
                    $context
                );

                return $resolvedParameters->get($key);
            },
            $parameter->getValue()
        );

        return $resolvedParameters->with($parameter->withValue($value));
    }
801999
public function func()
    {
        $args = func_get_args();
        $fns  = explode('|', array_shift($args));
        $res  = null;

        foreach (array_reverse($fns) as $fnc) {
            if (!isset($this->functions[$fnc])) {
                throw new \RuntimeException(sprintf('Template function "%s" does not exist.', $fnc));
            }

            $res = $this->functions[$fnc]->call($args);

            if (!$this->functions[$fnc]->getOption('is_safe_html')) {
                $res = $this->escape($res);
            }

            $args = [$res];
        }

        return $res;
    }