Issue 1:
Description

For structuring Yaml files we want to use a custom include tag (in our case !inc/file 'my_file.yml'). This is working just fine by having a custom YamlFileLoader that recursively parses any TaggedValue and having it make a new Parser() to handle the sub-document (or self::load() on the sub-document).

$loaderResolver = new LoaderResolver([new YamlFileLoader()]);
$delegatingLoader = new DelegatingLoader($loaderResolver);
$config = $delegatingLoader->load('my-base.yml');

But if your parent document has references, e.g.: &foo and you want to reference that within an included file with *foo, the sub-parser has no access to the refs from the main document.

At least two ways to solve it:

a way to pass refs to a parser

don't make a new parser, but calling parse() on the same instance as the parent document

Here option 2 seems a nice solution, but: parse() sets $this->refs = [] before and after every call to doParse().

The feature request is to either support option 1, or a flag (e.g.: Yaml::PARSE_KEEP_REFS) that disables setting $this->refs = [] before and after every call to doParse().

Example

const PARSE_KEEP_REFS = 2048;

/**
* Parses a YAML string to a PHP value.
*
* @param string $value A YAML string
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
*
* @return mixed A PHP value
*
* @throws ParseException If the YAML is not valid
*/
public function parse(string $value, int $flags = 0)
{
if (false === preg_match('//u', $value)) {
throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
}

if (!(Yaml::PARSE_KEEP_REFS & $flags)) {
$this->refs = [];
}

$mbEncoding = null;
$data = null;

if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');
}

try {
$data = $this->doParse($value, $flags);
} finally {
if (null !== $mbEncoding) {
mb_internal_encoding($mbEncoding);
}
$this->lines = [];
$this->currentLine = '';
if (!(Yaml::PARSE_KEEP_REFS & $flags)) {
$this->refs = [];
}
$this->skippedLineNumbers = [];
$this->locallySkippedLineNumbers = [];
}

return $data;
}

$configValues = $parser->parseFile($resource, Yaml::PARSE_CUSTOM_TAGS|Yaml::PARSE_KEEP_REFS);

Of course it's very possible there is a completely other solution that I missed. Since pretty much everything is private, extending the class with your own parser brings too much to the table.

PS: using Symfony config import (https://symfony.com/doc/current/configuration/configuration_organization.html#mix-and-match-configuration-formats) is not applicable for our use case. We need something more in the line of the $ref method of json-schema.

Issue 2:
Q
A

Bug report?
no

Feature request?
yes

BC Break report?
no

RFC?
no

Symfony version
4.1

This is a common problem. Only workarounds exists is not using form_* functions for subsequent fields.

Wanted to solve this by doing

{{ form_row(form.save) }}
{% do form.save.setRendered(false) %}
{{ form_row(form.save) }}

quickly found setRendered does not accept arguments and PRs for multiple different use cases has been rejected1 in2 past3. Is this use case good enough for this change now?

This is specifically very useful to split form visually to two, where one block is just for RepeatedType and SubmitType. Here was the requirement from our designer

If I could render same field twice, I could reuse same button field and be done with it.