File tree 2 files changed +43
-0
lines changed
src/Symfony/Component/DependencyInjection
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ class Definition
38
38
private $ public = true ;
39
39
private $ synthetic = false ;
40
40
private $ abstract = false ;
41
+ private $ deprecated = false ;
41
42
private $ synchronized = false ;
42
43
private $ lazy = false ;
43
44
private $ decoratedService ;
@@ -829,6 +830,36 @@ public function isAbstract()
829
830
return $ this ->abstract ;
830
831
}
831
832
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
+
832
863
/**
833
864
* Sets a configurator to call after the service is fully initialized.
834
865
*
Original file line number Diff line number Diff line change @@ -233,6 +233,18 @@ public function testSetIsAbstract()
233
233
$ this ->assertTrue ($ def ->isAbstract (), '->isAbstract() returns true if the instance must not be public. ' );
234
234
}
235
235
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
+
236
248
/**
237
249
* @covers Symfony\Component\DependencyInjection\Definition::setConfigurator
238
250
* @covers Symfony\Component\DependencyInjection\Definition::getConfigurator
You can’t perform that action at this time.
0 commit comments