upgrades core to 8.4.2

This commit is contained in:
Bachir Soussi Chiadmi
2017-11-14 16:09:54 +01:00
parent bd60eff9b3
commit c2b4e25be4
3504 changed files with 140306 additions and 38684 deletions
@@ -30,7 +30,7 @@ class MockFileFinder implements ClassFinderInterface {
/**
* Creates new mock file finder objects.
*/
static public function create($filename) {
public static function create($filename) {
$object = new static();
$object->filename = $filename;
return $object;
@@ -8,9 +8,9 @@
"php": ">=5.5.9",
"doctrine/common": "2.5.*",
"doctrine/annotations": "1.2.*",
"drupal/core-fileCache": "~8.2",
"drupal/core-plugin": "~8.2",
"drupal/core-utility": "~8.2"
"drupal/core-file-cache": "^8.2",
"drupal/core-plugin": "^8.2",
"drupal/core-utility": "^8.2"
},
"autoload": {
"psr-4": {
@@ -25,7 +25,7 @@ class Handle {
require __DIR__ . '/global_namespace_php5.php';
}
// PHP 5 - create a handler to throw the exception directly.
assert_options(ASSERT_CALLBACK, function($file = '', $line = 0, $code = '', $message = '') {
assert_options(ASSERT_CALLBACK, function ($file = '', $line = 0, $code = '', $message = '') {
if (empty($message)) {
$message = $code;
}
@@ -205,9 +205,9 @@ class Inspector {
* @return bool
* TRUE if $traversable can be traversed and all members have all keys.
*/
public static function assertAllHaveKey() {
public static function assertAllHaveKey($traversable) {
$args = func_get_args();
$traversable = array_shift($args);
unset($args[0]);
if (static::assertTraversable($traversable)) {
foreach ($traversable as $member) {
@@ -396,9 +396,9 @@ class Inspector {
* TRUE if $traversable can be traversed and all members are objects with
* at least one of the listed classes or interfaces.
*/
public static function assertAllObjects() {
public static function assertAllObjects($traversable) {
$args = func_get_args();
$traversable = array_shift($args);
unset($args[0]);
if (static::assertTraversable($traversable)) {
foreach ($traversable as $member) {
@@ -6,7 +6,7 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"zendframework/zend-feed": "~2.4"
"zendframework/zend-feed": "^2.4"
},
"autoload": {
"psr-4": {
@@ -1,6 +1,7 @@
<?php
namespace Drupal\Component\Datetime;
use Drupal\Component\Utility\ToStringTrait;
/**
@@ -250,7 +251,11 @@ class DateTimePlus {
* (optional) A date/time string. Defaults to 'now'.
* @param mixed $timezone
* (optional) \DateTimeZone object, time zone string or NULL. NULL uses the
* default system time zone. Defaults to NULL.
* default system time zone. Defaults to NULL. Note that the $timezone
* parameter and the current timezone are ignored when the $time parameter
* either is a UNIX timestamp (e.g. @946684800) or specifies a timezone
* (e.g. 2010-01-28T15:00:00+02:00).
* @see http://php.net/manual/en/datetime.construct.php
* @param array $settings
* (optional) Keyed array of settings. Defaults to empty array.
* - langcode: (optional) String two letter language code used to control
@@ -301,8 +306,25 @@ class DateTimePlus {
* Implements the magic __call method.
*
* Passes through all unknown calls onto the DateTime object.
*
* @param string $method
* The method to call on the decorated object.
* @param array $args
* Call arguments.
*
* @return mixed
* The return value from the method on the decorated object. If the proxied
* method call returns a DateTime object, then return the original
* DateTimePlus object, which allows function chaining to work properly.
* Otherwise, the value from the proxied method call is returned.
*
* @throws \Exception
* Thrown when the DateTime object is not set.
* @throws \BadMethodCallException
* Thrown when there is no corresponding method on the DateTime object to
* call.
*/
public function __call($method, $args) {
public function __call($method, array $args) {
// @todo consider using assert() as per https://www.drupal.org/node/2451793.
if (!isset($this->dateTimeObject)) {
throw new \Exception('DateTime object not set.');
@@ -310,19 +332,22 @@ class DateTimePlus {
if (!method_exists($this->dateTimeObject, $method)) {
throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $method));
}
return call_user_func_array([$this->dateTimeObject, $method], $args);
$result = call_user_func_array([$this->dateTimeObject, $method], $args);
return $result === $this->dateTimeObject ? $this : $result;
}
/**
* Returns the difference between two DateTimePlus objects.
*
* @param \Drupal\Component\Datetime\DateTimePlus|\DateTime $datetime2
* The date to compare to.
* The date to compare to.
* @param bool $absolute
* Should the interval be forced to be positive?
* Should the interval be forced to be positive?
*
* @return \DateInterval
* A DateInterval object representing the difference between the two dates.
* A DateInterval object representing the difference between the two dates.
*
* @throws \BadMethodCallException
* If the input isn't a DateTime or DateTimePlus object.
@@ -428,7 +453,6 @@ class DateTimePlus {
}
/**
* Examines getLastErrors() to see what errors to report.
*
@@ -627,8 +651,9 @@ class DateTimePlus {
* - timezone: (optional) String timezone name. Defaults to the timezone
* of the date object.
*
* @return string
* The formatted value of the date.
* @return string|null
* The formatted value of the date or NULL if there were construction
* errors.
*/
public function format($format, $settings = []) {
@@ -6,7 +6,7 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"drupal/core-utility": "~8.2"
"drupal/core-utility": "^8.2"
},
"autoload": {
"psr-4": {
@@ -3,9 +3,7 @@
namespace Drupal\Component\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\IntrospectableContainerInterface;
use Symfony\Component\DependencyInjection\ResettableContainerInterface;
use Symfony\Component\DependencyInjection\ScopeInterface;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
@@ -43,14 +41,10 @@ use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceExce
* getAServiceWithAnIdByCamelCase().
* - The function getServiceIds() was added as it has a use-case in core and
* contrib.
* - Scopes are explicitly not allowed, because Symfony 2.8 has deprecated
* them and they will be removed in Symfony 3.0.
* - Synchronized services are explicitly not supported, because Symfony 2.8 has
* deprecated them and they will be removed in Symfony 3.0.
*
* @ingroup container
*/
class Container implements IntrospectableContainerInterface, ResettableContainerInterface {
class Container implements ContainerInterface, ResettableContainerInterface {
/**
* The parameters of the container.
@@ -311,12 +305,8 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
}
}
// Share the service if it is public.
if (!isset($definition['public']) || $definition['public'] !== FALSE) {
// Forward compatibility fix for Symfony 2.8 update.
if (!isset($definition['shared']) || $definition['shared'] !== FALSE) {
$this->services[$id] = $service;
}
if (!isset($definition['shared']) || $definition['shared'] !== FALSE) {
$this->services[$id] = $service;
}
if (isset($definition['calls'])) {
@@ -361,11 +351,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
/**
* {@inheritdoc}
*/
public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) {
if (!in_array($scope, ['container', 'request']) || ('request' === $scope && 'request' !== $id)) {
@trigger_error('The concept of container scopes is deprecated since version 2.8 and will be removed in 3.0. Omit the third parameter.', E_USER_DEPRECATED);
}
public function set($id, $service) {
$this->services[$id] = $service;
}
@@ -587,61 +573,6 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
return $this->getAlternatives($name, array_keys($this->parameters));
}
/**
* {@inheritdoc}
*/
public function enterScope($name) {
if ('request' !== $name) {
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
}
throw new \BadMethodCallException(sprintf("'%s' is not supported by Drupal 8.", __FUNCTION__));
}
/**
* {@inheritdoc}
*/
public function leaveScope($name) {
if ('request' !== $name) {
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
}
throw new \BadMethodCallException(sprintf("'%s' is not supported by Drupal 8.", __FUNCTION__));
}
/**
* {@inheritdoc}
*/
public function addScope(ScopeInterface $scope) {
$name = $scope->getName();
if ('request' !== $name) {
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
}
throw new \BadMethodCallException(sprintf("'%s' is not supported by Drupal 8.", __FUNCTION__));
}
/**
* {@inheritdoc}
*/
public function hasScope($name) {
if ('request' !== $name) {
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
}
throw new \BadMethodCallException(sprintf("'%s' is not supported by Drupal 8.", __FUNCTION__));
}
/**
* {@inheritdoc}
*/
public function isScopeActive($name) {
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
throw new \BadMethodCallException(sprintf("'%s' is not supported by Drupal 8.", __FUNCTION__));
}
/**
* Gets all defined service IDs.
*
@@ -237,18 +237,6 @@ class OptimizedPhpArrayDumper extends Dumper {
$service['calls'] = $this->dumpMethodCalls($definition->getMethodCalls());
}
if (($scope = $definition->getScope()) !== ContainerInterface::SCOPE_CONTAINER) {
if ($scope === ContainerInterface::SCOPE_PROTOTYPE) {
// Scope prototype has been replaced with 'shared' => FALSE.
// This is a Symfony 2.8 forward compatibility fix.
// Reference: https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#dependencyinjection
$service['shared'] = FALSE;
}
else {
throw new InvalidArgumentException("The 'scope' definition is deprecated in Symfony 3.0 and not supported by Drupal 8.");
}
}
// By default services are shared, so just provide the flag, when needed.
if ($definition->isShared() === FALSE) {
$service['shared'] = $definition->isShared();
@@ -136,12 +136,8 @@ class PhpArrayContainer extends Container {
}
}
// Share the service if it is public.
if (!isset($definition['public']) || $definition['public'] !== FALSE) {
// Forward compatibility fix for Symfony 2.8 update.
if (!isset($definition['shared']) || $definition['shared'] !== FALSE) {
$this->services[$id] = $service;
}
if (!isset($definition['shared']) || $definition['shared'] !== FALSE) {
$this->services[$id] = $service;
}
if (isset($definition['calls'])) {
@@ -12,7 +12,7 @@
},
"require": {
"php": ">=5.5.9",
"symfony/dependency-injection": "~2.8"
"symfony/dependency-injection": "^2.8"
},
"suggest": {
"symfony/expression-language": "For using expressions in service container configuration"
+7 -5
View File
@@ -27,9 +27,11 @@ class Diff {
* Constructor.
* Computes diff between sequences of strings.
*
* @param $from_lines array An array of strings.
* (Typically these are lines from a file.)
* @param $to_lines array An array of strings.
* @param array $from_lines
* An array of strings.
* (Typically these are lines from a file.)
* @param array $to_lines
* An array of strings.
*/
public function __construct($from_lines, $to_lines) {
$eng = new DiffEngine();
@@ -44,8 +46,8 @@ class Diff {
*
* $diff = new Diff($lines1, $lines2);
* $rev = $diff->reverse();
* @return object A Diff object representing the inverse of the
* original diff.
* @return object
* A Diff object representing the inverse of the original diff.
*/
public function reverse() {
$rev = $this;
@@ -195,7 +195,7 @@ class DiffEngine {
}
$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
for ( ; $x < $x1; $x++) {
for (; $x < $x1; $x++) {
$line = $flip ? $this->yv[$x] : $this->xv[$x];
if (empty($ymatches[$line])) {
continue;
@@ -302,8 +302,7 @@ class DiffEngine {
//$nchunks = sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5);
//$nchunks = max(2, min(8, (int)$nchunks));
$nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1;
list($lcs, $seps)
= $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
list($lcs, $seps) = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
}
if ($lcs == 0) {
+10 -9
View File
@@ -19,16 +19,17 @@ class MappedDiff extends Diff {
* case-insensitive diffs, or diffs which ignore
* changes in white-space.
*
* @param $from_lines array An array of strings.
* @param array $from_lines
* An array of strings.
* (Typically these are lines from a file.)
* @param $to_lines array An array of strings.
* @param $mapped_from_lines array This array should
* have the same size number of elements as $from_lines.
* The elements in $mapped_from_lines and
* $mapped_to_lines are what is actually compared
* when computing the diff.
* @param $mapped_to_lines array This array should
* have the same number of elements as $to_lines.
* @param array $to_lines
* An array of strings.
* @param array $mapped_from_lines
* This array should have the same size number of elements as $from_lines.
* The elements in $mapped_from_lines and $mapped_to_lines are what is
* actually compared when computing the diff.
* @param array $mapped_to_lines
* This array should have the same number of elements as $to_lines.
*/
public function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) {
+1 -1
View File
@@ -6,7 +6,7 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"drupal/utility": "~8.2"
"drupal/core-utility": "^8.2"
},
"autoload": {
"psr-4": {
@@ -6,8 +6,8 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"drupal/core-filecache": "~8.2",
"drupal/core-serialization": "~8.2"
"drupal/core-file-cache": "^8.2",
"drupal/core-serialization": "^8.2"
},
"autoload": {
"psr-4": {
@@ -2,7 +2,7 @@
namespace Drupal\Component\EventDispatcher;
use Symfony\Component\DependencyInjection\IntrospectableContainerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -36,7 +36,7 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
/**
* The service container.
*
* @var \Symfony\Component\DependencyInjection\IntrospectableContainerInterface;
* @var \Symfony\Component\DependencyInjection\ContainerInterface;
*/
protected $container;
@@ -66,7 +66,7 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
/**
* Constructs a container aware event dispatcher.
*
* @param \Symfony\Component\DependencyInjection\IntrospectableContainerInterface $container
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The service container.
* @param array $listeners
* A nested array of listener definitions keyed by event name and priority.
@@ -77,7 +77,7 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
* A service entry will be resolved to a callable only just before its
* invocation.
*/
public function __construct(IntrospectableContainerInterface $container, array $listeners = []) {
public function __construct(ContainerInterface $container, array $listeners = []) {
$this->container = $container;
$this->listeners = $listeners;
$this->unsorted = [];
@@ -91,9 +91,6 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
$event = new Event();
}
$event->setDispatcher($this);
$event->setName($event_name);
if (isset($this->listeners[$event_name])) {
// Sort listeners if necessary.
if (isset($this->unsorted[$event_name])) {
@@ -6,8 +6,8 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"symfony/dependency-injection": "~2.8",
"symfony/event-dispatcher": "~2.7"
"symfony/dependency-injection": "^2.8",
"symfony/event-dispatcher": "^2.7"
},
"autoload": {
"psr-4": {
@@ -15,7 +15,7 @@ class FileCacheFactory {
/**
* The configuration used to create FileCache objects.
*
* @var array $configuration
* @var array
*/
protected static $configuration;
+2 -2
View File
@@ -104,7 +104,7 @@ class PoItem {
* Set the source string or the array of strings if the translation has
* plurals.
*
* @param string or array $source
* @param string|array $source
*/
public function setSource($source) {
$this->_source = $source;
@@ -124,7 +124,7 @@ class PoItem {
* Set the translation string or the array of strings if the translation has
* plurals.
*
* @param string or array $translation
* @param string|array $translation
*/
public function setTranslation($translation) {
$this->_translation = $translation;
@@ -104,7 +104,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
* If writing the data is not possible.
*/
private function write($data) {
$result = fputs($this->_fd, $data);
$result = fwrite($this->_fd, $data);
if ($result === FALSE) {
throw new Exception('Unable to write data: ' . substr($data, 0, 20));
}
@@ -10,7 +10,7 @@
},
"require": {
"php": ">=5.5.9",
"drupal/core-utility": "~8.2"
"drupal/core-utility": "^8.2"
},
"autoload": {
"psr-4": {
@@ -2,7 +2,7 @@
namespace Drupal\Component\HttpFoundation;
use \Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Provides a common base class for safe redirects.
@@ -6,7 +6,7 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"symfony/http-foundation": "~2.7"
"symfony/http-foundation": "^2.7"
},
"autoload": {
"psr-4": {
@@ -44,7 +44,7 @@ interface PhpStorageInterface {
* @param string $name
* The virtual file name. Can be a relative path.
* @param string $code
* The PHP code to be saved.
* The PHP code to be saved.
*
* @return bool
* TRUE if the save succeeded, FALSE if it failed.
@@ -2,7 +2,7 @@
namespace Drupal\Component\Plugin;
use \Drupal\Component\Plugin\Context\ContextInterface;
use Drupal\Component\Plugin\Context\ContextInterface;
/**
* Interface for defining context aware plugins.
@@ -5,4 +5,4 @@ namespace Drupal\Component\Plugin\Exception;
/**
* An exception class to be thrown for context plugin exceptions.
*/
class ContextException extends \Exception implements ExceptionInterface { }
class ContextException extends \Exception implements ExceptionInterface {}
@@ -5,4 +5,4 @@ namespace Drupal\Component\Plugin\Exception;
/**
* Exception interface for all exceptions thrown by the Plugin component.
*/
interface ExceptionInterface { }
interface ExceptionInterface {}
@@ -2,10 +2,10 @@
namespace Drupal\Component\Plugin\Exception;
use \BadMethodCallException;
use BadMethodCallException;
/**
* Exception thrown when a decorator's _call() method is triggered, but the
* decorated object does not contain the requested method.
*/
class InvalidDecoratedMethod extends BadMethodCallException implements ExceptionInterface { }
class InvalidDecoratedMethod extends BadMethodCallException implements ExceptionInterface {}
@@ -5,4 +5,4 @@ namespace Drupal\Component\Plugin\Exception;
/**
* Exception to be thrown if a plugin tries to use an invalid deriver.
*/
class InvalidDeriverException extends PluginException { }
class InvalidDeriverException extends PluginException {}
@@ -8,4 +8,4 @@ namespace Drupal\Component\Plugin\Exception;
* Extended interface for exceptions thrown specifically by the Mapper subsystem
* within the Plugin component.
*/
interface MapperExceptionInterface extends ExceptionInterface { }
interface MapperExceptionInterface extends ExceptionInterface {}
@@ -6,4 +6,4 @@ namespace Drupal\Component\Plugin\Exception;
* Generic Plugin exception class to be thrown when no more specific class
* is applicable.
*/
class PluginException extends \Exception implements ExceptionInterface { }
class PluginException extends \Exception implements ExceptionInterface {}
@@ -22,7 +22,7 @@ interface MapperInterface {
*
* @return object|false
* A fully configured plugin instance. The interface of the plugin instance
* will depends on the plugin type. If no instance can be retrieved, FALSE
* will depend on the plugin type. If no instance can be retrieved, FALSE
* will be returned.
*/
public function getInstance(array $options);
@@ -6,7 +6,7 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"symfony/validator": "~2.7"
"symfony/validator": "^2.7"
},
"autoload": {
"psr-4": {
@@ -6,7 +6,7 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"drupal/core-utility": "~8.2"
"drupal/core-utility": "^8.2"
},
"autoload": {
"psr-4": {
@@ -29,6 +29,9 @@ class YamlPecl implements SerializationInterface {
public static function decode($raw) {
static $init;
if (!isset($init)) {
// Decode binary, since Symfony YAML parser encodes binary from 3.1
// onwards.
ini_set('yaml.decode_binary', 1);
// We never want to unserialize !php/object.
ini_set('yaml.decode_php', 0);
$init = TRUE;
@@ -5,6 +5,7 @@ namespace Drupal\Component\Serialization;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Yaml\Yaml as SymfonyYaml;
/**
* Default serialization for YAML using the Symfony component.
@@ -16,9 +17,9 @@ class YamlSymfony implements SerializationInterface {
*/
public static function encode($data) {
try {
$yaml = new Dumper();
$yaml->setIndentation(2);
return $yaml->dump($data, PHP_INT_MAX, 0, TRUE, FALSE);
// Set the indentation to 2 to match Drupal's coding standards.
$yaml = new Dumper(2);
return $yaml->dump($data, PHP_INT_MAX, 0, SymfonyYaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
}
catch (\Exception $e) {
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
@@ -33,7 +34,7 @@ class YamlSymfony implements SerializationInterface {
$yaml = new Parser();
// Make sure we have a single trailing newline. A very simple config like
// 'foo: bar' with no newline will fail to parse otherwise.
return $yaml->parse($raw, TRUE, FALSE);
return $yaml->parse($raw, SymfonyYaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
}
catch (\Exception $e) {
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
@@ -6,7 +6,7 @@
"license": "GPL-2.0+",
"require": {
"php": ">=5.5.9",
"symfony/yaml": "~2.7"
"symfony/yaml": "^2.7"
},
"autoload": {
"psr-4": {
@@ -328,7 +328,7 @@ class NestedArray {
// Renumber integer keys as array_merge_recursive() does unless
// $preserve_integer_keys is set to TRUE. Note that PHP automatically
// converts array keys that are integer strings (e.g., '1') to integers.
if (is_integer($key) && !$preserve_integer_keys) {
if (is_int($key) && !$preserve_integer_keys) {
$result[] = $value;
}
// Recurse when both values are arrays.
+1 -1
View File
@@ -50,7 +50,7 @@ class Number {
// can't be represented with single precision floats are acceptable. The
// fractional part of a float has 24 bits. That means remainders smaller than
// $step * 2^-24 are acceptable.
$computed_acceptable_error = (double)($step / pow(2.0, 24));
$computed_acceptable_error = (double) ($step / pow(2.0, 24));
return $computed_acceptable_error >= $remainder || $remainder >= ($step - $computed_acceptable_error);
}
+5 -2
View File
@@ -143,7 +143,9 @@ class Random {
$vowels = ["a", "e", "i", "o", "u"];
$cons = ["b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",
"cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl", "sh"];
"cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr",
"sl", "cl", "sh",
];
$num_vowels = count($vowels);
$num_cons = count($cons);
@@ -219,7 +221,8 @@ class Random {
"utrum", "uxor", "valde", "valetudo", "validus", "vel", "velit",
"veniam", "venio", "vereor", "vero", "verto", "vicis", "vindico",
"virtus", "voco", "volutpat", "vulpes", "vulputate", "wisi", "ymo",
"zelus"];
"zelus",
];
$dictionary_flipped = array_flip($dictionary);
$greeking = '';
+3 -3
View File
@@ -20,7 +20,7 @@ class Timer {
* @param $name
* The name of the timer.
*/
static public function start($name) {
public static function start($name) {
static::$timers[$name]['start'] = microtime(TRUE);
static::$timers[$name]['count'] = isset(static::$timers[$name]['count']) ? ++static::$timers[$name]['count'] : 1;
}
@@ -34,7 +34,7 @@ class Timer {
* @return int
* The current timer value in ms.
*/
static public function read($name) {
public static function read($name) {
if (isset(static::$timers[$name]['start'])) {
$stop = microtime(TRUE);
$diff = round(($stop - static::$timers[$name]['start']) * 1000, 2);
@@ -57,7 +57,7 @@ class Timer {
* A timer array. The array contains the number of times the timer has been
* started and stopped (count) and the accumulated timer value in ms (time).
*/
static public function stop($name) {
public static function stop($name) {
if (isset(static::$timers[$name]['start'])) {
$stop = microtime(TRUE);
$diff = round(($stop - static::$timers[$name]['start']) * 1000, 2);
@@ -264,7 +264,9 @@ EOD;
return substr($string, 0, $len);
}
// Scan backwards to beginning of the byte sequence.
while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0);
// @todo Make the code more readable in https://www.drupal.org/node/2911497.
while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0) {
}
return substr($string, 0, $len);
}
@@ -376,7 +378,7 @@ EOD;
*/
public static function ucwords($text) {
$regex = '/(^|[' . static::PREG_CLASS_WORD_BOUNDARY . '])([^' . static::PREG_CLASS_WORD_BOUNDARY . '])/u';
return preg_replace_callback($regex, function(array $matches) {
return preg_replace_callback($regex, function (array $matches) {
return $matches[1] . Unicode::strtoupper($matches[2]);
}, $text);
}
@@ -580,7 +582,7 @@ EOD;
* Returns < 0 if $str1 is less than $str2; > 0 if $str1 is greater than
* $str2, and 0 if they are equal.
*/
public static function strcasecmp($str1 , $str2) {
public static function strcasecmp($str1, $str2) {
return strcmp(static::strtoupper($str1), static::strtoupper($str2));
}
@@ -607,7 +609,8 @@ EOD;
*/
public static function mimeHeaderEncode($string) {
if (preg_match('/[^\x20-\x7E]/', $string)) {
$chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
// floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
$chunk_size = 47;
$len = strlen($string);
$output = '';
while ($len > 0) {
@@ -148,6 +148,11 @@ class UrlHelper {
$scheme_delimiter_position = strpos($url, '://');
$query_delimiter_position = strpos($url, '?');
if ($scheme_delimiter_position !== FALSE && ($query_delimiter_position === FALSE || $scheme_delimiter_position < $query_delimiter_position)) {
// Split off the fragment, if any.
if (strpos($url, '#') !== FALSE) {
list($url, $options['fragment']) = explode('#', $url, 2);
}
// Split off everything before the query string into 'path'.
$parts = explode('?', $url);
@@ -158,12 +163,7 @@ class UrlHelper {
}
// If there is a query string, transform it into keyed query parameters.
if (isset($parts[1])) {
$query_parts = explode('#', $parts[1]);
parse_str($query_parts[0], $options['query']);
// Take over the fragment, if there is any.
if (isset($query_parts[1])) {
$options['fragment'] = $query_parts[1];
}
parse_str($parts[1], $options['query']);
}
}
// Internal URLs.
@@ -7,7 +7,7 @@
"require": {
"php": ">=5.5.9",
"paragonie/random_compat": "^1.0|^2.0",
"drupal/core-render": "~8.2"
"drupal/core-render": "^8.2"
},
"autoload": {
"psr-4": {
+1 -1
View File
@@ -10,7 +10,7 @@
},
"require": {
"php": ">=5.5.9",
"drupal/core-utility": "~8.2"
"drupal/core-utility": "^8.2"
},
"autoload": {
"psr-4": {