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

BugFix : count() func error when textColor is null #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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

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

@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