Skip to content

Conversation

gharlan
Copy link
Member

@gharlan gharlan commented Sep 1, 2025

No description provided.

@coveralls
Copy link

coveralls commented Sep 1, 2025

Coverage Status

coverage: 94.686% (-0.008%) from 94.694%
when pulling 68de3b8 on gharlan:exceptions
into b709222 on PHP-CS-Fixer:master.

@@ -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)));
Copy link
Member

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

Copy link
Member Author

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']

Copy link
Member Author

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",

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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

@gharlan gharlan enabled auto-merge (squash) September 2, 2025 09:30
@gharlan gharlan merged commit 2d6e1f6 into PHP-CS-Fixer:master Sep 2, 2025
30 of 31 checks passed
@gharlan gharlan deleted the exceptions branch September 2, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants