summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-12-06 13:03:56 (GMT)
committerNathaniel Catchpole2017-12-06 13:03:56 (GMT)
commit04dccf9472b48b14c0d8fa2c32442470291a9298 (patch)
tree8f79f5aadad080e62f7850b0af05f4589eaca8ee
parent730c5a97a97a52a234466e12affebfc024deacda (diff)
Issue #2853503 by Aki Tendo, alexpott, larowlan, Wim Leers, klausi, fgm, dawehner, mondrake, catch, Berdir, neclimdul, borisson_: Remove all assert('string') calls from Drupal core because deprecated in PHP 7.2
-rw-r--r--core/lib/Drupal/Component/Assertion/Inspector.php15
-rw-r--r--core/lib/Drupal/Component/Diff/Engine/DiffEngine.php14
-rw-r--r--core/lib/Drupal/Component/Utility/Html.php6
-rw-r--r--core/lib/Drupal/Core/Access/AccessResult.php4
-rw-r--r--core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php6
-rw-r--r--core/lib/Drupal/Core/Cache/ApcuBackend.php4
-rw-r--r--core/lib/Drupal/Core/Cache/Cache.php7
-rw-r--r--core/lib/Drupal/Core/Cache/CacheCollector.php3
-rw-r--r--core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php3
-rw-r--r--core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php2
-rw-r--r--core/lib/Drupal/Core/Cache/DatabaseBackend.php3
-rw-r--r--core/lib/Drupal/Core/Cache/MemoryBackend.php4
-rw-r--r--core/lib/Drupal/Core/Cache/PhpBackend.php4
-rw-r--r--core/lib/Drupal/Core/Entity/BundleEntityFormBase.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/DefaultPluginManager.php3
-rw-r--r--core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php4
-rw-r--r--core/modules/big_pipe/src/Render/BigPipe.php6
-rw-r--r--core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php3
-rw-r--r--core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php2
-rw-r--r--core/modules/rest/tests/src/Functional/ResourceTestBase.php4
-rw-r--r--core/modules/rest/tests/src/Kernel/Entity/ConfigDependenciesTest.php5
-rw-r--r--core/modules/views/src/Plugin/views/PluginBase.php6
23 files changed, 61 insertions, 51 deletions
diff --git a/core/lib/Drupal/Component/Assertion/Inspector.php b/core/lib/Drupal/Component/Assertion/Inspector.php
index 17cd434..dbf3f51 100644
--- a/core/lib/Drupal/Component/Assertion/Inspector.php
+++ b/core/lib/Drupal/Component/Assertion/Inspector.php
@@ -13,7 +13,7 @@ use Traversable;
*
* Example call:
* @code
- * assert('Drupal\\Component\\Assertion\\Inspector::assertAllStrings($array)');
+ * assert(Inspector::assertAllStrings($array));
* @endcode
*
* @ingroup php_assert
@@ -187,8 +187,8 @@ class Inspector {
* 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 @@ class Inspector {
* 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 e7c2941..c32017e 100644
--- a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
+++ b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
@@ -344,7 +344,7 @@ class DiffEngine {
$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 @@ class DiffEngine {
$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 @@ class DiffEngine {
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 @@ class DiffEngine {
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 @@ class DiffEngine {
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 97a14ec..353dac2 100644
--- a/core/lib/Drupal/Component/Utility/Html.php
+++ b/core/lib/Drupal/Component/Utility/Html.php
@@ -451,9 +451,9 @@ EOD;
* 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 f4962ec..0070e08 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 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable
* 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 91f702f..07df709 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -129,11 +129,11 @@ class LibraryDiscoveryParser {
// 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 d7847ff..e04e014 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 @@ class ApcuBackend implements CacheBackendInterface {
* {@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 9257aab..53aa181 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 @@ class Cache {
* 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 @@ class Cache {
* 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 b0c9f45..912b60f 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 ceb8f49..820da98 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 9a555f8..056f838 100644
--- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
+++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
@@ -100,7 +100,7 @@ class CacheContextsManager {
* 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 747186b..88f018f 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 @@ class DatabaseBackend implements CacheBackendInterface {
'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 edda4d3..99e6e3a 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 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
* {@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 2404493..d3af7f5 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 @@ class PhpBackend implements CacheBackendInterface {
* {@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 f51dd36..aa51cbc 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 5b659a0..7cb585f 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
@@ -245,7 +245,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
* 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 62260a2..389850c 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 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
* 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 8e90faa..7ca4123 100644
--- a/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php
+++ b/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php
@@ -35,7 +35,7 @@ class ChainedPlaceholderStrategy implements PlaceholderStrategyInterface {
}
// 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 @@ class ChainedPlaceholderStrategy implements PlaceholderStrategyInterface {
// 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 ef658c2..79aba6f 100644
--- a/core/modules/big_pipe/src/Render/BigPipe.php
+++ b/core/modules/big_pipe/src/Render/BigPipe.php
@@ -420,7 +420,7 @@ class BigPipe {
}
$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 @@ EOF;
* 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 @@ EOF;
* 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 94b8923..66ed363 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\Extension\ModuleHandlerInterface;
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 @@ class BigPipeResponseAttachmentsProcessor extends HtmlResponseAttachmentsProcess
* {@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 3d9f45c..3e0f460 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 @@ class BigPipeStrategy implements PlaceholderStrategyInterface {
* 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 c7dfc69..8283bef 100644
--- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php
@@ -109,7 +109,7 @@ abstract class ResourceTestBase extends BrowserTestBase {
$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 @@ abstract class ResourceTestBase extends BrowserTestBase {
$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 51ad3e9..c885990 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 @@ class ConfigDependenciesTest extends KernelTestBase {
* @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 5f9c978..7c17d2b 100644
--- a/core/modules/views/src/Plugin/views/PluginBase.php
+++ b/core/modules/views/src/Plugin/views/PluginBase.php
@@ -368,17 +368,17 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
// 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])) {