1 | <?php |
||
21 | class ArtifactAttachmentXMLLinker implements ArtifactAttachmentXMLExporter { |
||
22 | |||
23 | /** @var ArtifactXMLNodeHelper */ |
||
24 | private $node_helper; |
||
25 | |||
26 | /** @var ArtifactXMLExporterDao */ |
||
27 | private $dao; |
||
28 | |||
29 | public function __construct(ArtifactXMLNodeHelper $node_helper, ArtifactXMLExporterDao $dao) { |
||
33 | |||
34 | public function addFilesToArtifact(DOMElement $artifact_node, $artifact_type_id, $artifact_id) { |
||
35 | $dar = $this->dao->searchFilesForArtifact($artifact_id); |
||
36 | foreach($dar as $row) { |
||
|
|||
37 | $xml_file_id = ArtifactAttachmentFieldXMLExporter::XML_FILE_PREFIX.$row['id']; |
||
38 | |||
39 | $file = $this->node_helper->createElement('file'); |
||
40 | $file->setAttribute('id', $xml_file_id); |
||
41 | $file->appendChild($this->node_helper->getNodeWithValue('filename', $row['filename'])); |
||
42 | $file->appendChild($this->node_helper->getNodeWithValue('path', $this->getPathRelativeToTv3RootPath($artifact_type_id, $row['id']))); |
||
43 | $file->appendChild($this->node_helper->getNodeWithValue('filesize', $row['filesize'])); |
||
44 | $file->appendChild($this->node_helper->getNodeWithValue('filetype', $row['filetype'])); |
||
45 | $file->appendChild($this->node_helper->getNodeWithValue('description', $row['description'])); |
||
46 | $artifact_node->appendChild($file); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | private function getPathRelativeToTv3RootPath($artifact_type_id, $attachment_id) { |
||
51 | $full_path = $this->getFilePathOnServer($artifact_type_id, $attachment_id); |
||
52 | |||
53 | return dirname($full_path) . DIRECTORY_SEPARATOR . basename($full_path); |
||
54 | } |
||
55 | |||
56 | private function getFilePathOnServer($artifact_type_id, $attachment_id) { |
||
59 | } |
||
60 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.