@@ -38,6 +38,35 @@ final class PropertyTypeHandlingTest extends TestCase
3838 const SNIFF_CLASS = 'Fixtures \\TestStandard \\Sniffs \\SetProperty \\PropertyTypeHandlingSniff ' ;
3939
4040
41+ /**
42+ * Verify a deprecation notice is shown when an array property is set from the ruleset using a comma-separated string.
43+ *
44+ * Support for this format was (soft) deprecated in PHPCS 3.3.0.
45+ *
46+ * @return void
47+ */
48+ public function testUsingOldSchoolArrayFormatShowsDeprecationNotice ()
49+ {
50+ $ regex = '`^( ' ;
51+ $ regex .= 'DEPRECATED: Passing an array of values to a property using a comma-separated string\R ' ;
52+ $ regex .= 'was deprecated in PHP_CodeSniffer 3\.3\.0\. Support will be removed in PHPCS 4\.0\.0\.\R ' ;
53+ $ regex .= 'The deprecated syntax was used for property "expectsOldSchool(?:EmptyArray|ArrayWith(?:Extended|Only)?(?:KeysAnd)?Values)"\R ' ;
54+ $ regex .= 'for sniff " ' ;
55+ $ regex .= '(?:\./tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff\.php|TestStandard\.SetProperty\.PropertyTypeHandling) ' ;
56+ $ regex .= '"\.\R ' ;
57+ $ regex .= 'Pass array values via <element \[key="\.\.\." \]value="\.\.\."> nodes instead\.\R ' ;
58+ $ regex .= '){14}\R$` ' ;
59+
60+ $ this ->expectOutputRegex ($ regex );
61+
62+ // Set up the ruleset.
63+ $ standard = __DIR__ .'/PropertyTypeHandlingTest.xml ' ;
64+ $ config = new ConfigDouble (["--standard= $ standard " ]);
65+ new Ruleset ($ config );
66+
67+ }//end testUsingOldSchoolArrayFormatShowsDeprecationNotice()
68+
69+
4170 /**
4271 * Test the value type handling for properties set via a ruleset.
4372 *
@@ -234,6 +263,9 @@ public static function dataArrayPropertyExtending()
234263 /**
235264 * Test Helper.
236265 *
266+ * Note: the deprecations for using comma-separated string to pass an array, are silenced in this helper
267+ * as that's not what's being tested here.
268+ *
237269 * @see self::testTypeHandlingWhenSetViaRuleset()
238270 *
239271 * @return \PHP_CodeSniffer\Sniffs\Sniff
@@ -245,7 +277,7 @@ private function getSniffObjectForRuleset()
245277 if (isset ($ sniffObject ) === false ) {
246278 // Set up the ruleset.
247279 $ standard = __DIR__ .'/PropertyTypeHandlingTest.xml ' ;
248- $ config = new ConfigDouble (["--standard= $ standard " ]);
280+ $ config = new ConfigDouble (["--standard= $ standard " , ' -q ' ]);
249281 $ ruleset = new Ruleset ($ config );
250282
251283 // Verify that our target sniff has been registered.
0 commit comments