Skip to content

exclude-functions not working as expected #1131

@saas786

Description

@saas786

Hi,

I’m not sure if this is a bug or if I’m misunderstanding the intended behavior of exclude-functions.

I have the following file (function bodies stripped for simplicity):

<?php
use Hybrid\App;
use Olay\Tools\Media\Lazyload as MediaLazyload;

if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {
    function woocommerce_template_loop_product_thumbnail() {
    }
}

if ( ! function_exists( 'woocommerce_review_display_gravatar' ) ) {
    function woocommerce_review_display_gravatar( $comment ) {
    }
}

Scoped Output

php-scoper inspect -c ./bin-dev/php-scoper/scoper.inc.php dist/inc/WooCommerce/functions-overrides.php

Scoped contents:

<?php

namespace Olay_Vendor;

use Olay_Vendor\Hybrid\App;
use Olay\Tools\Media\Lazyload as MediaLazyload;

if (!\function_exists('woocommerce_template_loop_product_thumbnail') && !\function_exists('Olay_Vendor\woocommerce_template_loop_product_thumbnail')) {
    function woocommerce_template_loop_product_thumbnail()
    {
    }
}

if (!\function_exists('woocommerce_review_display_gravatar') && !\function_exists('Olay_Vendor\woocommerce_review_display_gravatar')) {
    function woocommerce_review_display_gravatar($comment)
    {
    }
}

Symbols Registry:

Humbug\PhpScoper\Symbol\SymbolsRegistry {#182
  -recordedFunctions: array:2 [
    "woocommerce_template_loop_product_thumbnail" => array:2 [
      0 => "woocommerce_template_loop_product_thumbnail"
      1 => "Olay_Vendor\woocommerce_template_loop_product_thumbnail"
    ]
    "woocommerce_review_display_gravatar" => array:2 [
      0 => "woocommerce_review_display_gravatar"
      1 => "Olay_Vendor\woocommerce_review_display_gravatar"
    ]
  ]
  -recordedClasses: []
}

Even though I’ve excluded woocommerce_template_loop_product_thumbnail using exclude-functions, it still appears to be scoped.

Is this the expected behavior, or should the excluded function remain untouched?


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions