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

v3.0.1: strlen() expects parameter 1 to be string, integer given #200

Closed
hostep opened this issue Jan 27, 2020 · 5 comments · Fixed by #201
Closed

v3.0.1: strlen() expects parameter 1 to be string, integer given #200

hostep opened this issue Jan 27, 2020 · 5 comments · Fixed by #201

Comments

@hostep
Copy link

hostep commented Jan 27, 2020

Hi!

I just attempted upgrading from version 2.2.0 to 3.0.1 (an up-to-date changelog would handy btw, but no pressure 😉) and I ran into this error:

In GitCommand.php line 182:

  strlen() expects parameter 1 to be string, integer given

This happened when calling the log method on a GitWorkingCopy instance:

$this->git->log(
    [
        'shortstat' => true,
        'n' => self::LAST_COMMIT_COUNT,
        'date' => 'unix',
    ]
);

It interprets xxx in the argument -n xxx as an integer and calling strlen on an integer throws the above error. Probably due to strict_types being enabled.

Suggested would be to change:

        return array_filter($command, function ($value): bool {
            return strlen($value) > 0;
        });

to

        return array_filter($command, function ($value): bool {
            return strlen((string) $value) > 0;
        });

Does this make sense?

Thanks!

@GrahamCampbell
Copy link
Contributor

I don't think that's what we actually want. I think we should fix the caller so it only calls this method with the correct types.

@GrahamCampbell
Copy link
Contributor

@GrahamCampbell
Copy link
Contributor

I don't think that's what we actually want. I think we should fix the caller so it only calls this method with the correct types.

Actually, there does seem to a bug here, with this. I think the return type of this method is also wrong...

@GrahamCampbell
Copy link
Contributor

Does #201 fix your issue?

@hostep
Copy link
Author

hostep commented Jan 27, 2020

#201 fixes the issue indeed, thanks for looking into this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants