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

Policies: treat true as allow, and false as deny #2534

Merged
merged 5 commits into from Jan 18, 2021

Conversation

askvortsov1
Copy link
Sponsor Member

Fixes #2525

This change allows devs to return boolean expressions directly, which is more intuitive and simpler.

// Without This Change
return SOME BOOLEAN LOGIC HERE ? $this->allow() : $this->deny();

// With This Change
return SOME BOOLEAN LOGIC HERE;

askvortsov1 and others added 2 commits January 9, 2021 18:21
This change allows devs to return boolean expressions directly, which is more intuitive and simpler.

```
// Without This Change
return SOME BOOLEAN LOGIC HERE ? $this->allow() : $this->deny();

// With This Change
return SOME BOOLEAN LOGIC HERE;
```
[ci skip] [skip ci]
Copy link
Member

@clarkwinkelmann clarkwinkelmann left a comment

Choose a reason for hiding this comment

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

Looking good! Not tested locally. Just a nitpick below.

src/User/Access/AbstractPolicy.php Outdated Show resolved Hide resolved
Copy link
Member

@clarkwinkelmann clarkwinkelmann left a comment

Choose a reason for hiding this comment

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

Looks good!

Something else I notice now: would a comment be useful? Either in the phpdoc or above the first if, to say something like "Allow returning true and false in addition to $this->allow() and $this->deny()". To someone not in the know, this code might look like some odd unneeded redundancy

@askvortsov1 askvortsov1 merged commit 89e821e into master Jan 18, 2021
@askvortsov1 askvortsov1 deleted the as/2525-policies-treat-bool-as-ALLOW-or-DENY branch January 18, 2021 23:28
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 this pull request may close these issues.

Policies: treat true as allow, and false as deny
3 participants