Problem/Motivation

The method is declared as:

> public function dumpToUri(string $data, string $file_extension, string $uri): string {

but there are several returns of FALSE, e.g.:

      if (!file_exists($uri) && !$this->fileSystem->saveData($data, $uri, FileExists::Replace)) {
        return FALSE;
      }

Because this file is missing a use strict, it's presumably being cast to an empty string?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3628390

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

hoxton made their first commit to this issue’s fork.

hoxton’s picture

The dumpToUri seems to update the file content and returns the $uri which was given to it as parameter for no-error state.
I believe it would be ok to return boolean only for no-error and error state.

burcu.sogut@drupart.com.tr made their first commit to this issue’s fork.

burcu.sogut@drupart.com.tr’s picture

Status: Active » Needs review

Opened an MR. Without strict types, PHP converts the FALSE returns to an empty string. The MR returns an empty string explicitly and adds declare(strict_types=1) to AssetDumper.php. The interface documents the empty string on failure. Callers do not change: AssetControllerBase ignores the return value.

Changing the return type to string|false is an API change, so the MR does not do that.

The MR adds AssetDumperTest. With strict types and the old code, the failure test throws a TypeError.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Some issue here, this is reading like AI https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquett...

Please disclose use of AI and make sure everything is reviewed.

Since the summary wasn't clear on a path forward moving to NW as good practice to have the summary filed out. Sections that don't apply can be left blank or add NA

joachim’s picture

> Since the summary wasn't clear on a path forward moving to NW as good practice to have the summary filed out

I wasn't clear on the path forward because I'm not sure what it should be -- probably one for the component maintainer to decide.

smustgrave’s picture

Good idea!