Was caught PhanTypeExpectedObjectPropAccess critical error by Phan tool in 1224 line of taxonomy_menu/taxonomy_menu.module "Expected an object instance when accessing an instance property, but saw an expression $t with type non-empty-array".
if (i18n_taxonomy_vocabulary_mode($t->vid, I18N_MODE_LOCALIZE)) {

During investigation I found out, that in fact variable $t is a result of _taxonomy_menu_get_item() (in taxonomy_menu.database.inc), which returns stdClass object or false on failure instead array.

function _taxonomy_menu_get_item($mlid) {
  $result = db_select('taxonomy_menu', 'tm')
    ->condition('mlid', $mlid, '=')
    ->fields('tm', array('tid', 'vid'))
    ->execute();

  return $result->fetch();
} 

Variable $result is object of DatabaseStatementBase class("\drupal\includes\database\database.inc"), which set PDO::FETCH_OBJ through constructor

  protected function __construct($dbh) {
    $this->dbh = $dbh;
    $this->setFetchMode(PDO::FETCH_OBJ);
  }

So, I suggest to change returned type of varible for _taxonomy_menu_get_item().

Comments

alena_stanul created an issue. See original summary.

alena_stanul’s picture

StatusFileSize
new480 bytes
liam morland’s picture

Issue tags: -PHP8.1, -php8 +PHP 8.1
alena_stanul’s picture

Status: Active » Needs review
hargobind’s picture

Priority: Normal » Minor
Status: Needs review » Reviewed & tested by the community

Thank you @alena_stanul for your deep analysis of this.

Although this issue is more about documentation of code, rather than the code itself, it's still helpful to get things right.

I looked into this by following your logic, and the patch in #2 checks out.

damienmckenna’s picture

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.