Skip to content

Stop instanciating an object to check its class name.#290

Merged
williamdes merged 1 commit intophpmyadmin:QAfrom
niconoe-:fix-246
Feb 9, 2020
Merged

Stop instanciating an object to check its class name.#290
williamdes merged 1 commit intophpmyadmin:QAfrom
niconoe-:fix-246

Conversation

@niconoe-
Copy link
Copy Markdown
Contributor

@niconoe- niconoe- commented Feb 6, 2020

Fixes #246
When set on master, where PHP 5.3 is not maintained anymore, this could be a little bit improved.

I did not use is_a because of the function call (not good for performance) and I did not use instanceof neither because $class is a string, not an object. We are actually comparing 2 strings, so let's just compare 2 strings...

I'm aware it has not the exact same behavior in case of $class is a string evaluated to a class name of a child of FunctionCall class, but it appears that FunctionCall has no children, so the misbehavior here is not applicable.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 6, 2020

Codecov Report

Merging #290 into QA will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff          @@
##               QA   #290   +/-   ##
=====================================
  Coverage     100%   100%           
+ Complexity   1865   1864    -1     
=====================================
  Files          63     63           
  Lines        4527   4527           
=====================================
  Hits         4527   4527

Comment thread src/Statement.php
@williamdes williamdes self-assigned this Feb 9, 2020
@williamdes williamdes added this to the 4.5.1 milestone Feb 9, 2020
williamdes added a commit that referenced this pull request Feb 9, 2020
Pull-request: #290

Signed-off-by: William Desportes <williamdes@wdes.fr>
williamdes added a commit that referenced this pull request Feb 9, 2020
Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes williamdes merged commit be2f4da into phpmyadmin:QA Feb 9, 2020
@williamdes williamdes linked an issue Feb 9, 2020 that may be closed by this pull request
@williamdes
Copy link
Copy Markdown
Member

Thank you @niconoe- for this fix !

@niconoe- niconoe- deleted the fix-246 branch February 27, 2023 14:51
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.

Use is_a() instead of creating an object to check for its class

2 participants