Skip to content

Commit 155e8a9

Browse files
committed
Add format fixes
1 parent 0c4cb77 commit 155e8a9

File tree

1 file changed

+10
-15
lines changed
  • app/code/Magento/Developer/Model/XmlCatalog/Format

1 file changed

+10
-15
lines changed

app/code/Magento/Developer/Model/XmlCatalog/Format/VsCode.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare (strict_types = 1);
67

78
namespace Magento\Developer\Model\XmlCatalog\Format;
89

9-
use Magento\Framework\App\ObjectManager;
1010
use Magento\Framework\DomDocument\DomDocumentFactory;
1111
use Magento\Framework\Exception\FileSystemException;
1212
use Magento\Framework\Filesystem\Directory\ReadFactory;
1313
use Magento\Framework\Filesystem\Directory\ReadInterface;
14+
use Magento\Framework\Filesystem\DriverPool;
1415
use Magento\Framework\Filesystem\File\WriteFactory;
1516

1617
/**
@@ -19,6 +20,8 @@
1920
class VsCode implements FormatInterface
2021
{
2122
private const PROJECT_PATH_IDENTIFIER = '..';
23+
private const FILE_MODE_READ = 'r';
24+
private const FILE_MODE_WRITE = 'w';
2225

2326
/**
2427
* @var ReadInterface
@@ -47,26 +50,22 @@ public function __construct(
4750
) {
4851
$this->currentDirRead = $readFactory->create(getcwd());
4952
$this->fileWriteFactory = $fileWriteFactory;
50-
$this->domDocumentFactory = $domDocumentFactory ?: ObjectManager::getInstance()->get(DomDocumentFactory::class);
53+
$this->domDocumentFactory = $domDocumentFactory;
5154
}
5255

5356
/**
5457
* Generate Catalog of URNs for the VsCode
5558
*
5659
* @param string[] $dictionary
57-
* @param string $configFilePath relative path to the PhpStorm misc.xml
60+
* @param string $configFile relative path to the VsCode catalog.xml
5861
* @return void
5962
*/
60-
public function generateCatalog(array $dictionary, $configFilePath)
63+
public function generateCatalog(array $dictionary, $configFile): void
6164
{
6265
$catalogNode = null;
6366

6467
try {
65-
$file = $this->fileWriteFactory->create(
66-
$configFilePath,
67-
\Magento\Framework\Filesystem\DriverPool::FILE,
68-
'r'
69-
);
68+
$file = $this->fileWriteFactory->create($configFile, DriverPool::FILE, self::FILE_MODE_READ);
7069
$dom = $this->domDocumentFactory->create();
7170
$fileContent = $file->readAll();
7271
if (!empty($fileContent)) {
@@ -91,11 +90,7 @@ public function generateCatalog(array $dictionary, $configFilePath)
9190
$catalogNode->appendChild($node);
9291
}
9392
$dom->formatOutput = true;
94-
$file = $this->fileWriteFactory->create(
95-
$configFilePath,
96-
\Magento\Framework\Filesystem\DriverPool::FILE,
97-
'w'
98-
);
93+
$file = $this->fileWriteFactory->create($configFile, DriverPool::FILE, self::FILE_MODE_WRITE);
9994
$file->write($dom->saveXML());
10095
$file->close();
10196
}
@@ -106,7 +101,7 @@ public function generateCatalog(array $dictionary, $configFilePath)
106101
* @param \DOMDocument $dom
107102
* @return \DOMElement
108103
*/
109-
private function initEmptyFile(\DOMDocument $dom)
104+
private function initEmptyFile(\DOMDocument $dom): \DOMElement
110105
{
111106
$catalogNode = $dom->createElement('catalog');
112107

0 commit comments

Comments
 (0)