diff --git a/app/Console/Commands/ValidateXml.php b/app/Console/Commands/ValidateXml.php index 4b09a7e5f5..094f7963d5 100644 --- a/app/Console/Commands/ValidateXml.php +++ b/app/Console/Commands/ValidateXml.php @@ -2,9 +2,10 @@ namespace App\Console\Commands; +use App\Exceptions\BadSubmissionException; use App\Utils\SubmissionUtils; +use BadMethodCallException; use Illuminate\Console\Command; -use App\Exceptions\XMLValidationException; class ValidateXml extends Command { @@ -43,41 +44,32 @@ public function handle(): int $has_skipped = true; continue; } - try { $xml_info = SubmissionUtils::get_xml_type($xml_file_handle, $input_xml_file); - } catch (XMLValidationException $e) { - foreach ($e->getDecodedMessage() as $error) { - $this->error($error); - } + } catch (BadSubmissionException $e) { + $this->error($e->getMessage()); $has_errors = true; continue; } finally { fclose($xml_file_handle); } - $file = $xml_info['xml_type']; - - // If validation is enabled and if this file has a corresponding schema, validate it - if (null === $xml_info['xml_handler']::$schema_file) { - $this->warn("WARNING: Skipped input file '{$input_xml_file}' as validation" - ." of this file format is currently not supported. Validator was" - ."{$xml_info['xml_handler']::$schema_file}"); - $has_skipped = true; - continue; - } // run the validator and collect errors if there are any try { - $xml_info['xml_handler']::validate_xml($input_xml_file); - } catch (XMLValidationException $e) { - foreach ($e->getDecodedMessage() as $error) { - $this->error($error); + $errors = $xml_info['xml_handler']::validate($input_xml_file); + if (count($errors) > 0) { + foreach ($errors as $error) { + $this->error($error); + } + $has_errors = true; + } else { + $this->line("Validated file: {$input_xml_file}."); } - $has_errors = true; - continue; + } catch (BadMethodCallException $e) { + $this->warn("WARNING: Skipped input file '{$input_xml_file}' as validation" + ." of this file format is currently not supported."); + $has_skipped = true; } - - $this->line("Validated file: {$input_xml_file}."); } // finally, report the results diff --git a/app/Exceptions/BadSubmissionException.php b/app/Exceptions/BadSubmissionException.php new file mode 100644 index 0000000000..5ac8ac120d --- /dev/null +++ b/app/Exceptions/BadSubmissionException.php @@ -0,0 +1,9 @@ + $message - */ - public function __construct(array $message = [], int $code = 0, Exception $previous = null) - { - $encoded_msg = json_encode($message); - $encoded_msg = $encoded_msg === false ? "" : $encoded_msg; - parent::__construct($encoded_msg, $code, $previous); - } - - /** - * @return array - */ - public function getDecodedMessage(bool $assoc = false): array - { - $decoded_msg = json_decode($this->getMessage(), $assoc); - if (!isset($decoded_msg) || is_bool($decoded_msg)) { - $return_array = ["An XML validation error has occurred!"]; - } else { - // Is associative array - $return_array = $decoded_msg; - } - return $return_array; - } -} diff --git a/app/Http/Controllers/SubmissionController.php b/app/Http/Controllers/SubmissionController.php index 317ba2c7fc..640f653b55 100644 --- a/app/Http/Controllers/SubmissionController.php +++ b/app/Http/Controllers/SubmissionController.php @@ -2,12 +2,12 @@ namespace App\Http\Controllers; +use App\Exceptions\BadSubmissionException; use App\Jobs\ProcessSubmission; use App\Models\Site; use App\Utils\AuthTokenUtil; use App\Utils\UnparsedSubmissionProcessor; use App\Utils\SubmissionUtils; -use App\Exceptions\XMLValidationException; use CDash\Model\Build; use CDash\Model\PendingSubmissions; use CDash\Model\Project; @@ -56,8 +56,8 @@ public function submit(): Response|JsonResponse } /** - * @throws XMLValidationException - **/ + * @throws BadSubmissionException + */ private function submitProcess(): Response { @set_time_limit(0); @@ -136,35 +136,17 @@ private function submitProcess(): Response // Figure out what type of XML file this is. $stored_filename = "inbox/".$filename; - try { - $xml_info = SubmissionUtils::get_xml_type(fopen(Storage::path($stored_filename), 'r'), $stored_filename); - } catch (XMLValidationException $e) { - foreach ($e->getDecodedMessage() as $error) { - Log::error($error); - } - abort(Response::HTTP_NOT_FOUND, 'Unable to determine the Type of the submission file.'); - } - $filehandle = $xml_info['file_handle']; - $handler_ref = $xml_info['xml_handler']; - $file = $xml_info['xml_type']; + $xml_info = SubmissionUtils::get_xml_type(fopen(Storage::path($stored_filename), 'r'), $stored_filename); // If validation is enabled and if this file has a corresponding schema, validate it - - if (isset($handler_ref::$schema_file) && !file_exists(base_path().$handler_ref::$schema_file)) { - throw new XMLValidationException(["ERROR: Could not find schema file '{$handler_ref::$schema_file}'" - ." to validate input file: '{$filename}'"]); - } else { - try { - $handler_ref::validate_xml(storage_path("app/".$stored_filename)); - } catch (XMLValidationException $e) { - $errorlist = ''; - foreach ($e->getDecodedMessage() as $error) { - Log::error("Validating $filename: ".$error); - $errorlist = $errorlist."\n\r".$error; - } - if ((bool) config('cdash.validate_xml_submissions') === true) { - abort(400, "Xml validation failed: rejected file $filename: $errorlist"); - } + $validation_errors = $xml_info['xml_handler']::validate(storage_path("app/" . $stored_filename)); + if (count($validation_errors) > 0) { + $error_string = implode(PHP_EOL, $validation_errors); + + // We always log validation failures, but we only send messages back to the client if configured to do so + Log::warning("Submission validation failed for file '$filename':" . PHP_EOL); + if ((bool) config('cdash.validate_xml_submissions') === true) { + abort(400, "XML validation failed: rejected file $filename:" . PHP_EOL . $error_string); } } diff --git a/app/Jobs/ProcessSubmission.php b/app/Jobs/ProcessSubmission.php index b42c27421d..f488404973 100644 --- a/app/Jobs/ProcessSubmission.php +++ b/app/Jobs/ProcessSubmission.php @@ -4,12 +4,11 @@ use AbstractSubmissionHandler; use ActionableBuildInterface; -use App\Exceptions\XMLValidationException; +use App\Exceptions\BadSubmissionException; use App\Utils\UnparsedSubmissionProcessor; use App\Models\SuccessfulJob; use BuildPropertiesJSONHandler; -use CDash\Model\Build; use CDash\Model\PendingSubmissions; use CDash\Model\Repository; @@ -124,7 +123,7 @@ private function requeueSubmissionFile($buildid): bool * Execute the job. * * @return void - * @throws XMLValidationException + * @throws BadSubmissionException */ public function handle() { @@ -187,7 +186,7 @@ public function failed(\Throwable $exception): void * This method could be running on a worker that is either remote or local, so it accepts * a file handle or a filename that it can query the CDash API for. * - * @throws XMLValidationException + * @throws BadSubmissionException **/ private function doSubmit($filename, $projectid, $buildid = null, $expected_md5 = ''): AbstractSubmissionHandler|UnparsedSubmissionProcessor|false { diff --git a/app/Utils/SubmissionUtils.php b/app/Utils/SubmissionUtils.php index d7b2a1f17c..c2a37ba600 100644 --- a/app/Utils/SubmissionUtils.php +++ b/app/Utils/SubmissionUtils.php @@ -4,17 +4,21 @@ namespace App\Utils; +use App\Exceptions\BadSubmissionException; use CDash\Database; use CDash\Model\Build; use CDash\Model\BuildUpdate; -use App\Exceptions\XMLValidationException; class SubmissionUtils { /** * Figure out what type of XML file this is - * @return array - * @throws XMLValidationException + * @return array{ + * file_handle: mixed, + * xml_handler: 'BuildHandler'|'ConfigureHandler'|'CoverageHandler'|'CoverageJUnitHandler'|'CoverageLogHandler'|'DoneHandler'|'DynamicAnalysisHandler'|'NoteHandler'|'ProjectHandler'|'TestingHandler'|'TestingJUnitHandler'|'UpdateHandler'|'UploadHandler', + * xml_type: 'Build'|'Configure'|'Coverage'|'CoverageJUnit'|'CoverageLog'|'Done'|'DynamicAnalysis'|'Notes'|'Project'|'Test'|'TestJUnit'|'Update'|'Upload', + * } + * @throws BadSubmissionException */ public static function get_xml_type(mixed $filehandle, string $xml_file): array { @@ -75,9 +79,8 @@ public static function get_xml_type(mixed $filehandle, string $xml_file): array rewind($filehandle); // perform minimal error checking as a sanity check - if ($file === '') { - throw new XMLValidationException(["ERROR: Could not determine submission" - ." file type for: '{$xml_file}'"]); + if ($file === '' || $handler === null) { + throw new BadSubmissionException("Could not determine submission file type for: '{$xml_file}'"); } return [ diff --git a/app/cdash/include/ctestparser.php b/app/cdash/include/ctestparser.php index c0db2e77a2..197db4ed0a 100644 --- a/app/cdash/include/ctestparser.php +++ b/app/cdash/include/ctestparser.php @@ -14,6 +14,7 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ +use App\Exceptions\BadSubmissionException; use CDash\Database; use App\Models\BuildFile; use App\Utils\SubmissionUtils; @@ -154,10 +155,11 @@ function parse_put_submission($filehandler, $projectid, $expected_md5, int|null return $handler; } -/** Main function to parse the incoming xml from ctest */ /** - * @throws App\Exceptions\XMLValidationException - **/ + * Main function to parse the incoming xml from ctest + * + * @throws BadSubmissionException + */ function ctest_parse($filehandle, string $filename, $projectid, $expected_md5 = '', int|null $buildid=null): AbstractSubmissionHandler|false { // Check if this is a new style PUT submission. diff --git a/app/cdash/tests/test_submissionvalidation.php b/app/cdash/tests/test_submissionvalidation.php index b0926a8e67..32950be015 100644 --- a/app/cdash/tests/test_submissionvalidation.php +++ b/app/cdash/tests/test_submissionvalidation.php @@ -1,6 +1,5 @@ Original = file_get_contents($this->ConfigFile); file_put_contents($this->ConfigFile, "VALIDATE_XML_SUBMISSIONS=true\n", FILE_APPEND | LOCK_EX); - $this->assertFalse($this->submit("invalid_Configure.xml"), "Submission of invalid_syntax_Build.xml was succeessful when it should have failed."); - $this->assertFalse($this->submit("invalid_syntax_Build.xml"), "Submission of invalid_syntax_Build.xml was succeessful when it should have failed."); + $this->assertFalse($this->submit("invalid_Configure.xml"), "Submission of invalid_syntax_Build.xml was successful when it should have failed."); + $this->assertFalse($this->submit("invalid_syntax_Build.xml"), "Submission of invalid_syntax_Build.xml was successful when it should have failed."); $this->assertTrue($this->submit("valid_Build.xml"), "Submission of valid_Build.xml was not successful when it should have passed."); file_put_contents($this->ConfigFile, $this->Original); diff --git a/app/cdash/xml_handlers/abstract_submission_handler.php b/app/cdash/xml_handlers/abstract_submission_handler.php index d5d1cfa072..690fa50ef3 100644 --- a/app/cdash/xml_handlers/abstract_submission_handler.php +++ b/app/cdash/xml_handlers/abstract_submission_handler.php @@ -32,4 +32,17 @@ public function getBuild(): Build { return $this->Build; } + + /** + * Accepts an absolute path to an input submission file. + * + * Returns an array of validation messages (if applicable). An empty return array indicates + * that validation was successful. Returns an empty array if no validation was defined. + * + * @return array + */ + public static function validate(string $path): array + { + return []; + } } diff --git a/app/cdash/xml_handlers/abstract_xml_handler.php b/app/cdash/xml_handlers/abstract_xml_handler.php index 7ebbd4d841..446a4cae49 100644 --- a/app/cdash/xml_handlers/abstract_xml_handler.php +++ b/app/cdash/xml_handlers/abstract_xml_handler.php @@ -18,7 +18,6 @@ use App\Utils\Stack; use CDash\Model\Build; use CDash\Model\Project; -use App\Exceptions\XMLValidationException; abstract class AbstractXmlHandler extends AbstractSubmissionHandler { @@ -29,6 +28,8 @@ abstract class AbstractXmlHandler extends AbstractSubmissionHandler private $ModelFactory; + protected static ?string $schema_file = null; + public function __construct(Build|Project $init) { parent::__construct($init); @@ -39,10 +40,15 @@ public function __construct(Build|Project $init) /** * Validate the given XML file based on its type - * @throws XMLValidationException + * + * @return array */ - public static function validate_xml(string $xml_file): void + public static function validate(string $path): array { + if (static::$schema_file === null) { + return []; + } + $errors = []; // let us control the failures so we can continue // parsing files instead of crashing midway @@ -50,23 +56,20 @@ public static function validate_xml(string $xml_file): void // load the input file to be validated $xml = new DOMDocument(); - $xml->load($xml_file, LIBXML_PARSEHUGE); + $xml->load($path, LIBXML_PARSEHUGE); - // run the validator and collect errors if there are any - // schema_file is defined in each child class - if (!$xml->schemaValidate(base_path().static::$schema_file)) { + // run the validator and collect errors if there are any. + if (!$xml->schemaValidate(base_path(static::$schema_file))) { $validation_errors = libxml_get_errors(); foreach ($validation_errors as $error) { if ($error->level === LIBXML_ERR_ERROR || $error->level === LIBXML_ERR_FATAL) { - $errors[] = "ERROR: {$error->message} in {$error->file}," - ." line: {$error->line}, column: {$error->column}"; + $errors[] = "ERROR: {$error->message} in {$error->file}, line: {$error->line}, column: {$error->column}"; } } libxml_clear_errors(); } - if (count($errors) !== 0) { - throw new XMLValidationException($errors); - } + + return $errors; } diff --git a/app/cdash/xml_handlers/build_handler.php b/app/cdash/xml_handlers/build_handler.php index 25d0ac2e4d..dee307002c 100644 --- a/app/cdash/xml_handlers/build_handler.php +++ b/app/cdash/xml_handlers/build_handler.php @@ -55,7 +55,7 @@ class BuildHandler extends AbstractXmlHandler implements ActionableBuildInterfac private $Generator; private $PullRequest; private $BuildErrorFilter; - public static string $schema_file = "/app/Validators/Schemas/Build.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Build.xsd'; public function __construct(Project $project) { diff --git a/app/cdash/xml_handlers/configure_handler.php b/app/cdash/xml_handlers/configure_handler.php index 21b35414fc..eecf3b5f6f 100644 --- a/app/cdash/xml_handlers/configure_handler.php +++ b/app/cdash/xml_handlers/configure_handler.php @@ -46,7 +46,7 @@ class ConfigureHandler extends AbstractXmlHandler implements ActionableBuildInte private $BuildStamp; private $Generator; private $PullRequest; - public static string $schema_file = "/app/Validators/Schemas/Configure.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Configure.xsd'; public function __construct(Project $project) { diff --git a/app/cdash/xml_handlers/coverage_handler.php b/app/cdash/xml_handlers/coverage_handler.php index 7063e92f31..8f8614efc0 100644 --- a/app/cdash/xml_handlers/coverage_handler.php +++ b/app/cdash/xml_handlers/coverage_handler.php @@ -35,7 +35,7 @@ class CoverageHandler extends AbstractXmlHandler private $CoverageFile; private $CoverageSummaries; private $Label; - public static string $schema_file = "/app/Validators/Schemas/Coverage.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Coverage.xsd'; /** Constructor */ public function __construct(Project $project) diff --git a/app/cdash/xml_handlers/coverage_log_handler.php b/app/cdash/xml_handlers/coverage_log_handler.php index fc4165036e..b8c5caa4cd 100644 --- a/app/cdash/xml_handlers/coverage_log_handler.php +++ b/app/cdash/xml_handlers/coverage_log_handler.php @@ -34,7 +34,7 @@ class CoverageLogHandler extends AbstractXmlHandler private $UpdateEndTime; private $CurrentLine; - public static string $schema_file = "/app/Validators/Schemas/CoverageLog.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/CoverageLog.xsd'; /** Constructor */ public function __construct(Project $project) { diff --git a/app/cdash/xml_handlers/done_handler.php b/app/cdash/xml_handlers/done_handler.php index e3192d7621..e303bbfff6 100644 --- a/app/cdash/xml_handlers/done_handler.php +++ b/app/cdash/xml_handlers/done_handler.php @@ -26,7 +26,7 @@ class DoneHandler extends AbstractXmlHandler private $PendingSubmissions; private $Requeue; public $backupFileName; - public static string $schema_file = "/app/Validators/Schemas/Done.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Done.xsd'; public function __construct(Project $project) { diff --git a/app/cdash/xml_handlers/dynamic_analysis_handler.php b/app/cdash/xml_handlers/dynamic_analysis_handler.php index d5bfb4e252..2982d6b27e 100644 --- a/app/cdash/xml_handlers/dynamic_analysis_handler.php +++ b/app/cdash/xml_handlers/dynamic_analysis_handler.php @@ -46,7 +46,8 @@ class DynamicAnalysisHandler extends AbstractXmlHandler implements ActionableBui private $Builds; private array $BuildInformation; - public static string $schema_file = "/app/Validators/Schemas/DynamicAnalysis.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/DynamicAnalysis.xsd'; + // Map SubProjects to Labels private $SubProjects; private $TestSubProjectName; diff --git a/app/cdash/xml_handlers/note_handler.php b/app/cdash/xml_handlers/note_handler.php index ae9cc0d195..abcebfe5c6 100644 --- a/app/cdash/xml_handlers/note_handler.php +++ b/app/cdash/xml_handlers/note_handler.php @@ -25,7 +25,7 @@ class NoteHandler extends AbstractXmlHandler { private $AdjustStartTime; private $NoteCreator; - public static string $schema_file = "/app/Validators/Schemas/Notes.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Notes.xsd'; /** Constructor */ public function __construct(Project $project) diff --git a/app/cdash/xml_handlers/project_handler.php b/app/cdash/xml_handlers/project_handler.php index a100863ec4..448144a89c 100644 --- a/app/cdash/xml_handlers/project_handler.php +++ b/app/cdash/xml_handlers/project_handler.php @@ -31,7 +31,7 @@ class ProjectHandler extends AbstractXmlHandler private $CurrentDependencies; // The dependencies of the current SubProject. private $Emails; // Email addresses associated with the current SubProject. private $ProjectNameMatches; - public static string $schema_file = "/app/Validators/Schemas/Project.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Project.xsd'; /** Constructor */ public function __construct(Project $project) diff --git a/app/cdash/xml_handlers/testing_handler.php b/app/cdash/xml_handlers/testing_handler.php index e28a90583d..27327a8b7a 100644 --- a/app/cdash/xml_handlers/testing_handler.php +++ b/app/cdash/xml_handlers/testing_handler.php @@ -26,7 +26,7 @@ class TestingHandler extends AbstractXmlHandler implements ActionableBuildInterf { use CommitAuthorHandlerTrait; - public static string $schema_file = "/app/Validators/Schemas/Test.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Test.xsd'; private $StartTimeStamp; private $EndTimeStamp; diff --git a/app/cdash/xml_handlers/update_handler.php b/app/cdash/xml_handlers/update_handler.php index 320f8b0c0d..5ec583fdc1 100644 --- a/app/cdash/xml_handlers/update_handler.php +++ b/app/cdash/xml_handlers/update_handler.php @@ -40,7 +40,7 @@ class UpdateHandler extends AbstractXmlHandler implements ActionableBuildInterfa private $EndTimeStamp; private $Update; private $UpdateFile; - public static string $schema_file = "/app/Validators/Schemas/Update.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Update.xsd'; /** Constructor */ public function __construct(Project $project) diff --git a/app/cdash/xml_handlers/upload_handler.php b/app/cdash/xml_handlers/upload_handler.php index 5eaed79729..de9eb813d2 100644 --- a/app/cdash/xml_handlers/upload_handler.php +++ b/app/cdash/xml_handlers/upload_handler.php @@ -50,7 +50,7 @@ class UploadHandler extends AbstractXmlHandler private $Label; private int $Timestamp; private bool $BuildInitialized; - public static string $schema_file = "/app/Validators/Schemas/Upload.xsd"; + protected static ?string $schema_file = '/app/Validators/Schemas/Upload.xsd'; /** If True, means an error happened while processing the file */ private $UploadError; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 96dad6c195..5d7e2d3224 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -176,27 +176,11 @@ parameters: count: 1 path: app/Console/Commands/UpdateDependencies.php - - - message: "#^Cannot access static property \\$schema_file on mixed\\.$#" - count: 2 - path: app/Console/Commands/ValidateXml.php - - - - message: "#^Cannot call static method validate_xml\\(\\) on mixed\\.$#" - count: 1 - path: app/Console/Commands/ValidateXml.php - - message: "#^Parameter \\#1 \\$path of function app_path expects string, bool\\|string given\\.$#" count: 1 path: app/Console/Kernel.php - - - message: "#^Method App\\\\Exceptions\\\\XMLValidationException\\:\\:getDecodedMessage\\(\\) should return array\\ but returns mixed\\.$#" - - count: 1 - path: app/Exceptions/XMLValidationException.php - - message: "#^PHPDoc type array of property App\\\\Exceptions\\\\Handler\\:\\:\\$dontFlash is not the same as PHPDoc type array\\ of overridden property Illuminate\\\\Foundation\\\\Exceptions\\\\Handler\\:\\:\\$dontFlash\\.$#" count: 1 @@ -2751,16 +2735,6 @@ parameters: count: 3 path: app/Http/Controllers/SubmissionController.php - - - message: "#^Cannot access static property \\$schema_file on mixed\\.$#" - count: 1 - path: app/Http/Controllers/SubmissionController.php - - - - message: "#^Cannot call static method validate_xml\\(\\) on mixed\\.$#" - count: 1 - path: app/Http/Controllers/SubmissionController.php - - message: "#^Loose comparison via \"\\!\\=\" is not allowed\\.$#" count: 1 @@ -14093,7 +14067,7 @@ parameters: path: app/cdash/include/ctestparser.php - - message: "#^Access to an undefined property object\\:\\:\\$backupFileName\\.$#" + message: "#^Access to an undefined property BuildHandler\\|ConfigureHandler\\|CoverageHandler\\|CoverageJUnitHandler\\|CoverageLogHandler\\|DoneHandler\\|DynamicAnalysisHandler\\|NoteHandler\\|ProjectHandler\\|TestingHandler\\|TestingJUnitHandler\\|UpdateHandler\\|UploadHandler\\:\\:\\$backupFileName\\.$#" count: 1 path: app/cdash/include/ctestparser.php @@ -14107,36 +14081,11 @@ parameters: count: 2 path: app/cdash/include/ctestparser.php - - - message: "#^Binary operation \"\\.\" between mixed and '\\.xml' results in an error\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - message: "#^Binary operation \"\\.\" between non\\-falsy\\-string and \\(list\\\\|string\\|null\\) results in an error\\.$#" count: 2 path: app/cdash/include/ctestparser.php - - - message: "#^Call to an undefined method object\\:\\:getBuildName\\(\\)\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - - - message: "#^Call to an undefined method object\\:\\:getBuildStamp\\(\\)\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - - - message: "#^Call to an undefined method object\\:\\:getSiteName\\(\\)\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - - - message: "#^Call to an undefined method object\\:\\:getSubProjectName\\(\\)\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - message: """ #^Call to deprecated function add_log\\(\\)\\: @@ -14181,11 +14130,6 @@ parameters: count: 1 path: app/cdash/include/ctestparser.php - - - message: "#^Function ctest_parse\\(\\) should return AbstractSubmissionHandler\\|false but returns object\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - message: "#^Function generateBackupFileName\\(\\) has no return type specified\\.$#" count: 1 @@ -14276,21 +14220,6 @@ parameters: count: 2 path: app/cdash/include/ctestparser.php - - - message: "#^Parameter \\#2 \\$handler of function xml_set_character_data_handler expects callable\\(\\)\\: mixed, array\\{object, 'text'\\} given\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - - - message: "#^Parameter \\#2 \\$start_handler of function xml_set_element_handler expects callable\\(\\)\\: mixed, array\\{object, 'startElement'\\} given\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - - - message: "#^Parameter \\#3 \\$end_handler of function xml_set_element_handler expects callable\\(\\)\\: mixed, array\\{object, 'endElement'\\} given\\.$#" - count: 1 - path: app/cdash/include/ctestparser.php - - message: "#^Argument of an invalid type array\\|false supplied for foreach, only iterables are supported\\.$#" count: 6 @@ -27028,11 +26957,6 @@ parameters: count: 1 path: app/cdash/tests/test_submission_assign_buildid.php - - - message: "#^Method SubmissionValidationTestCase\\:\\:testSubmissionValidation\\(\\) has App\\\\Exceptions\\\\XMLValidationException in PHPDoc @throws tag but it's not thrown\\.$#" - count: 1 - path: app/cdash/tests/test_submissionvalidation.php - - message: """ #^Call to deprecated method submission\\(\\) of class KWWebTestCase\\: @@ -30118,11 +30042,6 @@ parameters: count: 1 path: app/cdash/xml_handlers/SubProjectDirectories_handler.php - - - message: "#^Access to an undefined static property static\\(AbstractXmlHandler\\)\\:\\:\\$schema_file\\.$#" - count: 1 - path: app/cdash/xml_handlers/abstract_xml_handler.php - - message: "#^Class AbstractXmlHandler has an uninitialized property \\$Site\\. Give it default value or assign it in the constructor\\.$#" count: 1 @@ -32982,11 +32901,6 @@ parameters: count: 1 path: tests/Feature/UserCommand.php - - - message: "#^Part \\$file \\(mixed\\) of encapsed string cannot be cast to string\\.$#" - count: 1 - path: tests/Unit/app/Console/Command/ValidateXmlCommandTest.php - - message: "#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\\\|T of object, array\\\\|string given\\.$#" count: 1 diff --git a/tests/Unit/app/Console/Command/ValidateXmlCommandTest.php b/tests/Unit/app/Console/Command/ValidateXmlCommandTest.php index e849d796ef..8f7d3a0010 100644 --- a/tests/Unit/app/Console/Command/ValidateXmlCommandTest.php +++ b/tests/Unit/app/Console/Command/ValidateXmlCommandTest.php @@ -16,11 +16,11 @@ class ValidateXmlCommandTest extends TestCase * * @return array> */ - private function formatCommandParams() + private function formatCommandParams(string ...$files) { - $data_dir = base_path()."/tests/data/XmlValidation"; + $data_dir = base_path('/tests/data/XmlValidation'); $file_paths = []; - foreach (func_get_args() as $file) { + foreach ($files as $file) { $file_paths[] = "{$data_dir}/{$file}"; } return [