Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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 methods usage.
13
 *
14
 * @package    symfony
15
 * @subpackage task
16
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17
 * @version    SVN: $Id: sfDeprecatedMethodsValidation.class.php 25411 2009-12-15 15:31:29Z fabien $
18
 */
19
class sfDeprecatedMethodsValidation extends sfValidation
20
{
21
  public function getHeader()
22
  {
23
    return 'Checking usage of deprecated methods';
24
  }
25
 
26
  public function getExplanation()
27
  {
28
    return array(
29
          '',
30
          '  The files above use deprecated functions and/or methods',
31
          '  that have been removed in symfony 1.4.',
32
          '',
33
          '  You can find a list of all deprecated methods under the',
34
          '  "Methods and Functions" 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
    $found = array_merge(
44
      $this->doValidate(array(
45
        'sfToolkit::getTmpDir',
46
        'sfToolkit::removeArrayValueForPath',
47
        'sfToolkit::hasArrayValueForPath',
48
        'sfToolkit::getArrayValueForPathByRef',
49
        'sfValidatorBase::setInvalidMessage',
50
        'sfValidatorBase::setRequiredMessage',
51
        'debug_message',
52
        'sfContext::retrieveObjects',
53
        'getXDebugStack',
54
        'checkSymfonyVersion',
55
        'sh',
56
      ), array(
57
        sfConfig::get('sf_apps_dir'),
58
        sfConfig::get('sf_lib_dir'),
59
        sfConfig::get('sf_test_dir'),
60
        sfConfig::get('sf_plugins_dir'),
61
      )),
62
 
63
      $this->doValidate(array(
64
        'contains', 'responseContains', 'isRequestParameter', 'isResponseHeader',
65
        'isUserCulture', 'isRequestFormat', 'checkResponseElement',
66
      ), sfConfig::get('sf_test_dir')),
67
 
68
      $this->doValidate(array(
69
        'getDefaultView', 'handleError', 'validate', 'debugMessage', 'getController()->sendEmail'
70
      ), $this->getProjectActionDirectories())
71
    );
72
 
73
    return $found;
74
  }
75
 
76
  public function doValidate($methods, $dir)
77
  {
78
    $found = array();
79
    $files = sfFinder::type('file')->name('*.php')->prune('vendor')->in($dir);
80
    foreach ($files as $file)
81
    {
82
      $content = sfToolkit::stripComments(file_get_contents($file));
83
 
84
      $matches = array();
85
      foreach ($methods as $method)
86
      {
87
        if (preg_match('#\b'.preg_quote($method, '#').'\b#', $content))
88
        {
89
          $matches[] = $method;
90
        }
91
      }
92
 
93
      if ($matches)
94
      {
95
        $found[$file] = implode(', ', $matches);
96
      }
97
    }
98
 
99
    return $found;
100
  }
101
}