-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore: use get_debug_type
and ::class
in exception messages
#9006
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
Conversation
@@ -998,7 +998,7 @@ private static function separatedContextLessInclude(string $path): ConfigInterfa | |||
|
|||
// verify that the config has an instance of Config | |||
if (!$config instanceof ConfigInterface) { | |||
throw new InvalidConfigurationException(\sprintf('The config file: "%s" does not return a "PhpCsFixer\ConfigInterface" instance. Got: "%s".', $path, \is_object($config) ? \get_class($config) : \gettype($config))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you can update all usages of is_object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In many cases we add the value for scalar types, e.g. "string#foobar":
\is_object($parsed['indent']) ? \get_class($parsed['indent']) : \gettype($parsed['indent']).'#'.$parsed['indent'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some cases with additional null
check:
\is_object($spacing) ? \get_class($spacing) : (null === $spacing ? 'null' : \gettype($spacing).'#'.$spacing) |
in other cases with additional resource check:
\is_object($to) ? \get_class($to) : \gettype($to).(\is_resource($to) ? '' : '#'.$to), |
Should we maybe add a helper method somewhere which handles all these cases?
And it could return nicer outputs like got string "foobar"
instead of got "string#foobar"
,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In many cases we add the value for scalar types, e.g. "string#foobar"
sounds OK, we can unify towards this direction
handle null...
OKish to have it unified, would produce NULL#
, or we can have helper method as you suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be ok to merge this one as-is and have a look to the unification another time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, feel free to create a ticket for that
No description provided.