function Inspector::assertStringable
Same name in other branches
- 9 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertStringable()
- 8.9.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertStringable()
- 11.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertStringable()
Asserts argument is a string or an object castable to a string.
Use this instead of is_string() alone unless the argument being an object in any way will cause a problem.
Parameters
mixed $string: Variable to be examined
Return value
bool TRUE if $string is a string or an object castable to a string.
4 calls to Inspector::assertStringable()
- Inspector::assertAllStringable in core/
lib/ Drupal/ Component/ Assertion/ Inspector.php - Asserts all members are strings or objects with magic __toString() method.
- LayoutBuilderController::title in core/
modules/ layout_builder/ src/ Controller/ LayoutBuilderController.php - Provides a title callback.
- user_user_role_insert in core/
modules/ user/ user.module - Implements hook_ENTITY_TYPE_insert() for user_role entities.
- WorkspaceRepository::loadTree in core/
modules/ workspaces/ src/ WorkspaceRepository.php
File
-
core/
lib/ Drupal/ Component/ Assertion/ Inspector.php, line 121
Class
Namespace
Drupal\Component\AssertionCode
public static function assertStringable($string) {
return is_string($string) || is_object($string) && method_exists($string, '__toString');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.