Simple rule: Use internal if present but let params override any internal.

@param Context $internalProperty
@param array   $params

@return Context|null
@author Mario Mueller
488366
private function determineContext($internalProperty, array $params)
    {
        $ctx = null;
        if ($internalProperty !== null && isset($params['ctx']) !== true) {
            // We need to clone it as jms contexts are not reusable.
            $ctx = clone $internalProperty;
        }

        // When a passed context exists, override the internal one
        if (isset($params['ctx']) === true) {
            $ctx = $params['ctx'];
        }

        return $ctx;
    }
809017
protected function checkEmptyLoop($params)
    {
        $loopName = $this->getParam($params, 'rel');

        if (null == $loopName) {
            throw new \InvalidArgumentException(
                $this->translator->trans("Missing 'rel' parameter in ifloop/elseloop arguments")
            );
        }

        if (! isset($this->loopstack[$loopName])) {
            throw new \InvalidArgumentException(
                $this->translator->trans("Related loop name '%name'' is not defined.", ['%name' => $loopName])
            );
        }

        return $this->loopstack[$loopName]->isEmpty();
    }
935384
protected function prepareParams($object,&$params) {
        //Get all readble object properties
        $properties = get_object_vars($object);
    
        /**
         * For each property, if it is instance of AbstractRequest, recursive function called
         * Else if value of property is scalar we assign it
         */
        foreach ($properties as $p=>$v){
            if(is_object($v) && $v instanceof AbstractRequest){
                
                $this->prepareParams($v,$params);
            }
            if(is_scalar($v)){
                $params[$p] = $v;
            }
        }
    
    }
853576
public function update(string $app, string $property, array $params = [])
    {
        $path = $this->buildPropertiesPath($app, $property);

        return $this->put($path, $params);
    }
967128
public static function translate($key, array $params = [], $default = '')
    {
        $result = Application::$instance->getComponent('i18n')->translate($key,
            $params);

        return empty($result) ? self::prepareValueS($default, $params) : $result;
    }
53365
protected function update_init_params(array &$params, context $context,
            array $options = null) {

        $rowsnumber = $this->count_button_rows($params);
        if ($rowsnumber > 1) {
            $this->add_button_before($params, 1, 'pdw_toggle', '');
            $params['pdw_toggle_on'] = 1;
            $params['pdw_toggle_toolbars'] = join(',', range(2, $rowsnumber));

            // Add JS file, which uses default name.
            $this->add_js_plugin($params);
        }
    }
145715
public function getProperty($nameOrProperty): PhpProperty {
		if ($nameOrProperty instanceof PhpProperty) {
			$nameOrProperty = $nameOrProperty->getName();
		}

		if (!$this->properties->has($nameOrProperty)) {
			throw new \InvalidArgumentException(sprintf('The property "%s" does not exist.', $nameOrProperty));
		}

		return $this->properties->get($nameOrProperty);
	}
699807
public function init($param)
    {

        if (empty($param)) return false;

        $this->header = '';

        $param_list = new ParamList();
        foreach ($param as $key => $value) {
            if (property_exists($this, $key)) $this->$key = $value;
            elseif (property_exists($param_list, strtolower(str_replace('-', '_', $key)))) {
                if (is_string($value)) {
                    $this->header[] = new SingleParam($key, $value);
                } elseif (is_array($value)) {
                    $this->header[] = new MultiParam($key, $value);
                }
            }

        }


        return true;
    }
1023166
public function one(string $condition = '', array $params = []) {
        $this->model->builder->select('*')
            ->from($this->model->tableName);
        if ($condition) {
            $this->model->builder->where($condition, $params);
        }
        $r = $this->model->builder->limit(1)
            ->query();
        if (!is_array($r) || 0 === count($r)) {
            return null;
        }
        return $this->model->setup($r[0]);
    }
1138843
public static function getAndRemoveRequired(
        array &$params,
        string $key,
        $context = null
    ) {
        $value = self::getRequired(
            $params,
            $key,
            $context
        );

        self::remove(
            $params,
            $key
        );

        return $value;
    }
882932
public function findOneBy (array $params)
    {
        $entity = $this->er->findOneBy($params);

        if (NULL == $entity) {
            return NULL;
        }

        return $this->getModel($entity);
    }
1197089
public function getUrlByInternalName($internalName, $locale, $parameters = array(), $schemeRelative = false)
    {
        $routeParameters = $this->getRouteParametersByInternalName($internalName, $locale, $parameters);

        return $this->generator->generate(
            '_slug',
            $routeParameters,
            $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL
        );
    }
585471
public static function doesntContainParams(...$params): bool
    {
        if (is_array($params[0])) {
            $params = $params[0];
        }

        $targetCount = count($params);
        $params = array_flip($params);

        foreach (static::getAllParameters() as $name => $value) {
            if (array_key_exists($name, $params)) {
                unset($params[$name]);
            }
        }

        return count($params) == $targetCount;
    }
1324215
public function toSQL(Parameters $params, bool $inner_clause)
    {
        if ($key = $this->getKey())
        {
            try
            {
                $params->get($key);
            }
            catch (\OutOfRangeException $e)
            {
                $key = null;
            }
        }

        if ($key === null)
        {
            $val = $this->getValue();
            if (is_bool($val))
                $val = $val ? 1 : 0;
            $key = $params->assign($val, $this->getParameterType());
        }
        $this->bind($params, $key, null);

        return ':' . $key;
    }
7484
public static function get(
        array $params,
        string $key,
        $default = null
    ) {
        if (self::has($params, $key)) {
            return $params[$key];
        }

        return $default;
    }
1121600
public static function getRequired(
        array $params,
        string $key,
        $context = null
    ) {
        self::assertHas($params, $key, $context);

        return $params[$key];
    }
328528
public function hasPublicAlias($internalUrl, $asObject = false, $mode = UrlAlias::REWRITE)
    {
        $ret = null;

        if ($alias = $this->repository->findOneByInternalUrl($internalUrl, $mode)) {
            $ret = ($asObject ? $alias : $alias->getPublicUrl());
        }

        return $ret;
    }