Convert parent keys to error name

@param mixed $parent_keys
@return string
770981
public function parentKeysToErrorName($parent_keys) {
		$result = [];
		if (!is_array($parent_keys)) {
			$parent_keys = [$parent_keys];
		}
		foreach ($parent_keys as $v) {
			if (empty($result)) {
				$result[] = $v;
			} else {
				$result[] = '[' . $v . ']';
			}
		}
		return implode('', $result);
	}
462718
def keys_in_dict(d, parent_key, keys):
    
    for key, value in d.iteritems():
        if isinstance(value, dict):
            keys_in_dict(value, key, keys)
        else:
            if parent_key:
                prefix = parent_key + "."
            else:
                prefix = ""

            keys.append(prefix + key)

    return keys
97842
public function getAllErrors($keys = true)
    {
        return ($keys == true) ? $this->errors : array_values($this->errors);
    }
652776
protected static function buildErrorMessage(
        array $params,
        string $key,
        $message = null,
        $context = null
    ): string {
        if (empty($message)) {
            $message = 'There was an error with a key: (' . $key . ')'
                . ' in params: (' . json_encode($params, 0, 3) . ')';
        }

        $contextType = gettype($context);

        if (is_object($context)) {
            $context = get_class($context);
        }

        if ($context === null) {
            return $message;
        }

        // Clear json_last_error()
        json_encode(null);

        $json = json_encode($context, JSON_PRETTY_PRINT, self::$depth);

        if (JSON_ERROR_NONE !== json_last_error()) {
            return $message;
        }

        return $message . " - Context ({$contextType}): \n" . $json;
    }
1198530
public function errors( $key = null )
	{
		if ( !is_null( $key ) )
		{
			if ( isset( $this->errors[$key] ) )
			{
				return $this->errors[$key];
			}
			return array();
		}

		$errors = array();

		foreach( $this->errors as $error_array )
		{
			$errors = array_merge( $errors, $error_array );
		}

		return $errors;
	}
974886
private function convertParentsNamesToParentsObjects($themeName, array $parentsNames, array $existingThemes)
    {
        return array_map(static function ($parentName) use ($themeName, $existingThemes) {
            if (!isset($existingThemes[$parentName])) {
                throw new ThemeLoadingFailedException(sprintf(
                    'Unexisting theme "%s" is required by "%s".',
                    $parentName,
                    $themeName
                ));
            }

            return $existingThemes[$parentName];
        }, $parentsNames);
    }
393103
public function getParents($self_in = false)
    {
        if ($self_in) {
            $id = $this->id;
        } else {
            $id = $this->parent_id;
        }

        $map = self::createMap();
        $parentId = [];

        if (!is_array($map))
        {
            return $parentId;
        }

        while (isset($map[$id]) and $map[$id]->parent_id !== null)
        {
            $parentId[$id] = $map[$id];
            $id = $map[$id]->parent_id;
        }
        if (isset($map[$id])) {
            $parentId[$id] = $map[$id];
        }


        $parentId = array_reverse($parentId);

        return $parentId;
    }
109633
def _parent_foreign_key_mappings(cls):
        """"""
        parent_rel = cls.__mapper__.relationships.get(cls.export_parent)
        if parent_rel:
            return {l.name: r.name for (l, r) in parent_rel.local_remote_pairs}
        return {}
1091181
private function convertRecursive(array $array, $parentKey = null)
    {
        $return = [];
        if (!is_null($parentKey))
            $parentKey .= '.';

        foreach ($array as $k => $v) {
            if (is_array($v))
                $return[] = $this->convertRecursive($v, $parentKey . $k);
            else
                $return[$parentKey . $k] = $v;
        }
        return $this->array_flatten($return);
    }
304568
public function parent(string $path, int $levels = 1): string
    {
        [$scheme, $path] = $this->getSchemeAndHierarchy($path);

        if ($this->normalize !== false) {
            $path = $this->normalizePathPart($path);
        }

        if ($path === '' || $path === '.') {
            return '';
        }

        [$scheme, $parent] = $this->dirnameInternal($scheme, $path, $levels);

        return $parent !== $path ? $this->toString($scheme, $parent) : '';
    }
392112
protected static function getAttrs()
    {
        $class = get_called_class();
        $parent = get_parent_class($class);
        if ($parent) {
            $attrs_parent = $parent::getAttrs();
            $attrs = array_merge($attrs_parent, $class::$attrs);
        } else {
            $attrs = $class::$attrs;
        }
        if(empty($attrs)) $attrs = array();

        return array_diff_key($attrs, array('__private__'));

    }
154017
protected function keyTypeError(string $method, $key): string
    {
        $keyType = is_object($key) ? get_class($key) : gettype($key);

        return sprintf(
            '%s::%s expects key type (%s); received (%s) %s',
            static::class,
            $method,
            $this->keyType(),
            $keyType,
            VarPrinter::toString($key)
        );
    }
1042139
public function getForeignKeyName()
    {
        $key = $this->getQualifiedForeignKeyName();

        if (is_array($key)) { //Check for multi-columns relationship
            return array_map(function ($k) {
                $segments = explode('.', $k);

                return $segments[count($segments) - 1];
            }, $key);
        } else {
            $segments = explode('.', $key);

            return $segments[count($segments) - 1];
        }
    }
774455
protected function normalizeListParentParameter($parent)
    {
        $separator = $this->getListParentSeparator();

        if (is_integer($parent) && $parent < 0 || is_string($parent) && preg_match('#-\d+#', $parent)) {
            $parent = (int) $parent;

            if ($parent < 0) {
                // The the parent that conforms to the index in the parent chain
                // This only works within the context of this model, so no cross-model logic is expected
                $index = count($this->listParents) + $parent - 1;

                if ($index >= 0 && isset($this->listParents[ $index ])) {
                    $parent = $this->listParents[ $index ]->relation . $separator . $this->listParents[ $index ]->key;
                } else {
                    $parent = null;
                }

            } else {
                $parent = null;
            }
        }

        if (is_string($parent) && false === strpos($parent, $separator)) {
            $parent = null;
        }

        return $parent;
    }
50378
def prt_keys(self, prt, pre):
        """"""
        prt.write('{PRE}Relationship to parent: {ABC}\n'.format(
            PRE=pre, ABC=''.join(self.rel2chr.values())))
        for rel, alias in self.rel2chr.items():
            prt.write('{PRE}    {A} {DESC}\n'.format(PRE=pre, A=alias, DESC=rel))
        prt.write('\n{PRE}Relationship to child: {ABC}\n'.format(
            PRE=pre, ABC=''.join(self.rev2chr.values())))
        for rel, alias in self.rev2chr.items():
            prt.write('{PRE}    {A} {DESC}\n'.format(PRE=pre, A=alias, DESC=rel))
931925
public function newParentNames(string $child_name, string $parent_sex): array
    {
        if (preg_match(self::REGEX_SURNS, $child_name, $match)) {
            switch ($parent_sex) {
                case 'M':
                    return [
                        'NAME' => '/' . $match['SURN1'] . '/ //',
                        'SURN' => $match['SURN1'],
                    ];
                case 'F':
                    return [
                        'NAME' => '/' . $match['SURN2'] . '/ //',
                        'SURN' => $match['SURN2'],
                    ];
            }
        }

        return [
            'NAME' => '// //',
        ];
    }
1274479
private function _validateKey($key): string 
    {
        if(
            !\is_scalar($key) &&
            !\is_object($key) &&
            !\method_exists($key, "__toString")
        ) {
            throw InvalidKeyException::invalidKey();
        }
        return (string) $key;
    }