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 settings usage.
13
 *
14
 * @package    symfony
15
 * @subpackage task
16
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17
 * @version    SVN: $Id: sfDeprecatedSettingsValidation.class.php 25410 2009-12-15 15:19:07Z fabien $
18
 */
19
class sfDeprecatedSettingsValidation extends sfValidation
20
{
21
  public function getHeader()
22
  {
23
    return 'Checking usage of deprecated settings';
24
  }
25
 
26
  public function getExplanation()
27
  {
28
    return array(
29
          '',
30
          '  The files above use deprecated settings',
31
          '  that have been removed in symfony 1.4.',
32
          '',
33
          '  You can find a list of all deprecated settings under the',
34
          '  "Settings" 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
    $settings = array(
44
      'sf_check_symfony_version', 'sf_max_forwards', 'sf_lazy_cache_key', 'sf_strip_comments',
45
      'sf_lazy_routes_deserialize', 'sf_calendar_web_dir', 'sf_rich_text_js_dir', 'sf_validation_error_prefix',
46
      'sf_validation_error_suffix', 'sf_validation_error_class', 'sf_validation_error_id_prefix',
47
      '_is_internal', 'sf_doc_dir',
48
    );
49
 
50
    $found = array();
51
    $files = sfFinder::type('file')->name('*.php')->prune('vendor')->in(array(
52
      sfConfig::get('sf_apps_dir'),
53
      sfConfig::get('sf_lib_dir'),
54
      sfConfig::get('sf_test_dir'),
55
      sfConfig::get('sf_plugins_dir'),
56
    ));
57
    foreach ($files as $file)
58
    {
59
      $content = sfToolkit::stripComments(file_get_contents($file));
60
 
61
      $matches = array();
62
      foreach ($settings as $setting)
63
      {
64
        if (false !== stripos($content, $setting))
65
        {
66
          $matches[] = $setting;
67
        }
68
      }
69
 
70
      if ($matches)
71
      {
72
        $found[$file] = implode(', ', $matches);
73
      }
74
    }
75
 
76
    return $found;
77
  }
78
}