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

fix unmapped subclass of a mapped super class problem issue #39 #186 #228 #257

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
vendor
composer.lock
composer.lock
4 changes: 0 additions & 4 deletions Metadata/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@ public function loadMetadataForClass(\ReflectionClass $class)
}
}

if (null == $metadata->id && !$hasInjection) {
return null;
}

return $metadata;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance;

use JMS\DiExtraBundle\Annotation as DI;

class MappedSuperClass
{
private $foo;
private $bar;

/**
* @DI\InjectParams
*
* @param stdClass $foo
* @param stdClass $bar
*/
public function __construct($foo, $bar)
{
$this->foo = $foo;
$this->bar = $bar;
}

public function getFoo()
{
return $this->foo;
}

public function getBar()
{
return $this->bar;
}
}
13 changes: 13 additions & 0 deletions Tests/Functional/Bundle/TestBundle/Inheritance/UnmapedSubClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance;

use JMS\DiExtraBundle\Annotation as DI;

class UnmapedSubClass extends MappedSuperClass
{
public function getFoo()
{
return new \ArrayObject([]);
}
}
36 changes: 36 additions & 0 deletions Tests/Functional/MetadataFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace JMS\DiExtraBundle\Tests\Functional;

use Metadata\MetadataFactory;

class MetadataFactoryTest extends BaseTestCase
{
/**
* @runInSeparateProcess
*/
public function testGetMetadataFromMappedSuperClass()
{
$metadataFactory = $this->getMetadataFactory();

$this->assertInstanceOf('\Metadata\MetadataFactory', $metadataFactory);

$metadata = $metadataFactory->getMetadataForClass(
'JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance\UnmapedSubClass'
);

$this->assertCount(2, $metadata->classMetadata);
$this->assertEquals(
'JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance\UnmapedSubClass',
$metadata->getOutsideClassMetadata()->name
);
}

/**
* @return MetadataFactory
*/
private function getMetadataFactory()
{
return $this->createClient()->getContainer()->get('jms_di_extra.metadata.metadata_factory');
}
}
2 changes: 1 addition & 1 deletion Tests/Functional/config/framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ framework:
enabled: true
enable_annotations: true
router:
resource: %kernel.root_dir%/config/routing.yml
resource: "%kernel.root_dir%/config/routing.yml"

services:
logger:
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/config/twig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ framework:
engines: [twig, php]

twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"