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

[DI][DX] Allow exclude to be an array of patterns#24428

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

Closed
apetitpa wants to merge1 commit intosymfony:masterfromapetitpa:exclude-array
Closed

[DI][DX] Allow exclude to be an array of patterns#24428

apetitpa wants to merge1 commit intosymfony:masterfromapetitpa:exclude-array

Conversation

@apetitpa
Copy link

@apetitpaapetitpa commentedOct 4, 2017
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#23956
LicenseMIT
Doc PRnot provided yet

Before:

AppBundle\:resource:'../../src/AppBundle/*'exclude:'../../src/AppBundle/{Entity,Payload,Repository}'

After:

AppBundle\:resource:'../../src/AppBundle/*'exclude:    -'../../src/AppBundle/{Entity,Payload,Repository}'    -'../../src/AppBundle/Event/*Event.php'

theofidry, javiereguiluz, hhamon, demonkoryu, PhPPgAdminBug, sstok, umpirsky, apfelbox, ostrolucky, arderyp, and 7 more reacted with thumbs up emojisstok, Koc, and magnetik reacted with hooray emoji
@carsonbotcarsonbot added Status: Needs Review DependencyInjection DXDX = Developer eXperience (anything that improves the experience of using Symfony) Feature labelsOct 4, 2017
$loader->registerClasses(
newDefinition(),
'Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\\',
'Prototype/*',array(
Copy link
Contributor

Choose a reason for hiding this comment

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

FileLoader::registerClasses docblock must be updated, right?

* @param string $exclude A globed path of files to exclude

apetitpa reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

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

You're absolutely right, I completely missed this one. My bad

Copy link
Author

Choose a reason for hiding this comment

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

Docblock updated

* @param Definition$prototype A definition to use as template
* @param string$namespace The namespace prefix of classes in the scanned directory
* @param string$resource The directory to look for classes, glob-patterns allowed
* @param string|array $excludeA globed path of files toexcludeor an array ofglobedpaths of files to exclude
Copy link
Contributor

Choose a reason for hiding this comment

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

should it bestring[] instad ofarray ?

apetitpa reacted with thumbs up emoji
if (null ===$excludePrefix) {
$excludePrefix =$resource->getPrefix();
if ($excludePatterns) {
$excludePatterns = (array)$parameterBag->unescapeValue($parameterBag->resolveValue($excludePatterns));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather do the cast inregisterClasses and add thearray $excludePatterns typehint in this method

apetitpa reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

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

It's done

@nicolas-grekas
Copy link
Member

This might be enough for Yaml, but this doesn't benefit Xml nor the PHP configurators yet, do we want to make this available for these formats also?

smoench reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas added this to the4.1 milestoneOct 8, 2017
@nicolas-grekas
Copy link
Member

Moving to 4.1.

@apetitpa
Copy link
Author

apetitpa commentedOct 8, 2017
edited
Loading

@nicolas-grekas I'm sorry I could not finish this earlier, I'll rebase and edit base branch on github

@nicolas-grekas
Copy link
Member

@apetitpa let's continue this one?

@apetitpa
Copy link
Author

@nicolas-grekas I'm back on it ! Would you mind giving me a hint on what's left to do please ?

@apetitpaapetitpa changed the base branch from3.4 tomasterDecember 30, 2017 11:39
@nicolas-grekas
Copy link
Member

I think we should make this work somehow for other config formats (xml and php-dsl)

@apetitpa
Copy link
Author

apetitpa commentedJan 9, 2018
edited
Loading

@nicolas-grekas Thanks for your help I have rebased on master and started to work something out, so this means I should make this piece of xml configuration work, right ?

<prototypenamespace="AppBundle\"resource="../../src/AppBundle/*">    <exclude>../../src/AppBundle/{Entity,Repository}</exclude></prototype>

About the php based configuration it should already work since you can now pass an array as the third argument ofregisterClasses() or am I missing something ?

$this->registerClasses($definition,'AppBundle\\','../../src/AppBundle/*',array('../../src/AppBundle/{Entity,Repository}'));

@nicolas-grekas
Copy link
Member

I was more specifically referring to the Configurator in the Loader namespace. Look for a call to this method there, you should find something to adjust.

@nicolas-grekas
Copy link
Member

ping@apetitpa

@nicolas-grekas
Copy link
Member

@apetitpa do you think you can finish this PR before the feature freeze by the end of the month?

@apetitpa
Copy link
Author

@nicolas-grekas I'll do my best but I'm very short in time these days. I'll give it a try probably on next saturday evening, is it too late ?

Copy link
Member

@stofstof left a comment

Choose a reason for hiding this comment

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

Whne updating the XML loader, don't forget to update the XSD too.

* @param Definition$prototype A definition to use as template
* @param string$namespace The namespace prefix of classes in the scanned directory
* @param string$resource The directory to look for classes, glob-patterns allowed
* @param string|string[] $excludeA globed path of files toexcludeor an array ofglobedpaths of files to exclude
Copy link
Member

Choose a reason for hiding this comment

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

right type should actually bestring|string[]|null (the phpdoc should bestring|null in 3.4)

foreach ($this->glob($excludePattern,true,$resource)as$path =>$info) {
if (null ===$excludePrefix) {
$excludePrefix =$resource->getPrefix();
if ($excludePatterns) {
Copy link
Member

Choose a reason for hiding this comment

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

you could remove this diff, handling the empty array like any other array (thestring|null type was needing a dedicated handling ofnull before)

@nicolas-grekasnicolas-grekas modified the milestones:4.1,nextApr 20, 2018
@magnetik
Copy link
Contributor

It's now too late for 4.1. If you miss time to finish@apetitpa I can take it over if it's good for you.

@magnetik
Copy link
Contributor

I've created a pull request (just above) to finish it :)

magnetik added a commit to magnetik/symfony that referenced this pull requestApr 27, 2018
magnetik added a commit to magnetik/symfony that referenced this pull requestApr 27, 2018
@nicolas-grekas
Copy link
Member

Closing in favor of#27075.
Thank you@apetitpa for the inspiration!

@apetitpa
Copy link
Author

I'm sorry I couldn't make it guys and thank you@magnetik for taking over.

nicolas-grekas and tomhv reacted with heart emoji

@apetitpaapetitpa deleted the exclude-array branchApril 30, 2018 07:50
magnetik added a commit to magnetik/symfony that referenced this pull requestMay 2, 2018
magnetik added a commit to magnetik/symfony that referenced this pull requestMay 2, 2018
magnetik added a commit to magnetik/symfony that referenced this pull requestMay 2, 2018
magnetik added a commit to magnetik/symfony that referenced this pull requestMay 9, 2018
magnetik added a commit to magnetik/symfony that referenced this pull requestMay 9, 2018
fabpot added a commit that referenced this pull requestMay 9, 2018
…netik)This PR was merged into the 4.2-dev branch.Discussion----------[DI][DX] Allow exclude to be an array of patterns| Q             | A| ------------- | ---| Branch?       | 4.2| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#23956| License       | MITThis is basically continuing#24428.In YAML before:```yamlAppBundle\:  resource: '../../src/AppBundle/*'  exclude: '../../src/AppBundle/{Entity,Payload,Repository}'```in YAML after:```yamlAppBundle\:  resource: '../../src/AppBundle/*'  exclude:    - '../../src/AppBundle/{Entity,Payload,Repository}'    - '../../src/AppBundle/Event/*Event.php'```In XML before:```xml<prototype namespace="App\" resource="../src/*" exclude="../src/{Entity,Migrations,Tests}" />```in XML after:```xml<prototype namespace="App\" resource="../src/*">  <exclude>../src/{Entity,Migrations,Tests}</exclude>  <exclude>../src/Yolo</exclude></prototype>```In PHP before:```php$di->load(Prototype::class.'\\', '../Prototype')        ->autoconfigure()        ->exclude('../Prototype/{OtherDir,BadClasses}')```In PHP after:```php    $di->load(Prototype::class.'\\', '../Prototype')        ->autoconfigure()        ->exclude(['../Prototype/OtherDir', '../Prototype/BadClasses'])```Everything is backward compatible.Maybe a decision about handling both attribute exclude and element exclude in XML should be taken.Commits-------3ae3a03 [DI][DX] Allow exclude to be an array of patterns (taking#24428 over)
@nicolas-grekasnicolas-grekas modified the milestones:next,4.1Nov 1, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

+2 more reviewers

@staabmstaabmstaabm left review comments

@ogizanagiogizanagiogizanagi left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

DependencyInjectionDXDX = Developer eXperience (anything that improves the experience of using Symfony)FeatureStatus: Needs Work

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

8 participants

@apetitpa@nicolas-grekas@magnetik@staabm@stof@ogizanagi@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp