Closed kevinpapst closed 3 years ago
Indeed that would be definitively be safer. A PR for this would be great :)
Can confirm this issue. We, as well, use swagger (in nelmioApiDocBundle) and it breaks the namespaces. Had to go back to 2.8.3 to fix this.
Fixed by #2285 and released in https://github.com/FriendsOfSymfony/FOSRestBundle/releases/tag/2.8.5
Hi @GuilhemN ,
your fix for PHP 8 in the ClassUtils tokenizer here: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/d60e0ba3cc1f3dce11cedf65d8535cb17c506bd3/Routing/Loader/ClassUtils.php#L27-L31 seems to work in a standalone project.
The problem with this check is, that some libraries define this constant in user land code, see phpDocumentor and swagger-php for example (these two are used in a project of mine). And with this constant defined in user land code, the tokenizer breaks and the first namespace token is always
true
, resulting in a broken namespace1\\MyController
(see this CI run for example).At least the Swagger bundle is likely be used in other projects that also use the Rest bundle.
Now we could argue that the 2.x branch is kind of deprecated and that defining this constant in user land code is the real problem, BUT other libraries fix the problem in another way (a quick google searched brought up this Drupal code
Instead of using
if (defined('T_NAME_QUALIFIED')) {
we could simply useif (PHP_VERSION_ID >= 80000) {
.Would you accept a PR for this? I already added one for the handcrafterinthealps routing bundle to support users of the 3.x branch.