diff --git a/core/lib/Drupal/Component/Assertion/Inspector.php b/core/lib/Drupal/Component/Assertion/Inspector.php index 17cd434cfe1c787ffd5d00d4eb27d580f31b8c25..dbf3f511c18ecb6a78b1aceab9b5e0c64353b1bd 100644 --- a/core/lib/Drupal/Component/Assertion/Inspector.php +++ b/core/lib/Drupal/Component/Assertion/Inspector.php @@ -13,7 +13,7 @@ * * Example call: * @code - * assert('Drupal\\Component\\Assertion\\Inspector::assertAllStrings($array)'); + * assert(Inspector::assertAllStrings($array)); * @endcode * * @ingroup php_assert @@ -187,8 +187,8 @@ public static function assertAllStrictArrays($traversable) { * As an example, this assertion tests for the keys of a theme registry. * * @code - * assert('Drupal\\Component\\Assertion\\Inspector::assertAllHaveKey( - * $arrayToTest, "type", "theme path", "function", "template", "variables", "render element", "preprocess functions")'); + * assert(Inspector::assertAllHaveKey( + * $arrayToTest, "type", "theme path", "function", "template", "variables", "render element", "preprocess functions")); * @endcode * * Note: If a method requires certain keys to be present it will usually be @@ -375,16 +375,13 @@ public static function assertAllRegularExpressionMatch($pattern, $traversable) { * Here are some examples: * @code * // Just test all are objects, like a cache. - * assert('Drupal\\Component\\Assertion\\Inspector::assertAllObjects( - * $collection'); + * assert(Inspector::assertAllObjects($collection)); * * // Test if traversable objects (arrays won't pass this) - * assert('Drupal\\Component\\Assertion\\Inspector::assertAllObjects( - * $collection', \'\\Traversable\'); + * assert(Inspector::assertAllObjects($collection, '\\Traversable')); * * // Test for the Foo class or Bar\None interface - * assert('Drupal\\Component\\Assertion\\Inspector::assertAllObjects( - * $collection', \'\\Foo\', \'\\Bar\\None\''); + * assert(Inspector::assertAllObjects($collection, '\\Foo', '\\Bar\\None')); * @endcode * * @param mixed $traversable diff --git a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php index e7c2941a6222c49a1dc2a0888f93e49e8da64558..c32017e300fe88829cdd6f084f2facf7e1aa6ff4 100644 --- a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php +++ b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php @@ -344,7 +344,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { $i = 0; $j = 0; - $this::USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)'); + $this::USE_ASSERTS && assert(sizeof($lines) == sizeof($changed)); $len = sizeof($lines); $other_len = sizeof($other_changed); @@ -364,7 +364,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { $j++; } while ($i < $len && !$changed[$i]) { - $this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + $this::USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]); $i++; $j++; while ($j < $other_len && $other_changed[$j]) { @@ -400,11 +400,11 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { while ($start > 0 && $changed[$start - 1]) { $start--; } - $this::USE_ASSERTS && assert('$j > 0'); + $this::USE_ASSERTS && assert($j > 0); while ($other_changed[--$j]) { continue; } - $this::USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + $this::USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]); } /* @@ -427,7 +427,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { while ($i < $len && $changed[$i]) { $i++; } - $this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + $this::USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]); $j++; if ($j < $other_len && $other_changed[$j]) { $corresponding = $i; @@ -445,11 +445,11 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { while ($corresponding < $i) { $changed[--$start] = 1; $changed[--$i] = 0; - $this::USE_ASSERTS && assert('$j > 0'); + $this::USE_ASSERTS && assert($j > 0); while ($other_changed[--$j]) { continue; } - $this::USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + $this::USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]); } } } diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php index 97a14ecaf1d32edfb1fa97d0656f03434eb89060..353dac280ed52c3e309772446f4571809acb426c 100644 --- a/core/lib/Drupal/Component/Utility/Html.php +++ b/core/lib/Drupal/Component/Utility/Html.php @@ -451,9 +451,9 @@ public static function escape($text) { * The updated (X)HTML snippet. */ public static function transformRootRelativeUrlsToAbsolute($html, $scheme_and_host) { - assert('empty(array_diff(array_keys(parse_url($scheme_and_host)), ["scheme", "host", "port"]))', '$scheme_and_host contains scheme, host and port at most.'); - assert('isset(parse_url($scheme_and_host)["scheme"])', '$scheme_and_host is absolute and hence has a scheme.'); - assert('isset(parse_url($scheme_and_host)["host"])', '$base_url is absolute and hence has a host.'); + assert(empty(array_diff(array_keys(parse_url($scheme_and_host)), ["scheme", "host", "port"])), '$scheme_and_host contains scheme, host and port at most.'); + assert(isset(parse_url($scheme_and_host)["scheme"]), '$scheme_and_host is absolute and hence has a scheme.'); + assert(isset(parse_url($scheme_and_host)["host"]), '$base_url is absolute and hence has a host.'); $html_dom = Html::load($html); $xpath = new \DOMXpath($html_dom); diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php index f4962ec596944a6f375fa5e573b3d6209b85bd24..0070e089320cdb2883b4ca54bdf4d791e9ea8730 100644 --- a/core/lib/Drupal/Core/Access/AccessResult.php +++ b/core/lib/Drupal/Core/Access/AccessResult.php @@ -39,7 +39,7 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable * isNeutral() will be TRUE. */ public static function neutral($reason = NULL) { - assert('is_string($reason) || is_null($reason)'); + assert(is_string($reason) || is_null($reason)); return new AccessResultNeutral($reason); } @@ -64,7 +64,7 @@ public static function allowed() { * isForbidden() will be TRUE. */ public static function forbidden($reason = NULL) { - assert('is_string($reason) || is_null($reason)'); + assert(is_string($reason) || is_null($reason)); return new AccessResultForbidden($reason); } diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index 91f702ffac11d05bea5323fe855b79634cd6ed36..07df7090298f2d71ee58b94daca04ad821a5c62d 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -129,11 +129,11 @@ public function buildByExtension($extension) { // properly resolve dependencies for all (css) libraries per category, // and only once prior to rendering out an HTML page. if ($type == 'css' && !empty($library[$type])) { - assert('\Drupal\Core\Asset\LibraryDiscoveryParser::validateCssLibrary($library[$type]) < 2', 'CSS files should be specified as key/value pairs, where the values are configuration options. See https://www.drupal.org/node/2274843.'); - assert('\Drupal\Core\Asset\LibraryDiscoveryParser::validateCssLibrary($library[$type]) === 0', 'CSS must be nested under a category. See https://www.drupal.org/node/2274843.'); + assert(static::validateCssLibrary($library[$type]) < 2, 'CSS files should be specified as key/value pairs, where the values are configuration options. See https://www.drupal.org/node/2274843.'); + assert(static::validateCssLibrary($library[$type]) === 0, 'CSS must be nested under a category. See https://www.drupal.org/node/2274843.'); foreach ($library[$type] as $category => $files) { $category_weight = 'CSS_' . strtoupper($category); - assert('defined($category_weight)', 'Invalid CSS category: ' . $category . '. See https://www.drupal.org/node/2274843.'); + assert(defined($category_weight), 'Invalid CSS category: ' . $category . '. See https://www.drupal.org/node/2274843.'); foreach ($files as $source => $options) { if (!isset($options['weight'])) { $options['weight'] = 0; diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index d7847ffb8d4d6e00b529fc5c4fa207f6ff6e5363..e04e0141523bc0ab897ea25f2e03e827fbcd0aab 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -2,6 +2,8 @@ namespace Drupal\Core\Cache; +use Drupal\Component\Assertion\Inspector; + /** * Stores cache items in the Alternative PHP Cache User Cache (APCu). */ @@ -161,7 +163,7 @@ protected function prepareItem($cache, $allow_invalid) { * {@inheritdoc} */ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = []) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.'); + assert(Inspector::assertAllStrings($tags), 'Cache tags must be strings.'); $tags = array_unique($tags); $cache = new \stdClass(); $cache->cid = $cid; diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php index 9257aab3f69d04ad27c7e7d8ed590495706bf402..53aa1810aefb2ce1dba67c8922993a9af107194d 100644 --- a/core/lib/Drupal/Core/Cache/Cache.php +++ b/core/lib/Drupal/Core/Cache/Cache.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Cache; +use Drupal\Component\Assertion\Inspector; use Drupal\Core\Database\Query\SelectInterface; /** @@ -29,7 +30,7 @@ class Cache { */ public static function mergeContexts(array $a = [], array $b = []) { $cache_contexts = array_unique(array_merge($a, $b)); - assert('\Drupal::service(\'cache_contexts_manager\')->assertValidTokens($cache_contexts)'); + assert(\Drupal::service('cache_contexts_manager')->assertValidTokens($cache_contexts)); sort($cache_contexts); return $cache_contexts; } @@ -54,7 +55,7 @@ public static function mergeContexts(array $a = [], array $b = []) { * The merged array of cache tags. */ public static function mergeTags(array $a = [], array $b = []) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($a) && \Drupal\Component\Assertion\Inspector::assertAllStrings($b)', 'Cache tags must be valid strings'); + assert(Inspector::assertAllStrings($a) && Inspector::assertAllStrings($b), 'Cache tags must be valid strings'); $cache_tags = array_unique(array_merge($a, $b)); sort($cache_tags); @@ -96,7 +97,7 @@ public static function mergeMaxAges($a = Cache::PERMANENT, $b = Cache::PERMANENT * An array of cache tags. * * @deprecated - * Use assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)'); + * Use assert(Inspector::assertAllStrings($tags)); * * @throws \LogicException */ diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php index b0c9f45b1923ab2e78fd511288614c1f4ff567f1..912b60f943f5c7ea5b5a0a0cf9a67c28e7d4cdc2 100644 --- a/core/lib/Drupal/Core/Cache/CacheCollector.php +++ b/core/lib/Drupal/Core/Cache/CacheCollector.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Cache; +use Drupal\Component\Assertion\Inspector; use Drupal\Component\Utility\Crypt; use Drupal\Core\DestructableInterface; use Drupal\Core\Lock\LockBackendInterface; @@ -111,7 +112,7 @@ abstract class CacheCollector implements CacheCollectorInterface, DestructableIn * (optional) The tags to specify for the cache item. */ public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = []) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.'); + assert(Inspector::assertAllStrings($tags), 'Cache tags must be strings.'); $this->cid = $cid; $this->cache = $cache; $this->tags = $tags; diff --git a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php index ceb8f49e88f518571926ec51b2f23e7f8a14d6bc..820da9886bda0b2d38cddc5c71e7ba8a68cbeb1b 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php +++ b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Cache; +use Drupal\Component\Assertion\Inspector; use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** @@ -22,7 +23,7 @@ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface { * {@inheritdoc} */ public function invalidateTags(array $tags) { - assert('Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.'); + assert(Inspector::assertAllStrings($tags), 'Cache tags must be strings.'); // Notify all added cache tags invalidators. foreach ($this->invalidators as $invalidator) { diff --git a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php index 9a555f8bf1aa8a9b27e855eaebd0960d85d8b6ae..056f838c04a4e87e745bcba06c94dab55422017c 100644 --- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php +++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php @@ -100,7 +100,7 @@ public function getLabels($include_calculated_cache_contexts = FALSE) { * cacheability metadata. */ public function convertTokensToKeys(array $context_tokens) { - assert('$this->assertValidTokens($context_tokens)'); + assert($this->assertValidTokens($context_tokens)); $cacheable_metadata = new CacheableMetadata(); $optimized_tokens = $this->optimizeTokens($context_tokens); // Iterate over cache contexts that have been optimized away and get their diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 747186b9b7cda737bb2ef8c9ae7fef142d76cec9..88f018f8cc535088f29c6237fb9a0e1f3a3469cb 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Cache; +use Drupal\Component\Assertion\Inspector; use Drupal\Component\Utility\Crypt; use Drupal\Core\Database\Connection; use Drupal\Core\Database\SchemaObjectExistsException; @@ -222,7 +223,7 @@ protected function doSetMultiple(array $items) { 'tags' => [], ]; - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($item[\'tags\'])', 'Cache Tags must be strings.'); + assert(Inspector::assertAllStrings($item['tags']), 'Cache Tags must be strings.'); $item['tags'] = array_unique($item['tags']); // Sort the cache tags so that they are stored consistently in the DB. sort($item['tags']); diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index edda4d37f94dbf7bf3e1cda3b453729655fbfa89..99e6e3a3c60f7cee12d3fe45fd5259f5856b037e 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -2,6 +2,8 @@ namespace Drupal\Core\Cache; +use Drupal\Component\Assertion\Inspector; + /** * Defines a memory cache implementation. * @@ -98,7 +100,7 @@ protected function prepareItem($cache, $allow_invalid) { * {@inheritdoc} */ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.'); + assert(Inspector::assertAllStrings($tags), 'Cache Tags must be strings.'); $tags = array_unique($tags); // Sort the cache tags so that they are stored consistently in the database. sort($tags); diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index 2404493404f13992d86ad9e12e15cbda67d96a43..d3af7f5843461a55238ccf58a8ff78b7c0cce78c 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Cache; +use Drupal\Component\Assertion\Inspector; use Drupal\Core\PhpStorage\PhpStorageFactory; use Drupal\Component\Utility\Crypt; @@ -143,7 +144,8 @@ protected function prepareItem($cache, $allow_invalid) { * {@inheritdoc} */ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.'); + assert(Inspector::assertAllStrings($tags), 'Cache Tags must be strings.'); + $item = (object) [ 'cid' => $cid, 'data' => $data, diff --git a/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php b/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php index f51dd361cfbce72970cb25c434210115ffe09821..aa51cbcaac88ab262837c32fdcc6dfeb78e3018f 100644 --- a/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php +++ b/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php @@ -22,7 +22,7 @@ class BundleEntityFormBase extends EntityForm { protected function protectBundleIdElement(array $form) { $entity = $this->getEntity(); $id_key = $entity->getEntityType()->getKey('id'); - assert('isset($form[$id_key])'); + assert(isset($form[$id_key])); $element = &$form[$id_key]; // Make sure the element is not accidentally re-enabled if it has already diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 5b659a048dff1b9caab0fba45359f41ad8afba43..7cb585f5fc651990bfbb27988158a81974db611d 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -245,7 +245,7 @@ public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterfac * The schema data. */ protected function getSchemaFromStorageDefinition(FieldStorageDefinitionInterface $storage_definition) { - assert('!$storage_definition->hasCustomStorage();'); + assert(!$storage_definition->hasCustomStorage()); $table_mapping = $this->storage->getTableMapping(); $schema = []; if ($table_mapping->requiresDedicatedTableStorage($storage_definition)) { diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index 62260a2e23812cbe661495166d1a52a8865ef447..389850c2249d559de5cea5c4a92be8297e85a940 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Plugin; +use Drupal\Component\Assertion\Inspector; use Drupal\Component\Plugin\Definition\PluginDefinitionInterface; use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface; use Drupal\Core\Cache\CacheableDependencyInterface; @@ -148,7 +149,7 @@ public function __construct($subdir, \Traversable $namespaces, ModuleHandlerInte * definitions should be cleared along with other, related cache entries. */ public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = []) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($cache_tags)', 'Cache Tags must be strings.'); + assert(Inspector::assertAllStrings($cache_tags), 'Cache Tags must be strings.'); $this->cacheBackend = $cache_backend; $this->cacheKey = $cache_key; $this->cacheTags = $cache_tags; diff --git a/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php b/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php index 8e90faae86da7ac3365267fa7f213191a6bb9cfb..7ca41237b431e7387fa15e20848faad8e1f9a428 100644 --- a/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php +++ b/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php @@ -35,7 +35,7 @@ public function processPlaceholders(array $placeholders) { } // Assert that there is at least one strategy. - assert('!empty($this->placeholderStrategies)', 'At least one placeholder strategy must be present; by default the fallback strategy \Drupal\Core\Render\Placeholder\SingleFlushStrategy is always present.'); + assert(!empty($this->placeholderStrategies), 'At least one placeholder strategy must be present; by default the fallback strategy \Drupal\Core\Render\Placeholder\SingleFlushStrategy is always present.'); $new_placeholders = []; @@ -44,7 +44,7 @@ public function processPlaceholders(array $placeholders) { // and this uses a variation of the "chain of responsibility" design pattern. foreach ($this->placeholderStrategies as $strategy) { $processed_placeholders = $strategy->processPlaceholders($placeholders); - assert('array_intersect_key($processed_placeholders, $placeholders) === $processed_placeholders', 'Processed placeholders must be a subset of all placeholders.'); + assert(array_intersect_key($processed_placeholders, $placeholders) === $processed_placeholders, 'Processed placeholders must be a subset of all placeholders.'); $placeholders = array_diff_key($placeholders, $processed_placeholders); $new_placeholders += $processed_placeholders; diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php index ef658c275023b26dddc05b79c4edb8df99422f53..79aba6f9d64d234f3045fdc4d717be0f23234c41 100644 --- a/core/modules/big_pipe/src/Render/BigPipe.php +++ b/core/modules/big_pipe/src/Render/BigPipe.php @@ -420,7 +420,7 @@ protected function sendNoJsPlaceholders($html, $no_js_placeholders, AttachedAsse } $placeholder = $fragment; - assert('isset($no_js_placeholders[$placeholder])'); + assert(isset($no_js_placeholders[$placeholder])); $token = Crypt::randomBytesBase64(55); // Render the placeholder, but include the cumulative settings assets, so @@ -629,7 +629,7 @@ protected function sendPlaceholders(array $placeholders, array $placeholder_orde * AJAX page state. */ protected function filterEmbeddedResponse(Request $fake_request, Response $embedded_response) { - assert('$embedded_response instanceof \Drupal\Core\Render\HtmlResponse || $embedded_response instanceof \Drupal\Core\Ajax\AjaxResponse'); + assert($embedded_response instanceof HtmlResponse || $embedded_response instanceof AjaxResponse); return $this->filterResponse($fake_request, HttpKernelInterface::SUB_REQUEST, $embedded_response); } @@ -649,7 +649,7 @@ protected function filterEmbeddedResponse(Request $fake_request, Response $embed * The filtered response. */ protected function filterResponse(Request $request, $request_type, Response $response) { - assert('$request_type === \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST || $request_type === \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST'); + assert($request_type === HttpKernelInterface::MASTER_REQUEST || $request_type === HttpKernelInterface::SUB_REQUEST); $this->requestStack->push($request); $event = new FilterResponseEvent($this->httpKernel, $request, $request_type, $response); $this->eventDispatcher->dispatch(KernelEvents::RESPONSE, $event); diff --git a/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php b/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php index 94b8923700ddbd41a9a004bf68770cb279dd5641..66ed363b6c0f1d0840ca6da1b8495c1440bd8e85 100644 --- a/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php +++ b/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\EnforcedResponseException; use Drupal\Core\Render\AttachmentsInterface; use Drupal\Core\Render\AttachmentsResponseProcessorInterface; +use Drupal\Core\Render\HtmlResponse; use Drupal\Core\Render\HtmlResponseAttachmentsProcessor; use Drupal\Core\Render\RendererInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -57,7 +58,7 @@ public function __construct(AttachmentsResponseProcessorInterface $html_response * {@inheritdoc} */ public function processAttachments(AttachmentsInterface $response) { - assert('$response instanceof \Drupal\Core\Render\HtmlResponse'); + assert($response instanceof HtmlResponse); // First, render the actual placeholders; this will cause the BigPipe // placeholder strategy to generate BigPipe placeholders. We need those to diff --git a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php index 3d9f45cf3e8ff0f3dbe55082a933051883214428..3e0f460e9a12309daaa0776c549807dff514ae8f 100644 --- a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php +++ b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php @@ -180,7 +180,7 @@ protected function doProcessPlaceholders(array $placeholders) { * a placeholder for a HTML attribute value or a subset of it). */ protected static function placeholderIsAttributeSafe($placeholder) { - assert('is_string($placeholder)'); + assert(is_string($placeholder)); return $placeholder[0] !== '<' || $placeholder !== Html::normalize($placeholder); } diff --git a/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/core/modules/rest/tests/src/Functional/ResourceTestBase.php index c7dfc69999aec99b57feb7f2f9e2ae97ba09bd00..8283bef260010b79991644347312b690023e3af7 100644 --- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php @@ -109,7 +109,7 @@ public function setUp() { $user_role->revokePermission($permission); } $user_role->save(); - assert('[] === $user_role->getPermissions()', 'The anonymous user role has no permissions at all.'); + assert([] === $user_role->getPermissions(), 'The anonymous user role has no permissions at all.'); if (static::$auth !== FALSE) { // Ensure the authenticated user role has no permissions at all. @@ -118,7 +118,7 @@ public function setUp() { $user_role->revokePermission($permission); } $user_role->save(); - assert('[] === $user_role->getPermissions()', 'The authenticated user role has no permissions at all.'); + assert([] === $user_role->getPermissions(), 'The authenticated user role has no permissions at all.'); // Create an account. $this->account = $this->createUser(); diff --git a/core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php b/core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php index 51ad3e977f088067988445f71990f37353ea5679..c885990ff7414fe4ecba2bb566720840572c57cd 100644 --- a/core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php +++ b/core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php @@ -202,8 +202,9 @@ public function testOnDependencyRemovalRemoveAuthAndFormats() { * @dataProvider providerOnDependencyRemovalForResourceGranularity */ public function testOnDependencyRemovalForResourceGranularity(array $configuration, $module, $expected_configuration) { - assert('is_string($module)'); - assert('$expected_configuration === FALSE || is_array($expected_configuration)'); + assert(is_string($module)); + assert($expected_configuration === FALSE || is_array($expected_configuration)); + $config_dependencies = new ConfigDependencies(['hal_json' => 'hal', 'json' => 'serialization'], ['basic_auth' => 'basic_auth']); $rest_config = RestResourceConfig::create($configuration); diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index 5f9c9788de31d547141fa5a319732b012b6955b4..7c17d2bf9b71fdebda179431e591a664d784a331 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -368,17 +368,17 @@ protected function viewsTokenReplace($text, $tokens) { // We need to validate tokens are valid Twig variables. Twig uses the // same variable naming rules as PHP. // @see http://php.net/manual/language.variables.basics.php - assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $token) === 1', 'Tokens need to be valid Twig variables.'); + assert(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $token) === 1, 'Tokens need to be valid Twig variables.'); $twig_tokens[$token] = $replacement; } else { $parts = explode('.', $token); $top = array_shift($parts); - assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $top) === 1', 'Tokens need to be valid Twig variables.'); + assert(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $top) === 1, 'Tokens need to be valid Twig variables.'); $token_array = [array_pop($parts) => $replacement]; foreach (array_reverse($parts) as $key) { // The key could also be numeric (array index) so allow that. - assert('is_numeric($key) || (preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1)', 'Tokens need to be valid Twig variables.'); + assert(is_numeric($key) || preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $key) === 1, 'Tokens need to be valid Twig variables.'); $token_array = [$key => $token_array]; } if (!isset($twig_tokens[$top])) {