HEX
Server: LiteSpeed
System: Linux s383.bitcommand.com 5.14.0-687.24.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 9 18:14:06 EDT 2026 x86_64
User: pclast (1605)
PHP: 8.1.34
Disabled: exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/pclast/www/wp-content/plugins/woocommerce/lib/packages/GraphQL/Utils/PhpDoc.php
<?php declare(strict_types=1);

namespace Automattic\WooCommerce\Vendor\GraphQL\Utils;

class PhpDoc
{
    /** @param string|false|null $docBlock */
    public static function unwrap($docBlock): ?string
    {
        if ($docBlock === false || $docBlock === null) {
            return null;
        }

        $content = preg_replace('~([\r\n]) \* (.*)~i', '$1$2', $docBlock); // strip *
        assert(is_string($content), 'regex is statically known to be valid');

        $content = preg_replace('~([\r\n])[\* ]+([\r\n])~i', '$1$2', $content); // strip single-liner *
        assert(is_string($content), 'regex is statically known to be valid');

        $content = substr($content, 3); // strip leading /**
        $content = substr($content, 0, -2); // strip trailing */

        return static::nonEmptyOrNull($content);
    }

    /** @param string|false|null $docBlock */
    public static function unpad($docBlock): ?string
    {
        if ($docBlock === false || $docBlock === null) {
            return null;
        }

        $lines = explode("\n", $docBlock);
        $lines = array_map(
            static fn (string $line): string => ' ' . trim($line),
            $lines
        );

        $content = implode("\n", $lines);

        return static::nonEmptyOrNull($content);
    }

    protected static function nonEmptyOrNull(string $maybeEmptyString): ?string
    {
        $trimmed = trim($maybeEmptyString);

        return $trimmed === ''
            ? null
            : $trimmed;
    }
}