File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
src/Symfony/Component/DependencyInjection Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ class Definition
3838 private $ public = true ;
3939 private $ synthetic = false ;
4040 private $ abstract = false ;
41+ private $ deprecated = false ;
4142 private $ synchronized = false ;
4243 private $ lazy = false ;
4344 private $ decoratedService ;
@@ -829,6 +830,36 @@ public function isAbstract()
829830 return $ this ->abstract ;
830831 }
831832
833+ /**
834+ * Whether this definition is deprecated, that means it should not be called
835+ * anymore.
836+ *
837+ * @param bool $status
838+ *
839+ * @return Definition the current instance
840+ *
841+ * @api
842+ */
843+ public function setDeprecated ($ status = true )
844+ {
845+ $ this ->deprecated = (bool ) $ status ;
846+
847+ return $ this ;
848+ }
849+
850+ /**
851+ * Whether this definition is deprecated, that means it should not be called
852+ * anymore.
853+ *
854+ * @return bool
855+ *
856+ * @api
857+ */
858+ public function isDeprecated ()
859+ {
860+ return $ this ->deprecated ;
861+ }
862+
832863 /**
833864 * Sets a configurator to call after the service is fully initialized.
834865 *
Original file line number Diff line number Diff line change @@ -233,6 +233,18 @@ public function testSetIsAbstract()
233233 $ this ->assertTrue ($ def ->isAbstract (), '->isAbstract() returns true if the instance must not be public. ' );
234234 }
235235
236+ /**
237+ * @covers Symfony\Component\DependencyInjection\Definition::setDeprecated
238+ * @covers Symfony\Component\DependencyInjection\Definition::isDeprecated
239+ */
240+ public function testSetIsDeprecated ()
241+ {
242+ $ def = new Definition ('stdClass ' );
243+ $ this ->assertFalse ($ def ->isDeprecated (), '->isDeprecated() returns false by default ' );
244+ $ this ->assertSame ($ def , $ def ->setDeprecated (true ), '->setDeprecated() implements a fluent interface ' );
245+ $ this ->assertTrue ($ def ->isDeprecated (), '->isDeprecated() returns true if the instance should not be used anymore. ' );
246+ }
247+
236248 /**
237249 * @covers Symfony\Component\DependencyInjection\Definition::setConfigurator
238250 * @covers Symfony\Component\DependencyInjection\Definition::getConfigurator
You can’t perform that action at this time.
0 commit comments