Problem/Motivation


CUSTOM PROJECTS
--------------------------------------------------------------------------------
Examples for Developers
Scanned on Tue, 05/26/2020 - 19:04.

5 errors found. Avoid some manual work by using drupal-rector for fixing issues
automatically or Upgrade Rector to generate patches.

modules/contrib/examples/file_example/src/Form/FileExampleReadWriteForm.php:
┌──────────┬──────┬─────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                           │
├──────────┼──────┼─────────────────────────────────────────────────────────────┤
│ Fix now  │ 392  │ Call to deprecated constant FILE_EXISTS_RENAME: Deprecated  │
│          │      │ in drupal:8.7.0 and is removed from drupal:9.0.0. Use       │
│          │      │ Drupal\Core\File\FileSystemInterface::EXISTS_RENAME.        │
│          │      │                                                             │
│ Fix with │ 452  │ Call to deprecated constant FILE_EXISTS_REPLACE: Deprecated │
│ rector   │      │ in drupal:8.7.0 and is removed from drupal:9.0.0. Use       │
│          │      │ Drupal\Core\File\FileSystemInterface::EXISTS_REPLACE.       │
│          │      │                                                             │
└──────────┴──────┴─────────────────────────────────────────────────────────────┘

modules/contrib/examples/testing_example/src/Tests/NaiveConversionTest.php:
┌─────────┬──────┬──────────────────────────────────────────────────────────────┐
│ STATUS  │ LINE │                           MESSAGE                            │
├─────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Fix now │ 17   │ Class Drupal\testing_example\Tests\NaiveConversionTest       │
│         │      │ extends deprecated class Drupal\simpletest\WebTestBase.      │
│         │      │ Deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. │
│         │      │ Instead, use Drupal\Tests\BrowserTestBase. See               │
│         │      │ https://www.drupal.org/node/3030340. Replacement available   │
│         │      │ from drupal:8.6.0.                                           │
│         │      │                                                              │
└─────────┴──────┴──────────────────────────────────────────────────────────────┘

modules/contrib/examples/testing_example/src/Tests/SimpleTestExampleMockModuleTe
st.php:
┌─────────┬──────┬──────────────────────────────────────────────────────────────┐
│ STATUS  │ LINE │                           MESSAGE                            │
├─────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Fix now │ 32   │ Class                                                        │
│         │      │ Drupal\testing_example\Tests\SimpleTestExampleMockModuleTest │
│         │      │ extends deprecated class Drupal\simpletest\WebTestBase.      │
│         │      │ Deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. │
│         │      │ Instead, use Drupal\Tests\BrowserTestBase. See               │
│         │      │ https://www.drupal.org/node/3030340. Replacement available   │
│         │      │ from drupal:8.6.0.                                           │
│         │      │                                                              │
└─────────┴──────┴──────────────────────────────────────────────────────────────┘

modules/contrib/examples/testing_example/src/Tests/SimpleTestExampleTest.php:
┌─────────┬──────┬──────────────────────────────────────────────────────────────┐
│ STATUS  │ LINE │                           MESSAGE                            │
├─────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Fix now │ 31   │ Class Drupal\testing_example\Tests\SimpleTestExampleTest     │
│         │      │ extends deprecated class Drupal\simpletest\WebTestBase.      │
│         │      │ Deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. │
│         │      │ Instead, use Drupal\Tests\BrowserTestBase. See               │
│         │      │ https://www.drupal.org/node/3030340. Replacement available   │
│         │      │ from drupal:8.6.0.                                           │
│         │      │                                                              │
└─────────┴──────┴──────────────────────────────────────────────────────────────┘





Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

SerShevchyk’s picture

drupal-check modules/contrib/examples
222/222 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

------ ---------------------------------------------------------------------
Line cache_example/src/Form/CacheExampleForm.php
------ ---------------------------------------------------------------------
117 Call to deprecated function file_scan_directory():
in drupal:8.8.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\File\FileSystemInterface::scanDirectory() instead.
------ ---------------------------------------------------------------------

------ --------------------------------------------------------------------------------------
Line phpunit_example/tests/src/Unit/AddClassTest.php
------ --------------------------------------------------------------------------------------
114 Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:
in drupal:8.8.0 and is removed from drupal:9.0.0.
Backward compatibility for PHPUnit 4 will no longer be supported.
------ --------------------------------------------------------------------------------------

------ --------------------------------------------------------------------------------------
Line phpunit_example/tests/src/Unit/ProtectedPrivatesTest.php
------ --------------------------------------------------------------------------------------
113 Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:
in drupal:8.8.0 and is removed from drupal:9.0.0.
Backward compatibility for PHPUnit 4 will no longer be supported.
143 Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:
in drupal:8.8.0 and is removed from drupal:9.0.0.
Backward compatibility for PHPUnit 4 will no longer be supported.
------ --------------------------------------------------------------------------------------

------ -------------------------------------------------------------------------------
Line stream_wrapper_example/tests/src/Kernel/StreamWrapperTest.php
------ -------------------------------------------------------------------------------
49 Call to deprecated method validScheme() of class Drupal\Core\File\FileSystem:
in drupal:8.0.0 and will be removed before Drupal 9.0.0. Use
Drupal\Core\StreamWrapper\StreamWrapperManagerInterface::isValidScheme()
instead.
------ -------------------------------------------------------------------------------

------ ----------------------------------------------------------------------------------------------------------------
Line testing_example/src/Tests/NaiveConversionTest.php
------ ----------------------------------------------------------------------------------------------------------------
17 Class Drupal\testing_example\Tests\NaiveConversionTest extends deprecated class Drupal\simpletest\WebTestBase:
in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead,
use \Drupal\Tests\BrowserTestBase. See https://www.drupal.org/node/3030340.
------ ----------------------------------------------------------------------------------------------------------------

------ ----------------------------------------------------------------------------------------------------------------------------
Line testing_example/src/Tests/SimpleTestExampleMockModuleTest.php
------ ----------------------------------------------------------------------------------------------------------------------------
32 Class Drupal\testing_example\Tests\SimpleTestExampleMockModuleTest extends deprecated class Drupal\simpletest\WebTestBase:
in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead,
use \Drupal\Tests\BrowserTestBase. See https://www.drupal.org/node/3030340.
------ ----------------------------------------------------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------------------------------------------
Line testing_example/src/Tests/SimpleTestExampleTest.php
------ ------------------------------------------------------------------------------------------------------------------
31 Class Drupal\testing_example\Tests\SimpleTestExampleTest extends deprecated class Drupal\simpletest\WebTestBase:
in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead,
use \Drupal\Tests\BrowserTestBase. See https://www.drupal.org/node/3030340.
------ ------------------------------------------------------------------------------------------------------------------

[ERROR] Found 8 errors

valthebald’s picture

Down to 7:

drupal-check -ad modules/dev/examples/
 222/222 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ---------------------------------------------------------------------- 
  Line   cron_example/tests/src/Functional/CronExampleTest.php                 
 ------ ---------------------------------------------------------------------- 
  45     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------ 
  Line   field_example/tests/src/Functional/FieldExampleBrowserTestBase.php      
 ------ ------------------------------------------------------------------------ 
  82     Method Drupal\Tests\BrowserTestBase::checkPermissions() invoked with 2  
         parameters, 1 required.                                                 
 ------ ------------------------------------------------------------------------ 

 ------ ---------------------------------------------------------------------- 
  Line   phpunit_example/src/AddClass.php                                      
 ------ ---------------------------------------------------------------------- 
  26     Return typehint of method Drupal\phpunit_example\AddClass::add() has  
         invalid type Drupal\phpunit_example\numeric.                          
 ------ ---------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------- 
  Line   phpunit_example/src/ProtectedPrivates.php                                
 ------ ------------------------------------------------------------------------- 
  33     Return typehint of method                                                
         Drupal\phpunit_example\ProtectedPrivates::protectedAdd() has invalid     
         type Drupal\phpunit_example\numeric.                                     
  52     Return typehint of method                                                
         Drupal\phpunit_example\ProtectedPrivates::privateAdd() has invalid type  
         Drupal\phpunit_example\numeric.                                          
 ------ ------------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------- 
  Line   plugin_type_example/src/SandwichPluginManager.php                      
 ------ ----------------------------------------------------------------------- 
  38     Plugin manager has cache backend specified but does not declare cache  
         tags.                                                                  
 ------ ----------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------- 
  Line   stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php     
 ------ ---------------------------------------------------------------------- 
  156    \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 

                                                                                
 [ERROR] Found 7 errors   
alt.dev’s picture

I ran the code analysis with the drupal-check version 1.0.14. Its return 18 errors.



 ------ --------------------------------------------------------------------- 
  Line   cache_example/src/Form/CacheExampleForm.php                          
 ------ --------------------------------------------------------------------- 
  117    Call to deprecated function file_scan_directory():                   
         in drupal:8.8.0 and is removed from drupal:9.0.0.                    
         Use \Drupal\Core\File\FileSystemInterface::scanDirectory() instead.  
 ------ --------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------ 
  Line   cron_example/tests/src/Functional/CronExampleTest.php                         
 ------ ------------------------------------------------------------------------------ 
  45     \Drupal calls should be avoided in classes, use dependency injection instead  
 ------ ------------------------------------------------------------------------------ 

 ------ -------------------------------------------------------------------------- 
  Line   examples.module                                                           
 ------ -------------------------------------------------------------------------- 
  44     Call to deprecated function system_get_info():                            
         in drupal:8.8.0 and is removed from drupal:9.0.0. Use                     
         \Drupal::service('extension.list.$type')->getExtensionInfo() or           
         \Drupal::service('extension.list.$type')->getAllInstalledInfo() instead.  
 ------ -------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------ 
  Line   field_example/tests/src/Functional/FieldExampleBrowserTestBase.php                              
 ------ ------------------------------------------------------------------------------------------------ 
  82     Method Drupal\Tests\BrowserTestBase::checkPermissions() invoked with 2 parameters, 1 required.  
 ------ ------------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------ 
  Line   form_api_example/src/Form/InputDemo.php                     
 ------ ------------------------------------------------------------ 
  56     Call to deprecated function drupal_get_user_timezone():     
         in drupal:8.8.0 and will be removed from drupal:9.0.0. Use  
         date_default_timezone_get() instead.                        
  57     Call to deprecated function drupal_get_user_timezone():     
         in drupal:8.8.0 and will be removed from drupal:9.0.0. Use  
         date_default_timezone_get() instead.                        
 ------ ------------------------------------------------------------ 

 ------ ----------------------------------------------------------------------------------- 
  Line   phpunit_example/src/AddClass.php                                                   
 ------ ----------------------------------------------------------------------------------- 
  26     Return typehint of method Drupal\phpunit_example\AddClass::add() has invalid type  
         Drupal\phpunit_example\numeric.                                                    
 ------ ----------------------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------------------------------------- 
  Line   phpunit_example/src/ProtectedPrivates.php                                                            
 ------ ----------------------------------------------------------------------------------------------------- 
  33     Return typehint of method Drupal\phpunit_example\ProtectedPrivates::protectedAdd() has invalid type  
         Drupal\phpunit_example\numeric.                                                                      
  52     Return typehint of method Drupal\phpunit_example\ProtectedPrivates::privateAdd() has invalid type    
         Drupal\phpunit_example\numeric.                                                                      
 ------ ----------------------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------- 
  Line   phpunit_example/tests/src/Unit/AddClassTest.php                                       
 ------ -------------------------------------------------------------------------------------- 
  114    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
 ------ -------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------- 
  Line   phpunit_example/tests/src/Unit/ProtectedPrivatesTest.php                              
 ------ -------------------------------------------------------------------------------------- 
  113    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
  143    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
 ------ -------------------------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------------- 
  Line   plugin_type_example/src/SandwichPluginManager.php                            
 ------ ----------------------------------------------------------------------------- 
  38     Plugin manager has cache backend specified but does not declare cache tags.  
 ------ ----------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------ 
  Line   stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php             
 ------ ------------------------------------------------------------------------------ 
  156    \Drupal calls should be avoided in classes, use dependency injection instead  
 ------ ------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------- 
  Line   stream_wrapper_example/tests/src/Kernel/StreamWrapperTest.php                  
 ------ ------------------------------------------------------------------------------- 
  49     Call to deprecated method validScheme() of class Drupal\Core\File\FileSystem:  
         in drupal:8.0.0 and will be removed before Drupal 9.0.0. Use                   
         Drupal\Core\StreamWrapper\StreamWrapperManagerInterface::isValidScheme()       
         instead.                                                                       
 ------ ------------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------------- 
  Line   testing_example/src/Tests/NaiveConversionTest.php                                
 ------ --------------------------------------------------------------------------------- 
  17     Class Drupal\testing_example\Tests\NaiveConversionTest extends deprecated class  
         Drupal\simpletest\WebTestBase:                                                   
         in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead,                
         use \Drupal\Tests\BrowserTestBase. See https://www.drupal.org/node/3030340.      
 ------ --------------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------------------------- 
  Line   testing_example/src/Tests/SimpleTestExampleMockModuleTest.php                                
 ------ --------------------------------------------------------------------------------------------- 
  32     Class Drupal\testing_example\Tests\SimpleTestExampleMockModuleTest extends deprecated class  
         Drupal\simpletest\WebTestBase:                                                               
         in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead,                            
         use \Drupal\Tests\BrowserTestBase. See https://www.drupal.org/node/3030340.                  
 ------ --------------------------------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------------------- 
  Line   testing_example/src/Tests/SimpleTestExampleTest.php                                
 ------ ----------------------------------------------------------------------------------- 
  31     Class Drupal\testing_example\Tests\SimpleTestExampleTest extends deprecated class  
         Drupal\simpletest\WebTestBase:                                                     
         in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead,                  
         use \Drupal\Tests\BrowserTestBase. See https://www.drupal.org/node/3030340.        
 ------ ----------------------------------------------------------------------------------- 

 [ERROR] Found 18 errors                                                                                              

I'm going to work on these failures on the DrupalCon Amsterdam 2019

  • valthebald committed 56eebb7 on 8.x-1.x
    Issue #3072416: Fix default cache tags for cache manager.
    
mradcliffe’s picture

Also remember to add core_version_requirement: ^8 || ^9 to all info.yml files.

Kristen Pol’s picture

Issue tags: +Drupal 9 compatibility

Per a Slack discussion with Gábor Hojtsy regarding usage of D9 tags (Drupal 9, Drupal 9 compatibility, Drupal 9 readiness, etc.), "Drupal 9 compatibility" should be used for contributed projects that need updating and "Drupal 9" was the old tag for D8 issues before the D9 branch was ready. Doing tag cleanup here based on that discussion.

karthik.arumugam’s picture

I have removed the deprecated functions and updated the respective replacement functions. Please review.

andypost’s picture

@karthik.arumugam please use child issues this meta supposed to coordinate other issues

+++ b/cache_example/src/Form/CacheExampleForm.php
@@ -114,7 +115,7 @@ class CacheExampleForm extends FormBase {
-      $files_count = count(file_scan_directory('core', '/.php/'));
+      $files_count = count(FileSystemInterface::scanDirectory('core', '/.php/'));

interface cat't have method implmentations

Kristen Pol’s picture

Status: Active » Needs work

Marked "Active" but looks like it should be "Needs work" based on last comment.

Kristen Pol’s picture

Status: Needs work » Active

Never mind, I misunderstood. Sorry for the noise.

jungle’s picture

Version: 8.x-1.x-dev » 3.x-dev
jungle’s picture

Issue summary: View changes

Updating IS

jungle’s picture

jungle’s picture

Status: Active » Fixed

Crediting everyone, and I think this was fixed. Thanks!

jungle’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.