denzyldick / phanalist

Performant static analyzer for PHP, which is extremely easy to use. It helps you catch common mistakes in your PHP code.
https://denzyldick.github.io/phanalist/
MIT License
127 stars 5 forks source link

Traversing #48

Closed denzyldick closed 5 months ago

denzyldick commented 6 months ago

At the time of writing this issue, I can feel that I'm duplicating some sections of the rules. For example, the code below has already been written twice.

fn validate(){
 if let Statement::Class(class) = self.statement {
            for member in &class.body.members {
                if let ClassMember::ConcreteMethod(concretemethod) = member {
                    let MethodBody {
                        comments: _,
                        left_brace: _,
                        statements,
                        right_brace: _,
                    } = &concretemethod.body;
                    {
                        /// Execute logic.
                    }
                }
            }
        }

}

I need to create a way to reuse it. There should be a function find_members_and_execute or something like that.

SerheyDolgushev commented 6 months ago

As part of https://github.com/denzyldick/phanalist/issues/47 I will do a refactoring and will try to submit it during the weekend. Let's get back to it afterward.

SerheyDolgushev commented 6 months ago

@denzyldick please have a look at https://github.com/denzyldick/phanalist/pull/51, it might resolve concern described in this issue.