diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 693da9a..702d4d2 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -156,18 +156,14 @@ public function getFilters() { // be used in "trans" tags. // @see TwigNodeTrans::compileString() new \Twig_SimpleFilter('placeholder', [$this, 'escapePlaceholder'], array('is_safe' => array('html'), 'needs_environment' => TRUE)), - // Replace twig's escape filter with our own. new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')), - // Implements safe joining. // @todo Make that the default for |join? Upstream issue: // https://github.com/fabpot/Twig/issues/1420 new \Twig_SimpleFilter('safe_join', [$this, 'safeJoin'], ['needs_environment' => true, 'is_safe' => ['html']]), - // Array filters. new \Twig_SimpleFilter('without', 'twig_without'), - // CSS class and ID filters. new \Twig_SimpleFilter('clean_class', '\Drupal\Component\Utility\Html::getClass'), new \Twig_SimpleFilter('clean_id', '\Drupal\Component\Utility\Html::getId'), @@ -372,6 +368,9 @@ public function attachLibrary($library) { * * @return string|null * The escaped, rendered output, or NULL if there is no valid output. + * + * @throws \Exception + * When passed $string as an object that has no __toString() method. */ public function escapePlaceholder($env, $string) { return '' . $this->escapeFilter($env, $string) . ''; @@ -400,6 +399,9 @@ public function escapePlaceholder($env, $string) { * @return string|null * The escaped, rendered output, or NULL if there is no valid output. * + * @throws \Exception + * When passed $arg is an object that has no __toString() method. + * * @todo Refactor this to keep it in sync with theme_render_and_autoescape() * in https://www.drupal.org/node/2575065 */ @@ -431,7 +433,7 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $ elseif (method_exists($arg, '__toString')) { $return = (string) $arg; } - // You can't throw exceptions in the magic PHP __toString methods, see + // You can't throw exceptions in the magic PHP __toString() methods, see // http://php.net/manual/en/language.oop5.magic.php#object.tostring so // we also support a toString method. elseif (method_exists($arg, 'toString')) { @@ -457,7 +459,6 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $ // This is a normal render array, which is safe by definition, with // special simple cases already handled. - // Early return if this element was pre-rendered (no need to re-render). if (isset($arg['#printed']) && $arg['#printed'] == TRUE && isset($arg['#markup']) && strlen($arg['#markup']) > 0) { return $arg['#markup']; @@ -469,11 +470,10 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $ /** * Wrapper around render() for twig printed output. * - * If an object is passed that has no __toString method an exception is thrown; - * other objects are casted to string. However in the case that the object is an - * instance of a Twig_Markup object it is returned directly to support auto - * escaping. - * + * If an object is passed that has no __toString() method an exception is + * thrown; Other objects are casted to string. However in the case that the + * object is an instance of a Twig_Markup object it is returned directly to + * support auto escaping. * If an array is passed it is rendered via render() and scalar values are * returned directly. * @@ -483,6 +483,9 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $ * @return mixed * The rendered output or an Twig_Markup object. * + * @throws \Exception + * When passed $arg as an object that has no __toString() method. + * * @see render * @see TwigNodeVisitor */ @@ -509,7 +512,7 @@ public function renderVar($arg) { elseif (method_exists($arg, '__toString')) { return (string) $arg; } - // You can't throw exceptions in the magic PHP __toString methods, see + // You can't throw exceptions in the magic PHP __toString() methods, see // http://php.net/manual/en/language.oop5.magic.php#object.tostring so // we also support a toString method. elseif (method_exists($arg, 'toString')) { @@ -550,9 +553,9 @@ public function safeJoin(\Twig_Environment $env, $value, $glue = '') { } return implode($glue, array_map(function($item) use ($env) { - // If $item is not marked safe then it will be escaped. - return $this->escapeFilter($env, $item, 'html', NULL, TRUE); - }, (array) $value)); + // If $item is not marked safe then it will be escaped. + return $this->escapeFilter($env, $item, 'html', NULL, TRUE); + }, (array) $value)); } } diff --git a/core/modules/contextual/src/ContextualController.php b/core/modules/contextual/src/ContextualController.php index 62ee55a..a0afafa 100644 --- a/core/modules/contextual/src/ContextualController.php +++ b/core/modules/contextual/src/ContextualController.php @@ -30,6 +30,9 @@ class ContextualController implements ContainerAwareInterface { * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. + * + * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException + * Thrown when the contextual IDs are not found. */ public function render(Request $request) { $ids = $request->request->get('ids'); diff --git a/core/modules/editor/src/EditorController.php b/core/modules/editor/src/EditorController.php index fd605cd..f491e23 100644 --- a/core/modules/editor/src/EditorController.php +++ b/core/modules/editor/src/EditorController.php @@ -60,6 +60,9 @@ public function getUntransformedText(EntityInterface $entity, $field_name, $lang * @return \Symfony\Component\HttpFoundation\JsonResponse * A JSON response containing the XSS-filtered value. * + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * Thrown when there is no value found with requested object to filter. + * * @see editor_filter_xss() */ public function filterXss(Request $request, FilterFormatInterface $filter_format) { diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index fb85d62..2b3ecd7 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -71,6 +71,9 @@ function hook_field_info_alter(&$info) { * @param \Drupal\field\FieldStorageConfigInterface $prior_field_storage * The field storage as it is pre-update. * + * @throws \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException + * Thrown when a storage definition update is forbidden. + * * @see entity_crud */ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfigInterface $field_storage, \Drupal\field\FieldStorageConfigInterface $prior_field_storage) { diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc index bd9203c..b7efaee 100644 --- a/core/modules/field/field.purge.inc +++ b/core/modules/field/field.purge.inc @@ -156,7 +156,8 @@ function field_purge_field(FieldConfigInterface $field) { * @param \Drupal\field\FieldStorageConfigInterface $field_storage * The field storage to purge. * - * @throws Drupal\field\FieldException + * @throws \Drupal\Core\Field\FieldException + * Thrown when the field storage has fields. */ function field_purge_field_storage(FieldStorageConfigInterface $field_storage) { $fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $field_storage->uuid(), 'include_deleted' => TRUE)); diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php index 8e0e0b4..2d25641 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldConfig.php @@ -88,6 +88,11 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface { * used to set the corresponding properties on the class; see the class * property documentation for details. * + * @throws \Drupal\Core\Field\FieldException + * Thrown when the given field storage is not an instance of + * FieldStorageConfigInterface and also thrown if there is no field name, + * entity type, or bundle associated. + * * @see entity_create() */ public function __construct(array $values, $entity_type = 'field_config') { diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index d4c2922..81bf66f 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -241,6 +241,11 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI * entity_create('field_storage_config', $values)), where $values is the same * parameter as in this constructor. * + * @throws \Drupal\Core\Field\FieldException + * Thrown when there is no field name, there are special characters found in + * field name, there is no field type specified, or there is no entity type + * associated. + * * @see entity_create() */ public function __construct(array $values, $entity_type = 'field_storage_config') { diff --git a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php index 9c71da4..e628f3b 100644 --- a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php +++ b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php @@ -125,6 +125,7 @@ public function normalize($entity, $format = NULL, array $context = array()) { * entity. * * @throws \Symfony\Component\Serializer\Exception\UnexpectedValueException + * Thrown when there is no type link relation specified. */ public function denormalize($data, $class, $format = NULL, array $context = array()) { // Get type, necessary for determining which bundle to create. @@ -222,6 +223,8 @@ protected function getEntityUri(EntityInterface $entity) { * @return array * The typed data IDs. * + * @throws \Symfony\Component\Serializer\Exception\UnexpectedValueException + * Thrown when there is no link type attribute found. */ protected function getTypedDataIds($types, $context = array()) { // The 'type' can potentially contain an array of type objects. By default, diff --git a/core/modules/history/src/Controller/HistoryController.php b/core/modules/history/src/Controller/HistoryController.php index 9d6c394..1441218 100644 --- a/core/modules/history/src/Controller/HistoryController.php +++ b/core/modules/history/src/Controller/HistoryController.php @@ -25,6 +25,11 @@ class HistoryController extends ControllerBase { * @param \Symfony\Component\HttpFoundation\Request $request * The request of the page. * + * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException + * AccessDeniedHttpException represents an "Access Denined for unauthorised user" + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * NotFoundHttpException represents a "Page Not found" + * * @return Symfony\Component\HttpFoundation\JsonResponse * The JSON response. */ @@ -45,8 +50,13 @@ public function getNodeReadTimestamps(Request $request) { * * @param \Symfony\Component\HttpFoundation\Request $request * The request of the page. + * * @param \Drupal\node\NodeInterface $node * The node whose "last read" timestamp should be updated. + * + * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException + * AccessDeniedHttpException represents an "Access Denined for unauthorised + * user" */ public function readNode(Request $request, NodeInterface $node) { if ($this->currentUser()->isAnonymous()) { diff --git a/core/modules/language/src/Entity/ContentLanguageSettings.php b/core/modules/language/src/Entity/ContentLanguageSettings.php index 7501012..aca58fa 100644 --- a/core/modules/language/src/Entity/ContentLanguageSettings.php +++ b/core/modules/language/src/Entity/ContentLanguageSettings.php @@ -77,6 +77,9 @@ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguag * Other array elements will be used to set the corresponding properties on * the class; see the class property documentation for details. * + * @throws \Drupal\language\ContentLanguageSettingsException + * Thrown when there is no entity type or bundle associated. + * * @see entity_create() */ public function __construct(array $values, $entity_type = 'language_content_settings') { diff --git a/core/modules/locale/src/Gettext.php b/core/modules/locale/src/Gettext.php index 4d5b65e..7cff4de 100644 --- a/core/modules/locale/src/Gettext.php +++ b/core/modules/locale/src/Gettext.php @@ -42,6 +42,9 @@ class Gettext { * @return array * Report array as defined in Drupal\locale\PoDatabaseWriter. * + * @throws \Exception + * Thrown when there is no header found. + * * @see \Drupal\locale\PoDatabaseWriter */ public static function fileToDatabase($file, $options) { diff --git a/core/modules/locale/src/PoDatabaseWriter.php b/core/modules/locale/src/PoDatabaseWriter.php index 1ee862a..37ec913 100644 --- a/core/modules/locale/src/PoDatabaseWriter.php +++ b/core/modules/locale/src/PoDatabaseWriter.php @@ -149,7 +149,9 @@ public function getHeader() { * @param \Drupal\Component\Gettext\PoHeader $header * Header metadata. * - * @throws Exception + * @throws \Exception + * Thrown when the options already exist, or the language code is not + * assigned. */ public function setHeader(PoHeader $header) { $this->header = $header; diff --git a/core/modules/quickedit/src/QuickEditController.php b/core/modules/quickedit/src/QuickEditController.php index ed26a09..08010c4 100644 --- a/core/modules/quickedit/src/QuickEditController.php +++ b/core/modules/quickedit/src/QuickEditController.php @@ -95,6 +95,9 @@ public static function create(ContainerInterface $container) { * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. + * + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * NotFoundHttpException represents a "Page Not found" */ public function metadata(Request $request) { $fields = $request->request->get('fields'); @@ -146,6 +149,9 @@ public function metadata(Request $request) { * * @return \Drupal\Core\Ajax\AjaxResponse * The Ajax response. + * + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * NotFoundHttpException represents a "Page Not found" */ public function attachments(Request $request) { $response = new AjaxResponse(); diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index af87c5b..684bf13 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -360,6 +360,9 @@ function template_preprocess_responsive_image(&$variables) { * * @return \Drupal\Core\Template\Attribute[] * An array of attributes for the source tag. + * + * @throws \LogicException + * Thrown when the image's width is not specified. */ function responsive_image_build_source_attributes(ImageInterface $image, array $variables, BreakpointInterface $breakpoint, array $multipliers) { $width = isset($variables['width']) && !empty($variables['width']) ? $variables['width'] : $image->getWidth(); diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index 5a04cd8..47d86e3 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -34,6 +34,9 @@ class RequestHandler implements ContainerAwareInterface { * * @return \Symfony\Component\HttpFoundation\Response * The response object. + * + * @throws \Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException + * UnsupportedMediaTypeHttpException represents an "Unsupported Media Type" */ public function handle(RouteMatchInterface $route_match, Request $request) { diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 2edfc81..e3032aa 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -1255,6 +1255,9 @@ protected function tearDown() { * add HTTP authentication headers. This is necessary for testing sites that * are protected by login credentials from public access. * See the description of $curl_options for other options. + * + * @throws \UnexpectedValueException + * Thrown when the specified cURL options have already been set. */ protected function curlInitialize() { global $base_url; @@ -1703,6 +1706,9 @@ protected function drupalGetXHR($path, array $options = array(), array $headers * is done by drupalPostAjaxForm(). This string is literally appended to the * POST data, so it must already be urlencoded and contain a leading "&" * (e.g., "&extra_var1=hello+world&extra_var2=you%26me"). + * + * @throws \Exception + * Thrown when there is no Ajax path specified. */ protected function drupalPostForm($path, $edit, $submit, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) { if (is_object($submit)) { @@ -1846,6 +1852,9 @@ protected function drupalPostForm($path, $edit, $submit, array $options = array( * @return * An array of Ajax commands. * + * @throws \Exception + * Thrown when there is no Ajax path specified. + * * @see drupalPostForm() * @see drupalProcessAjaxResponse() * @see ajax.js diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php index f9cfb53..e7520d4 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php @@ -121,6 +121,9 @@ public static function create(ContainerInterface $container, array $configuratio * * @return \Drupal\system\Plugin\ImageToolkit\GDToolkit * An instance of the current toolkit object. + * + * @throws \InvalidArgumentException + * Thrown when the given image resource is not valid. */ public function setResource($resource) { if (!is_resource($resource) || get_resource_type($resource) != 'gd') { diff --git a/core/modules/system/src/Tests/Routing/MockAliasManager.php b/core/modules/system/src/Tests/Routing/MockAliasManager.php index 55f2ae2..2c8c4b5 100644 --- a/core/modules/system/src/Tests/Routing/MockAliasManager.php +++ b/core/modules/system/src/Tests/Routing/MockAliasManager.php @@ -51,6 +51,9 @@ class MockAliasManager implements AliasManagerInterface { * The alias of the system path. * @param type $path_language * The language of this alias. + * + * @throws \InvalidArgumentException + * Thrown when the path or alias does not begin with a slash. */ public function addAlias($path, $alias, $path_language = NULL) { $language = $path_language ?: $this->defaultLanguage; diff --git a/core/modules/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php index 772884b..c991850 100644 --- a/core/modules/user/src/Controller/UserController.php +++ b/core/modules/user/src/Controller/UserController.php @@ -189,6 +189,10 @@ public function logout() { * * @return \Symfony\Component\HttpFoundation\RedirectResponse * A redirect response. + * + * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException + * AccessDeniedHttpException represents an "Access Denined for unauthorised + * user" */ public function confirmCancel(UserInterface $user, $timestamp = 0, $hashed_pass = '') { // Time out in seconds until cancel URL expires; 24 hours = 86400 seconds. diff --git a/core/modules/user/src/PrivateTempStore.php b/core/modules/user/src/PrivateTempStore.php index 3b5fe4a..677b873 100644 --- a/core/modules/user/src/PrivateTempStore.php +++ b/core/modules/user/src/PrivateTempStore.php @@ -115,6 +115,9 @@ public function get($key) { * The key of the data to store. * @param mixed $value * The data to store. + * + * @throws \Drupal\user\TempStoreException + * Thrown when a lock cannot be acquired. */ public function set($key, $value) { $key = $this->createkey($key); @@ -164,6 +167,9 @@ public function getMetadata($key) { * @return bool * TRUE if the object was deleted or does not exist, FALSE if it exists but * is not owned by $this->owner. + * + * @throws \Drupal\user\TempStoreException + * Thrown when a lock cannot be acquired. */ public function delete($key) { $key = $this->createkey($key); diff --git a/core/modules/user/src/SharedTempStore.php b/core/modules/user/src/SharedTempStore.php index 0a70b7f..501ed8c 100644 --- a/core/modules/user/src/SharedTempStore.php +++ b/core/modules/user/src/SharedTempStore.php @@ -190,6 +190,9 @@ public function setIfOwner($key, $value) { * The key of the data to store. * @param mixed $value * The data to store. + * + * @throws \Drupal\user\TempStoreException + * Thrown when a lock cannot be acquired. */ public function set($key, $value) { if (!$this->lockBackend->acquire($key)) { @@ -233,6 +236,9 @@ public function getMetadata($key) { * * @param string $key * The key of the data to delete. + * + * @throws \Drupal\user\TempStoreException + * Thrown when a lock cannot be acquired. */ public function delete($key) { if (!$this->lockBackend->acquire($key)) { diff --git a/core/modules/views/src/Controller/ViewAjaxController.php b/core/modules/views/src/Controller/ViewAjaxController.php index bd2f3c1..897f456 100644 --- a/core/modules/views/src/Controller/ViewAjaxController.php +++ b/core/modules/views/src/Controller/ViewAjaxController.php @@ -111,6 +111,8 @@ public static function create(ContainerInterface $container) { * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * Thrown when the view was not found. + * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException + * Thrown if either the view isn't found, or the access check fails. */ public function ajaxView(Request $request) { $name = $request->request->get('view_name'); diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 9f5d32a..0c28b20 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -1781,6 +1781,11 @@ public function hasUrl($args = NULL, $display_id = NULL) { * (optional) Specify the display ID to link to, fallback to the current ID. * * @return \Drupal\Core\Url + * The display URL object. + * + * @throws \InvalidArgumentException + * Thrown when the display plugin does not have a URL to return. + * */ public function getUrl($args = NULL, $display_id = NULL) { if (!empty($this->override_url)) { diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php index 06b835e..6811af1 100644 --- a/core/modules/views/src/Views.php +++ b/core/modules/views/src/Views.php @@ -507,6 +507,9 @@ public static function getHandlerTypes() { * * @return array * An array of plugin types. + * + * @throws \Exception + * Thrown when the type is neither plugin nor handler. */ public static function getPluginTypes($type = NULL) { if ($type === NULL) {