From 2b612e56e4f1231c328af8dceb363cd59142def3 Mon Sep 17 00:00:00 2001 From: Ivan Vegner Date: Wed, 14 Feb 2018 18:02:30 +0300 Subject: [PATCH 1/2] Add a test for auto declare trait inheritance --- tests/ContainerAwareTraitTest.php | 15 +++++++++++++++ tests/ParentConsumer.php | 12 ++++++++++++ tests/SubclassConsumer.php | 10 ++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/ContainerAwareTraitTest.php create mode 100644 tests/ParentConsumer.php create mode 100644 tests/SubclassConsumer.php diff --git a/tests/ContainerAwareTraitTest.php b/tests/ContainerAwareTraitTest.php new file mode 100644 index 0000000..2e450e0 --- /dev/null +++ b/tests/ContainerAwareTraitTest.php @@ -0,0 +1,15 @@ +produce(SubclassConsumer::class); + $this->assertSame($container, $subclassConsumer->getService(), 'Subclass must inherit auto declare trait'); + } +} diff --git a/tests/ParentConsumer.php b/tests/ParentConsumer.php new file mode 100644 index 0000000..c0615f8 --- /dev/null +++ b/tests/ParentConsumer.php @@ -0,0 +1,12 @@ +getContainer(); + } +} From 3ac414d0107463814f6c26a084137d08297781d3 Mon Sep 17 00:00:00 2001 From: Ivan Vegner Date: Wed, 14 Feb 2018 18:03:34 +0300 Subject: [PATCH 2/2] Fix auto declare trait inheritance --- src/ContainerAwareTrait.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ContainerAwareTrait.php b/src/ContainerAwareTrait.php index 932cbc6..5e55406 100644 --- a/src/ContainerAwareTrait.php +++ b/src/ContainerAwareTrait.php @@ -1,16 +1,18 @@ container = $container; } - private function getContainer(): Container { + protected function getContainer(): Container + { return $this->container; } }