-
Notifications
You must be signed in to change notification settings - Fork 828
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
fix: add missing trigger_deprecation calls to deprecated classes, methods #2265
base: master
Are you sure you want to change the base?
fix: add missing trigger_deprecation calls to deprecated classes, methods #2265
Conversation
1c83c97
to
ce09829
Compare
ce09829
to
aa51929
Compare
if (null === $schema) { | ||
trigger_deprecation( | ||
'nelmio/api-doc-bundle', | ||
'4.15.0', | ||
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable', | ||
); | ||
} | ||
|
||
if (null !== $groups) { | ||
trigger_deprecation( | ||
'nelmio/api-doc-bundle', | ||
'4.17.0', | ||
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']', | ||
); | ||
} |
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 this way of checking the parameter be better for triggering deprecations?
if (null === $schema) { | |
trigger_deprecation( | |
'nelmio/api-doc-bundle', | |
'4.15.0', | |
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable', | |
); | |
} | |
if (null !== $groups) { | |
trigger_deprecation( | |
'nelmio/api-doc-bundle', | |
'4.17.0', | |
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']', | |
); | |
} | |
if (null !== $groups || func_num_args() >= 3) { | |
trigger_deprecation( | |
'nelmio/api-doc-bundle', | |
'4.17.0', | |
'Using the $groups parameter of "%s" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\'].', __METHOD__ | |
); | |
} | |
if (\func_num_args() < 4 || null === $schema) { | |
trigger_deprecation( | |
'nelmio/api-doc-bundle', | |
'4.15.0', | |
'The "%s()" method will have a new "OA\Schema $schema" arument not defining it is deprecated.', __METHOD__ | |
); | |
$schema = null; | |
} else { | |
$schema = func_get_arg(3); | |
} |
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.
@DjordyKoert I'm not entirely sure that relying on the func_num_args
count is an approach we should take here. Mainly because we deprecate not defining one argument while also deprecating if another is defined.
For example, with func_num_args() >= 3
we wouldn't know if someone calls the method like this, which would be totally valid:
$describer->describe(
types: $types,
property: $property,
schema: $schema,
);
While func_num_args() < 4
would not work if someone calls the method like this, even though $schema
is not defined/null
:
$describer->describe(
types: $types,
property: $property,
groups: $groups,
context: $context,
);
342312d
to
3e7acf7
Compare
3e7acf7
to
dc3701e
Compare
dc3701e
to
6f05acd
Compare
Adds missing deprecation triggers to classes and methods that have been deprecated with a
@deprecated
annotation.