Skip to content
Closed
Changes from all commits
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
5 changes: 5 additions & 0 deletions src/Gregwar/Captcha/CaptchaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ protected function writePhrase($image, $phrase, $font, $width, $height)
$x = ($width - $textWidth) / 2;
$y = ($height - $textHeight) / 2 + $size;

// Define a empty array when textColor is null
if(is_null($this->textColor)){
$this->textColor = array();
}

Comment on lines +351 to +355
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Define a empty array when textColor is null
if(is_null($this->textColor)){
$this->textColor = array();
}

if (!$this->textColor) {
Copy link
Collaborator

@bytestream bytestream Aug 5, 2022

Choose a reason for hiding this comment

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

Suggested change
if (!$this->textColor) {
if ($this->textColor === null || ! $this->textColor) {

Copy link

Choose a reason for hiding this comment

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

So when textColor always be an array, why should it compared with null?
The if is for empty arrays i think.

Copy link

Choose a reason for hiding this comment

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

I see you edit it. !$this->textColor should be enough. If $this->textColor is null its also true.

$textColor = array($this->rand(0, 150), $this->rand(0, 150), $this->rand(0, 150));
} else {
Expand Down