diff --git a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
index 9f3e504..9267237 100644
--- a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
+++ b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
@@ -109,5 +109,5 @@ public function testSettingsForm() {
 namespace Drupal\Core\Form;
 
 if (!function_exists('drupal_set_message')) {
-  public function drupal_set_message() {}
+  function drupal_set_message() {}
 }
diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
index 8e3bba1..18da223 100644
--- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
@@ -322,7 +322,7 @@ protected function getMockNode($has_field, $comment_status, $form_location, $com
 namespace Drupal\comment;
 
 if (!function_exists('history_read')) {
-  public function history_read() {
+  function history_read() {
     return 0;
   }
 }
diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
index 950b38d..825ca7d 100644
--- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
+++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
@@ -256,7 +256,7 @@ public function providerTestDomain() {
 namespace Drupal\language\Plugin\LanguageNegotiation;
 
 if (!function_exists('base_path')) {
-  public function base_path() {
+  function base_path() {
     return '/';
   }
 }
diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
index aa146aa..1e9e75d 100644
--- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
+++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
@@ -35,7 +35,7 @@ protected function setUp() {
 # Define a function to be able to check that this file was loaded with
 # function_exists().
 if (!function_exists('simpletest_test_stub_settings_function')) {
-  public function simpletest_test_stub_settings_function() {}
+  function simpletest_test_stub_settings_function() {}
 }
 EOS;
 
diff --git a/core/modules/simpletest/src/Tests/SimpleTestTest.php b/core/modules/simpletest/src/Tests/SimpleTestTest.php
index 7b808e5..a32c142 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestTest.php
@@ -75,7 +75,7 @@ protected function setUp() {
 # Define a function to be able to check that this file was loaded with
 # function_exists().
 if (!function_exists('simpletest_test_stub_settings_function')) {
-  public function simpletest_test_stub_settings_function() {}
+  function simpletest_test_stub_settings_function() {}
 }
 EOD;
 
diff --git a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
index 12cc87e..74bcc08 100644
--- a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
+++ b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
@@ -1108,7 +1108,7 @@ public function setKey($key, $value) {
 namespace Drupal\entity_test\Entity;
 
 if (!function_exists('t')) {
-  public function t($string, array $args = []) {
+  function t($string, array $args = []) {
     return strtr($string, $args);
   }
 }
@@ -1117,7 +1117,7 @@ public function t($string, array $args = []) {
 namespace Drupal\Core\Entity;
 
 if (!function_exists('t')) {
-  public function t($string, array $args = []) {
+  function t($string, array $args = []) {
     return strtr($string, $args);
   }
 }
diff --git a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
index c9ad280..cbe6ade 100644
--- a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
@@ -203,6 +203,6 @@ public function testBuildFailed() {
 namespace Drupal\views\Plugin\Block;
 
 if (!function_exists('views_add_contextual_links')) {
-  public function views_add_contextual_links() {
+  function views_add_contextual_links() {
   }
 }
diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
index e16c7cd..0b33a58 100644
--- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
@@ -731,7 +731,7 @@ public function setLinkGenerator(LinkGeneratorInterface $link_generator) {
 namespace Drupal\views\Plugin\views\field;
 
 if (!function_exists('base_path')) {
-  public function base_path() {
+  function base_path() {
     return '/';
   }
 }
diff --git a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
index 922eb1a..9242545 100644
--- a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
+++ b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
@@ -182,6 +182,6 @@ public function testHandleWithArgumentsOnOverriddenRouteWithUpcasting() {
 namespace Drupal\views\Routing;
 
 if (!function_exists('views_add_contextual_links')) {
-  public function views_add_contextual_links() {
+  function views_add_contextual_links() {
   }
 }
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index e4e42be..fb1ff75 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -74,6 +74,7 @@
   <rule ref="Drupal.InfoFiles.ClassFiles"/>
   <rule ref="Drupal.InfoFiles.DuplicateEntry"/>
   <rule ref="Drupal.InfoFiles.Required"/>
+  <rule ref="Drupal.Scope.MethodScope"/>
   <rule ref="Drupal.Semantics.EmptyInstall"/>
   <rule ref="Drupal.Semantics.FunctionT">
     <exclude name="Drupal.Semantics.FunctionT.BackslashSingleQuote"/>
diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
index d85fce3..c7f1f3d 100644
--- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
@@ -473,7 +473,7 @@ public function testRenderInvalidType() {
  * Component/Utility.
  */
 if (!function_exists('Drupal\Tests\Core\Asset\file_create_url')) {
-  public function file_create_url($uri) {
+  function file_create_url($uri) {
     return 'file_create_url:' . $uri;
   }
 }
@@ -483,7 +483,7 @@ public function file_create_url($uri) {
  * Component/Utility.
  */
 if (!function_exists('Drupal\Tests\Core\Asset\file_url_transform_relative')) {
-  public function file_url_transform_relative($uri) {
+  function file_url_transform_relative($uri) {
     return 'file_url_transform_relative:' . $uri;
   }
 }
@@ -501,7 +501,7 @@ public function file_url_transform_relative($uri) {
    * Temporary mock for file_create_url(), until that is moved into
    * Component/Utility.
    */
-  public function file_create_url($uri) {
+  function file_create_url($uri) {
     return \Drupal\Tests\Core\Asset\file_create_url($uri);
   }
 
@@ -512,7 +512,7 @@ public function file_create_url($uri) {
    * Temporary mock of file_url_transform_relative, until that is moved into
    * Component/Utility.
    */
-  public function file_url_transform_relative($uri) {
+  function file_url_transform_relative($uri) {
     return \Drupal\Tests\Core\Asset\file_url_transform_relative($uri);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php
index 8d5daff..59ddca0e 100644
--- a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php
@@ -269,7 +269,7 @@ public function testTypeExternal() {
  * Component/Utility.
  */
 if (!function_exists('Drupal\Tests\Core\Asset\file_create_url')) {
-  public function file_create_url($uri) {
+  function file_create_url($uri) {
     return 'file_create_url:' . $uri;
   }
 }
@@ -279,7 +279,7 @@ public function file_create_url($uri) {
  * Component/Utility.
  */
 if (!function_exists('Drupal\Tests\Core\Asset\file_url_transform_relative')) {
-  public function file_url_transform_relative($uri) {
+  function file_url_transform_relative($uri) {
     return 'file_url_transform_relative:' . $uri;
   }
 }
@@ -297,7 +297,7 @@ public function file_url_transform_relative($uri) {
    * Temporary mock for file_create_url(), until that is moved into
    * Component/Utility.
    */
-  public function file_create_url($uri) {
+  function file_create_url($uri) {
     return \Drupal\Tests\Core\Asset\file_create_url($uri);
   }
 
@@ -308,14 +308,14 @@ public function file_create_url($uri) {
    * Temporary mock of file_url_transform_relative, until that is moved into
    * Component/Utility.
    */
-  public function file_url_transform_relative($uri) {
+  function file_url_transform_relative($uri) {
     return \Drupal\Tests\Core\Asset\file_url_transform_relative($uri);
   }
 
 }
 if (!function_exists('Drupal\Core\Asset\file_uri_scheme')) {
 
-  public function file_uri_scheme($uri) {
+  function file_uri_scheme($uri) {
     return FALSE;
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php b/core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php
index 2ab953e..0dcdc58 100644
--- a/core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php
@@ -112,7 +112,7 @@ public function testProcessMachineName() {
 namespace Drupal\Core\Render\Element;
 
 if (!function_exists('t')) {
-  public function t($string, array $args = []) {
+  function t($string, array $args = []) {
     return strtr($string, $args);
   }
 }
diff --git a/core/tests/Drupal/Tests/Core/Session/AccountProxyTest.php b/core/tests/Drupal/Tests/Core/Session/AccountProxyTest.php
index de12aa2..0e575a0 100644
--- a/core/tests/Drupal/Tests/Core/Session/AccountProxyTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/AccountProxyTest.php
@@ -47,7 +47,7 @@ public function testSetInitialAccountIdException() {
 namespace Drupal\Core\Session;
 
 if (!function_exists('drupal_get_user_timezone')) {
-  public function drupal_get_user_timezone() {
+  function drupal_get_user_timezone() {
     return date_default_timezone_get();
   }
 }
diff --git a/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php b/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
index a6ea311..aa980f8 100644
--- a/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
@@ -250,7 +250,7 @@ public function testGenerateNoCache() {
 
 // @todo remove once user_role_permissions() can be injected.
 if (!function_exists('user_role_permissions')) {
-  public function user_role_permissions(array $roles) {
+  function user_role_permissions(array $roles) {
     $role_permissions = [];
     foreach ($roles as $rid) {
       $role_permissions[$rid] = [];
