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

Fix bool logic for inCall flag #1233

Merged
merged 1 commit into from
Oct 2, 2018

Conversation

nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Oct 2, 2018

var_dump(true & 1 !== 0); // int(1)
var_dump((true & 1) !== 0); // bool(true)
var_dump(true & (1 !== 0)); // int(1)

Copy link
Member

@fancycode fancycode left a comment

Choose a reason for hiding this comment

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

While it's not strictly required (the check is actually int-number & Participant::FLAG_IN_CALL !== 0), it's better to explicitly add brackets so lgtm.

Could you please also change it here for consistency:

isInCall: this.model.get('participantFlags') & OCA.SpreedMe.app.FLAG_IN_CALL !== 0,

Should be (this.model.get('participantFlags') & OCA.SpreedMe.app.FLAG_IN_CALL) !== 0.

@nickvergessen
Copy link
Member Author

nickvergessen commented Oct 2, 2018

Well for the flag with 1 it works the same way, yes. But if you check flag 2 it fails:

var_dump(true & 2 !== 0); // int(1)
var_dump((true & 2) !== 0); // bool(false)
var_dump(true & (2 !== 0)); // int(1)

the problem is, that php first evaluates !== and then & if there are no brackets

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the followup/1231/fix-bool-logic-for-incall-flag branch from fa87b8b to e4f6aae Compare October 2, 2018 13:38
@nickvergessen
Copy link
Member Author

its the same in js, so fixed it there too:

console.log(true & 1 !== 0);
console.log((true & 1) !== 0);
console.log(true & (1 !== 0));
1
true
1

@fancycode
Copy link
Member

The first variable in your checks is a number (i.e. the flags), not true/false - or am I missing something?

@nickvergessen
Copy link
Member Author

makes no difference:

var_dump(1 & 2 !== 0); // int(1)
var_dump((1 & 2) !== 0); // bool(false)
var_dump(1 & (2 !== 0)); // int(1)

@fancycode
Copy link
Member

You are right. I was testing the other way round (2 & 1 !== 0) which returned false (from 2 & true), so I got confused 🙈 Anyway, still lgtm 😃

@nickvergessen nickvergessen merged commit e258e24 into master Oct 2, 2018
@nickvergessen nickvergessen deleted the followup/1231/fix-bool-logic-for-incall-flag branch October 2, 2018 15:08
marcoambrosini pushed a commit that referenced this pull request Oct 9, 2019
Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.16.0 to 2.17.1.
<details>
<summary>Changelog</summary>

*Sourced from [eslint-plugin-import's changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md).*

> ## [2.17.1] - 2019-04-13
> 
> ### Fixed
> - require v2.4 of `eslint-module-utils` ([#1322])
> 
> ## [2.17.0] - 2019-04-13
> 
> ### Added
> - Autofixer for [`no-duplicates`] rule ([#1312], thanks [@&#8203;lydell])
> - [`no-useless-path-segments`]: Add `noUselessIndex` option ([#1290], thanks [@&#8203;timkraut])
> - [`no-duplicates`]: Add autofix ([#1312], thanks [@&#8203;lydell])
> - Add [`no-unused-modules`] rule ([#1142], thanks [@&#8203;rfermann])
> - support export type named exports from typescript ([#1304], thanks [@&#8203;bradennapier] and [@&#8203;schmod])
> 
> ### Fixed
> - [`order`]: Fix interpreting some external modules being interpreted as internal modules ([#793], [#794] thanks [@&#8203;ephys])
> - allow aliases that start with @ to be "internal" ([#1293], [#1294], thanks [@&#8203;jeffshaver])
> - aliased internal modules that look like core modules ([#1297], thanks [@&#8203;echenley])
> - [`namespace`]: add check for null ExportMap ([#1235], [#1144], thanks [@&#8203;ljqx])
> - [ExportMap] fix condition for checking if block comment ([#1234], [#1233], thanks [@&#8203;ljqx])
> - Fix overwriting of dynamic import() CallExpression ([`no-cycle`], [`no-relative-parent-import`], [`no-unresolved`], [`no-useless-path-segments`]) ([#1218], [#1166], [#1035], thanks [@&#8203;vikr01])
> - [`export`]: false positives for typescript type + value export ([#1319], thanks [@&#8203;bradzacher])
> - [`export`]: Support typescript namespaces ([#1320], [#1300], thanks [@&#8203;bradzacher])
> 
> ### Docs
> - Update readme for Typescript ([#1256], [#1277], thanks [[@&#8203;kirill](https://github.com/kirill)-konshin])
> - make rule names consistent ([#1112], thanks [@&#8203;feychenie])
> 
> ### Tests
> - fix broken tests on master ([#1295], thanks [@&#8203;jeffshaver] and [@&#8203;ljharb])
> - [`no-commonjs`]: add tests that show corner cases ([#1308], thanks [@&#8203;TakeScoop])
</details>
<details>
<summary>Commits</summary>

- [`b0c5e1a`](import-js/eslint-plugin-import@b0c5e1a) bump to v2.17.1
- [`f6716ad`](import-js/eslint-plugin-import@f6716ad) [fix] require v2.4 of `eslint-module-utils`
- [`5124dde`](import-js/eslint-plugin-import@5124dde) [utils] v2.4.0
- [`0499050`](import-js/eslint-plugin-import@0499050) bump to v2.17.0
- [`f479635`](import-js/eslint-plugin-import@f479635) [webpack] v0.11.1
- [`8a4226d`](import-js/eslint-plugin-import@8a4226d) Merge pull request [#1320](https://github-redirect.dependabot.com/benmosher/eslint-plugin-import/issues/1320) from bradzacher/export-ts-namespaces
- [`988e12b`](import-js/eslint-plugin-import@988e12b) fix(export): Support typescript namespaces
- [`70c3679`](import-js/eslint-plugin-import@70c3679) [docs] make rule names consistent
- [`6ab25ea`](import-js/eslint-plugin-import@6ab25ea) [Tests] skip a TS test in eslint < 4
- [`405900e`](import-js/eslint-plugin-import@405900e) [Tests] fix tests from [#1319](https://github-redirect.dependabot.com/benmosher/eslint-plugin-import/issues/1319)
- Additional commits viewable in [compare view](import-js/eslint-plugin-import@v2.16.0...v2.17.1)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=eslint-plugin-import&package-manager=npm_and_yarn&previous-version=2.16.0&new-version=2.17.1)](https://dependabot.com/compatibility-score.html?dependency-name=eslint-plugin-import&package-manager=npm_and_yarn&previous-version=2.16.0&new-version=2.17.1)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
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.

2 participants