Just return __FILE__ when the realpath fails.

This commit is contained in:
Narek Zakarian 2025-07-04 17:11:20 +04:00
parent 0caa74c021
commit e713abfd75
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7
4 changed files with 6 additions and 31 deletions

View file

@ -101,13 +101,8 @@ class PayLaterBlockModule implements ServiceModule, ExtendingModule, ExecutableM
)
);
/**
* Cannot return false for this path.
*
* @psalm-suppress PossiblyFalseArgument
*/
register_block_type(
dirname( realpath( __FILE__ ), 2 ),
dirname( realpath( __FILE__ ) ?: __FILE__, 2 ),
array(
'render_callback' => function ( array $attributes ) use ( $c ) {
$renderer = $c->get( 'paylater-block.renderer' );

View file

@ -192,13 +192,8 @@ class PayLaterWCBlocksModule implements ServiceModule, ExtendingModule, Executab
return;
}
/**
* Cannot return false for this path.
*
* @psalm-suppress PossiblyFalseArgument
*/
register_block_type(
dirname( realpath( __FILE__ ), 2 ) . '/resources/js/CartPayLaterMessagesBlock',
dirname( realpath( __FILE__ ) ?: __FILE__, 2 ) . '/resources/js/CartPayLaterMessagesBlock',
array(
'render_callback' => function ( array $attributes ) use ( $c ) {
return PayLaterWCBlocksUtils::render_paylater_block(
@ -211,13 +206,8 @@ class PayLaterWCBlocksModule implements ServiceModule, ExtendingModule, Executab
)
);
/**
* Cannot return false for this path.
*
* @psalm-suppress PossiblyFalseArgument
*/
register_block_type(
dirname( realpath( __FILE__ ), 2 ) . '/resources/js/CheckoutPayLaterMessagesBlock',
dirname( $path, 2 ) . '/resources/js/CheckoutPayLaterMessagesBlock',
array(
'render_callback' => function ( array $attributes ) use ( $c ) {
return PayLaterWCBlocksUtils::render_paylater_block(

View file

@ -109,7 +109,7 @@ class ScriptDataHandler {
*
* @psalm-suppress UnresolvableInclude
*/
$script_asset_file = require dirname( realpath( __FILE__ ) ?: '', 3 ) . '/assets/index.asset.php';
$script_asset_file = require dirname( realpath( __FILE__ ) ?: __FILE__, 3 ) . '/assets/index.asset.php';
$module_url = $this->settings_url;
@ -127,12 +127,7 @@ class ScriptDataHandler {
'woocommerce-paypal-payments',
);
/**
* Require resolves.
*
* @psalm-suppress UnresolvableInclude
*/
$style_asset_file = require dirname( realpath( __FILE__ ) ?: '', 3 ) . '/assets/style.asset.php';
$style_asset_file = require dirname( realpath( __FILE__ ) ?: __FILE__, 3 ) . '/assets/style.asset.php';
wp_register_style(
'ppcp-admin-settings',

View file

@ -104,12 +104,7 @@ class SettingsModule implements ServiceModule, ExecutableModule {
static function () use ( $container ) {
$module_url = $container->get( 'settings.url' );
/**
* Require resolves.
*
* @psalm-suppress UnresolvableInclude
*/
$script_asset_file = require dirname( realpath( __FILE__ ) ?: '', 2 ) . '/assets/switchSettingsUi.asset.php';
$script_asset_file = require dirname( realpath( __FILE__ ) ?: __FILE__, 2 ) . '/assets/switchSettingsUi.asset.php';
wp_register_script(
'ppcp-switch-settings-ui',