Skip to content

Conversation

@rustamwin
Copy link
Member

@rustamwin rustamwin commented Sep 22, 2023

Q A
Is bugfix?
New feature? ✔️
Breaks BC? ✔️/❌
Fixed issues

#22

@rustamwin rustamwin added the status:code review The pull request needs review. label Sep 22, 2023
@rustamwin rustamwin requested a review from a team September 22, 2023 05:07
@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (f8f7776) 98.11% compared to head (5b23a1f) 98.96%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #38      +/-   ##
============================================
+ Coverage     98.11%   98.96%   +0.85%     
- Complexity       20       83      +63     
============================================
  Files             1       10       +9     
  Lines            53      193     +140     
============================================
+ Hits             52      191     +139     
- Misses            1        2       +1     
Files Coverage Δ
src/AbstractClassifier.php 100.00% <100.00%> (ø)
src/Filter/ClassAttributes.php 100.00% <100.00%> (ø)
src/Filter/ClassImplements.php 100.00% <100.00%> (ø)
src/Filter/SubclassOf.php 100.00% <100.00%> (ø)
src/Filter/TargetAttribute.php 100.00% <100.00%> (ø)
src/NativeClassifier.php 100.00% <100.00%> (ø)
src/ReflectionFile.php 100.00% <100.00%> (ø)
src/TokenizerClassifier.php 100.00% <100.00%> (ø)
src/Filter/Condition/FilterAnd.php 88.88% <88.88%> (ø)
src/Filter/Condition/FilterOr.php 88.88% <88.88%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@what-the-diff
Copy link

what-the-diff bot commented Sep 22, 2023

PR Summary

  • New Abstract Classifier Structure
    A file named src/AbstractClassifier.php was added. It contains a foundational 'Abstract Classifier' which holds a certain function—find()—among others to aid in locating elements across our system.

  • Classifier Interface Implementation
    src/ClassifierInterface.php was added, this holds the Classifier Interface—a defined set of rules for the 'Classifier' to follow, stipulating that any 'Classifier' needs to have a find() function.

  • Classifier Visitor Addition
    The src/ClassifierVisitor.php file was included. This features a 'Classifier Visitor'—a tool that goes through various 'Classifiers' and retrieves any needed information.

  • PHP Parser Classifier
    The file src/PhpParserClassifier.php has been added, introducing a new 'Classifier' that extends the capacities of the Abstract Classifier. This enables it to parse PHP files and find classes within them, thereby making it easier to understand and manage our codebase.

  • Base Classifier Testing
    The file tests/BaseClassifierTest.php was included, extending our 'Test Case' with specific testing methods for the newly incorporated 'Classifiers' within various scenarios.

  • Revisions to Existing Classifier Test
    The existing tests/ClassifierTest.php file was altered to encompass the functionality of the new 'Base Classifier Test'. This allows it to create a 'PHP Parser Classifier' instance and thus, tests its functionality more efficiently.

@rustamwin rustamwin requested a review from vjik September 28, 2023 06:57
@rustamwin rustamwin changed the title Refactoring & PhpParserClassifier Refactoring & ParserClassifier Sep 28, 2023
@xepozz
Copy link
Member

xepozz commented Sep 28, 2023

Look at this file and get some optimization from the visitor.
Returning false make the parser skip scanning all children nodes.

@vjik
Copy link
Member

vjik commented Sep 28, 2023

Look at this file and get some optimization from the visitor. Returning false make the parser skip scanning all children nodes.

Good optimization. But it can be implemented in separate PR.

@rustamwin
Copy link
Member Author

rustamwin commented Oct 15, 2023

OK, I removed the parser classifier from the PR (moved it to #40). But I have some things to do here.

@rustamwin rustamwin added status:under development Someone is working on a pull request. and removed status:code review The pull request needs review. labels Oct 15, 2023
@rustamwin rustamwin changed the title Refactoring & ParserClassifier Refactoring Oct 15, 2023
@rustamwin
Copy link
Member Author

rustamwin commented Oct 27, 2023

Benchmark results:
With XDebug
telegram-cloud-photo-size-2-5321473048660004612-y

Without XDebug
image

{
$classifier = $params['classifier'];
$classifierInstance = new $classifier(...$params['dirs']);
$classifierInstance->find();
Copy link
Member

Choose a reason for hiding this comment

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

Please add tests for finding:

  • Interfaces
  • Classes implements interfaces
  • Classes inherits other classes

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@vjik
Copy link
Member

vjik commented Oct 27, 2023

My benchmark results:

image

image

@rustamwin rustamwin requested a review from a team October 31, 2023 06:24
@rustamwin rustamwin added status:code review The pull request needs review. and removed status:under development Someone is working on a pull request. labels Oct 31, 2023
@rustamwin rustamwin requested a review from a team November 4, 2023 07:53
*
* @return bool `true` if class matches against filter. Otherwise, `false`.
*/
public function match(ReflectionClass $reflectionClass): bool;
Copy link
Member

Choose a reason for hiding this comment

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

Not all classifier implementations use reflections. Better use filter as DTO, and implementation of classifier will filter by itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants