Skip to content

Commit 7780ee2

Browse files
authored
Merge pull request #83 from Crizz0/iss/80
Remove special rule set for help_ files
2 parents 6ce4273 + a2fb73f commit 7780ee2

File tree

2 files changed

+1
-145
lines changed

2 files changed

+1
-145
lines changed

src/Phpbb/TranslationValidator/Validator/FileValidator.php

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,6 @@ public function validate($sourceFile, $originFile)
248248
{
249249
$this->validateEmail($sourceFile, $originFile);
250250
}
251-
else if (strpos($originFile, $this->originLanguagePath . 'help_') === 0 && substr($originFile, -4) === '.php')
252-
{
253-
$this->validateHelpFile($sourceFile, $originFile);
254-
}
255251
else if (substr($originFile, -4) === '.php')
256252
{
257253
$this->validateLangFile($sourceFile, $originFile);
@@ -486,101 +482,7 @@ public function validateEmail($sourceFile, $originFile)
486482
$this->output->addMessage(Output::FATAL, 'Missing new line at the end of the file', $originFile);
487483
}
488484
}
489-
490-
/**
491-
* Validates a help_*.php file
492-
*
493-
* Files must only contain the variable $help.
494-
* This variable must be an array of arrays.
495-
* Subarrays must only have the indexes 0 and 1,
496-
* with 0 being the headline and 1 being the description.
497-
*
498-
* Files must contain an entry with 0 and 1 being '--',
499-
* causing the column break in the page.
500-
*
501-
* @todo Check for template vars and html
502-
* @todo Check for triple --- and other typos of it.
503-
*
504-
* @param string $sourceFile Source file for comparison
505-
* @param string $originFile File to validate
506-
* @return null
507-
*/
508-
public function validateHelpFile($sourceFile, $originFile)
509-
{
510-
$originFilePath = $this->originPath . '/' . $originFile;
511-
$sourceFilePath = $this->sourcePath . '/' . $sourceFile;
512-
513-
if (!$this->safeMode)
514-
{
515-
/** @var $help */
516-
include($originFilePath);
517-
518-
$defined_variables = get_defined_vars();
519-
if (sizeof($defined_variables) != 5 || !isset($defined_variables['help']) || gettype($defined_variables['help']) != 'array')
520-
{
521-
$this->output->addMessage(Output::FATAL, 'Should only contain the help-array', $originFile);
522-
return;
523-
}
524-
}
525-
526-
else
527-
{
528-
/** @var $help */
529-
$help = ValidatorRunner::langParser($originFilePath);
530-
$this->output->addMessage(Output::NOTICE, '<bg=yellow;options=bold>[Safe Mode]</> Manually run the translation validator to check help variables.', $originFile);
531-
}
532-
533-
$validate = $help;
534-
unset($help);
535-
536-
if (!$this->safeMode)
537-
{
538-
/** @var $help */
539-
include($sourceFilePath);
540-
}
541-
542-
else
543-
{
544-
/** @var $help */
545-
$help = ValidatorRunner::langParser($sourceFilePath);
546-
}
547-
548-
$against = $help;
549-
unset($help);
550-
551-
$column_breaks = 0;
552-
$entry = 0;
553-
foreach ($validate as $help)
554-
{
555-
if (gettype($help) != 'array' || sizeof($help) != 2 || !isset($help[0]) || !isset($help[1]))
556-
{
557-
$this->output->addMessage(Output::FATAL, 'Found invalid entry: ' . serialize($help), $originFile, $entry);
558-
}
559-
else if ($help[0] == '--' && $help[1] == '--')
560-
{
561-
$column_breaks++;
562-
}
563-
564-
if (isset($help[0]))
565-
{
566-
$compare = isset($against[$entry][0]) ? $against[$entry][0] : '';
567-
$this->langKeyValidator->validate($originFile, $entry . '.0', $compare, $help[0]);
568-
}
569-
570-
if (isset($help[1]))
571-
{
572-
$compare = isset($against[$entry][1]) ? $against[$entry][1] : '';
573-
$this->langKeyValidator->validate($originFile, $entry . '.1', $compare, $help[1]);
574-
}
575-
$entry++;
576-
}
577-
578-
if ($column_breaks != 1)
579-
{
580-
$this->output->addMessage(Output::FATAL, 'Must have exactly one column break entry', $originFile);
581-
}
582-
}
583-
485+
584486
/**
585487
* Validates the LICENSE file
586488
*

tests/FileValidator/ValidateHelpTest.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)