Automated native_function_invocation fixes
This commit is contained in:
1 parent
94b654175c
commit
eb88bb4c3a
62 files changed
+237
-237
No files matched your search
@@ -43,8 +43,8 @@ class BorderHelper
|
||||
{
|
||||
$borderStyle = self::getBorderStyle($borderPart);
|
||||
|
||||
$colorEl = $borderPart->getColor() ? sprintf('<color rgb="%s"/>', $borderPart->getColor()) : '';
|
||||
$partEl = sprintf(
|
||||
$colorEl = $borderPart->getColor() ? \sprintf('<color rgb="%s"/>', $borderPart->getColor()) : '';
|
||||
$partEl = \sprintf(
|
||||
'<%s style="%s">%s</%s>',
|
||||
$borderPart->getName(),
|
||||
$borderStyle,
|
||||
|
||||
@@ -112,7 +112,7 @@ class FileSystemHelper extends \Box\Spout\Common\Helper\FileSystemHelper impleme
|
||||
*/
|
||||
private function createRootFolder()
|
||||
{
|
||||
$this->rootFolder = $this->createFolder($this->baseFolderRealPath, uniqid('xlsx', true));
|
||||
$this->rootFolder = $this->createFolder($this->baseFolderRealPath, \uniqid('xlsx', true));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class OptionsManager extends OptionsManagerAbstract
|
||||
->setFontName(self::DEFAULT_FONT_NAME)
|
||||
->build();
|
||||
|
||||
$this->setOption(Options::TEMP_FOLDER, sys_get_temp_dir());
|
||||
$this->setOption(Options::TEMP_FOLDER, \sys_get_temp_dir());
|
||||
$this->setOption(Options::DEFAULT_ROW_STYLE, $defaultRowStyle);
|
||||
$this->setOption(Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY, true);
|
||||
$this->setOption(Options::SHOULD_USE_INLINE_STRINGS, true);
|
||||
|
||||
@@ -40,13 +40,13 @@ EOD;
|
||||
public function __construct($xlFolder, $stringsEscaper)
|
||||
{
|
||||
$sharedStringsFilePath = $xlFolder . '/' . self::SHARED_STRINGS_FILE_NAME;
|
||||
$this->sharedStringsFilePointer = fopen($sharedStringsFilePath, 'w');
|
||||
$this->sharedStringsFilePointer = \fopen($sharedStringsFilePath, 'w');
|
||||
|
||||
$this->throwIfSharedStringsFilePointerIsNotAvailable();
|
||||
|
||||
// the headers is split into different parts so that we can fseek and put in the correct count and uniqueCount later
|
||||
$header = self::SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER . ' ' . self::DEFAULT_STRINGS_COUNT_PART . '>';
|
||||
fwrite($this->sharedStringsFilePointer, $header);
|
||||
\fwrite($this->sharedStringsFilePointer, $header);
|
||||
|
||||
$this->stringsEscaper = $stringsEscaper;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ EOD;
|
||||
*/
|
||||
public function writeString($string)
|
||||
{
|
||||
fwrite($this->sharedStringsFilePointer, '<si><t xml:space="preserve">' . $this->stringsEscaper->escape($string) . '</t></si>');
|
||||
\fwrite($this->sharedStringsFilePointer, '<si><t xml:space="preserve">' . $this->stringsEscaper->escape($string) . '</t></si>');
|
||||
$this->numSharedStrings++;
|
||||
|
||||
// Shared string ID is zero-based
|
||||
@@ -87,20 +87,20 @@ EOD;
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (!is_resource($this->sharedStringsFilePointer)) {
|
||||
if (!\is_resource($this->sharedStringsFilePointer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fwrite($this->sharedStringsFilePointer, '</sst>');
|
||||
\fwrite($this->sharedStringsFilePointer, '</sst>');
|
||||
|
||||
// Replace the default strings count with the actual number of shared strings in the file header
|
||||
$firstPartHeaderLength = strlen(self::SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER);
|
||||
$defaultStringsCountPartLength = strlen(self::DEFAULT_STRINGS_COUNT_PART);
|
||||
$firstPartHeaderLength = \strlen(self::SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER);
|
||||
$defaultStringsCountPartLength = \strlen(self::DEFAULT_STRINGS_COUNT_PART);
|
||||
|
||||
// Adding 1 to take into account the space between the last xml attribute and "count"
|
||||
fseek($this->sharedStringsFilePointer, $firstPartHeaderLength + 1);
|
||||
fwrite($this->sharedStringsFilePointer, sprintf("%-{$defaultStringsCountPartLength}s", 'count="' . $this->numSharedStrings . '" uniqueCount="' . $this->numSharedStrings . '"'));
|
||||
\fseek($this->sharedStringsFilePointer, $firstPartHeaderLength + 1);
|
||||
\fwrite($this->sharedStringsFilePointer, \sprintf("%-{$defaultStringsCountPartLength}s", 'count="' . $this->numSharedStrings . '" uniqueCount="' . $this->numSharedStrings . '"'));
|
||||
|
||||
fclose($this->sharedStringsFilePointer);
|
||||
\fclose($this->sharedStringsFilePointer);
|
||||
}
|
||||
}
|
||||
@@ -88,8 +88,8 @@ EOD;
|
||||
$format = $style->getFormat();
|
||||
$tags[] = '<numFmt numFmtId="' . $numFmtId . '" formatCode="' . $format . '"/>';
|
||||
}
|
||||
$content = '<numFmts count="' . count($tags) . '">';
|
||||
$content .= implode('', $tags);
|
||||
$content = '<numFmts count="' . \count($tags) . '">';
|
||||
$content .= \implode('', $tags);
|
||||
$content .= '</numFmts>';
|
||||
|
||||
return $content;
|
||||
@@ -104,7 +104,7 @@ EOD;
|
||||
{
|
||||
$registeredStyles = $this->styleRegistry->getRegisteredStyles();
|
||||
|
||||
$content = '<fonts count="' . count($registeredStyles) . '">';
|
||||
$content = '<fonts count="' . \count($registeredStyles) . '">';
|
||||
|
||||
/** @var Style $style */
|
||||
foreach ($registeredStyles as $style) {
|
||||
@@ -145,8 +145,8 @@ EOD;
|
||||
$registeredFills = $this->styleRegistry->getRegisteredFills();
|
||||
|
||||
// Excel reserves two default fills
|
||||
$fillsCount = count($registeredFills) + 2;
|
||||
$content = sprintf('<fills count="%d">', $fillsCount);
|
||||
$fillsCount = \count($registeredFills) + 2;
|
||||
$content = \sprintf('<fills count="%d">', $fillsCount);
|
||||
|
||||
$content .= '<fill><patternFill patternType="none"/></fill>';
|
||||
$content .= '<fill><patternFill patternType="gray125"/></fill>';
|
||||
@@ -157,7 +157,7 @@ EOD;
|
||||
$style = $this->styleRegistry->getStyleFromStyleId($styleId);
|
||||
|
||||
$backgroundColor = $style->getBackgroundColor();
|
||||
$content .= sprintf(
|
||||
$content .= \sprintf(
|
||||
'<fill><patternFill patternType="solid"><fgColor rgb="%s"/></patternFill></fill>',
|
||||
$backgroundColor
|
||||
);
|
||||
@@ -178,7 +178,7 @@ EOD;
|
||||
$registeredBorders = $this->styleRegistry->getRegisteredBorders();
|
||||
|
||||
// There is one default border with index 0
|
||||
$borderCount = count($registeredBorders) + 1;
|
||||
$borderCount = \count($registeredBorders) + 1;
|
||||
|
||||
$content = '<borders count="' . $borderCount . '">';
|
||||
|
||||
@@ -233,7 +233,7 @@ EOD;
|
||||
{
|
||||
$registeredStyles = $this->styleRegistry->getRegisteredStyles();
|
||||
|
||||
$content = '<cellXfs count="' . count($registeredStyles) . '">';
|
||||
$content = '<cellXfs count="' . \count($registeredStyles) . '">';
|
||||
|
||||
foreach ($registeredStyles as $style) {
|
||||
$styleId = $style->getId();
|
||||
@@ -247,13 +247,13 @@ EOD;
|
||||
$content .= ' applyFont="1"';
|
||||
}
|
||||
|
||||
$content .= sprintf(' applyBorder="%d"', $style->shouldApplyBorder() ? 1 : 0);
|
||||
$content .= \sprintf(' applyBorder="%d"', $style->shouldApplyBorder() ? 1 : 0);
|
||||
|
||||
if ($style->shouldApplyCellAlignment() || $style->shouldWrapText()) {
|
||||
$content .= ' applyAlignment="1">';
|
||||
$content .= '<alignment';
|
||||
if ($style->shouldApplyCellAlignment()) {
|
||||
$content .= sprintf(' horizontal="%s"', $style->getCellAlignment());
|
||||
$content .= \sprintf(' horizontal="%s"', $style->getCellAlignment());
|
||||
}
|
||||
if ($style->shouldWrapText()) {
|
||||
$content .= ' wrapText="1"';
|
||||
|
||||
@@ -221,7 +221,7 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
|
||||
|
||||
if ($style->shouldApplyBorder()) {
|
||||
$border = $style->getBorder();
|
||||
$serializedBorder = serialize($border);
|
||||
$serializedBorder = \serialize($border);
|
||||
|
||||
$isBorderAlreadyRegistered = isset($this->registeredBorders[$serializedBorder]);
|
||||
|
||||
@@ -231,7 +231,7 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
|
||||
$this->styleIdToBorderMappingTable[$styleId] = $registeredBorderId;
|
||||
} else {
|
||||
$this->registeredBorders[$serializedBorder] = $styleId;
|
||||
$this->styleIdToBorderMappingTable[$styleId] = count($this->registeredBorders);
|
||||
$this->styleIdToBorderMappingTable[$styleId] = \count($this->registeredBorders);
|
||||
}
|
||||
} else {
|
||||
// If no border should be applied - the mapping is the default border: 0
|
||||
|
||||
@@ -44,7 +44,7 @@ class WorkbookManager extends WorkbookManagerAbstract
|
||||
{
|
||||
$worksheetFilesFolder = $this->fileSystemHelper->getXlWorksheetsFolder();
|
||||
|
||||
return $worksheetFilesFolder . '/' . strtolower($sheet->getName()) . '.xml';
|
||||
return $worksheetFilesFolder . '/' . \strtolower($sheet->getName()) . '.xml';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -107,13 +107,13 @@ EOD;
|
||||
*/
|
||||
public function startSheet(Worksheet $worksheet)
|
||||
{
|
||||
$sheetFilePointer = fopen($worksheet->getFilePath(), 'w');
|
||||
$sheetFilePointer = \fopen($worksheet->getFilePath(), 'w');
|
||||
$this->throwIfSheetFilePointerIsNotAvailable($sheetFilePointer);
|
||||
|
||||
$worksheet->setFilePointer($sheetFilePointer);
|
||||
|
||||
fwrite($sheetFilePointer, self::SHEET_XML_FILE_HEADER);
|
||||
fwrite($sheetFilePointer, '<sheetData>');
|
||||
\fwrite($sheetFilePointer, self::SHEET_XML_FILE_HEADER);
|
||||
\fwrite($sheetFilePointer, '<sheetData>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ EOD;
|
||||
|
||||
$rowXML .= '</row>';
|
||||
|
||||
$wasWriteSuccessful = fwrite($worksheet->getFilePointer(), $rowXML);
|
||||
$wasWriteSuccessful = \fwrite($worksheet->getFilePointer(), $rowXML);
|
||||
if ($wasWriteSuccessful === false) {
|
||||
throw new IOException("Unable to write data in {$worksheet->getFilePath()}");
|
||||
}
|
||||
@@ -227,7 +227,7 @@ EOD;
|
||||
$cellXML = '';
|
||||
}
|
||||
} else {
|
||||
throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cell->getValue()));
|
||||
throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue()));
|
||||
}
|
||||
|
||||
return $cellXML;
|
||||
@@ -263,12 +263,12 @@ EOD;
|
||||
{
|
||||
$worksheetFilePointer = $worksheet->getFilePointer();
|
||||
|
||||
if (!is_resource($worksheetFilePointer)) {
|
||||
if (!\is_resource($worksheetFilePointer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fwrite($worksheetFilePointer, '</sheetData>');
|
||||
fwrite($worksheetFilePointer, '</worksheet>');
|
||||
fclose($worksheetFilePointer);
|
||||
\fwrite($worksheetFilePointer, '</sheetData>');
|
||||
\fwrite($worksheetFilePointer, '</worksheet>');
|
||||
\fclose($worksheetFilePointer);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user