-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yaml::parse #66
Comments
The |
Yes but the new way to do that stuff suggested by docs is replacing and then replace The way it is now, there was a merge to fix this problem by adding file_get_contents($path) but as suggested in Doc it will be removed in 3.0
|
I think this discussion would be better held in the according repository, however we could include files which contain trigger_error and E_USER_DEPRECATED in the search for deprecations. |
I still think that this isn't an issue you can resolve with static code analysis (you can hardly tell if the passed value is a filename or simply a YAML string). |
i am 👎 - guessing filenames based on strings is very error prone. |
IMO we could implement something like a warning, because it is like @xabbuh said impossible to know the value of variables. |
Using Yaml::parse is also deprecated and it needs rule
$config = Yaml::parse(file_get_contents($someConfigFile));
The original function
/**
* Parses YAML into a PHP array.
*
* The parse method, when supplied with a YAML stream (string or file),
* will do its best to convert YAML in a file into a PHP array.
*
* Usage:
*
* $array = Yaml::parse(file_get_contents('config.yml'));
* print_r($array);
*
*
* As this method accepts both plain strings and file names as an input,
* you must validate the input before calling this method. Passing a file
* as an input is a deprecated feature and will be removed in 3.0.
*
* Note: the ability to pass file names to the Yaml::parse method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead.
*
* @param string $input Path to a YAML file or a string containing YAML
* @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
* @param bool $objectSupport True if object support is enabled, false otherwise
* @param bool $objectForMap True if maps should return a stdClass instead of array()
*
* @return array The YAML converted to a PHP array
*
* @throws ParseException If the YAML is not valid
*
* @api
*/
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false)
{
// if input is a file, process it
$file = '';
if (strpos($input, "\n") === false && is_file($input)) {
@trigger_error('The ability to pass file names to the '.METHOD.' method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead.', E_USER_DEPRECATED);
This also needs rule since deprecator does not see this.
Maybe we should make PR on Symfony with @deprecated ?
This way you can not see deprecated notice on detector
The text was updated successfully, but these errors were encountered: