Fixed coding standard with strict comparisons

This commit is contained in:
aswinkumar863 2022-04-17 17:42:35 +05:30
parent 8889ecf044
commit 3a6ebc0ce6
No known key found for this signature in database
GPG Key ID: 8A69BFA6AEF8FA3E
1 changed files with 4 additions and 4 deletions

View File

@ -90,7 +90,7 @@ class Table
{ {
$name = trim($name); $name = trim($name);
if (strlen($name) == 1 && in_array($name, ['C', 'c', 'R', 'r'])) { if (strlen($name) === 1 && in_array($name, ['C', 'c', 'R', 'r'])) {
throw new PhpSpreadsheetException('The table name is invalid'); throw new PhpSpreadsheetException('The table name is invalid');
} }
if (strlen($name) > 255) { if (strlen($name) > 255) {
@ -238,12 +238,12 @@ class Table
*/ */
public function setWorksheet(?Worksheet $worksheet = null) public function setWorksheet(?Worksheet $worksheet = null)
{ {
if ($this->name != '' && $worksheet != null) { if ($this->name !== '' && $worksheet !== null) {
$spreadsheet = $worksheet->getParent(); $spreadsheet = $worksheet->getParent();
foreach ($spreadsheet->getWorksheetIterator() as $sheet) { foreach ($spreadsheet->getWorksheetIterator() as $sheet) {
foreach ($sheet->getTableCollection() as $table) { foreach ($sheet->getTableCollection() as $table) {
if ($table->getName() == $this->name) { if ($table->getName() === $this->name) {
throw new PhpSpreadsheetException("Workbook already contains a table named '{$this->name}'"); throw new PhpSpreadsheetException("Workbook already contains a table named '{$this->name}'");
} }
} }
@ -446,7 +446,7 @@ class Table
} else { } else {
$this->{$key} = clone $value; $this->{$key} = clone $value;
} }
} elseif ((is_array($value)) && ($key == 'columns')) { } elseif ((is_array($value)) && ($key === 'columns')) {
// The columns array of \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\Table objects // The columns array of \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\Table objects
$this->{$key} = []; $this->{$key} = [];
foreach ($value as $k => $v) { foreach ($value as $k => $v) {