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

Compiler cannot process conditions for strings that are null #2299

Closed
niden opened this issue Oct 3, 2021 · 0 comments · Fixed by #2323
Closed

Compiler cannot process conditions for strings that are null #2299

niden opened this issue Oct 3, 2021 · 0 comments · Fixed by #2323
Assignees
Labels
bug Hacktoberfest See https://hacktoberfest.digitalocean.com/ for participants details
Milestone

Comments

@niden
Copy link
Contributor

niden commented Oct 3, 2021

/**
 * Returns the inherited roles for a passed role name. If no role name
 * has been specified it will return the whole array. If the role has not
 * been found it returns an empty array
 */
public function getInheritedRoles(string roleName = null) -> array
{
    var result;

    if null !== roleName {
        return this->roleInherits;
    }

    if !fetch result, this->roleInherits[roleName] {
        return [];
    }

    return result;
}

This produces:

[ERROR] Unknown type: string in /srv/phalcon/Acl/Adapter/Memory.zep on line 527

If we change the condition:

if null !== roleName {

to

if !roleName {

or

if typeof roleName !== "string" {

it works fine.

@Jeckerson Jeckerson added bug Hacktoberfest See https://hacktoberfest.digitalocean.com/ for participants details labels Oct 3, 2021
@Jeckerson Jeckerson added this to the 0.16.0 milestone Oct 24, 2021
@Jeckerson Jeckerson self-assigned this Nov 7, 2021
Jeckerson added a commit that referenced this issue Nov 7, 2021
Jeckerson added a commit that referenced this issue Nov 7, 2021
@AlexNDRmac AlexNDRmac linked a pull request Nov 7, 2021 that will close this issue
3 tasks
AlexNDRmac added a commit that referenced this issue Nov 7, 2021
…tion

#2299 - Fix left `null` with `string` condition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Hacktoberfest See https://hacktoberfest.digitalocean.com/ for participants details
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants