Is `nonce` attribute on the script tag needed?

@param array $headers

@return boolean
197355
public function shouldAppendNonce($headers)
    {
        foreach ($headers as $header) {
            if (strpos($header, 'Content-Security-Policy') !== false &&
                strpos($header, "'unsafe-inline'") !== false) {
                return true;
            }
        }
        
        return false;
    }
1135570
public function setHeaders(\OtherCode\Rest\Payloads\Headers $headers = null)
    {
        if (isset($headers)) {
            $this->headers = $headers;
        } else {
            $this->headers = new \OtherCode\Rest\Payloads\Headers();
        }
    }
1085617
private function canInjectStrictDynamic(Header $header)
    {
        # check if a relevant directive exists
        if (
            $header->hasAttribute($directive = 'script-src')
            or $header->hasAttribute($directive = 'default-src')
        ) {
            if (
                preg_match(
                    "/(?:^|\s)(?:'strict-dynamic'|'none')(?:$|\s)/i",
                    $header->getAttributeValue($directive)
                )
            ) {
                return -1;
            }

            $nonceOrHashRe = implode(
                '|',
                array_map(
                    function ($s)
                    {
                        return preg_quote($s, '/');
                    },
                    array_merge(
                        ['nonce'],
                        $this->allowedCSPHashAlgs
                    )
                )
            );

            # if the directive contains a nonce or hash, return the directive
            # that strict-dynamic should be injected into
            $containsNonceOrHash = preg_match(
                "/(?:^|\s)'(?:$nonceOrHashRe)-/i",
                $header->getAttributeValue($directive)
            );

            if ($containsNonceOrHash)
            {
                return $directive;
            }
        }

        return false;
    }
649552
public function setCustomHeaders(array $headers)
    {
        foreach ($headers as $k => &$v) {
            if (strpos($v, ':') === false) {
                $v = $k.': '.$v;
            }
        }
        $this->headers = $headers;
    }
1166750
public function setHeaders(array $headers)
	{
		foreach ($headers as $key => $header) {
			$this->setHeader($key, $header);
		}

		return $this;
	}
1291631
protected function setHeaders(array $headers)
    {
        foreach ($headers as $header) {

            if (isset($header['name']) && isset($header['value'])) {
                $this->headers[$header['name']] = $header['value'];
            }
        }

        return $this;
    }
802419
protected function _sanitizeHeaders(&$headers)
    {
        foreach ($headers as $key => $value) {
            $headers[$key] =
                preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
                             null, $value);
        }
    }
277624
public function setHeaders(array $headers)
    {
        $headers = array_values($headers);
        if (!empty($headers) && !is_array($headers[0])) {
            $headers = array($headers);
        }

        $this->headersCopy = $headers;

        return parent::setHeaders($headers);
    }
1190303
protected function setHeaders(Array $headers = []) {
    foreach ($headers as $property => $value) {
      $this->client->setHeader($property, $value);
    }
  }
1124468
public function headerDeferJavascripts()
    {
        add_filter('script_loader_tag', function ($tag, $handle) {
            // Main WP jQuery is not concerned
            if (strpos($tag, '/wp-includes/js/jquery/jquery')) {
                return $tag;
            }

            // Defer on MSIE is not permitted
            if (isset($_SERVER['HTTP_USER_AGENT']) && false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 9.')) {
                return $tag;
            }

            return str_replace(' src', ' defer src', $tag);
        }, 10, 2);
    }
455751
public function replace(array $headers = []): void
    {
        $this->headerNames = [];
        $this->headers = [];

        $headers !== [] && $this->add($headers);

        if (!isset($this->headers['Cache-Control'])) {
            $this->set('Cache-Control', '');
        }
    }
70985
public function parseHeaders(array $headers)
    {
        foreach ($headers as $key => $value) {
            if (strpos($key, 'HTTP_') !== false) {
                $newKey                 = str_replace(['http_', '_'], ['', '-'],
                    mb_strtolower($key));
                $this->headers[$newKey] = $value;
            }
        }
        return $this->headers;
    }
432680
private function updateCspHeaders(Response $response, array $nonces = [])
    {
        $nonces = array_replace([
            'csp_script_nonce' => $this->generateNonce(),
            'csp_style_nonce' => $this->generateNonce(),
        ], $nonces);

        $ruleIsSet = false;

        $headers = $this->getCspHeaders($response);

        foreach ($headers as $header => $directives) {
            foreach (['script-src' => 'csp_script_nonce', 'style-src' => 'csp_style_nonce'] as $type => $tokenName) {
                if ($this->authorizesInline($directives, $type)) {
                    continue;
                }
                if (!isset($headers[$header][$type])) {
                    if (isset($headers[$header]['default-src'])) {
                        $headers[$header][$type] = $headers[$header]['default-src'];
                    } else {
                        // If there is no script-src/style-src and no default-src, no additional rules required.
                        continue;
                    }
                }
                $ruleIsSet = true;
                if (!\in_array('\'unsafe-inline\'', $headers[$header][$type], true)) {
                    $headers[$header][$type][] = '\'unsafe-inline\'';
                }
                $headers[$header][$type][] = sprintf('\'nonce-%s\'', $nonces[$tokenName]);
            }
        }

        if (!$ruleIsSet) {
            return $nonces;
        }

        foreach ($headers as $header => $directives) {
            $response->headers->set($header, $this->generateCspHeader($directives));
        }

        return $nonces;
    }
643142
public function addHeaders(array $headers)
    {
        foreach ($headers as $name => $content) {
            $this->headers[$name] = $content;
        }
    }
1353186
private function normalizeHeaders(array $headers)
    {
        $ignoreHeaders = $this->ignoreHeaders;

        foreach ($ignoreHeaders as $ignoreHeader) {
            $headers = array_filter($headers, function($header) use ($ignoreHeader) {
                return stripos($header, $ignoreHeader.':') !== 0;
            });
        }

        return $headers;
    }
211295
private function validateHeaders(HeaderBag $headers)
    {
        $this->errors = array_merge(
            $this->errors,
            Validator::validate($headers)
        );
    }
448734
public static function buildJs(
        $config,
        $headers = null,
        $nonce = null,
        $customJs = ""
    ) {
        $helper = new self($config);
        return $helper->addJs($headers, $nonce, $customJs);
    }