Skip to content
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

Support attributes #527

Merged
merged 2 commits into from
Mar 5, 2024
Merged

Support attributes #527

merged 2 commits into from
Mar 5, 2024

Conversation

tugmaks
Copy link
Contributor

@tugmaks tugmaks commented Mar 1, 2024

Hello, thanks for this package. I want to submit PR that covers usage of php attributes ( #404 )

The short example why it is useful: imagine that you start a symfony project from skeleton
symfony new my_project_directory --version="7.0.*" --webapp
As you can see it is not dependent on symfony/routing
And create simple controller in src/Controllers

<?php

declare(strict_types=1);

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;

final class FooController extends AbstractController
{
    #[Route('/foo')]
    public function invoke(): JsonResponse
    {
        return new JsonResponse();
    }
}

Now it starts to depend on symfony/routing

So, if you run checker output will be:

$ XDEBUG_MODE=off vendor/bin/composer-require-checker
ComposerRequireChecker 4.8.0@1c7498e4c31ff7e467ac1b5138d277736c838393
The following 2 unknown symbols were found:
+-----------------------------------------------+--------------------+
| Unknown Symbol                                | Guessed Dependency |
+-----------------------------------------------+--------------------+
| Symfony\Component\HttpFoundation\JsonResponse |                    |
| Symfony\Component\HttpKernel\Kernel           |                    |
+-----------------------------------------------+--------------------+

No warning about Symfony\Component\Routing\Attribute\Route attribute

My branch produces that output:

XDEBUG_MODE=off vendor/bin/composer-require-checker
ComposerRequireChecker dev-php-attributes@bd0f004bd5c6b2214eb6a5fa273b0227745e0568
The following 3 unknown symbols were found:
+-----------------------------------------------+--------------------+
| Unknown Symbol                                | Guessed Dependency |
+-----------------------------------------------+--------------------+
| Symfony\Component\HttpFoundation\JsonResponse |                    |
| Symfony\Component\HttpKernel\Kernel           |                    |
| Symfony\Component\Routing\Attribute\Route     |                    |
+-----------------------------------------------+--------------------+

Copy link
Collaborator

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

src/ComposerRequireChecker/Cli/Options.php Outdated Show resolved Hide resolved
@Ocramius Ocramius added this to the 4.9.0 milestone Mar 5, 2024
@Ocramius Ocramius self-assigned this Mar 5, 2024
Copy link
Collaborator

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tugmaks!

@Ocramius Ocramius merged commit 0a6f7ba into maglnet:4.9.x Mar 5, 2024
17 checks passed
@tugmaks tugmaks deleted the php-attributes branch March 5, 2024 10:16
@Levivb Levivb mentioned this pull request Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants