| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class sfParameterHolderValidation extends sfValidation |
|---|
| 20 |
{ |
|---|
| 21 |
public function getHeader() |
|---|
| 22 |
{ |
|---|
| 23 |
return 'Checking usage of array notation with a parameter holder'; |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
public function getExplanation() |
|---|
| 27 |
{ |
|---|
| 28 |
return array( |
|---|
| 29 |
'', |
|---|
| 30 |
' The files above use the array notation with a parameter holder,', |
|---|
| 31 |
' which is not supported anymore in symfony 1.4.', |
|---|
| 32 |
' For instance, you need to change this construct:', |
|---|
| 33 |
'', |
|---|
| 34 |
' $foo = $request->getParameter(\'foo[bar]\')', |
|---|
| 35 |
'', |
|---|
| 36 |
' to this one:', |
|---|
| 37 |
'', |
|---|
| 38 |
' $params = $request->getParameter(\'foo\')', |
|---|
| 39 |
' $foo = $params[\'bar\'])', |
|---|
| 40 |
'', |
|---|
| 41 |
); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
public function validate() |
|---|
| 45 |
{ |
|---|
| 46 |
$found = array(); |
|---|
| 47 |
$files = sfFinder::type('file')->name('*.php')->prune('vendor')->in(array( |
|---|
| 48 |
sfConfig::get('sf_apps_dir'), |
|---|
| 49 |
sfConfig::get('sf_lib_dir'), |
|---|
| 50 |
sfConfig::get('sf_test_dir'), |
|---|
| 51 |
sfConfig::get('sf_plugins_dir'), |
|---|
| 52 |
)); |
|---|
| 53 |
foreach ($files as $file) |
|---|
| 54 |
{ |
|---|
| 55 |
$content = sfToolkit::stripComments(file_get_contents($file)); |
|---|
| 56 |
|
|---|
| 57 |
if (preg_match('#\b(get|has|remove)(Request)*Parameter\(\s*[\'"][^\),]*?\[[^\),]#', $content)) |
|---|
| 58 |
{ |
|---|
| 59 |
$found[$file] = true; |
|---|
| 60 |
} |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
return $found; |
|---|
| 64 |
} |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|