@@ -46,7 +46,7 @@ |
||
46 | 46 | |
47 | 47 | $suite = new TestSuite('PHP CodeSniffer Standards'); |
48 | 48 | |
49 | - $isInstalled = !is_file(__DIR__.'/../../autoload.php'); |
|
49 | + $isInstalled = ! is_file(__DIR__.'/../../autoload.php'); |
|
50 | 50 | |
51 | 51 | // Optionally allow for ignoring the tests for one or more standards. |
52 | 52 | $ignoreTestsForStandards = getenv('PHPCS_IGNORE_TESTS'); |
@@ -18,106 +18,106 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Prepare the test runner. |
|
23 | - * |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public static function main() |
|
27 | - { |
|
28 | - TestRunner::run(self::suite()); |
|
29 | - |
|
30 | - }//end main() |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Add all sniff unit tests into a test suite. |
|
35 | - * |
|
36 | - * Sniff unit tests are found by recursing through the 'Tests' directory |
|
37 | - * of each installed coding standard. |
|
38 | - * |
|
39 | - * @return \PHPUnit\Framework\TestSuite |
|
40 | - */ |
|
41 | - public static function suite() |
|
42 | - { |
|
43 | - $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = []; |
|
44 | - $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = []; |
|
45 | - $GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES'] = []; |
|
46 | - |
|
47 | - $suite = new TestSuite('PHP CodeSniffer Standards'); |
|
48 | - |
|
49 | - $isInstalled = !is_file(__DIR__.'/../../autoload.php'); |
|
50 | - |
|
51 | - // Optionally allow for ignoring the tests for one or more standards. |
|
52 | - $ignoreTestsForStandards = getenv('PHPCS_IGNORE_TESTS'); |
|
53 | - if ($ignoreTestsForStandards === false) { |
|
54 | - $ignoreTestsForStandards = []; |
|
55 | - } else { |
|
56 | - $ignoreTestsForStandards = explode(',', $ignoreTestsForStandards); |
|
57 | - } |
|
58 | - |
|
59 | - $installedStandards = self::getInstalledStandardDetails(); |
|
60 | - |
|
61 | - foreach ($installedStandards as $standard => $details) { |
|
62 | - Autoload::addSearchPath($details['path'], $details['namespace']); |
|
63 | - |
|
64 | - // If the test is running PEAR installed, the built-in standards |
|
65 | - // are split into different directories; one for the sniffs and |
|
66 | - // a different file system location for tests. |
|
67 | - if ($isInstalled === true && is_dir(dirname($details['path']).DIRECTORY_SEPARATOR.'Generic') === true) { |
|
68 | - $testPath = realpath(__DIR__.'/../../src/Standards/'.$standard); |
|
69 | - } else { |
|
70 | - $testPath = $details['path']; |
|
71 | - } |
|
72 | - |
|
73 | - if (in_array($standard, $ignoreTestsForStandards, true) === true) { |
|
74 | - continue; |
|
75 | - } |
|
76 | - |
|
77 | - $testsDir = $testPath.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR; |
|
78 | - if (is_dir($testsDir) === false) { |
|
79 | - // No tests for this standard. |
|
80 | - continue; |
|
81 | - } |
|
82 | - |
|
83 | - $di = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($testsDir)); |
|
84 | - |
|
85 | - foreach ($di as $file) { |
|
86 | - // Skip hidden files. |
|
87 | - if (substr($file->getFilename(), 0, 1) === '.') { |
|
88 | - continue; |
|
89 | - } |
|
90 | - |
|
91 | - // Tests must have the extension 'php'. |
|
92 | - $parts = explode('.', $file); |
|
93 | - $ext = array_pop($parts); |
|
94 | - if ($ext !== 'php') { |
|
95 | - continue; |
|
96 | - } |
|
97 | - |
|
98 | - $className = Autoload::loadFile($file->getPathname()); |
|
99 | - $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$className] = $details['path']; |
|
100 | - $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$className] = $testsDir; |
|
101 | - $suite->addTestSuite($className); |
|
102 | - } |
|
103 | - }//end foreach |
|
104 | - |
|
105 | - return $suite; |
|
106 | - |
|
107 | - }//end suite() |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Get the details of all coding standards installed. |
|
112 | - * |
|
113 | - * @return array |
|
114 | - * @see Standards::getInstalledStandardDetails() |
|
115 | - */ |
|
116 | - protected static function getInstalledStandardDetails() |
|
117 | - { |
|
118 | - return Standards::getInstalledStandardDetails(true); |
|
119 | - |
|
120 | - }//end getInstalledStandardDetails() |
|
21 | + /** |
|
22 | + * Prepare the test runner. |
|
23 | + * |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public static function main() |
|
27 | + { |
|
28 | + TestRunner::run(self::suite()); |
|
29 | + |
|
30 | + }//end main() |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Add all sniff unit tests into a test suite. |
|
35 | + * |
|
36 | + * Sniff unit tests are found by recursing through the 'Tests' directory |
|
37 | + * of each installed coding standard. |
|
38 | + * |
|
39 | + * @return \PHPUnit\Framework\TestSuite |
|
40 | + */ |
|
41 | + public static function suite() |
|
42 | + { |
|
43 | + $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = []; |
|
44 | + $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = []; |
|
45 | + $GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES'] = []; |
|
46 | + |
|
47 | + $suite = new TestSuite('PHP CodeSniffer Standards'); |
|
48 | + |
|
49 | + $isInstalled = !is_file(__DIR__.'/../../autoload.php'); |
|
50 | + |
|
51 | + // Optionally allow for ignoring the tests for one or more standards. |
|
52 | + $ignoreTestsForStandards = getenv('PHPCS_IGNORE_TESTS'); |
|
53 | + if ($ignoreTestsForStandards === false) { |
|
54 | + $ignoreTestsForStandards = []; |
|
55 | + } else { |
|
56 | + $ignoreTestsForStandards = explode(',', $ignoreTestsForStandards); |
|
57 | + } |
|
58 | + |
|
59 | + $installedStandards = self::getInstalledStandardDetails(); |
|
60 | + |
|
61 | + foreach ($installedStandards as $standard => $details) { |
|
62 | + Autoload::addSearchPath($details['path'], $details['namespace']); |
|
63 | + |
|
64 | + // If the test is running PEAR installed, the built-in standards |
|
65 | + // are split into different directories; one for the sniffs and |
|
66 | + // a different file system location for tests. |
|
67 | + if ($isInstalled === true && is_dir(dirname($details['path']).DIRECTORY_SEPARATOR.'Generic') === true) { |
|
68 | + $testPath = realpath(__DIR__.'/../../src/Standards/'.$standard); |
|
69 | + } else { |
|
70 | + $testPath = $details['path']; |
|
71 | + } |
|
72 | + |
|
73 | + if (in_array($standard, $ignoreTestsForStandards, true) === true) { |
|
74 | + continue; |
|
75 | + } |
|
76 | + |
|
77 | + $testsDir = $testPath.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR; |
|
78 | + if (is_dir($testsDir) === false) { |
|
79 | + // No tests for this standard. |
|
80 | + continue; |
|
81 | + } |
|
82 | + |
|
83 | + $di = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($testsDir)); |
|
84 | + |
|
85 | + foreach ($di as $file) { |
|
86 | + // Skip hidden files. |
|
87 | + if (substr($file->getFilename(), 0, 1) === '.') { |
|
88 | + continue; |
|
89 | + } |
|
90 | + |
|
91 | + // Tests must have the extension 'php'. |
|
92 | + $parts = explode('.', $file); |
|
93 | + $ext = array_pop($parts); |
|
94 | + if ($ext !== 'php') { |
|
95 | + continue; |
|
96 | + } |
|
97 | + |
|
98 | + $className = Autoload::loadFile($file->getPathname()); |
|
99 | + $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$className] = $details['path']; |
|
100 | + $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$className] = $testsDir; |
|
101 | + $suite->addTestSuite($className); |
|
102 | + } |
|
103 | + }//end foreach |
|
104 | + |
|
105 | + return $suite; |
|
106 | + |
|
107 | + }//end suite() |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Get the details of all coding standards installed. |
|
112 | + * |
|
113 | + * @return array |
|
114 | + * @see Standards::getInstalledStandardDetails() |
|
115 | + */ |
|
116 | + protected static function getInstalledStandardDetails() |
|
117 | + { |
|
118 | + return Standards::getInstalledStandardDetails(true); |
|
119 | + |
|
120 | + }//end getInstalledStandardDetails() |
|
121 | 121 | |
122 | 122 | |
123 | 123 | }//end class |
@@ -16,20 +16,20 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Runs the tests and collects their result in a TestResult. |
|
21 | - * |
|
22 | - * @param \PHPUnit\Framework\TestResult $result A test result. |
|
23 | - * |
|
24 | - * @return \PHPUnit\Framework\TestResult |
|
25 | - */ |
|
26 | - public function run(TestResult $result=null): TestResult |
|
27 | - { |
|
28 | - $result = parent::run($result); |
|
29 | - printPHPCodeSnifferTestOutput(); |
|
30 | - return $result; |
|
31 | - |
|
32 | - }//end run() |
|
19 | + /** |
|
20 | + * Runs the tests and collects their result in a TestResult. |
|
21 | + * |
|
22 | + * @param \PHPUnit\Framework\TestResult $result A test result. |
|
23 | + * |
|
24 | + * @return \PHPUnit\Framework\TestResult |
|
25 | + */ |
|
26 | + public function run(TestResult $result=null): TestResult |
|
27 | + { |
|
28 | + $result = parent::run($result); |
|
29 | + printPHPCodeSnifferTestOutput(); |
|
30 | + return $result; |
|
31 | + |
|
32 | + }//end run() |
|
33 | 33 | |
34 | 34 | |
35 | 35 | }//end class |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * |
24 | 24 | * @return \PHPUnit\Framework\TestResult |
25 | 25 | */ |
26 | - public function run(TestResult $result=null): TestResult |
|
26 | + public function run(TestResult $result = null): TestResult |
|
27 | 27 | { |
28 | 28 | $result = parent::run($result); |
29 | 29 | printPHPCodeSnifferTestOutput(); |
@@ -16,120 +16,120 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Test valid public function/method names. |
|
21 | - * |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function testValidNotClassFormatPublic() |
|
25 | - { |
|
26 | - $this->assertTrue(Common::isCamelCaps('thisIsCamelCaps', false, true, true)); |
|
27 | - $this->assertTrue(Common::isCamelCaps('thisISCamelCaps', false, true, false)); |
|
28 | - |
|
29 | - }//end testValidNotClassFormatPublic() |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * Test invalid public function/method names. |
|
34 | - * |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - public function testInvalidNotClassFormatPublic() |
|
38 | - { |
|
39 | - $this->assertFalse(Common::isCamelCaps('_thisIsCamelCaps', false, true, true)); |
|
40 | - $this->assertFalse(Common::isCamelCaps('thisISCamelCaps', false, true, true)); |
|
41 | - $this->assertFalse(Common::isCamelCaps('ThisIsCamelCaps', false, true, true)); |
|
42 | - |
|
43 | - $this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, true, true)); |
|
44 | - $this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, true, true)); |
|
45 | - $this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, true, true)); |
|
46 | - |
|
47 | - $this->assertFalse(Common::isCamelCaps('this*IsCamelCaps', false, true, true)); |
|
48 | - $this->assertFalse(Common::isCamelCaps('this-IsCamelCaps', false, true, true)); |
|
49 | - $this->assertFalse(Common::isCamelCaps('this_IsCamelCaps', false, true, true)); |
|
50 | - $this->assertFalse(Common::isCamelCaps('this_is_camel_caps', false, true, true)); |
|
51 | - |
|
52 | - }//end testInvalidNotClassFormatPublic() |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Test valid private method names. |
|
57 | - * |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function testValidNotClassFormatPrivate() |
|
61 | - { |
|
62 | - $this->assertTrue(Common::isCamelCaps('_thisIsCamelCaps', false, false, true)); |
|
63 | - $this->assertTrue(Common::isCamelCaps('_thisISCamelCaps', false, false, false)); |
|
64 | - $this->assertTrue(Common::isCamelCaps('_i18N', false, false, true)); |
|
65 | - $this->assertTrue(Common::isCamelCaps('_i18n', false, false, true)); |
|
66 | - |
|
67 | - }//end testValidNotClassFormatPrivate() |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Test invalid private method names. |
|
72 | - * |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public function testInvalidNotClassFormatPrivate() |
|
76 | - { |
|
77 | - $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', false, false, true)); |
|
78 | - $this->assertFalse(Common::isCamelCaps('_thisISCamelCaps', false, false, true)); |
|
79 | - $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', false, false, true)); |
|
80 | - $this->assertFalse(Common::isCamelCaps('__thisIsCamelCaps', false, false, true)); |
|
81 | - $this->assertFalse(Common::isCamelCaps('__thisISCamelCaps', false, false, false)); |
|
82 | - |
|
83 | - $this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, false, true)); |
|
84 | - $this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, false, true)); |
|
85 | - $this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, false, true)); |
|
86 | - $this->assertFalse(Common::isCamelCaps('_this_is_camel_caps', false, false, true)); |
|
87 | - |
|
88 | - }//end testInvalidNotClassFormatPrivate() |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * Test valid class names. |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public function testValidClassFormatPublic() |
|
97 | - { |
|
98 | - $this->assertTrue(Common::isCamelCaps('ThisIsCamelCaps', true, true, true)); |
|
99 | - $this->assertTrue(Common::isCamelCaps('ThisISCamelCaps', true, true, false)); |
|
100 | - $this->assertTrue(Common::isCamelCaps('This3IsCamelCaps', true, true, false)); |
|
101 | - |
|
102 | - }//end testValidClassFormatPublic() |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * Test invalid class names. |
|
107 | - * |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - public function testInvalidClassFormat() |
|
111 | - { |
|
112 | - $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', true)); |
|
113 | - $this->assertFalse(Common::isCamelCaps('This-IsCamelCaps', true)); |
|
114 | - $this->assertFalse(Common::isCamelCaps('This_Is_Camel_Caps', true)); |
|
115 | - |
|
116 | - }//end testInvalidClassFormat() |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * Test invalid class names with the private flag set. |
|
121 | - * |
|
122 | - * Note that the private flag is ignored if the class format |
|
123 | - * flag is set, so these names are all invalid. |
|
124 | - * |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - public function testInvalidClassFormatPrivate() |
|
128 | - { |
|
129 | - $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, true)); |
|
130 | - $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, false)); |
|
131 | - |
|
132 | - }//end testInvalidClassFormatPrivate() |
|
19 | + /** |
|
20 | + * Test valid public function/method names. |
|
21 | + * |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function testValidNotClassFormatPublic() |
|
25 | + { |
|
26 | + $this->assertTrue(Common::isCamelCaps('thisIsCamelCaps', false, true, true)); |
|
27 | + $this->assertTrue(Common::isCamelCaps('thisISCamelCaps', false, true, false)); |
|
28 | + |
|
29 | + }//end testValidNotClassFormatPublic() |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * Test invalid public function/method names. |
|
34 | + * |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + public function testInvalidNotClassFormatPublic() |
|
38 | + { |
|
39 | + $this->assertFalse(Common::isCamelCaps('_thisIsCamelCaps', false, true, true)); |
|
40 | + $this->assertFalse(Common::isCamelCaps('thisISCamelCaps', false, true, true)); |
|
41 | + $this->assertFalse(Common::isCamelCaps('ThisIsCamelCaps', false, true, true)); |
|
42 | + |
|
43 | + $this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, true, true)); |
|
44 | + $this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, true, true)); |
|
45 | + $this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, true, true)); |
|
46 | + |
|
47 | + $this->assertFalse(Common::isCamelCaps('this*IsCamelCaps', false, true, true)); |
|
48 | + $this->assertFalse(Common::isCamelCaps('this-IsCamelCaps', false, true, true)); |
|
49 | + $this->assertFalse(Common::isCamelCaps('this_IsCamelCaps', false, true, true)); |
|
50 | + $this->assertFalse(Common::isCamelCaps('this_is_camel_caps', false, true, true)); |
|
51 | + |
|
52 | + }//end testInvalidNotClassFormatPublic() |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Test valid private method names. |
|
57 | + * |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function testValidNotClassFormatPrivate() |
|
61 | + { |
|
62 | + $this->assertTrue(Common::isCamelCaps('_thisIsCamelCaps', false, false, true)); |
|
63 | + $this->assertTrue(Common::isCamelCaps('_thisISCamelCaps', false, false, false)); |
|
64 | + $this->assertTrue(Common::isCamelCaps('_i18N', false, false, true)); |
|
65 | + $this->assertTrue(Common::isCamelCaps('_i18n', false, false, true)); |
|
66 | + |
|
67 | + }//end testValidNotClassFormatPrivate() |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Test invalid private method names. |
|
72 | + * |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public function testInvalidNotClassFormatPrivate() |
|
76 | + { |
|
77 | + $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', false, false, true)); |
|
78 | + $this->assertFalse(Common::isCamelCaps('_thisISCamelCaps', false, false, true)); |
|
79 | + $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', false, false, true)); |
|
80 | + $this->assertFalse(Common::isCamelCaps('__thisIsCamelCaps', false, false, true)); |
|
81 | + $this->assertFalse(Common::isCamelCaps('__thisISCamelCaps', false, false, false)); |
|
82 | + |
|
83 | + $this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, false, true)); |
|
84 | + $this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, false, true)); |
|
85 | + $this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, false, true)); |
|
86 | + $this->assertFalse(Common::isCamelCaps('_this_is_camel_caps', false, false, true)); |
|
87 | + |
|
88 | + }//end testInvalidNotClassFormatPrivate() |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * Test valid class names. |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public function testValidClassFormatPublic() |
|
97 | + { |
|
98 | + $this->assertTrue(Common::isCamelCaps('ThisIsCamelCaps', true, true, true)); |
|
99 | + $this->assertTrue(Common::isCamelCaps('ThisISCamelCaps', true, true, false)); |
|
100 | + $this->assertTrue(Common::isCamelCaps('This3IsCamelCaps', true, true, false)); |
|
101 | + |
|
102 | + }//end testValidClassFormatPublic() |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * Test invalid class names. |
|
107 | + * |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + public function testInvalidClassFormat() |
|
111 | + { |
|
112 | + $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', true)); |
|
113 | + $this->assertFalse(Common::isCamelCaps('This-IsCamelCaps', true)); |
|
114 | + $this->assertFalse(Common::isCamelCaps('This_Is_Camel_Caps', true)); |
|
115 | + |
|
116 | + }//end testInvalidClassFormat() |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * Test invalid class names with the private flag set. |
|
121 | + * |
|
122 | + * Note that the private flag is ignored if the class format |
|
123 | + * flag is set, so these names are all invalid. |
|
124 | + * |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + public function testInvalidClassFormatPrivate() |
|
128 | + { |
|
129 | + $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, true)); |
|
130 | + $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, false)); |
|
131 | + |
|
132 | + }//end testInvalidClassFormatPrivate() |
|
133 | 133 | |
134 | 134 | |
135 | 135 | }//end class |
@@ -16,20 +16,20 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Runs the tests and collects their result in a TestResult. |
|
21 | - * |
|
22 | - * @param \PHPUnit\Framework\TestResult $result A test result. |
|
23 | - * |
|
24 | - * @return \PHPUnit\Framework\TestResult |
|
25 | - */ |
|
26 | - public function run(TestResult $result=null) |
|
27 | - { |
|
28 | - $result = parent::run($result); |
|
29 | - printPHPCodeSnifferTestOutput(); |
|
30 | - return $result; |
|
31 | - |
|
32 | - }//end run() |
|
19 | + /** |
|
20 | + * Runs the tests and collects their result in a TestResult. |
|
21 | + * |
|
22 | + * @param \PHPUnit\Framework\TestResult $result A test result. |
|
23 | + * |
|
24 | + * @return \PHPUnit\Framework\TestResult |
|
25 | + */ |
|
26 | + public function run(TestResult $result=null) |
|
27 | + { |
|
28 | + $result = parent::run($result); |
|
29 | + printPHPCodeSnifferTestOutput(); |
|
30 | + return $result; |
|
31 | + |
|
32 | + }//end run() |
|
33 | 33 | |
34 | 34 | |
35 | 35 | }//end class |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * |
24 | 24 | * @return \PHPUnit\Framework\TestResult |
25 | 25 | */ |
26 | - public function run(TestResult $result=null) |
|
26 | + public function run(TestResult $result = null) |
|
27 | 27 | { |
28 | 28 | $result = parent::run($result); |
29 | 29 | printPHPCodeSnifferTestOutput(); |
@@ -46,11 +46,11 @@ |
||
46 | 46 | * |
47 | 47 | * @return void |
48 | 48 | */ |
49 | - public function process_token( $stackPtr ) { |
|
49 | + public function process_token($stackPtr) { |
|
50 | 50 | |
51 | - if ( ! $this->has_whitelist_comment( 'loose comparison', $stackPtr ) ) { |
|
52 | - $error = 'Found: ' . $this->tokens[ $stackPtr ]['content'] . '. Use strict comparisons (=== or !==).'; |
|
53 | - $this->phpcsFile->addWarning( $error, $stackPtr, 'LooseComparison' ); |
|
51 | + if ( ! $this->has_whitelist_comment('loose comparison', $stackPtr)) { |
|
52 | + $error = 'Found: '.$this->tokens[$stackPtr]['content'].'. Use strict comparisons (=== or !==).'; |
|
53 | + $this->phpcsFile->addWarning($error, $stackPtr, 'LooseComparison'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | } |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | * @return array |
46 | 46 | */ |
47 | 47 | public function getGroups() { |
48 | - if ( empty( $this->target_functions ) ) { |
|
48 | + if (empty($this->target_functions)) { |
|
49 | 49 | return array(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | return array( |
53 | 53 | $this->group_name => array( |
54 | - 'functions' => array_keys( $this->target_functions ), |
|
54 | + 'functions' => array_keys($this->target_functions), |
|
55 | 55 | ), |
56 | 56 | ); |
57 | 57 | } |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * @return int|void Integer stack pointer to skip forward or void to continue |
67 | 67 | * normal file processing. |
68 | 68 | */ |
69 | - public function process_matched_token( $stackPtr, $group_name, $matched_content ) { |
|
69 | + public function process_matched_token($stackPtr, $group_name, $matched_content) { |
|
70 | 70 | |
71 | - $parameters = $this->get_function_call_parameters( $stackPtr ); |
|
71 | + $parameters = $this->get_function_call_parameters($stackPtr); |
|
72 | 72 | |
73 | - if ( empty( $parameters ) ) { |
|
74 | - return $this->process_no_parameters( $stackPtr, $group_name, $matched_content ); |
|
73 | + if (empty($parameters)) { |
|
74 | + return $this->process_no_parameters($stackPtr, $group_name, $matched_content); |
|
75 | 75 | } else { |
76 | - return $this->process_parameters( $stackPtr, $group_name, $matched_content, $parameters ); |
|
76 | + return $this->process_parameters($stackPtr, $group_name, $matched_content, $parameters); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return int|void Integer stack pointer to skip forward or void to continue |
91 | 91 | * normal file processing. |
92 | 92 | */ |
93 | - abstract public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ); |
|
93 | + abstract public function process_parameters($stackPtr, $group_name, $matched_content, $parameters); |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Process the function if no parameters were found. |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return int|void Integer stack pointer to skip forward or void to continue |
106 | 106 | * normal file processing. |
107 | 107 | */ |
108 | - public function process_no_parameters( $stackPtr, $group_name, $matched_content ) { |
|
108 | + public function process_no_parameters($stackPtr, $group_name, $matched_content) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | class AssetRegistrationException extends RuntimeException |
18 | 18 | { |
19 | - /** |
|
20 | - * @param $script_handle |
|
21 | - * @param string $message |
|
22 | - * @param int $code |
|
23 | - * @param Exception|null $previous |
|
24 | - */ |
|
25 | - public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
26 | - { |
|
27 | - if (empty($message)) { |
|
28 | - $message = sprintf( |
|
29 | - esc_html_x( |
|
30 | - 'The "%1$s" script could not be registered with WordPress core.', |
|
31 | - 'The "script-handle" script could not be registered with WordPress core.', |
|
32 | - 'event_espresso' |
|
33 | - ), |
|
34 | - $script_handle |
|
35 | - ); |
|
36 | - } |
|
37 | - parent::__construct($message, $code, $previous); |
|
38 | - } |
|
19 | + /** |
|
20 | + * @param $script_handle |
|
21 | + * @param string $message |
|
22 | + * @param int $code |
|
23 | + * @param Exception|null $previous |
|
24 | + */ |
|
25 | + public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
26 | + { |
|
27 | + if (empty($message)) { |
|
28 | + $message = sprintf( |
|
29 | + esc_html_x( |
|
30 | + 'The "%1$s" script could not be registered with WordPress core.', |
|
31 | + 'The "script-handle" script could not be registered with WordPress core.', |
|
32 | + 'event_espresso' |
|
33 | + ), |
|
34 | + $script_handle |
|
35 | + ); |
|
36 | + } |
|
37 | + parent::__construct($message, $code, $previous); |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -15,106 +15,106 @@ |
||
15 | 15 | */ |
16 | 16 | class ExportTransaction implements PersonalDataExporterInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EEM_Transaction $transaction_model |
|
20 | - */ |
|
21 | - protected $transaction_model; |
|
18 | + /** |
|
19 | + * @var EEM_Transaction $transaction_model |
|
20 | + */ |
|
21 | + protected $transaction_model; |
|
22 | 22 | |
23 | - /** |
|
24 | - * ExportTransaction constructor. |
|
25 | - * |
|
26 | - * @param $transaction_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Transaction $transaction_model) |
|
29 | - { |
|
30 | - $this->transaction_model = $transaction_model; |
|
31 | - } |
|
23 | + /** |
|
24 | + * ExportTransaction constructor. |
|
25 | + * |
|
26 | + * @param $transaction_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Transaction $transaction_model) |
|
29 | + { |
|
30 | + $this->transaction_model = $transaction_model; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Returns data for export. |
|
36 | - * |
|
37 | - * @param string $email_address , |
|
38 | - * @param int $page starts at 1, not 0 |
|
39 | - * @return array { |
|
40 | - * @type array $data { |
|
41 | - * @type array { |
|
42 | - * @type string $group_id (not translated, same for all exports) |
|
43 | - * @type string $group_label (translated string) |
|
44 | - * @type string|int $item_id |
|
45 | - * @type array $data { |
|
46 | - * @type array { |
|
47 | - * @type string $name what's shown in the left-column of the export row |
|
48 | - * @type string $value what's showin the right-column of the export row |
|
49 | - * } |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - */ |
|
55 | - public function export($email_address, $page = 1) |
|
56 | - { |
|
57 | - $page_size = 10; |
|
58 | - $transactions = $this->transaction_model->get_all( |
|
59 | - array( |
|
60 | - array( |
|
61 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
62 | - ), |
|
63 | - 'limit' => array( |
|
64 | - ($page - 1) * $page_size, |
|
65 | - $page_size, |
|
66 | - ), |
|
67 | - ) |
|
68 | - ); |
|
69 | - $export_fields = array_intersect_key( |
|
70 | - EEM_Transaction::instance()->field_settings(), |
|
71 | - array_flip( |
|
72 | - array( |
|
73 | - 'TXN_timestamp', |
|
74 | - 'TXN_total', |
|
75 | - 'TXN_paid', |
|
76 | - 'TXN_session_data', |
|
77 | - ) |
|
78 | - ) |
|
79 | - ); |
|
80 | - $export_items = array(); |
|
81 | - $found_something = false; |
|
82 | - foreach ($transactions as $transaction) { |
|
83 | - $found_something = true; |
|
84 | - $data = array(); |
|
85 | - foreach ($export_fields as $field_name => $field_obj) { |
|
86 | - if ($field_name === 'TXN_session_data') { |
|
87 | - $value = $transaction->get_pretty($field_name, 'print_r'); |
|
88 | - } else { |
|
89 | - $value = $transaction->get_pretty($field_name); |
|
90 | - } |
|
91 | - $data[] = array( |
|
92 | - 'name' => $field_obj->get_nicename(), |
|
93 | - 'value' => $value, |
|
94 | - ); |
|
95 | - } |
|
96 | - $export_items[] = array( |
|
97 | - 'group_id' => 'transactions', |
|
98 | - 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99 | - 'item_id' => $transaction->ID(), |
|
100 | - 'data' => $data, |
|
101 | - ); |
|
102 | - } |
|
103 | - return array( |
|
104 | - 'data' => $export_items, |
|
105 | - 'done' => ! $found_something, |
|
106 | - ); |
|
107 | - } |
|
34 | + /** |
|
35 | + * Returns data for export. |
|
36 | + * |
|
37 | + * @param string $email_address , |
|
38 | + * @param int $page starts at 1, not 0 |
|
39 | + * @return array { |
|
40 | + * @type array $data { |
|
41 | + * @type array { |
|
42 | + * @type string $group_id (not translated, same for all exports) |
|
43 | + * @type string $group_label (translated string) |
|
44 | + * @type string|int $item_id |
|
45 | + * @type array $data { |
|
46 | + * @type array { |
|
47 | + * @type string $name what's shown in the left-column of the export row |
|
48 | + * @type string $value what's showin the right-column of the export row |
|
49 | + * } |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + */ |
|
55 | + public function export($email_address, $page = 1) |
|
56 | + { |
|
57 | + $page_size = 10; |
|
58 | + $transactions = $this->transaction_model->get_all( |
|
59 | + array( |
|
60 | + array( |
|
61 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
62 | + ), |
|
63 | + 'limit' => array( |
|
64 | + ($page - 1) * $page_size, |
|
65 | + $page_size, |
|
66 | + ), |
|
67 | + ) |
|
68 | + ); |
|
69 | + $export_fields = array_intersect_key( |
|
70 | + EEM_Transaction::instance()->field_settings(), |
|
71 | + array_flip( |
|
72 | + array( |
|
73 | + 'TXN_timestamp', |
|
74 | + 'TXN_total', |
|
75 | + 'TXN_paid', |
|
76 | + 'TXN_session_data', |
|
77 | + ) |
|
78 | + ) |
|
79 | + ); |
|
80 | + $export_items = array(); |
|
81 | + $found_something = false; |
|
82 | + foreach ($transactions as $transaction) { |
|
83 | + $found_something = true; |
|
84 | + $data = array(); |
|
85 | + foreach ($export_fields as $field_name => $field_obj) { |
|
86 | + if ($field_name === 'TXN_session_data') { |
|
87 | + $value = $transaction->get_pretty($field_name, 'print_r'); |
|
88 | + } else { |
|
89 | + $value = $transaction->get_pretty($field_name); |
|
90 | + } |
|
91 | + $data[] = array( |
|
92 | + 'name' => $field_obj->get_nicename(), |
|
93 | + 'value' => $value, |
|
94 | + ); |
|
95 | + } |
|
96 | + $export_items[] = array( |
|
97 | + 'group_id' => 'transactions', |
|
98 | + 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99 | + 'item_id' => $transaction->ID(), |
|
100 | + 'data' => $data, |
|
101 | + ); |
|
102 | + } |
|
103 | + return array( |
|
104 | + 'data' => $export_items, |
|
105 | + 'done' => ! $found_something, |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Gets the Translated name of this exporter |
|
111 | - * |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function name() |
|
115 | - { |
|
116 | - return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117 | - } |
|
109 | + /** |
|
110 | + * Gets the Translated name of this exporter |
|
111 | + * |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function name() |
|
115 | + { |
|
116 | + return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | // End of file ExportTransaction.php |
120 | 120 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportTransaction.php |
@@ -15,116 +15,116 @@ |
||
15 | 15 | */ |
16 | 16 | class ExportAttendee implements PersonalDataExporterInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EEM_Attendee |
|
20 | - */ |
|
21 | - protected $attendee_model; |
|
18 | + /** |
|
19 | + * @var EEM_Attendee |
|
20 | + */ |
|
21 | + protected $attendee_model; |
|
22 | 22 | |
23 | - /** |
|
24 | - * ExportAttendee constructor. |
|
25 | - * |
|
26 | - * @param EEM_Attendee $attendee_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Attendee $attendee_model) |
|
29 | - { |
|
30 | - $this->attendee_model = $attendee_model; |
|
31 | - } |
|
23 | + /** |
|
24 | + * ExportAttendee constructor. |
|
25 | + * |
|
26 | + * @param EEM_Attendee $attendee_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Attendee $attendee_model) |
|
29 | + { |
|
30 | + $this->attendee_model = $attendee_model; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Returns data for export. |
|
36 | - * |
|
37 | - * @param string $email_address , |
|
38 | - * @param int $page starts at 1, not 0 |
|
39 | - * @return array { |
|
40 | - * @type array $data { |
|
41 | - * @type array { |
|
42 | - * @type string $group_id (not translated, same for all exports) |
|
43 | - * @type string $group_label (translated string) |
|
44 | - * @type string|int $item_id |
|
45 | - * @type array $data { |
|
46 | - * @type array { |
|
47 | - * @type string $name what's shown in the left-column of the export row |
|
48 | - * @type string $value what's showin the right-column of the export row |
|
49 | - * } |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - */ |
|
55 | - public function export($email_address, $page = 1) |
|
56 | - { |
|
57 | - $attendees = $this->attendee_model->get_all( |
|
58 | - array( |
|
59 | - array( |
|
60 | - 'ATT_email' => $email_address, |
|
61 | - ), |
|
62 | - ) |
|
63 | - ); |
|
34 | + /** |
|
35 | + * Returns data for export. |
|
36 | + * |
|
37 | + * @param string $email_address , |
|
38 | + * @param int $page starts at 1, not 0 |
|
39 | + * @return array { |
|
40 | + * @type array $data { |
|
41 | + * @type array { |
|
42 | + * @type string $group_id (not translated, same for all exports) |
|
43 | + * @type string $group_label (translated string) |
|
44 | + * @type string|int $item_id |
|
45 | + * @type array $data { |
|
46 | + * @type array { |
|
47 | + * @type string $name what's shown in the left-column of the export row |
|
48 | + * @type string $value what's showin the right-column of the export row |
|
49 | + * } |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + */ |
|
55 | + public function export($email_address, $page = 1) |
|
56 | + { |
|
57 | + $attendees = $this->attendee_model->get_all( |
|
58 | + array( |
|
59 | + array( |
|
60 | + 'ATT_email' => $email_address, |
|
61 | + ), |
|
62 | + ) |
|
63 | + ); |
|
64 | 64 | |
65 | - if (empty($attendees)) { |
|
66 | - return array( |
|
67 | - 'data' => array(), |
|
68 | - 'done' => true, |
|
69 | - ); |
|
70 | - } |
|
65 | + if (empty($attendees)) { |
|
66 | + return array( |
|
67 | + 'data' => array(), |
|
68 | + 'done' => true, |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - $export_items = array(); |
|
73 | - foreach ($attendees as $attendee) { |
|
74 | - $export_fields = array_intersect_key( |
|
75 | - $this->attendee_model->field_settings(), |
|
76 | - array_flip( |
|
77 | - array( |
|
78 | - 'ATT_fname', |
|
79 | - 'ATT_lname', |
|
80 | - 'ATT_email', |
|
81 | - 'ATT_address1', |
|
82 | - 'ATT_address2', |
|
83 | - 'ATT_city', |
|
84 | - 'STA_ID', |
|
85 | - 'CNT_ISO', |
|
86 | - 'ATT_zip', |
|
87 | - 'ATT_phone', |
|
88 | - ) |
|
89 | - ) |
|
90 | - ); |
|
91 | - $data = array(); |
|
92 | - foreach ($export_fields as $field_name => $field_obj) { |
|
93 | - if ($field_name === 'STA_ID') { |
|
94 | - $value = $attendee->state_name(); |
|
95 | - } elseif ($field_name == 'CNT_ISO') { |
|
96 | - $value = $attendee->country_name(); |
|
97 | - } else { |
|
98 | - $value = $attendee->get_pretty($field_name); |
|
99 | - } |
|
100 | - $data[] = array( |
|
101 | - 'name' => $field_obj->get_nicename(), |
|
102 | - 'value' => $value, |
|
103 | - ); |
|
104 | - } |
|
105 | - $export_items[] = |
|
106 | - array( |
|
107 | - 'group_id' => 'att-' . $attendee->ID(), |
|
108 | - 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
|
109 | - 'item_id' => $attendee->ID(), |
|
110 | - 'data' => $data, |
|
111 | - ); |
|
112 | - } |
|
113 | - return array( |
|
114 | - 'data' => $export_items, |
|
115 | - 'done' => true, |
|
116 | - ); |
|
117 | - } |
|
72 | + $export_items = array(); |
|
73 | + foreach ($attendees as $attendee) { |
|
74 | + $export_fields = array_intersect_key( |
|
75 | + $this->attendee_model->field_settings(), |
|
76 | + array_flip( |
|
77 | + array( |
|
78 | + 'ATT_fname', |
|
79 | + 'ATT_lname', |
|
80 | + 'ATT_email', |
|
81 | + 'ATT_address1', |
|
82 | + 'ATT_address2', |
|
83 | + 'ATT_city', |
|
84 | + 'STA_ID', |
|
85 | + 'CNT_ISO', |
|
86 | + 'ATT_zip', |
|
87 | + 'ATT_phone', |
|
88 | + ) |
|
89 | + ) |
|
90 | + ); |
|
91 | + $data = array(); |
|
92 | + foreach ($export_fields as $field_name => $field_obj) { |
|
93 | + if ($field_name === 'STA_ID') { |
|
94 | + $value = $attendee->state_name(); |
|
95 | + } elseif ($field_name == 'CNT_ISO') { |
|
96 | + $value = $attendee->country_name(); |
|
97 | + } else { |
|
98 | + $value = $attendee->get_pretty($field_name); |
|
99 | + } |
|
100 | + $data[] = array( |
|
101 | + 'name' => $field_obj->get_nicename(), |
|
102 | + 'value' => $value, |
|
103 | + ); |
|
104 | + } |
|
105 | + $export_items[] = |
|
106 | + array( |
|
107 | + 'group_id' => 'att-' . $attendee->ID(), |
|
108 | + 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
|
109 | + 'item_id' => $attendee->ID(), |
|
110 | + 'data' => $data, |
|
111 | + ); |
|
112 | + } |
|
113 | + return array( |
|
114 | + 'data' => $export_items, |
|
115 | + 'done' => true, |
|
116 | + ); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Gets the Translated name of this exporter |
|
121 | - * |
|
122 | - * @return string |
|
123 | - */ |
|
124 | - public function name() |
|
125 | - { |
|
126 | - return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
|
127 | - } |
|
119 | + /** |
|
120 | + * Gets the Translated name of this exporter |
|
121 | + * |
|
122 | + * @return string |
|
123 | + */ |
|
124 | + public function name() |
|
125 | + { |
|
126 | + return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
|
127 | + } |
|
128 | 128 | } |
129 | 129 | // End of file ExportAttendee.php |
130 | 130 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportAttendee.php |
@@ -104,7 +104,7 @@ |
||
104 | 104 | } |
105 | 105 | $export_items[] = |
106 | 106 | array( |
107 | - 'group_id' => 'att-' . $attendee->ID(), |
|
107 | + 'group_id' => 'att-'.$attendee->ID(), |
|
108 | 108 | 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
109 | 109 | 'item_id' => $attendee->ID(), |
110 | 110 | 'data' => $data, |