PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Group-I/jobeet/lib/vendor/symfony/lib/task/project/sfProjectValidateTask.class.php

https://bitbucket.org/hosseinzolfi/db-lab-spring-2011/
PHP | 102 lines | 61 code | 20 blank | 21 comment | 4 complexity | 7f3340709bccf19283dad83def832469 MD5 | raw file
Possible License(s): ISC, AGPL-3.0, LGPL-2.1, BSD-3-Clause, LGPL-3.0
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Finds deprecated usage in a project.
  11. *
  12. * @package symfony
  13. * @subpackage task
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfProjectValidateTask.class.php 24610 2009-11-30 22:07:34Z FabianLange $
  16. */
  17. class sfValidateTask extends sfBaseTask
  18. {
  19. /**
  20. * @see sfTask
  21. */
  22. protected function configure()
  23. {
  24. $this->namespace = 'project';
  25. $this->name = 'validate';
  26. $this->briefDescription = 'Finds deprecated usage in a project';
  27. $this->detailedDescription = <<<EOF
  28. The [project:validate|INFO] task detects deprecated usage in your project.
  29. [./symfony project:validate|INFO]
  30. The task lists all the files you need to change before switching to
  31. symfony 1.4.
  32. EOF;
  33. }
  34. /**
  35. * @see sfTask
  36. */
  37. protected function execute($arguments = array(), $options = array())
  38. {
  39. foreach ($this->getUpgradeClasses() as $i => $class)
  40. {
  41. $v = new $class($this->dispatcher, $this->formatter);
  42. $this->logBlock(($i + 1).'. '.$v->getHeader(), 'QUESTION_LARGE');
  43. $v->setCommandApplication($this->commandApplication);
  44. $v->setConfiguration($this->configuration);
  45. $files = $v->validate();
  46. if (!$files)
  47. {
  48. $this->log(' '.$this->formatter->format(' OK ', 'INFO'));
  49. continue;
  50. }
  51. $this->log(' '.$this->formatter->format(' '.count($files).' file(s) need to be changed. ', 'ERROR'));
  52. foreach ($files as $file => $value)
  53. {
  54. $this->log(' '.$this->formatter->format($this->formatFile($file), 'INFO'));
  55. if (true !== $value)
  56. {
  57. $this->log(' '.$value);
  58. }
  59. }
  60. $this->log($v->getExplanation());
  61. }
  62. }
  63. protected function formatFile($file)
  64. {
  65. return str_replace(realpath(sfConfig::get('sf_root_dir')), 'ROOT', realpath($file));
  66. }
  67. protected function getUpgradeClasses()
  68. {
  69. $baseDir = dirname(__FILE__).'/validation/';
  70. $classes = array();
  71. foreach (glob($baseDir.'*.class.php') as $file)
  72. {
  73. $class = str_replace(array($baseDir, '.class.php'), '', $file);
  74. if ('sfValidation' != $class)
  75. {
  76. $classes[] = $class;
  77. require_once $baseDir.$class.'.class.php';
  78. }
  79. }
  80. return $classes;
  81. }
  82. }