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
Utils - save only unique deprecations to avoid memory issues #5695
Conversation
Running Maybe using a key for ensuring the uniqueness would be better as it's O(1), but it would introduce a change of meaning into /**
* Handle triggering deprecation error.
*
* @param string $message
* @param string $exceptionClass
*/
public static function triggerDeprecation($message, $exceptionClass = \RuntimeException::class)
{
if (getenv('PHP_CS_FIXER_FUTURE_MODE')) {
throw new $exceptionClass("{$message} This check was performed as `PHP_CS_FIXER_FUTURE_MODE` env var is set.");
}
- if (false === array_search($message, self::$deprecations, true)) {
- self::$deprecations[] = $message;
- }
+ self::$deprecations[$message] = true;
@trigger_error($message, E_USER_DEPRECATED);
}
public static function getTriggeredDeprecations()
{
- return self::$deprecations;
+ return array_keys(self::$deprecations);
} Not sure which approach is preferable for this project, so I'm just putting it there... |
I like the proposal with assyc array. shitty we don't have native Set support |
maybe just sort the array in |
version is excluded because of high memory usage, see PHP-CS-Fixer/PHP-CS-Fixer#5695
Thank you @PetrHeinz. |
version is excluded because of high memory usage, see PHP-CS-Fixer/PHP-CS-Fixer#5695
version is excluded because of high memory usage, see PHP-CS-Fixer/PHP-CS-Fixer#5695
version is excluded because of high memory usage, see PHP-CS-Fixer/PHP-CS-Fixer#5695
version is excluded because of high memory usage, see PHP-CS-Fixer/PHP-CS-Fixer#5695
version is excluded because of high memory usage, see PHP-CS-Fixer/PHP-CS-Fixer#5695
With the #5674 merged, we have run into exhaustion of allowed memory pretty quickly, see https://github.com/shopsys/shopsys/pull/2308/checks?check_run_id=2511509379
Even though it would be better for us to fix all the deprecations, and we definitely plan to do it in the future, it will be rather time consuming and we would like to use the newer version in the meantime.
I propose to save the deprecation message only if it's unique. Because
array_unique
is called on the result afterwards, I see no issues with this approach.