Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ReferenceHelper.php #1873

Merged
merged 3 commits into from
Mar 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/PhpSpreadsheet/ReferenceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,12 @@ public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pShee
// Update workbook: define names
if (count($pSheet->getParent()->getDefinedNames()) > 0) {
foreach ($pSheet->getParent()->getDefinedNames() as $definedName) {
if ($definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) {
$hash = null;
if ($definedName->getWorksheet()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the sake of readability, can you do an explicit comparison for not null)..

This is something that I've been doing in all the code that I've been working with recently, and it does make the if comparison a lot more explicit rather than relying on the loose typed truthiness/falsiness of PHP

$hash = $definedName->getWorksheet()->getHashCode();
}

if ($hash === $pSheet->getHashCode()) {
$definedName->setValue($this->updateCellReference($definedName->getValue(), $pBefore, $pNumCols, $pNumRows));
}
}
Expand Down