Check modifier functions against fields
@param array $array
@param mixed $parent
@param string|null $parentKey
@throws \Tripod\Exceptions\ConfigException
185436
public function checkModifierFunctions(array $array, $parent, $parentKey = null)
    {
        foreach($array as $k => $v)
        {
            // You can have recursive modifiers so we check if the value is an array.
            if(is_array($v))
            {
                // Check config
                // Valid configs can be top level modifiers and their attributes inside - you can have a top level modifier
                // inside a top level modifier - that's why we also check \Tripod\Mongo\Composites\Tables::$predicatesModifiers direct
                if(!array_key_exists($k, $parent) && !array_key_exists($k, \Tripod\Mongo\Composites\Tables::$predicateModifiers))
                {
                    throw new \Tripod\Exceptions\ConfigException("Invalid modifier: '".$k."' in key '".$parentKey."'");
                }

                // If this config value is a top level modifier, use that as the parent so that we can check the attributes
                if(array_key_exists($k, \Tripod\Mongo\Composites\Tables::$predicateModifiers))
                {
                    $this->checkModifierFunctions($v, \Tripod\Mongo\Composites\Tables::$predicateModifiers[$k], $k);
                } else
                {
                    $this->checkModifierFunctions($v, $parent[$k], $k);
                }

            } else if(is_string($k))
            {
                // Check key
                if(!array_key_exists($k, $parent))
                {
                    throw new \Tripod\Exceptions\ConfigException("Invalid modifier: '".$k."' in key '".$parentKey."'");
                }
            }
        }
    }
1212719
protected function bindData(&$parent, $data)
  {
    if ( is_object($data) ){
      $data = get_object_vars($data);
    }
    else {
      $data = (array) $data;
    }
    
    foreach($data as $k => $v){
      if ( (is_array($v) && ArrayHelper::isAssociative($v)) || is_object($v) ){
        $parent->$k = new \stdClass;
        $this->bindData($parent->$k, $v);
      }
      else {
        $parent->$k = $v;
      }
    }
  }
1280760
public static function key_exists($array, $key)
    {
        if (!is_array($array) and !$array instanceof ArrayAccess) {
            throw new InvalidArgumentException('First parameter must be an array or ArrayAccess object.');
        }

        is_object($key) and $key = (string) $key;

        if (!is_string($key)) {
            return false;
        }
        if (array_key_exists($key, $array)) {
            return true;
        }
        foreach (explode('.', $key) as $key_part) {
            if (($array instanceof ArrayAccess and isset($array[$key_part])) === false) {
                if (!is_array($array) or ! array_key_exists($key_part, $array)) {
                    return false;
                }
            }
            $array = $array[$key_part];
        }
        return true;
    }
437396
public function isParentOf($toolKey, $parentKey, $data = null)
    {
        $data = is_null($data) ? $this->getToolSectionMap() : $data;

        foreach ($data as $idx => $tool) {
            if ($tool['key'] === $toolKey) {
                $this->sectionParent = $tool['parent'];
            }

            if (!empty($tool['children']) && $tool['key'] !== $toolKey) {
                $this->isParentOf($toolKey, $parentKey, $tool['children']);
            }
        }

        return $this->sectionParent == $parentKey;
    }
461054
public static function isKeyWithElements($array, $key)
    {
        if (false === is_array($array) || false === isset($array[$key])) {
            return false;
        }

        if (false === is_array($array[$key])) {
            return false;
        }

        if (0 === count($array[$key])) {
            return false;
        }

        return true;
    }
72535
private static function findInArray(array $array, string $key, $default = null)
    {
        if (($pos = strrpos($key, '.')) !== false) {
            $array = self::findInArray($array, substr($key, 0, $pos), $default);
            $key = substr($key, $pos + 1);
        }

        return is_array($array) && array_key_exists($key, $array) ? $array[$key] : $default;
    }
1068906
public function findAdminHierarchiesByParents(array $parents)
    {
        if (count($parents) === 0) {
            throw new \InvalidArgumentException('Array argument cannot be empty');
        }

        $index = 0;
        $eol = PHP_EOL;
        $parentsTest = '(';

        foreach ($parents as $parent) {
            $parentsTest .= $index > 0 ? '    OR ' : '    ';
            $parentsTest .= "p.id = {$parent}{$eol}";
            $index++;
        }
        $parentsTest .= "){$eol}";

        $dql = "
            SELECT h
            FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
            JOIN h.parent p
            WHERE h.user IS NULL
            AND {$parentsTest}
        ";
        $query = $this->_em->createQuery($dql);

        return $query->getResult();
    }
958212
public function validateByParent($nodeType, NodeInterface $parent = null)
    {
        if (!$nodeType) {
            return true;
        }

        $config = $this->getNodeTypeConfig($nodeType);
        if (null === $config) {
            return false;
        }

        if ((null !== $parent) && $parent->getType()) {
            return in_array($parent->getType(), $config->getParentTypes());
        }

        return false;
    }
837893
public function attachParents(array $parents)
    {
        $this->_parents = [];

        foreach ($parents as $parent) {
            $this->attachParent($parent, false);
        }
    }
523555
protected function parseFunction( ADT_PHP_File $parent, $matches )
	{
		$function	= new ADT_PHP_Function( $matches[6] );
		$function->setParent( $parent );
		$function->setLine( $this->lineNumber );

		if( trim( $matches[7] ) )
		{
			$paramList	= array();
			foreach( explode( ",", $matches[7] ) as $param )
			{
				$param	 = trim( $param );
				if( !preg_match( $this->regexParam, $param, $matches ) )
					continue;
				$function->setParameter( $this->parseParameter( $function, $matches ) );
			}
		}
		if( $this->openBlocks )
		{
			$methodBlock	= array_pop( $this->openBlocks );
			$this->decorateCodeDataWithDocData( $function, $methodBlock );
			$this->openBlocks	= array();
		}
		return $function;
	}
1159568
protected function getRule(string $name, string $key, array $parent_names = []): array
    {
        if (isset($this->rules[$key])) {
            return $this->rules[$key];
        }
        if ($this->total_rules === 1 || !$parent_names) {
            return $this->rules['*']; // Done here.
        }
        foreach (array_map('strtolower', $parent_names) as $_parent_key) {
            if (isset($this->rules[$_parent_key])) {
                return $this->rules[$_parent_key];
            }
        } // unset($_parent_key); // Housekeeping.

        return $this->rules['*'];
    }
698005
public static function ThrowIfJsonDefNotValid(string $type, array $array) : array
    {
        $jsonProps = $type::DaftObjectJsonPropertyNames();
        $array = JsonTypeUtilities::FilterThrowIfJsonDefNotValid($type, $jsonProps, $array);
        $jsonDef = $type::DaftObjectJsonProperties();

        $keys = array_keys($array);

        /**
        * @var array<int|string, scalar|(scalar|array|object|null)[]|object|null>
        */
        $out = array_combine($keys, array_map(
            JsonTypeUtilities::MakeMapperThrowIfJsonDefNotValid($type, $jsonDef, $array),
            $keys
        ));

        return $out;
    }
751355
public static function set(array &$array, $keyPath, $value)
    {
        self::checkKeyPathIsValidAndNonEmpty($keyPath);
        $keys = self::explodeKeys(strval($keyPath));
        $result = $array;
        $ptr = &$result;

        $parentKeys = array();
        while ($keys !== array()) {
            $key = array_shift($keys);
            $parentKeys[] = $key;

            if (!array_key_exists($key, $ptr)) {
                $ptr[$key] = $keys === array() ? $value : array();
                $ptr = &$ptr[$key];
                continue;
            }
            $ptr = &$ptr[$key];
            if ($keys === array()) {
                $ptr = $value;
                break;
            }
            elseif (!is_array($ptr)) {
                throw new InconsistentKeyTypes($ptr, array(), implode('.', $parentKeys));
            }
        }

        $array = $result;
    }
369725
public static function queryByParentType( $parentType, $config = [] ) {

		$type	= isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
		$status	= isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;

		return self::find()->where( [ 'parentType' => $parentType, 'type' => $type, 'status' => $status ] );
	}
272281
protected function matchToMorphParents($type, EntityCollection $results, array $parents)
    {
        $mapper = $this->relatedMapper->getManager()->mapper($type);
        $keyName = $mapper->getEntityMap()->getKeyName();

        $keys = array_map(function ($parent) use ($keyName) {
            return $parent[$keyName];
        }, $parents);

        $parents = array_combine($keys, $parents);

        foreach ($results as $result) {
            $key = $result[$keyName];

            if (isset($this->dictionary[$type][$key])) {
                foreach ($this->dictionary[$type][$key] as $parent) {
                    $parents[$parent[$keyName]][$this->relation] = $result;
                }
            }
        }

        return array_values($parents);
    }
1356204
public static function convertByParent($data, $parent_field, $options = []) {
		$pointers = [];
		foreach ($data as $k => $v) {
			if (empty($v[$parent_field])) {
				continue;
			}
			// if parent is down the road
			if (!empty($data[$v[$parent_field]])) {
				$data[$v[$parent_field]]['options'][$k] = $data[$k];
				// disable parents
				if (!empty($options['disable_parents'])) {
					$data[$v[$parent_field]]['disabled'] = 1;
				}
				$pointers[$k] = & $data[$v[$parent_field]]['options'][$k];
				unset($data[$k]);
			} else if (!empty($pointers[$v[$parent_field]])) {
				$pointer = & $pointers[$v[$parent_field]];
				$pointer['options'][$k] = $data[$k];
				$pointers[$k] = & $pointer['options'][$k];
				unset($data[$k]);
			}
		}
		return $data;
	}
1012563
public function loadInlineFields($parentKey)
    {
        $json = $this->load();
        $inlineFields = array();
        foreach ($json as $table) {
            if ($table["tca"]) {
                foreach ($table["tca"] as $key => $tca) {
                    if ($tca["inlineParent"] == $parentKey) {
                        if ($tca["config"]["type"] == "inline") {
                            $tca["inlineFields"] = $this->loadInlineFields($key);
                        }
                        $tca["maskKey"] = "tx_mask_" . $tca["key"];
                        $inlineFields[] = $tca;
                    }
                }
            }
        }
        return $inlineFields;
    }