Skip to content

Commit

Permalink
Fix: Call to protected method has_feed() of class GatherPress\Core\En…
Browse files Browse the repository at this point in the history
…dpoints\Endpoint.
  • Loading branch information
carstingaxion committed Oct 4, 2024
1 parent dc4384f commit 7480c2a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion includes/core/classes/endpoints/class-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function template_redirect(): void {
*
* @return string The slug of the endpoint or an empty string if not a feed template.
*/
protected function has_feed(): string {
public function has_feed(): string {
if ( false !== strpos( $this->reg_ex, '/feed/' ) ) {
$feed_slug = current( $this->get_slugs( __NAMESPACE__ . '\Endpoint_Template' ) );
if ( ! empty( $feed_slug ) ) {
Expand Down
42 changes: 42 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon
# Bleeding edge offers a preview of the next major version.
# When you enable Bleeding edge in your configuration file, you will get new rules,
# behaviour, and bug fixes that will be enabled for everyone later
# when the next PHPStan’s major version is released.
- phar://phpstan.phar/conf/bleedingEdge.neon

parameters:
bootstrapFiles:
# Constants, functions, etc. used by GatherPress
#- phpstan.stubs
# - vendor/pmc/unit-test/src/classes/autoloader.php
# - vendor/autoload.php
# - gatherpress.php
parallel:
maximumNumberOfProcesses: 1
processTimeout: 300.0

# the analysis level, from 0 (loose) to 9 (strict)
# https://phpstan.org/user-guide/rule-levels
level: 5

paths:
- includes/
# - test/

# excludePaths:
# analyse:
# - vendor/

ignoreErrors:
- '#^Constant GATHERPRESS_CORE_FILE not found\.$#'
- '#^Constant GATHERPRESS_CORE_PATH not found\.$#'
- '#^Constant GATHERPRESS_CORE_URL not found\.$#'
- '#^Constant GATHERPRESS_REST_NAMESPACE not found\.$#'
- '#^Constant GATHERPRESS_REQUIRES_PHP not found\.$#'

# core/classes/class-setup.php
#
# A dev-only error, which can occur if the gatherpress is symlinked into a WP instance or called via wp-env or Playground.
- '#^Path in require_once\(\) "\./wp-admin/includes/upgrade\.php" is not a file or it does not exist\.$#'
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function test_has_feed(): void {
);

$this->assertEmpty(
Utility::invoke_hidden_method( $instance, 'has_feed' ),
$instance->has_feed(),
'Failed to assert, endpoint is not for feeds.'
);

Expand All @@ -265,7 +265,7 @@ public function test_has_feed(): void {
);

$this->assertEmpty(
Utility::invoke_hidden_method( $instance, 'has_feed' ),
$instance->has_feed(),
'Failed to assert, endpoint is for feeds, but has no Endpoint_Template type.'
);

Expand All @@ -284,7 +284,7 @@ public function test_has_feed(): void {

$this->assertSame(
'endpoint_template_1',
Utility::invoke_hidden_method( $instance, 'has_feed' ),
$instance->has_feed(),
'Failed to assert, that feed template is found.'
);
}
Expand Down

0 comments on commit 7480c2a

Please sign in to comment.