Skip to content

[DI] : Fix bad generation of proxy class when use overriden getter on class with constructor #21508

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

Merged
merged 1 commit into from
Feb 2, 2017

Conversation

jean-pasqualini
Copy link
Contributor

[DI] : Fix bad generation of proxy class when use overriden getter on class with constructor

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21507
License MIT
  • Add test fail
  • Fix bug
  • Run test pass

@@ -344,6 +344,27 @@ public function testDumpOverridenGetters()
$this->assertSame('baz', $r->invoke($baz));
}

public function testDumpOverridenGettersWithConstructor()
{
$container = include self::$fixturesPath.'/containers/container34.php';
Copy link
Member

Choose a reason for hiding this comment

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

please give it a non numeric name (new policy for added test cases :) )

Copy link
Member

Choose a reason for hiding this comment

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

maybe can you merge this test case with the existing one on the topic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, should I do this in a new commit or modify my existing commit?

Copy link
Member

Choose a reason for hiding this comment

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

we will squash anyway, so same commit is ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

$dump = $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Overriden_Getters_With_Constructor'));
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services34.php', $dump);
$res = $container->getResources();
$this->assertSame(realpath(self::$fixturesPath.'/containers/container34.php'), array_pop($res)->getResource());
Copy link
Member

Choose a reason for hiding this comment

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

this looks wrong to me, as we can have other resources, and the on added for this file may not be the first one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You suggest that I should only check the presence of this resource in the array instead of what I'm doing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed your advice

Resolved

@jean-pasqualini jean-pasqualini force-pushed the issue-21507 branch 4 times, most recently from 04ae996 to baad4b6 Compare February 2, 2017 10:46

$dump = $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Overriden_Getters_With_Constructor'));
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_dump_overriden_getters_with_constructor.php', $dump);
$resources = array_map(
Copy link
Member

@nicolas-grekas nicolas-grekas Feb 2, 2017

Choose a reason for hiding this comment

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

array_map('strval', $resources) would be better I think, because getResource is not part of ResourceInterface

Copy link
Contributor Author

@jean-pasqualini jean-pasqualini Feb 2, 2017

Choose a reason for hiding this comment

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

Ok, thanks for your return and the tip you gave me

Copy link
Member

Choose a reason for hiding this comment

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

@nicolas-grekas we actually need to check for a file resource, as you did in #21505

Copy link
Member

Choose a reason for hiding this comment

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

the string version of a resource is supposed to uniquely identify it, so that's not strictly required to me

… class with constructor

- [X] Add test fail
- [X] Fix bug
- [X] Run test pass
@xabbuh xabbuh added this to the 3.3 milestone Feb 2, 2017
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍

@nicolas-grekas
Copy link
Member

Thank you @jean-pasqualini.

@nicolas-grekas nicolas-grekas merged commit 2440b0f into symfony:master Feb 2, 2017
nicolas-grekas added a commit that referenced this pull request Feb 2, 2017
…n getter on class with constructor (jean-pasqualini)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] : Fix bad generation of proxy class when use overriden getter on class with constructor

[DI] : Fix bad generation of proxy class when use overriden getter on class with constructor

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21507
| License       | MIT

- [X] Add test fail
- [X] Fix bug
- [X] Run test pass

Commits
-------

2440b0f [DI] : Fix bad generation of proxy class when use overriden getter on class with constructor
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.

5 participants