bobbingwide / oik-shortcodes

Shortcode, block and API server
https://www.oik-plugins.com/oik-plugins/oik-shortcode-server/
GNU General Public License v2.0
1 stars 0 forks source link

Parse error: syntax_error, unexpected ';', expecting '(' in /tmp/oikscloae0qwnk on line 2 #82

Open bobbingwide opened 3 years ago

bobbingwide commented 3 years ago

While processing Jetpack through oik-shortcodes.php the following error was encountered.

Processing API: site_url, extensions/blocks/premium-content/_inc/subscription-service/class-unconfigured-subscription-service.php, jetpack, plugin API: site_url

Processing: site_url,site_url,extensions/blocks/premium-content/_inc/subscription-service/class-unconfigured-subscription-service.php

Parse error: syntax error, unexpected ';', expecting '(' in /tmp/oikscloae0qwnk on line 2

The source file being parsed starts with

<?php
/**
 * The environment does not have a subscription service available.
 * This represents this scenario.
 *
 * @package Automattic\Jetpack\Extensions\Premium_Content
 */

namespace Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service;

use function site_url;
// phpcs:disable

/**
 * Class Unconfigured_Subscription_Service
 *
 * @package Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service
 */
class Unconfigured_Subscription_Service implements Subscription_Service {
bobbingwide commented 3 years ago

Workaround

Skip this file by passing additional parameters: db3acdb 244

bobbingwide commented 2 years ago

I got a similar problem recently. The parsing of Jetpack v11.3.1 failed while processing jetpack_vendor/automattic/jetpack-device-detection/src/class-device-detection.php

Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR), expecting '(' in /tmp/oikscloakrE59f on line 2

Attempting to reproduce the problem by copying the source into foobar I got a series of Warnings but not the

Processing file: foobar,space dir/class-device-detection.php
Continue to process file? ( y=yes/n=no/s=skip/g=go/q=quit )y
Processing: space dir/class-device-detection.php, foobar, plugin
<p>Creating file: space dir/class-device-detection.php</p><p>Creating file: space dir</p>
Processing file: foobar,space dir/class-device-detection.php ended
Processing valid: foobar space dir/class-device-detection.php plugin
Processing API: Device_Detection::, space dir/class-device-detection.php, foobar, plugin
API: Device_Detection::

Processing classref: Device_Detection::,space dir/class-device-detection.php
Processing API: Device_Detection::get_info, space dir/class-device-detection.php, foobar, plugin
API: Device_Detection::get_info

Processing: get_info,Device_Detection::get_info,space dir/class-device-detection.php

Warning: Trying to access array offset on value of type null in C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\classes\class-oiksc-api-cache.php on line 93
Processing API: Device_Detection::is_phone, space dir/class-device-detection.php, foobar, plugin
API: Device_Detection::is_phone

Processing: is_phone,Device_Detection::is_phone,space dir/class-device-detection.php

Warning: Trying to access array offset on value of type null in C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\classes\class-oiksc-api-cache.php on line 93

These Warnings were because the $posts variable was null for APIs that haven't already been processed.

bobbingwide commented 2 years ago

I reproduced the original problem by copy the starting lines from the first comment into a new file in foobar called issue-82.php. The temporary file has been produced for invalidly detected function due to the use function site_url; line.

<?php //site_url
function oiksc_dummy_function_0;
// phpcs:disable

/**
 * Class Unconfigured_Subscription_Service
 *
 * @package Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service
 */
class Unconfigured_Subscription_Service implements Subscription_Service {
}
bobbingwide commented 2 years ago

It would appear that the more recent problem was due to a similar line of code.

use function Automattic\Jetpack\Device_Detection\wp_unslash;
bobbingwide commented 2 years ago

Having made changes for other issues I've since been unable to reproduce the problem locally or on the live site. I bit of a surprise but hey ho!