Development

/branches/1.4/lib/task/project/validation/sfDeprecatedClassesValidation.class.php

You must first sign up to be able to contribute.

root/branches/1.4/lib/task/project/validation/sfDeprecatedClassesValidation.class.php

Revision 25411, 3.3 kB (checked in by fabien, 4 years ago)

[1.2, 1.3, 1.4] changed project:validate task to generate less false positive (closes #7852)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * Finds deprecated classes usage.
13  *
14  * @package    symfony
15  * @subpackage task
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfDeprecatedClassesValidation extends sfValidation
20 {
21   public function getHeader()
22   {
23     return 'Checking usage of deprecated classes';
24   }
25
26   public function getExplanation()
27   {
28     return array(
29           '',
30           '  The files above use deprecated classes',
31           '  that have been removed in symfony 1.4.',
32           '',
33           '  You can find a list of all deprecated classes under the',
34           '  "Classes" section of the DEPRECATED tutorial:',
35           '',
36           '  http://www.symfony-project.org/tutorial/1_4/en/deprecated',
37           '',
38     );
39   }
40
41   public function validate()
42   {
43     $classes = array(
44       'sfDoctrineLogger', 'sfNoRouting', 'sfPathInfoRouting', 'sfRichTextEditor',
45       'sfRichTextEditorFCK', 'sfRichTextEditorTinyMCE', 'sfCrudGenerator', 'sfAdminGenerator',
46       'sfPropelCrudGenerator', 'sfPropelAdminGenerator', 'sfPropelUniqueValidator', 'sfDoctrineUniqueValidator',
47       'sfLoader', 'sfConsoleRequest', 'sfConsoleResponse', 'sfConsoleController',
48       'sfDoctrineDataRetriever', 'sfPropelDataRetriever',
49       'sfWidgetFormI18nSelectLanguage', 'sfWidgetFormI18nSelectCurrency', 'sfWidgetFormI18nSelectCountry',
50       'sfWidgetFormChoiceMany', 'sfWidgetFormPropelChoiceMany', 'sfWidgetFormDoctrineChoiceMany',
51       'sfValidatorChoiceMany', 'sfValidatorPropelChoiceMany', 'sfValidatorPropelDoctrineMany',
52       'SfExtensionObjectBuilder', 'SfExtensionPeerBuilder', 'SfMultiExtendObjectBuilder',
53       'SfNestedSetBuilder', 'SfNestedSetPeerBuilder', 'SfObjectBuilder', 'SfPeerBuilder',
54       'sfWidgetFormPropelSelect', 'sfWidgetFormPropelSelectMany',
55       'sfWidgetFormDoctrineSelect', 'sfWidgetFormDoctrineSelectMany',
56
57       // classes from sfCompat10Plugin
58       'sfEzComponentsBridge', 'sfZendFrameworkBridge', 'sfProcessCache', 'sfValidatorConfigHandler',
59       'sfActionException', 'sfValidatorException', 'sfFillInFormFilter', 'sfValidationExecutionFilter',
60       'sfRequestCompat10', 'sfFillInForm', 'sfCallbackValidator', 'sfCompareValidator', 'sfDateValidator',
61       'sfEmailValidator', 'sfFileValidator', 'sfNumberValidator', 'sfRegexValidator', 'sfStringValidator',
62       'sfUrlValidator', 'sfValidator', 'sfValidatorManager', 'sfMailView', 'sfMail',
63     );
64
65     $found = array();
66     $files = sfFinder::type('file')->name('*.php')->prune('vendor')->in(array(
67       sfConfig::get('sf_apps_dir'),
68       sfConfig::get('sf_lib_dir'),
69       sfConfig::get('sf_test_dir'),
70       sfConfig::get('sf_plugins_dir'),
71     ));
72     foreach ($files as $file)
73     {
74       $content = sfToolkit::stripComments(file_get_contents($file));
75
76       $matches = array();
77       foreach ($classes as $class)
78       {
79         if (preg_match('#\b'.preg_quote($class, '#').'\b#', $content))
80         {
81           $matches[] = $class;
82         }
83       }
84
85       if ($matches)
86       {
87         $found[$file] = implode(', ', $matches);
88       }
89     }
90
91     return $found;
92   }
93 }
94
Note: See TracBrowser for help on using the browser.