Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Command] Improve--show-arguments for commanddebug:container#58718

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
chadyred wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromchadyred:feat/list-locator-services-command-debug

Conversation

chadyred
Copy link
Contributor

@chadyredchadyred commentedOct 30, 2024
edited
Loading

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
Issues-
LicenseMIT

Hello,

I improved the text descriptor and test for of the "--show-arguments" command in order to show in a service locator (arguments or a tagged iterator) and other iterator argument to display more information of the services in the arguments.

I moved information of arguments just after the main table because a lots of service could exist.

A fake class for a test :

<?phpdeclare(strict_types=1);namespaceApp\Service\Fake;usePsr\Container\ContainerInterface;useSymfony\Component\DependencyInjection\Attribute\AutowireIterator;useSymfony\Component\DependencyInjection\Attribute\AutowireLocator;readonlyclass ServiceWithTaggedIteratorAndServiceLocatorInjection{publicfunction__construct(publicarray$simpleIterator,public\Closure$serviceLocatorAsClosure,        #[AutowireLocator(services: ['one' => One::class,'two' => Two::class,        ])]publicContainerInterface$autowireLocator,        #[AutowireLocator('app.fake_tag')]publicContainerInterface$autowireLocatorWithStringTag,        #[AutowireIterator('app.fake_tag')]publicContainerInterface$taggedLocator,publicContainerInterface$servicesTagged,publicServiceHasLocator$serviceLocator,publicContainerInterface$containerServiceLocator,publicContainerInterface$containerServiceLocatorNotAutoconfigure,publicstring$abstractArg,publicFooEnum$enumArg,publicarray$iteratorArgument,    )    {    }}

Its yaml services configuration :

services:_defaults:autowire:trueautoconfigure:trueApp\:resource:'../src/'exclude:            -'../src/DependencyInjection/'            -'../src/Entity/'            -'../src/Kernel.php'App\Service\Fake\One:tags:[{name: 'app.fake_tag'}, {name: 'app.fake_tag_2'}]App\Service\Fake\Two:tags:[{name: 'app.fake_tag'}, {name: 'app.fake_tag_2'}]App\Service\Fake\Three:tags:[{name: 'app.fake_tag'}, {name: 'app.fake_tag_2'}]App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection:arguments:$containerServiceLocator:'@my.locator'$simpleIterator:['@App\Service\Fake\One', '@App\Service\Fake\Two']$serviceLocatorAsClosure:!service_locatorApp\Service\Fake\One:'@App\Service\Fake\One'App\Service\Fake\Two:'@App\Service\Fake\Two'$taggedLocator:!tagged_locator {tag: 'app.fake_tag_2'}$servicesTagged:!tagged_iterator {tag: 'app.fake_tag'}$serviceLocator:'@App\Service\Fake\ServiceHasLocator'# Not expanded, it is a service which has a locator in its own context$containerServiceLocatorNotAutoconfigure:'@my.locator_not_autoconfigure'$abstractArg:!abstract 'should be defined by Pass'$enumArg:!php/enum App\Service\Fake\FooEnum::ONE$iteratorArgument:              -'@App\Service\Fake\One'              -'@App\Service\Fake\Two'my.locator:# A classical locatorclass:Symfony\Component\DependencyInjection\ServiceLocatorarguments:        -router:'@router'request_stack:'@request_stack'http_kernel:'@http_kernel'session:'@session'parameter_bag:'@parameter_bag'contact_email:"mail@contact.com"mailerAsClosure:!service_closure '@mailer'my.locator_not_autoconfigure:autoconfigure:falseclass:Symfony\Component\DependencyInjection\ServiceLocatorarguments:        -router:'@router'request_stack:'@request_stack'http_kernel:'@http_kernel'session:'@session'parameter_bag:'@parameter_bag'tags:[ 'container.service_locator' ]

Before :

php bin/console deb:cont"ServiceWithTaggedIteratorAndServiceLocatorInjection" --show-argumentsInformationfor Service"App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection"============================================================================================== ---------------- ----------------------------------------------------------------------   Option           Value                                                                  ---------------- ----------------------------------------------------------------------   Service ID       App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection    Class            App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection    Tags             -                                                                       Public           no                                                                      Synthetic        no                                                                      Lazy             no                                                                      Shared           yes                                                                     Abstract         no                                                                      Autowired        yes                                                                     Autoconfigured   yes                                                                     Arguments        Array (2 element(s))                                                                     Service(.service_locator.BU3KPRp)                                                        Service(.service_locator.oF5goiR)                                                        Service(.service_locator.AdwCYyt)                                                        Service(.service_locator.idLRJzM)                                                        Tagged Iteratorfor"app.fake_tag"                                                       Service(App\Service\Fake\ServiceHasLocator)                                              Service(my.locator)                                                                      Service(my.locator_not_autoconfigure)                                                    Abstract argument (should be defined by Pass)                                            App\Service\Fake\FooEnum::ONE                                                            Array (2 element(s))                                                    Usages           none                                                                   ---------------- ----------------------------------------------------------------------

After :

php bin/console deb:cont"ServiceWithTaggedIteratorAndServiceLocatorInjection" --show-argumentsInformationfor Service"App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection"============================================================================================== ---------------- ----------------------------------------------------------------------   Option           Value                                                                  ---------------- ----------------------------------------------------------------------   Service ID       App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection    Class            App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection    Tags             -                                                                       Public           no                                                                      Synthetic        no                                                                      Lazy             no                                                                      Shared           yes                                                                     Abstract         no                                                                      Autowired        yes                                                                     Autoconfigured   yes                                                                     Usages           none                                                                   ---------------- ---------------------------------------------------------------------- +----+---------------------------- Arguments --------+------------------------+|#  | Service                                       | Argument(s)            |+----+-----------------------------------------------+------------------------+| 1| Service locator (7 element(s))| router.default|||| request_stack|||| http_kernel|||| session|||| parameter_bag|||| ["mail@contact.com"]|||| mailer.mailer|+----+-----------------------------------------------+------------------------+| 2| Array (2 element(s))| -|+----+-----------------------------------------------+------------------------+| 3| Service locator (2 element(s))| App\Service\Fake\One|||| App\Service\Fake\Two|+----+-----------------------------------------------+------------------------+| 4| Service locator (2 element(s))| App\Service\Fake\One|||| App\Service\Fake\Two|+----+-----------------------------------------------+------------------------+| 5| Service locator (3 element(s))| App\Service\Fake\Three|||| App\Service\Fake\Two|||| App\Service\Fake\One|+----+-----------------------------------------------+------------------------+| 6| Service locator (3 element(s))| App\Service\Fake\Two|||| App\Service\Fake\Three|||| App\Service\Fake\One|+----+-----------------------------------------------+------------------------+| 7| Tagged Iteratorfor"app.fake_tag"| App\Service\Fake\One|||| App\Service\Fake\Three|||| App\Service\Fake\Two|+----+-----------------------------------------------+------------------------+| 8| Service(App\Service\Fake\ServiceHasLocator)| -|+----+-----------------------------------------------+------------------------+| 9| Service locator (5 element(s))| router.default|||| request_stack|||| http_kernel|||| session|||| parameter_bag|+----+-----------------------------------------------+------------------------+| 10| Abstract argument (should be defined by Pass)| -|+----+-----------------------------------------------+------------------------+| 11| App\Service\Fake\FooEnum::ONE| -|+----+-----------------------------------------------+------------------------+| 12| Array (2 element(s))| -|+----+-----------------------------------------------+------------------------+

I try to cover any sort of argument with the use of a locator into a service, but it could be useful to me if you have more cases to test (maybe some type, some kind of Definition or anything could be useful).

Thanks a lot :)

jschaedl and OskarStark reacted with heart emojitourze reacted with eyes emoji
@carsonbotcarsonbot added this to the7.2 milestoneOct 30, 2024
@chadyredchadyredforce-pushed thefeat/list-locator-services-command-debug branch from969c6e8 to69c922bCompareOctober 30, 2024 15:20
@chadyredchadyred changed the title[WIP][Command] Improve--show-arguments for commanddebug:container[Command] Improve--show-arguments for commanddebug:containerOct 30, 2024
@chadyredchadyredforce-pushed thefeat/list-locator-services-command-debug branch 3 times, most recently fromffbbac9 toeb0dd52CompareOctober 30, 2024 16:42
@chadyred
Copy link
ContributorAuthor

Status: Needs Review

@chadyred
Copy link
ContributorAuthor

Hello,

We pick only the fact to show or not the arguments, and it is explicit, -v is great to do "expand infos", for command with interaction, but we could add options to choose what we really need to show, and we could add many and many options, and the -v imply that we have to show all the content of all options ?

Symfony uses option as unit when we need a piece of information.. It is possible to combine both : --show-arguments with -vvv, but to me, it is not enough clear...You choose to show or not something, -v and various -vv, -vvv could imply many level of information etc

@chadyred
Copy link
ContributorAuthor

You ask about the "array", I look at them : an ArrayArgument could contain : scalar, object etc so I stop by keeping previous code which indicate the "count" of the array. We have to check each type, find the good way to display informatino about them...and display it without beaking things (json_encode ?) but if it is a big object, or array etc...we have to truncate. So, I think about doing that into another PR.

@chadyredchadyredforce-pushed thefeat/list-locator-services-command-debug branch 2 times, most recently from93d9fc4 to48ffd47CompareNovember 18, 2024 09:36
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@chadyredchadyredforce-pushed thefeat/list-locator-services-command-debug branch 3 times, most recently from5376468 to2289fd1CompareNovember 26, 2024 09:48
@chadyredchadyredforce-pushed thefeat/list-locator-services-command-debug branch 2 times, most recently from0fa4aac toceac852CompareDecember 9, 2024 09:08
@chadyredchadyredforce-pushed thefeat/list-locator-services-command-debug branch fromceac852 to2a55d6cCompareDecember 13, 2024 12:46
@chadyredchadyredforce-pushed thefeat/list-locator-services-command-debug branch from2a55d6c to118cf3aCompareDecember 16, 2024 09:33
@chadyredchadyredforce-pushed thefeat/list-locator-services-command-debug branch 2 times, most recently froma9d019a to118cf3aCompareJanuary 8, 2025 15:35
@chadyred
Copy link
ContributorAuthor

Close because--show-arguments is mark as deprecated

@chalasr
Copy link
Member

The option is deprecated because arguments will always be shown as of Symfony 7.3. So improving the arguments representation is welcome (note that I didn't review this yet though)

@chadyred
Copy link
ContributorAuthor

chadyred commentedJan 8, 2025
edited
Loading

Thanks@chalasr, I reopen, I have to take time to rework the pull request. But now, the arguments are always visible,, my table seems ugly and not acceptable for DX IMO.

  1. I think about something with the-v
  2. Or why not with a future tree helper something like
1. Service Locator (7 éléments)├── router.default├── request_stack├── http_kernel├── session├── parameter_bag├── ["mail@contact.com"]└── mailer.mailer2. Array (2 éléments)└── -3. Service Locator (2 éléments)├── App\Service\Fake\One└── App\Service\Fake\Two4. Service Locator (2 éléments)├── App\Service\Fake\One└── App\Service\Fake\Two5. Service Locator (3 éléments)├── App\Service\Fake\Three├── App\Service\Fake\Two└── App\Service\Fake\One6. Service Locator (3 éléments)├── App\Service\Fake\Two├── App\Service\Fake\Three└── App\Service\Fake\One7. Tagged Iterator pour "app.fake_tag"├── App\Service\Fake\One├── App\Service\Fake\Three└── App\Service\Fake\Two8. Service (App\Service\Fake\ServiceHasLocator)└── -9. Service Locator (5 éléments)├── router.default├── request_stack├── http_kernel├── session└── parameter_bag10. Abstract Argument (devrait être défini par Pass)└── -11. App\Service\Fake\FooEnum::ONE└── -12. Array (2 éléments)└── -

OR

+--------------------+| Type: object       || Class: MyClassA    || Object Handle: 4   || Children count: 1  |+--------------------+         ^         |         3         |         |+---------------------+| Type: array         || Is root: No         || Children count: 100 |+---------------------+         ^         |    second level         |         |+--------------------+| Type: array        || Is root: No        || Children count: 1  |+--------------------+         ^         |    first level         |         |+---------------------------+| Type: array               || Is root: Yes              || Children count: 1         |+---------------------------+

@chadyredchadyred reopened thisJan 8, 2025
@chadyred
Copy link
ContributorAuthor

Status: Needs work

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

4 participants
@chadyred@chalasr@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp