elementor / WordPressURLDetector

A library to get all public URLs from a WordPress application.
The Unlicense
7 stars 4 forks source link

deal with global and object variable CS errors #2

Closed leonstafford closed 3 years ago

leonstafford commented 3 years ago
FILE: ...WordPressURLDetector/src/DetectCategoryPagination.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 31 | ERROR | Variable "wp_rewrite" is not in valid camel caps
    |       | format
    |       | (Squiz.NamingConventions.ValidVariableName.NotCamelCaps)
 41 | ERROR | Variable "wp_rewrite" is not in valid camel caps
    |       | format
    |       | (Squiz.NamingConventions.ValidVariableName.NotCamelCaps)
 41 | ERROR | Member variable "pagination_base" is not in valid camel
    |       | caps format
    |       | (Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps)
----------------------------------------------------------------------

Jó napot, @szepeviktor! Is there a simple way via phpcs.xml to exclude certain vars for these sniffs, like we can do with WordPress.NamingConventions.ValidVariableName?

szepeviktor commented 3 years ago

"WordPress application"

What an upgrade! 🤣

szepeviktor commented 3 years ago

So naming it wpRewrite is impossible?

szepeviktor commented 3 years ago

I see, it is a global...

// phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
... $wp_rewrite ...
leonstafford commented 3 years ago

Yeah, starting to feel like solution is to just avoid that at all costs and grab pagination base by other means... Close?

szepeviktor commented 3 years ago

WordPress uses a global variable instead of a DI container.

leonstafford commented 3 years ago

Looks like get_option( 'rewrite_rules' ) may be more useful way to determine some URL structures for this repo... I should be OK for now, thanks for coming to rescue again! I'm just doing first pass at this repo adjusting for Codesniffer, then will get to PHPStan and friends next and cry for help when I get stuck :D

leonstafford commented 3 years ago

more work to do in design, but CS issue cleared