Problem/Motivation

Six interface checks in four classes use class_implements() followed by in_array(). These checks create an interface list to answer a boolean question.

Proposed resolution

  1. Use is_subclass_of(), which has supported interface checks since PHP 5.3.7, in ContextDefinition, BatchBuilder, and CKEditor5PluginDefinition.
    is_subclass_of()'s error behaviour differs as it returns FALSE for unknown classes.
    BatchBuilder and CKEditor5PluginDefinition already check class existence. ContextDefinition now throws its existing validation exception instead of producing a PHP warning followed by a TypeError. CKEditor 5 still rejects missing or NULL plugin classes.
  2. Use the existing EntityType::entityClassImplements() method in EntityDataDefinition.

Main benefits are clearer interface checks and, for invalid ContextDefinition classes, a meaningful validation exception instead of a PHP warning followed by an unrelated in_array() TypeError.

Isolated benchmarks also show small performance improvements.

Remaining tasks

Review.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork drupal-3632565

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

pancho created an issue. See original summary.

pancho’s picture

Status: Active » Needs review

Ready for review.