updated core and modules
This commit is contained in:
@@ -52,7 +52,7 @@ class Plugin implements AnnotationInterface {
|
||||
* The parsed annotation as a definition.
|
||||
*/
|
||||
protected function parse(array $values) {
|
||||
$definitions = array();
|
||||
$definitions = [];
|
||||
foreach ($values as $key => $value) {
|
||||
if ($value instanceof AnnotationInterface) {
|
||||
$definitions[$key] = $value->get();
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
namespace Drupal\Component\Annotation\Plugin\Discovery;
|
||||
|
||||
use Drupal\Component\Annotation\AnnotationInterface;
|
||||
use Drupal\Component\FileCache\FileCacheFactory;
|
||||
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
|
||||
use Drupal\Component\Annotation\Reflection\MockFileFinder;
|
||||
use Doctrine\Common\Annotations\SimpleAnnotationReader;
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Doctrine\Common\Reflection\StaticReflectionParser;
|
||||
use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
|
||||
/**
|
||||
* Defines a discovery mechanism to find annotated plugins in PSR-0 namespaces.
|
||||
@@ -48,6 +50,13 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
|
||||
*/
|
||||
protected $annotationNamespaces = [];
|
||||
|
||||
/**
|
||||
* The file cache object.
|
||||
*
|
||||
* @var \Drupal\Component\FileCache\FileCacheInterface
|
||||
*/
|
||||
protected $fileCache;
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
*
|
||||
@@ -60,10 +69,14 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
|
||||
* @param string[] $annotation_namespaces
|
||||
* (optional) Additional namespaces to be scanned for annotation classes.
|
||||
*/
|
||||
function __construct($plugin_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin', array $annotation_namespaces = []) {
|
||||
public function __construct($plugin_namespaces = [], $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin', array $annotation_namespaces = []) {
|
||||
$this->pluginNamespaces = $plugin_namespaces;
|
||||
$this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
|
||||
$this->annotationNamespaces = $annotation_namespaces;
|
||||
|
||||
$file_cache_suffix = str_replace('\\', '_', $plugin_definition_annotation_name);
|
||||
$file_cache_suffix .= ':' . Crypt::hashBase64(serialize($annotation_namespaces));
|
||||
$this->fileCache = FileCacheFactory::get('annotation_discovery:' . $file_cache_suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +105,7 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefinitions() {
|
||||
$definitions = array();
|
||||
$definitions = [];
|
||||
|
||||
$reader = $this->getAnnotationReader();
|
||||
|
||||
@@ -110,6 +123,14 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
|
||||
);
|
||||
foreach ($iterator as $fileinfo) {
|
||||
if ($fileinfo->getExtension() == 'php') {
|
||||
if ($cached = $this->fileCache->get($fileinfo->getPathName())) {
|
||||
if (isset($cached['id'])) {
|
||||
// Explicitly unserialize this to create a new object instance.
|
||||
$definitions[$cached['id']] = unserialize($cached['content']);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$sub_path = $iterator->getSubIterator()->getSubPath();
|
||||
$sub_path = $sub_path ? str_replace(DIRECTORY_SEPARATOR, '\\', $sub_path) . '\\' : '';
|
||||
$class = $namespace . '\\' . $sub_path . $fileinfo->getBasename('.php');
|
||||
@@ -123,7 +144,16 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
|
||||
/** @var $annotation \Drupal\Component\Annotation\AnnotationInterface */
|
||||
if ($annotation = $reader->getClassAnnotation($parser->getReflectionClass(), $this->pluginDefinitionAnnotationName)) {
|
||||
$this->prepareAnnotationDefinition($annotation, $class);
|
||||
$definitions[$annotation->getId()] = $annotation->get();
|
||||
|
||||
$id = $annotation->getId();
|
||||
$content = $annotation->get();
|
||||
$definitions[$id] = $content;
|
||||
// Explicitly serialize this to create a new object instance.
|
||||
$this->fileCache->set($fileinfo->getPathName(), ['id' => $id, 'content' => serialize($content)]);
|
||||
}
|
||||
else {
|
||||
// Store a NULL object, so the file is not reparsed again.
|
||||
$this->fileCache->set($fileinfo->getPathName(), [NULL]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Annotation\Plugin\Discovery;
|
||||
|
||||
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
|
||||
use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
|
||||
|
||||
/**
|
||||
* Ensures that all definitions are run through the annotation process.
|
||||
*/
|
||||
class AnnotationBridgeDecorator implements DiscoveryInterface {
|
||||
|
||||
use DiscoveryTrait;
|
||||
|
||||
/**
|
||||
* The decorated plugin discovery.
|
||||
*
|
||||
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
|
||||
*/
|
||||
protected $decorated;
|
||||
|
||||
/**
|
||||
* The name of the annotation that contains the plugin definition.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $pluginDefinitionAnnotationName;
|
||||
|
||||
/**
|
||||
* ObjectDefinitionDiscoveryDecorator constructor.
|
||||
*
|
||||
* @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
|
||||
* The discovery object that is being decorated.
|
||||
* @param string $plugin_definition_annotation_name
|
||||
* The name of the annotation that contains the plugin definition. The class
|
||||
* corresponding to this name must implement
|
||||
* \Drupal\Component\Annotation\AnnotationInterface.
|
||||
*/
|
||||
public function __construct(DiscoveryInterface $decorated, $plugin_definition_annotation_name) {
|
||||
$this->decorated = $decorated;
|
||||
$this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefinitions() {
|
||||
$definitions = $this->decorated->getDefinitions();
|
||||
foreach ($definitions as $id => $definition) {
|
||||
// Annotation constructors expect an array of values. If the definition is
|
||||
// not an array, it usually means it has been processed already and can be
|
||||
// ignored.
|
||||
if (is_array($definition)) {
|
||||
$definitions[$id] = (new $this->pluginDefinitionAnnotationName($definition))->get();
|
||||
}
|
||||
}
|
||||
return $definitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes through all unknown calls onto the decorated object.
|
||||
*
|
||||
* @param string $method
|
||||
* The method to call on the decorated plugin discovery.
|
||||
* @param array $args
|
||||
* The arguments to send to the method.
|
||||
*
|
||||
* @return mixed
|
||||
* The method result.
|
||||
*/
|
||||
public function __call($method, $args) {
|
||||
return call_user_func_array([$this->decorated, $method], $args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,11 +22,11 @@ class PluginID extends AnnotationBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get() {
|
||||
return array(
|
||||
return [
|
||||
'id' => $this->value,
|
||||
'class' => $this->class,
|
||||
'provider' => $this->provider,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
"php": ">=5.5.9",
|
||||
"doctrine/common": "2.5.*",
|
||||
"doctrine/annotations": "1.2.*",
|
||||
"drupal/core-plugin": "~8.1",
|
||||
"drupal/core-utility": "~8.1"
|
||||
"drupal/core-fileCache": "~8.2",
|
||||
"drupal/core-plugin": "~8.2",
|
||||
"drupal/core-utility": "~8.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -1,41 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Component\Assertion\Handle.
|
||||
*
|
||||
* For PHP 5 this contains \AssertionError as well.
|
||||
*/
|
||||
|
||||
namespace {
|
||||
|
||||
if (!class_exists('AssertionError', FALSE)) {
|
||||
|
||||
/**
|
||||
* Emulates PHP 7 AssertionError as closely as possible.
|
||||
*
|
||||
* We force this class to exist at the root namespace for PHP 5.
|
||||
* This class exists natively in PHP 7. Note that in PHP 7 it extends from
|
||||
* Error, not Exception, but that isn't possible for PHP 5 - all exceptions
|
||||
* must extend from exception.
|
||||
*/
|
||||
class AssertionError extends Exception {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($message = '', $code = 0, Exception $previous = NULL, $file = '', $line = 0) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
// Preserve the filename and line number of the assertion failure.
|
||||
$this->file = $file;
|
||||
$this->line = $line;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace Drupal\Component\Assertion {
|
||||
namespace Drupal\Component\Assertion;
|
||||
|
||||
/**
|
||||
* Handler for runtime assertion failures.
|
||||
@@ -56,6 +21,9 @@ class Handle {
|
||||
assert_options(ASSERT_WARNING, FALSE);
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.0.0-dev') < 0) {
|
||||
if (!class_exists('AssertionError', FALSE)) {
|
||||
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 = '') {
|
||||
if (empty($message)) {
|
||||
@@ -71,5 +39,3 @@ class Handle {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class Inspector {
|
||||
* Use this instead of is_string() alone unless the argument being an object
|
||||
* in any way will cause a problem.
|
||||
*
|
||||
* @param mixed string
|
||||
* @param mixed $string
|
||||
* Variable to be examined
|
||||
*
|
||||
* @return bool
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains PHP5 version of the \AssertionError class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Emulates PHP 7 AssertionError as closely as possible.
|
||||
*
|
||||
* This class is declared in the global namespace. It will only be included by
|
||||
* \Drupal\Component\Assertion\Handle for PHP5 since this class exists natively
|
||||
* in PHP 7. Note that in PHP 7 it extends from Error, not Exception, but that
|
||||
* isn't possible for PHP 5 - all exceptions must extend from exception.
|
||||
*/
|
||||
class AssertionError extends Exception {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($message = '', $code = 0, Exception $previous = NULL, $file = '', $line = 0) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
// Preserve the filename and line number of the assertion failure.
|
||||
$this->file = $file;
|
||||
$this->line = $line;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan
|
||||
*
|
||||
* @see \Drupal\Component\Bridge\ZfExtensionManagerSfContainer::canonicalizeName().
|
||||
*/
|
||||
protected $canonicalNamesReplacements = array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => '');
|
||||
protected $canonicalNamesReplacements = ['-' => '', '_' => '', ' ' => '', '\\' => '', '/' => ''];
|
||||
|
||||
/**
|
||||
* The prefix to be used when retrieving plugins from the container.
|
||||
@@ -55,7 +55,7 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan
|
||||
* The prefix to be used when retrieving plugins from the container.
|
||||
*/
|
||||
public function __construct($prefix = '') {
|
||||
return $this->prefix = $prefix;
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\ClassFinder;
|
||||
|
||||
use Doctrine\Common\Reflection\ClassFinderInterface;
|
||||
|
||||
/**
|
||||
* A Utility class that uses active autoloaders to find a file for a class.
|
||||
*/
|
||||
class ClassFinder implements ClassFinderInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findFile($class) {
|
||||
$loaders = spl_autoload_functions();
|
||||
foreach ($loaders as $loader) {
|
||||
if (is_array($loader) && isset($loader[0]) && is_object($loader[0]) && method_exists($loader[0], 'findFile')) {
|
||||
$file = call_user_func_array([$loader[0], 'findFile'], [$class]);
|
||||
// Different implementations return different empty values. For example,
|
||||
// \Composer\Autoload\ClassLoader::findFile() returns FALSE whilst
|
||||
// \Doctrine\Common\Reflection\ClassFinderInterface::findFile()
|
||||
// documents that a NULL should be returned.
|
||||
if (!empty($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,12 @@
|
||||
The Drupal ClassFinder Component
|
||||
|
||||
Thanks for using this Drupal component.
|
||||
|
||||
You can participate in its development on Drupal.org, through our issue system:
|
||||
https://www.drupal.org/project/issues/drupal
|
||||
|
||||
You can get the full Drupal repo here:
|
||||
https://www.drupal.org/project/drupal/git-instructions
|
||||
|
||||
You can browse the full Drupal repo here:
|
||||
http://cgit.drupalcode.org/drupal
|
||||
@@ -0,0 +1,18 @@
|
||||
HOW-TO: Test this Drupal component
|
||||
|
||||
In order to test this component, you'll need to get the entire Drupal repo and
|
||||
run the tests there.
|
||||
|
||||
You'll find the tests under core/tests/Drupal/Tests/Component.
|
||||
|
||||
You can get the full Drupal repo here:
|
||||
https://www.drupal.org/project/drupal/git-instructions
|
||||
|
||||
You can find more information about running PHPUnit tests with Drupal here:
|
||||
https://www.drupal.org/node/2116263
|
||||
|
||||
Each component in the Drupal\Component namespace has its own annotated test
|
||||
group. You can use this group to run only the tests for this component. Like
|
||||
this:
|
||||
|
||||
$ ./vendor/bin/phpunit -c core --group ClassFinder
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "drupal/core-class-finder",
|
||||
"description": "This class provides a class finding utility.",
|
||||
"keywords": ["drupal"],
|
||||
"homepage": "https://www.drupal.org/project/drupal",
|
||||
"license": "GPL-2.0+",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"doctrine/common": "2.5.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Drupal\\Component\\ClassFinder\\": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,14 +41,14 @@ class DateTimePlus {
|
||||
/**
|
||||
* An array of possible date parts.
|
||||
*/
|
||||
protected static $dateParts = array(
|
||||
protected static $dateParts = [
|
||||
'year',
|
||||
'month',
|
||||
'day',
|
||||
'hour',
|
||||
'minute',
|
||||
'second',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* The value of the time value passed to the constructor.
|
||||
@@ -88,7 +88,7 @@ class DateTimePlus {
|
||||
/**
|
||||
* An array of errors encountered when creating this date.
|
||||
*/
|
||||
protected $errors = array();
|
||||
protected $errors = [];
|
||||
|
||||
/**
|
||||
* The DateTime object.
|
||||
@@ -108,7 +108,7 @@ class DateTimePlus {
|
||||
* @return static
|
||||
* A new DateTimePlus object.
|
||||
*/
|
||||
public static function createFromDateTime(\DateTime $datetime, $settings = array()) {
|
||||
public static function createFromDateTime(\DateTime $datetime, $settings = []) {
|
||||
return new static($datetime->format(static::FORMAT), $datetime->getTimezone(), $settings);
|
||||
}
|
||||
|
||||
@@ -130,10 +130,10 @@ class DateTimePlus {
|
||||
* @return static
|
||||
* A new DateTimePlus object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \InvalidArgumentException
|
||||
* If the array date values or value combination is not correct.
|
||||
*/
|
||||
public static function createFromArray(array $date_parts, $timezone = NULL, $settings = array()) {
|
||||
public static function createFromArray(array $date_parts, $timezone = NULL, $settings = []) {
|
||||
$date_parts = static::prepareArray($date_parts, TRUE);
|
||||
if (static::checkArray($date_parts)) {
|
||||
// Even with validation, we can end up with a value that the
|
||||
@@ -144,7 +144,7 @@ class DateTimePlus {
|
||||
return new static($iso_date, $timezone, $settings);
|
||||
}
|
||||
else {
|
||||
throw new \Exception('The array contains invalid values.');
|
||||
throw new \InvalidArgumentException('The array contains invalid values.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,12 +164,12 @@ class DateTimePlus {
|
||||
* @return static
|
||||
* A new DateTimePlus object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \InvalidArgumentException
|
||||
* If the timestamp is not numeric.
|
||||
*/
|
||||
public static function createFromTimestamp($timestamp, $timezone = NULL, $settings = array()) {
|
||||
public static function createFromTimestamp($timestamp, $timezone = NULL, $settings = []) {
|
||||
if (!is_numeric($timestamp)) {
|
||||
throw new \Exception('The timestamp must be numeric.');
|
||||
throw new \InvalidArgumentException('The timestamp must be numeric.');
|
||||
}
|
||||
$datetime = new static('', $timezone, $settings);
|
||||
$datetime->setTimestamp($timestamp);
|
||||
@@ -202,11 +202,12 @@ class DateTimePlus {
|
||||
* @return static
|
||||
* A new DateTimePlus object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* If the a date cannot be created from the given format, or if the
|
||||
* created date does not match the input value.
|
||||
* @throws \InvalidArgumentException
|
||||
* If the a date cannot be created from the given format.
|
||||
* @throws \UnexpectedValueException
|
||||
* If the created date does not match the input value.
|
||||
*/
|
||||
public static function createFromFormat($format, $time, $timezone = NULL, $settings = array()) {
|
||||
public static function createFromFormat($format, $time, $timezone = NULL, $settings = []) {
|
||||
if (!isset($settings['validate_format'])) {
|
||||
$settings['validate_format'] = TRUE;
|
||||
}
|
||||
@@ -218,7 +219,7 @@ class DateTimePlus {
|
||||
|
||||
$date = \DateTime::createFromFormat($format, $time, $datetimeplus->getTimezone());
|
||||
if (!$date instanceof \DateTime) {
|
||||
throw new \Exception('The date cannot be created from a format.');
|
||||
throw new \InvalidArgumentException('The date cannot be created from a format.');
|
||||
}
|
||||
else {
|
||||
// Functions that parse date is forgiving, it might create a date that
|
||||
@@ -236,7 +237,7 @@ class DateTimePlus {
|
||||
$datetimeplus->setTimezone($date->getTimezone());
|
||||
|
||||
if ($settings['validate_format'] && $test_time != $time) {
|
||||
throw new \Exception('The created date does not match the input value.');
|
||||
throw new \UnexpectedValueException('The created date does not match the input value.');
|
||||
}
|
||||
}
|
||||
return $datetimeplus;
|
||||
@@ -257,7 +258,7 @@ class DateTimePlus {
|
||||
* - debug: (optional) Boolean choice to leave debug values in the
|
||||
* date object for debugging purposes. Defaults to FALSE.
|
||||
*/
|
||||
public function __construct($time = 'now', $timezone = NULL, $settings = array()) {
|
||||
public function __construct($time = 'now', $timezone = NULL, $settings = []) {
|
||||
|
||||
// Unpack settings.
|
||||
$this->langcode = !empty($settings['langcode']) ? $settings['langcode'] : NULL;
|
||||
@@ -267,10 +268,11 @@ class DateTimePlus {
|
||||
$prepared_timezone = $this->prepareTimezone($timezone);
|
||||
|
||||
try {
|
||||
$this->errors = [];
|
||||
if (!empty($prepared_time)) {
|
||||
$test = date_parse($prepared_time);
|
||||
if (!empty($test['errors'])) {
|
||||
$this->errors[] = $test['errors'];
|
||||
$this->errors = $test['errors'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +286,6 @@ class DateTimePlus {
|
||||
|
||||
// Clean up the error messages.
|
||||
$this->checkErrors();
|
||||
$this->errors = array_unique($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,7 +310,7 @@ 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(array($this->dateTimeObject, $method), $args);
|
||||
return call_user_func_array([$this->dateTimeObject, $method], $args);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,7 +346,7 @@ class DateTimePlus {
|
||||
if (!method_exists('\DateTime', $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_called_class(), $method));
|
||||
}
|
||||
return call_user_func_array(array('\DateTime', $method), $args);
|
||||
return call_user_func_array(['\DateTime', $method], $args);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,7 +442,7 @@ class DateTimePlus {
|
||||
public function checkErrors() {
|
||||
$errors = \DateTime::getLastErrors();
|
||||
if (!empty($errors['errors'])) {
|
||||
$this->errors += $errors['errors'];
|
||||
$this->errors = array_merge($this->errors, $errors['errors']);
|
||||
}
|
||||
// Most warnings are messages that the date could not be parsed
|
||||
// which causes it to be altered. For validation purposes, a warning
|
||||
@@ -450,6 +451,8 @@ class DateTimePlus {
|
||||
if (!empty($errors['warnings'])) {
|
||||
$this->errors[] = 'The date is invalid.';
|
||||
}
|
||||
|
||||
$this->errors = array_values(array_unique($this->errors));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -528,24 +531,24 @@ class DateTimePlus {
|
||||
public static function prepareArray($array, $force_valid_date = FALSE) {
|
||||
if ($force_valid_date) {
|
||||
$now = new \DateTime();
|
||||
$array += array(
|
||||
$array += [
|
||||
'year' => $now->format('Y'),
|
||||
'month' => 1,
|
||||
'day' => 1,
|
||||
'hour' => 0,
|
||||
'minute' => 0,
|
||||
'second' => 0,
|
||||
);
|
||||
];
|
||||
}
|
||||
else {
|
||||
$array += array(
|
||||
$array += [
|
||||
'year' => '',
|
||||
'month' => '',
|
||||
'day' => '',
|
||||
'hour' => '',
|
||||
'minute' => '',
|
||||
'second' => '',
|
||||
);
|
||||
];
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
@@ -576,7 +579,7 @@ class DateTimePlus {
|
||||
}
|
||||
// Testing for valid time is reversed. Missing time is OK,
|
||||
// but incorrect values are not.
|
||||
foreach (array('hour', 'minute', 'second') as $key) {
|
||||
foreach (['hour', 'minute', 'second'] as $key) {
|
||||
if (array_key_exists($key, $array)) {
|
||||
$value = $array[$key];
|
||||
switch ($key) {
|
||||
@@ -627,7 +630,7 @@ class DateTimePlus {
|
||||
* @return string
|
||||
* The formatted value of the date.
|
||||
*/
|
||||
public function format($format, $settings = array()) {
|
||||
public function format($format, $settings = []) {
|
||||
|
||||
// If there were construction errors, we can't format the date.
|
||||
if ($this->hasErrors()) {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Datetime;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* Provides a class for obtaining system time.
|
||||
*/
|
||||
class Time implements TimeInterface {
|
||||
|
||||
/**
|
||||
* The request stack.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\RequestStack
|
||||
*/
|
||||
protected $requestStack;
|
||||
|
||||
/**
|
||||
* Constructs a Time object.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
|
||||
* The request stack.
|
||||
*/
|
||||
public function __construct(RequestStack $request_stack) {
|
||||
$this->requestStack = $request_stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequestTime() {
|
||||
return $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequestMicroTime() {
|
||||
return $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME_FLOAT');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCurrentTime() {
|
||||
return time();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCurrentMicroTime() {
|
||||
return microtime(TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Datetime;
|
||||
|
||||
/**
|
||||
* Defines an interface for obtaining system time.
|
||||
*/
|
||||
interface TimeInterface {
|
||||
|
||||
/**
|
||||
* Returns the timestamp for the current request.
|
||||
*
|
||||
* This method should be used to obtain the current system time at the start
|
||||
* of the request. It will be the same value for the life of the request
|
||||
* (even for long execution times).
|
||||
*
|
||||
* This method can replace instances of
|
||||
* @code
|
||||
* $request_time = $_SERVER['REQUEST_TIME'];
|
||||
* $request_time = REQUEST_TIME;
|
||||
* $request_time = $requestStack->getCurrentRequest()->server->get('REQUEST_TIME');
|
||||
* $request_time = $request->server->get('REQUEST_TIME');
|
||||
* @endcode
|
||||
* and most instances of
|
||||
* @code
|
||||
* $time = time();
|
||||
* @endcode
|
||||
* with
|
||||
* @code
|
||||
* $request_time = \Drupal::time()->getRequestTime();
|
||||
* @endcode
|
||||
* or the equivalent using the injected service.
|
||||
*
|
||||
* Using the time service, rather than other methods, is especially important
|
||||
* when creating tests, which require predictable timestamps.
|
||||
*
|
||||
* @return int
|
||||
* A Unix timestamp.
|
||||
*
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getRequestMicroTime()
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getCurrentTime()
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getCurrentMicroTime()
|
||||
*/
|
||||
public function getRequestTime();
|
||||
|
||||
/**
|
||||
* Returns the timestamp for the current request with microsecond precision.
|
||||
*
|
||||
* This method should be used to obtain the current system time, with
|
||||
* microsecond precision, at the start of the request. It will be the same
|
||||
* value for the life of the request (even for long execution times).
|
||||
*
|
||||
* This method can replace instances of
|
||||
* @code
|
||||
* $request_time_float = $_SERVER['REQUEST_TIME_FLOAT'];
|
||||
* $request_time_float = $requestStack->getCurrentRequest()->server->get('REQUEST_TIME_FLOAT');
|
||||
* $request_time_float = $request->server->get('REQUEST_TIME_FLOAT');
|
||||
* @endcode
|
||||
* and many instances of
|
||||
* @code
|
||||
* $microtime = microtime();
|
||||
* $microtime = microtime(TRUE);
|
||||
* @endcode
|
||||
* with
|
||||
* @code
|
||||
* $request_time = \Drupal::time()->getRequestMicroTime();
|
||||
* @endcode
|
||||
* or the equivalent using the injected service.
|
||||
*
|
||||
* Using the time service, rather than other methods, is especially important
|
||||
* when creating tests, which require predictable timestamps.
|
||||
*
|
||||
* @return float
|
||||
* A Unix timestamp with a fractional portion.
|
||||
*
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getRequestTime()
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getCurrentTime()
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getCurrentMicroTime()
|
||||
*/
|
||||
public function getRequestMicroTime();
|
||||
|
||||
/**
|
||||
* Returns the current system time as an integer.
|
||||
*
|
||||
* This method should be used to obtain the current system time, at the time
|
||||
* the method was called.
|
||||
*
|
||||
* This method can replace many instances of
|
||||
* @code
|
||||
* $time = time();
|
||||
* @endcode
|
||||
* with
|
||||
* @code
|
||||
* $request_time = \Drupal::time()->getCurrentTime();
|
||||
* @endcode
|
||||
* or the equivalent using the injected service.
|
||||
*
|
||||
* This method should only be used when the current system time is actually
|
||||
* needed, such as with timers or time interval calculations. If only the
|
||||
* time at the start of the request is needed,
|
||||
* use TimeInterface::getRequestTime().
|
||||
*
|
||||
* Using the time service, rather than other methods, is especially important
|
||||
* when creating tests, which require predictable timestamps.
|
||||
*
|
||||
* @return int
|
||||
* A Unix timestamp.
|
||||
*
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getRequestTime()
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getRequestMicroTime()
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getCurrentMicroTime()
|
||||
*/
|
||||
public function getCurrentTime();
|
||||
|
||||
/**
|
||||
* Returns the current system time with microsecond precision.
|
||||
*
|
||||
* This method should be used to obtain the current system time, with
|
||||
* microsecond precision, at the time the method was called.
|
||||
*
|
||||
* This method can replace many instances of
|
||||
* @code
|
||||
* $microtime = microtime();
|
||||
* $microtime = microtime(TRUE);
|
||||
* @endcode
|
||||
* with
|
||||
* @code
|
||||
* $request_time = \Drupal::time()->getCurrentMicroTime();
|
||||
* @endcode
|
||||
* or the equivalent using the injected service.
|
||||
*
|
||||
* This method should only be used when the current system time is actually
|
||||
* needed, such as with timers or time interval calculations. If only the
|
||||
* time at the start of the request and microsecond precision is needed,
|
||||
* use TimeInterface::getRequestMicroTime().
|
||||
*
|
||||
* Using the time service, rather than other methods, is especially important
|
||||
* when creating tests, which require predictable timestamps.
|
||||
*
|
||||
* @return float
|
||||
* A Unix timestamp with a fractional portion.
|
||||
*
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getRequestTime()
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getRequestMicroTime()
|
||||
* @see \Drupal\Component\Datetime\TimeInterface::getCurrentTime()
|
||||
*/
|
||||
public function getCurrentMicroTime();
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
"license": "GPL-2.0+",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"drupal/core-utility": "~8.1"
|
||||
"drupal/core-utility": "~8.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -57,42 +57,42 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $parameters = array();
|
||||
protected $parameters = [];
|
||||
|
||||
/**
|
||||
* The aliases of the container.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $aliases = array();
|
||||
protected $aliases = [];
|
||||
|
||||
/**
|
||||
* The service definitions of the container.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $serviceDefinitions = array();
|
||||
protected $serviceDefinitions = [];
|
||||
|
||||
/**
|
||||
* The instantiated services.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $services = array();
|
||||
protected $services = [];
|
||||
|
||||
/**
|
||||
* The instantiated private services.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $privateServices = array();
|
||||
protected $privateServices = [];
|
||||
|
||||
/**
|
||||
* The currently loading services.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $loading = array();
|
||||
protected $loading = [];
|
||||
|
||||
/**
|
||||
* Whether the container parameters can still be changed.
|
||||
@@ -116,14 +116,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
||||
* - machine_format: Whether this container definition uses the optimized
|
||||
* machine-readable container format.
|
||||
*/
|
||||
public function __construct(array $container_definition = array()) {
|
||||
public function __construct(array $container_definition = []) {
|
||||
if (!empty($container_definition) && (!isset($container_definition['machine_format']) || $container_definition['machine_format'] !== TRUE)) {
|
||||
throw new InvalidArgumentException('The non-optimized format is not supported by this class. Use an optimized machine-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper.');
|
||||
}
|
||||
|
||||
$this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array();
|
||||
$this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array();
|
||||
$this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array();
|
||||
$this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : [];
|
||||
$this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : [];
|
||||
$this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : [];
|
||||
$this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE;
|
||||
|
||||
// Register the service_container with itself.
|
||||
@@ -228,7 +228,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
||||
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The service container does not know how to construct this service. The service will need to be set before it is first used.', $id));
|
||||
}
|
||||
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
if (isset($definition['arguments'])) {
|
||||
$arguments = $definition['arguments'];
|
||||
|
||||
@@ -238,14 +238,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
||||
}
|
||||
|
||||
if (isset($definition['file'])) {
|
||||
$file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters(array($definition['file'])));
|
||||
$file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters([$definition['file']]));
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
if (isset($definition['factory'])) {
|
||||
$factory = $definition['factory'];
|
||||
if (is_array($factory)) {
|
||||
$factory = $this->resolveServicesAndParameters(array($factory[0], $factory[1]));
|
||||
$factory = $this->resolveServicesAndParameters([$factory[0], $factory[1]]);
|
||||
}
|
||||
elseif (!is_string($factory)) {
|
||||
throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id));
|
||||
@@ -254,7 +254,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
||||
$service = call_user_func_array($factory, $arguments);
|
||||
}
|
||||
else {
|
||||
$class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class'])));
|
||||
$class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters([$definition['class']]));
|
||||
$length = isset($definition['arguments_count']) ? $definition['arguments_count'] : count($arguments);
|
||||
|
||||
// Optimize class instantiation for services with up to 10 parameters as
|
||||
@@ -322,14 +322,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
||||
if (isset($definition['calls'])) {
|
||||
foreach ($definition['calls'] as $call) {
|
||||
$method = $call[0];
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
if (!empty($call[1])) {
|
||||
$arguments = $call[1];
|
||||
if ($arguments instanceof \stdClass) {
|
||||
$arguments = $this->resolveServicesAndParameters($arguments);
|
||||
}
|
||||
}
|
||||
call_user_func_array(array($service, $method), $arguments);
|
||||
call_user_func_array([$service, $method], $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) {
|
||||
if (!in_array($scope, array('container', 'request')) || ('request' === $scope && 'request' !== $id)) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
|
||||
* An array of strings with suitable alternatives.
|
||||
*/
|
||||
protected function getAlternatives($search_key, array $keys) {
|
||||
$alternatives = array();
|
||||
$alternatives = [];
|
||||
foreach ($keys as $key) {
|
||||
$lev = levenshtein($search_key, $key);
|
||||
if ($lev <= strlen($search_key) / 3 || strpos($key, $search_key) !== FALSE) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Drupal\Component\DependencyInjection\Dumper;
|
||||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Parameter;
|
||||
@@ -48,7 +49,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(array $options = array()) {
|
||||
public function dump(array $options = []) {
|
||||
return serialize($this->getArray());
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* A PHP array representation of the service container.
|
||||
*/
|
||||
public function getArray() {
|
||||
$definition = array();
|
||||
$definition = [];
|
||||
$this->aliases = $this->getAliases();
|
||||
$definition['aliases'] = $this->getAliases();
|
||||
$definition['parameters'] = $this->getParameters();
|
||||
@@ -76,7 +77,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* The aliases.
|
||||
*/
|
||||
protected function getAliases() {
|
||||
$alias_definitions = array();
|
||||
$alias_definitions = [];
|
||||
|
||||
$aliases = $this->container->getAliases();
|
||||
foreach ($aliases as $alias => $id) {
|
||||
@@ -98,7 +99,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
*/
|
||||
protected function getParameters() {
|
||||
if (!$this->container->getParameterBag()->all()) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$parameters = $this->container->getParameterBag()->all();
|
||||
@@ -114,10 +115,10 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
*/
|
||||
protected function getServiceDefinitions() {
|
||||
if (!$this->container->getDefinitions()) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$services = array();
|
||||
$services = [];
|
||||
foreach ($this->container->getDefinitions() as $id => $definition) {
|
||||
// Only store public service definitions, references to shared private
|
||||
// services are handled in ::getReferenceCall().
|
||||
@@ -142,7 +143,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* An array of prepared parameters.
|
||||
*/
|
||||
protected function prepareParameters(array $parameters, $escape = TRUE) {
|
||||
$filtered = array();
|
||||
$filtered = [];
|
||||
foreach ($parameters as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$value = $this->prepareParameters($value, $escape);
|
||||
@@ -167,7 +168,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* The escaped parameters.
|
||||
*/
|
||||
protected function escape(array $parameters) {
|
||||
$args = array();
|
||||
$args = [];
|
||||
|
||||
foreach ($parameters as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
@@ -198,7 +199,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* scope different from SCOPE_CONTAINER and SCOPE_PROTOTYPE.
|
||||
*/
|
||||
protected function getServiceDefinition(Definition $definition) {
|
||||
$service = array();
|
||||
$service = [];
|
||||
if ($definition->getClass()) {
|
||||
$service['class'] = $definition->getClass();
|
||||
}
|
||||
@@ -278,11 +279,11 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* The PHP array representation of the method calls.
|
||||
*/
|
||||
protected function dumpMethodCalls(array $calls) {
|
||||
$code = array();
|
||||
$code = [];
|
||||
|
||||
foreach ($calls as $key => $call) {
|
||||
$method = $call[0];
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
if (!empty($call[1])) {
|
||||
$arguments = $this->dumpCollection($call[1]);
|
||||
}
|
||||
@@ -308,7 +309,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* The collection in a suitable format.
|
||||
*/
|
||||
protected function dumpCollection($collection, &$resolve = FALSE) {
|
||||
$code = array();
|
||||
$code = [];
|
||||
|
||||
foreach ($collection as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
@@ -331,11 +332,11 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
return (object) array(
|
||||
return (object) [
|
||||
'type' => 'collection',
|
||||
'value' => $code,
|
||||
'resolve' => $resolve,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +351,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
protected function dumpCallable($callable) {
|
||||
if (is_array($callable)) {
|
||||
$callable[0] = $this->dumpValue($callable[0]);
|
||||
$callable = array($callable[0], $callable[1]);
|
||||
$callable = [$callable[0], $callable[1]];
|
||||
}
|
||||
|
||||
return $callable;
|
||||
@@ -373,15 +374,15 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
protected function getPrivateServiceCall($id, Definition $definition, $shared = FALSE) {
|
||||
$service_definition = $this->getServiceDefinition($definition);
|
||||
if (!$id) {
|
||||
$hash = hash('sha1', serialize($service_definition));
|
||||
$hash = Crypt::hashBase64(serialize($service_definition));
|
||||
$id = 'private__' . $hash;
|
||||
}
|
||||
return (object) array(
|
||||
return (object) [
|
||||
'type' => 'private_service',
|
||||
'id' => $id,
|
||||
'value' => $service_definition,
|
||||
'shared' => $shared,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,7 +399,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
*/
|
||||
protected function dumpValue($value) {
|
||||
if (is_array($value)) {
|
||||
$code = array();
|
||||
$code = [];
|
||||
foreach ($value as $k => $v) {
|
||||
$code[$k] = $this->dumpValue($v);
|
||||
}
|
||||
@@ -440,7 +441,7 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
*
|
||||
* @param string $id
|
||||
* The ID of the service to get a reference for.
|
||||
* @param \Symfony\Component\DependencyInjection\Reference|NULL $reference
|
||||
* @param \Symfony\Component\DependencyInjection\Reference|null $reference
|
||||
* (optional) The reference object to process; needed to get the invalid
|
||||
* behavior value.
|
||||
*
|
||||
@@ -481,11 +482,11 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* A suitable representation of the service reference.
|
||||
*/
|
||||
protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
|
||||
return (object) array(
|
||||
return (object) [
|
||||
'type' => 'service',
|
||||
'id' => $id,
|
||||
'invalidBehavior' => $invalid_behavior,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -498,10 +499,10 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
* A suitable representation of the parameter reference.
|
||||
*/
|
||||
protected function getParameterCall($name) {
|
||||
return (object) array(
|
||||
return (object) [
|
||||
'type' => 'parameter',
|
||||
'name' => $name,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ class PhpArrayDumper extends OptimizedPhpArrayDumper {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function dumpCollection($collection, &$resolve = FALSE) {
|
||||
$code = array();
|
||||
$code = [];
|
||||
|
||||
foreach ($collection as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
|
||||
@@ -27,16 +27,16 @@ class PhpArrayContainer extends Container {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $container_definition = array()) {
|
||||
public function __construct(array $container_definition = []) {
|
||||
if (isset($container_definition['machine_format']) && $container_definition['machine_format'] === TRUE) {
|
||||
throw new InvalidArgumentException('The machine-optimized format is not supported by this class. Use a human-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper.');
|
||||
}
|
||||
|
||||
// Do not call the parent's constructor as it would bail on the
|
||||
// machine-optimized format.
|
||||
$this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array();
|
||||
$this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array();
|
||||
$this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array();
|
||||
$this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : [];
|
||||
$this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : [];
|
||||
$this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : [];
|
||||
$this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE;
|
||||
|
||||
// Register the service_container with itself.
|
||||
@@ -57,20 +57,20 @@ class PhpArrayContainer extends Container {
|
||||
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The service container does not know how to construct this service. The service will need to be set before it is first used.', $id));
|
||||
}
|
||||
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
if (isset($definition['arguments'])) {
|
||||
$arguments = $this->resolveServicesAndParameters($definition['arguments']);
|
||||
}
|
||||
|
||||
if (isset($definition['file'])) {
|
||||
$file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters(array($definition['file'])));
|
||||
$file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters([$definition['file']]));
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
if (isset($definition['factory'])) {
|
||||
$factory = $definition['factory'];
|
||||
if (is_array($factory)) {
|
||||
$factory = $this->resolveServicesAndParameters(array($factory[0], $factory[1]));
|
||||
$factory = $this->resolveServicesAndParameters([$factory[0], $factory[1]]);
|
||||
}
|
||||
elseif (!is_string($factory)) {
|
||||
throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id));
|
||||
@@ -79,7 +79,7 @@ class PhpArrayContainer extends Container {
|
||||
$service = call_user_func_array($factory, $arguments);
|
||||
}
|
||||
else {
|
||||
$class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class'])));
|
||||
$class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters([$definition['class']]));
|
||||
$length = isset($definition['arguments_count']) ? $definition['arguments_count'] : count($arguments);
|
||||
|
||||
// Optimize class instantiation for services with up to 10 parameters as
|
||||
@@ -147,12 +147,12 @@ class PhpArrayContainer extends Container {
|
||||
if (isset($definition['calls'])) {
|
||||
foreach ($definition['calls'] as $call) {
|
||||
$method = $call[0];
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
if (!empty($call[1])) {
|
||||
$arguments = $call[1];
|
||||
$arguments = $this->resolveServicesAndParameters($arguments);
|
||||
}
|
||||
call_user_func_array(array($service, $method), $arguments);
|
||||
call_user_func_array([$service, $method], $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class Diff {
|
||||
*/
|
||||
public function reverse() {
|
||||
$rev = $this;
|
||||
$rev->edits = array();
|
||||
$rev->edits = [];
|
||||
foreach ($this->edits as $edit) {
|
||||
$rev->edits[] = $edit->reverse();
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class Diff {
|
||||
* @return array The original sequence of strings.
|
||||
*/
|
||||
public function orig() {
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
|
||||
foreach ($this->edits as $edit) {
|
||||
if ($edit->orig) {
|
||||
@@ -115,7 +115,7 @@ class Diff {
|
||||
* @return array The sequence of strings.
|
||||
*/
|
||||
public function closing() {
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
|
||||
foreach ($this->edits as $edit) {
|
||||
if ($edit->closing) {
|
||||
|
||||
@@ -36,6 +36,16 @@ class DiffFormatter {
|
||||
*/
|
||||
public $trailing_context_lines = 0;
|
||||
|
||||
/**
|
||||
* The line stats.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $line_stats = [
|
||||
'counter' => ['x' => 0, 'y' => 0],
|
||||
'offset' => ['x' => 0, 'y' => 0],
|
||||
];
|
||||
|
||||
/**
|
||||
* Format a diff.
|
||||
*
|
||||
@@ -48,7 +58,7 @@ class DiffFormatter {
|
||||
public function format(Diff $diff) {
|
||||
$xi = $yi = 1;
|
||||
$block = FALSE;
|
||||
$context = array();
|
||||
$context = [];
|
||||
|
||||
$nlead = $this->leading_context_lines;
|
||||
$ntrail = $this->trailing_context_lines;
|
||||
@@ -77,7 +87,7 @@ class DiffFormatter {
|
||||
$context = array_slice($context, sizeof($context) - $nlead);
|
||||
$x0 = $xi - sizeof($context);
|
||||
$y0 = $yi - sizeof($context);
|
||||
$block = array();
|
||||
$block = [];
|
||||
if ($context) {
|
||||
$block[] = new DiffOpCopy($context);
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ class DiffEngine {
|
||||
$n_from = sizeof($from_lines);
|
||||
$n_to = sizeof($to_lines);
|
||||
|
||||
$this->xchanged = $this->ychanged = array();
|
||||
$this->xv = $this->yv = array();
|
||||
$this->xind = $this->yind = array();
|
||||
$this->xchanged = $this->ychanged = [];
|
||||
$this->xv = $this->yv = [];
|
||||
$this->xind = $this->yind = [];
|
||||
unset($this->seq);
|
||||
unset($this->in_seq);
|
||||
unset($this->lcs);
|
||||
@@ -93,14 +93,14 @@ class DiffEngine {
|
||||
$this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged);
|
||||
|
||||
// Compute the edit operations.
|
||||
$edits = array();
|
||||
$edits = [];
|
||||
$xi = $yi = 0;
|
||||
while ($xi < $n_from || $yi < $n_to) {
|
||||
$this::USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]);
|
||||
$this::USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]);
|
||||
|
||||
// Skip matching "snake".
|
||||
$copy = array();
|
||||
$copy = [];
|
||||
while ( $xi < $n_from && $yi < $n_to && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
|
||||
$copy[] = $from_lines[$xi++];
|
||||
++$yi;
|
||||
@@ -109,11 +109,11 @@ class DiffEngine {
|
||||
$edits[] = new DiffOpCopy($copy);
|
||||
}
|
||||
// Find deletes & adds.
|
||||
$delete = array();
|
||||
$delete = [];
|
||||
while ($xi < $n_from && $this->xchanged[$xi]) {
|
||||
$delete[] = $from_lines[$xi++];
|
||||
}
|
||||
$add = array();
|
||||
$add = [];
|
||||
while ($yi < $n_to && $this->ychanged[$yi]) {
|
||||
$add[] = $to_lines[$yi++];
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class DiffEngine {
|
||||
// Things seems faster (I'm not sure I understand why)
|
||||
// when the shortest sequence in X.
|
||||
$flip = TRUE;
|
||||
list($xoff, $xlim, $yoff, $ylim) = array($yoff, $ylim, $xoff, $xlim);
|
||||
list($xoff, $xlim, $yoff, $ylim) = [$yoff, $ylim, $xoff, $xlim];
|
||||
}
|
||||
|
||||
if ($flip) {
|
||||
@@ -182,8 +182,8 @@ class DiffEngine {
|
||||
}
|
||||
$this->lcs = 0;
|
||||
$this->seq[0] = $yoff - 1;
|
||||
$this->in_seq = array();
|
||||
$ymids[0] = array();
|
||||
$this->in_seq = [];
|
||||
$ymids[0] = [];
|
||||
|
||||
$numer = $xlim - $xoff + $nchunks - 1;
|
||||
$x = $xoff;
|
||||
@@ -228,16 +228,16 @@ class DiffEngine {
|
||||
}
|
||||
}
|
||||
|
||||
$seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
|
||||
$seps[] = $flip ? [$yoff, $xoff] : [$xoff, $yoff];
|
||||
$ymid = $ymids[$this->lcs];
|
||||
for ($n = 0; $n < $nchunks - 1; $n++) {
|
||||
$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
|
||||
$y1 = $ymid[$n] + 1;
|
||||
$seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
|
||||
$seps[] = $flip ? [$y1, $x1] : [$x1, $y1];
|
||||
}
|
||||
$seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
|
||||
$seps[] = $flip ? [$ylim, $xlim] : [$xlim, $ylim];
|
||||
|
||||
return array($this->lcs, $seps);
|
||||
return [$this->lcs, $seps];
|
||||
}
|
||||
|
||||
protected function _lcs_pos($ypos) {
|
||||
|
||||
@@ -20,7 +20,7 @@ class HWLDFWordAccumulator {
|
||||
*/
|
||||
const NBSP = ' ';
|
||||
|
||||
protected $lines = array();
|
||||
protected $lines = [];
|
||||
|
||||
protected $line = '';
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ class WordLevelDiff extends MappedDiff {
|
||||
}
|
||||
|
||||
protected function _split($lines) {
|
||||
$words = array();
|
||||
$stripped = array();
|
||||
$words = [];
|
||||
$stripped = [];
|
||||
$first = TRUE;
|
||||
foreach ($lines as $line) {
|
||||
// If the line is too long, just pretend the entire line is one big word
|
||||
@@ -46,7 +46,7 @@ class WordLevelDiff extends MappedDiff {
|
||||
}
|
||||
}
|
||||
}
|
||||
return array($words, $stripped);
|
||||
return [$words, $stripped];
|
||||
}
|
||||
|
||||
public function orig() {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"license": "GPL-2.0+",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"drupal/utility": "~8.1"
|
||||
"drupal/utility": "~8.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -65,7 +65,7 @@ class YamlDirectoryDiscovery implements DiscoverableInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findAll() {
|
||||
$all = array();
|
||||
$all = [];
|
||||
|
||||
$files = $this->findFiles();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class YamlDiscovery implements DiscoverableInterface {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $directories = array();
|
||||
protected $directories = [];
|
||||
|
||||
/**
|
||||
* Constructs a YamlDiscovery object.
|
||||
@@ -42,7 +42,7 @@ class YamlDiscovery implements DiscoverableInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findAll() {
|
||||
$all = array();
|
||||
$all = [];
|
||||
|
||||
$files = $this->findFiles();
|
||||
$provider_by_files = array_flip($files);
|
||||
@@ -61,7 +61,7 @@ class YamlDiscovery implements DiscoverableInterface {
|
||||
foreach ($provider_by_files as $file => $provider) {
|
||||
// If a file is empty or its contents are commented out, return an empty
|
||||
// array instead of NULL for type consistency.
|
||||
$all[$provider] = Yaml::decode(file_get_contents($file)) ?: [];
|
||||
$all[$provider] = $this->decode($file);
|
||||
$file_cache->set($file, $all[$provider]);
|
||||
}
|
||||
}
|
||||
@@ -69,13 +69,24 @@ class YamlDiscovery implements DiscoverableInterface {
|
||||
return $all;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a YAML file.
|
||||
*
|
||||
* @param string $file
|
||||
* Yaml file path.
|
||||
* @return array
|
||||
*/
|
||||
protected function decode($file) {
|
||||
return Yaml::decode(file_get_contents($file)) ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of file paths, keyed by provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function findFiles() {
|
||||
$files = array();
|
||||
$files = [];
|
||||
foreach ($this->directories as $provider => $directory) {
|
||||
$file = $directory . '/' . $provider . '.' . $this->name . '.yml';
|
||||
if (file_exists($file)) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
"license": "GPL-2.0+",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"drupal/core-filecache": "~8.1",
|
||||
"drupal/core-serialization": "~8.1"
|
||||
"drupal/core-filecache": "~8.2",
|
||||
"drupal/core-serialization": "~8.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -156,6 +156,35 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListenerPriority($eventName, $listener) {
|
||||
// Parts copied from \Symfony\Component\EventDispatcher, that's why you see
|
||||
// a yoda condition here.
|
||||
if (!isset($this->listeners[$eventName])) {
|
||||
return;
|
||||
}
|
||||
foreach ($this->listeners[$eventName] as $priority => $listeners) {
|
||||
if (FALSE !== ($key = array_search(['callable' => $listener], $listeners, TRUE))) {
|
||||
return $priority;
|
||||
}
|
||||
}
|
||||
// Resolve service definitions if the listener has not been found so far.
|
||||
foreach ($this->listeners[$eventName] as $priority => &$definitions) {
|
||||
foreach ($definitions as $key => &$definition) {
|
||||
if (!isset($definition['callable'])) {
|
||||
// Once the callable is retrieved we keep it for subsequent method
|
||||
// invocations on this class.
|
||||
$definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
|
||||
if ($definition['callable'] === $listener) {
|
||||
return $priority;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -201,14 +230,14 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
|
||||
public function addSubscriber(EventSubscriberInterface $subscriber) {
|
||||
foreach ($subscriber->getSubscribedEvents() as $event_name => $params) {
|
||||
if (is_string($params)) {
|
||||
$this->addListener($event_name, array($subscriber, $params));
|
||||
$this->addListener($event_name, [$subscriber, $params]);
|
||||
}
|
||||
elseif (is_string($params[0])) {
|
||||
$this->addListener($event_name, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
|
||||
$this->addListener($event_name, [$subscriber, $params[0]], isset($params[1]) ? $params[1] : 0);
|
||||
}
|
||||
else {
|
||||
foreach ($params as $listener) {
|
||||
$this->addListener($event_name, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
|
||||
$this->addListener($event_name, [$subscriber, $listener[0]], isset($listener[1]) ? $listener[1] : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,11 +250,11 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
|
||||
foreach ($subscriber->getSubscribedEvents() as $event_name => $params) {
|
||||
if (is_array($params) && is_array($params[0])) {
|
||||
foreach ($params as $listener) {
|
||||
$this->removeListener($event_name, array($subscriber, $listener[0]));
|
||||
$this->removeListener($event_name, [$subscriber, $listener[0]]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->removeListener($event_name, array($subscriber, is_string($params) ? $params : $params[0]));
|
||||
$this->removeListener($event_name, [$subscriber, is_string($params) ? $params : $params[0]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,11 @@ namespace Drupal\Component\FileCache;
|
||||
*/
|
||||
class FileCacheFactory {
|
||||
|
||||
/**
|
||||
* The configuration key to disable FileCache completely.
|
||||
*/
|
||||
const DISABLE_CACHE = 'file_cache_disable';
|
||||
|
||||
/**
|
||||
* The configuration used to create FileCache objects.
|
||||
*
|
||||
@@ -34,23 +39,35 @@ class FileCacheFactory {
|
||||
* The initialized FileCache object.
|
||||
*/
|
||||
public static function get($collection, $default_configuration = []) {
|
||||
$default_configuration += [
|
||||
// If there is a special key in the configuration, disable FileCache completely.
|
||||
if (!empty(static::$configuration[static::DISABLE_CACHE])) {
|
||||
return new NullFileCache('', '');
|
||||
}
|
||||
|
||||
$configuration = [];
|
||||
|
||||
// Check for a collection specific setting first.
|
||||
if (isset(static::$configuration[$collection])) {
|
||||
$configuration += static::$configuration[$collection];
|
||||
}
|
||||
// Then check if a default configuration has been provided.
|
||||
if (!empty($default_configuration)) {
|
||||
$configuration += $default_configuration;
|
||||
}
|
||||
// Last check if a default setting has been provided.
|
||||
if (isset(static::$configuration['default'])) {
|
||||
$configuration += static::$configuration['default'];
|
||||
}
|
||||
|
||||
// Ensure that all properties are set.
|
||||
$fallback_configuration = [
|
||||
'class' => '\Drupal\Component\FileCache\FileCache',
|
||||
'collection' => $collection,
|
||||
'cache_backend_class' => NULL,
|
||||
'cache_backend_configuration' => [],
|
||||
];
|
||||
|
||||
$configuration = [];
|
||||
if (isset(static::$configuration[$collection])) {
|
||||
$configuration = static::$configuration[$collection];
|
||||
}
|
||||
elseif (isset(static::$configuration['default'])) {
|
||||
$configuration = static::$configuration['default'];
|
||||
}
|
||||
|
||||
// Add defaults to the configuration.
|
||||
$configuration = $configuration + $default_configuration;
|
||||
$configuration = $configuration + $fallback_configuration;
|
||||
|
||||
$class = $configuration['class'];
|
||||
return new $class(static::getPrefix(), $configuration['collection'], $configuration['cache_backend_class'], $configuration['cache_backend_configuration']);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\FileSystem;
|
||||
|
||||
/**
|
||||
* Provides file system functions.
|
||||
*/
|
||||
class FileSystem {
|
||||
|
||||
/**
|
||||
* Discovers a writable system-appropriate temporary directory.
|
||||
*
|
||||
* @return string|false
|
||||
* A string containing the path to the temporary directory, or FALSE if no
|
||||
* suitable temporary directory can be found.
|
||||
*/
|
||||
public static function getOsTemporaryDirectory() {
|
||||
$directories = [];
|
||||
|
||||
// Has PHP been set with an upload_tmp_dir?
|
||||
if (ini_get('upload_tmp_dir')) {
|
||||
$directories[] = ini_get('upload_tmp_dir');
|
||||
}
|
||||
|
||||
// Operating system specific dirs.
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
$directories[] = 'c:\\windows\\temp';
|
||||
$directories[] = 'c:\\winnt\\temp';
|
||||
}
|
||||
else {
|
||||
$directories[] = '/tmp';
|
||||
}
|
||||
// PHP may be able to find an alternative tmp directory.
|
||||
$directories[] = sys_get_temp_dir();
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
if (is_dir($directory) && is_writable($directory)) {
|
||||
// Both sys_get_temp_dir() and ini_get('upload_tmp_dir') can return paths
|
||||
// with a trailing directory separator.
|
||||
return rtrim($directory, DIRECTORY_SEPARATOR);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class PoHeader {
|
||||
* Plural form component from the header, for example:
|
||||
* 'nplurals=2; plural=(n > 1);'.
|
||||
*/
|
||||
function getPluralForms() {
|
||||
public function getPluralForms() {
|
||||
return $this->_pluralForms;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class PoHeader {
|
||||
* @param string $languageName
|
||||
* Human readable language name.
|
||||
*/
|
||||
function setLanguageName($languageName) {
|
||||
public function setLanguageName($languageName) {
|
||||
$this->_languageName = $languageName;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class PoHeader {
|
||||
* @return string
|
||||
* The human readable language name.
|
||||
*/
|
||||
function getLanguageName() {
|
||||
public function getLanguageName() {
|
||||
return $this->_languageName;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class PoHeader {
|
||||
* @param string $projectName
|
||||
* Human readable project name.
|
||||
*/
|
||||
function setProjectName($projectName) {
|
||||
public function setProjectName($projectName) {
|
||||
$this->_projectName = $projectName;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ class PoHeader {
|
||||
* @return string
|
||||
* The human readable project name.
|
||||
*/
|
||||
function getProjectName() {
|
||||
public function getProjectName() {
|
||||
return $this->_projectName;
|
||||
}
|
||||
|
||||
@@ -190,10 +190,10 @@ class PoHeader {
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
function parsePluralForms($pluralforms) {
|
||||
$plurals = array();
|
||||
public function parsePluralForms($pluralforms) {
|
||||
$plurals = [];
|
||||
// First, delete all whitespace.
|
||||
$pluralforms = strtr($pluralforms, array(" " => "", "\t" => ""));
|
||||
$pluralforms = strtr($pluralforms, [" " => "", "\t" => ""]);
|
||||
|
||||
// Select the parts that define nplurals and plural.
|
||||
$nplurals = strstr($pluralforms, "nplurals=");
|
||||
@@ -215,7 +215,7 @@ class PoHeader {
|
||||
|
||||
// If the number of plurals is zero, we return a default result.
|
||||
if ($nplurals == 0) {
|
||||
return array($nplurals, array('default' => 0));
|
||||
return [$nplurals, ['default' => 0]];
|
||||
}
|
||||
|
||||
// Calculate possible plural positions of different plural values. All known
|
||||
@@ -233,7 +233,7 @@ class PoHeader {
|
||||
});
|
||||
$plurals['default'] = $default;
|
||||
|
||||
return array($nplurals, $plurals);
|
||||
return [$nplurals, $plurals];
|
||||
}
|
||||
else {
|
||||
throw new \Exception('The plural formula could not be parsed.');
|
||||
@@ -250,7 +250,7 @@ class PoHeader {
|
||||
* An associative array of key-value pairs.
|
||||
*/
|
||||
private function parseHeader($header) {
|
||||
$header_parsed = array();
|
||||
$header_parsed = [];
|
||||
$lines = array_map('trim', explode("\n", $header));
|
||||
foreach ($lines as $line) {
|
||||
if ($line) {
|
||||
@@ -275,17 +275,17 @@ class PoHeader {
|
||||
*/
|
||||
private function parseArithmetic($string) {
|
||||
// Operator precedence table.
|
||||
$precedence = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
|
||||
$precedence = ["(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8];
|
||||
// Right associativity.
|
||||
$right_associativity = array("?" => 1, ":" => 1);
|
||||
$right_associativity = ["?" => 1, ":" => 1];
|
||||
|
||||
$tokens = $this->tokenizeFormula($string);
|
||||
|
||||
// Parse by converting into infix notation then back into postfix
|
||||
// Operator stack - holds math operators and symbols.
|
||||
$operator_stack = array();
|
||||
$operator_stack = [];
|
||||
// Element Stack - holds data to be operated on.
|
||||
$element_stack = array();
|
||||
$element_stack = [];
|
||||
|
||||
foreach ($tokens as $token) {
|
||||
$current_token = $token;
|
||||
@@ -373,7 +373,7 @@ class PoHeader {
|
||||
*/
|
||||
private function tokenizeFormula($formula) {
|
||||
$formula = str_replace(" ", "", $formula);
|
||||
$tokens = array();
|
||||
$tokens = [];
|
||||
for ($i = 0; $i < strlen($formula); $i++) {
|
||||
if (is_numeric($formula[$i])) {
|
||||
$num = $formula[$i];
|
||||
|
||||
@@ -59,7 +59,7 @@ class PoItem {
|
||||
*
|
||||
* @return string with langcode
|
||||
*/
|
||||
function getLangcode() {
|
||||
public function getLangcode() {
|
||||
return $this->_langcode;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class PoItem {
|
||||
*
|
||||
* @param string $langcode
|
||||
*/
|
||||
function setLangcode($langcode) {
|
||||
public function setLangcode($langcode) {
|
||||
$this->_langcode = $langcode;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class PoItem {
|
||||
*
|
||||
* @return string $context
|
||||
*/
|
||||
function getContext() {
|
||||
public function getContext() {
|
||||
return $this->_context;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class PoItem {
|
||||
*
|
||||
* @param string $context
|
||||
*/
|
||||
function setContext($context) {
|
||||
public function setContext($context) {
|
||||
$this->_context = $context;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class PoItem {
|
||||
*
|
||||
* @return string or array $translation
|
||||
*/
|
||||
function getSource() {
|
||||
public function getSource() {
|
||||
return $this->_source;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class PoItem {
|
||||
*
|
||||
* @param string or array $source
|
||||
*/
|
||||
function setSource($source) {
|
||||
public function setSource($source) {
|
||||
$this->_source = $source;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ class PoItem {
|
||||
*
|
||||
* @return string or array $translation
|
||||
*/
|
||||
function getTranslation() {
|
||||
public function getTranslation() {
|
||||
return $this->_translation;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class PoItem {
|
||||
*
|
||||
* @param string or array $translation
|
||||
*/
|
||||
function setTranslation($translation) {
|
||||
public function setTranslation($translation) {
|
||||
$this->_translation = $translation;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ class PoItem {
|
||||
*
|
||||
* @param bool $plural
|
||||
*/
|
||||
function setPlural($plural) {
|
||||
public function setPlural($plural) {
|
||||
$this->_plural = $plural;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ class PoItem {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function isPlural() {
|
||||
public function isPlural() {
|
||||
return $this->_plural;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ class PoItem {
|
||||
*
|
||||
* @return String $comment
|
||||
*/
|
||||
function getComment() {
|
||||
public function getComment() {
|
||||
return $this->_comment;
|
||||
}
|
||||
|
||||
@@ -162,16 +162,16 @@ class PoItem {
|
||||
*
|
||||
* @param string $comment
|
||||
*/
|
||||
function setComment($comment) {
|
||||
public function setComment($comment) {
|
||||
$this->_comment = $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the PoItem from a structured array.
|
||||
*
|
||||
* @param array values
|
||||
* @param array $values
|
||||
*/
|
||||
public function setFromArray(array $values = array()) {
|
||||
public function setFromArray(array $values = []) {
|
||||
if (isset($values['context'])) {
|
||||
$this->setContext($values['context']);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ class PoMemoryWriter implements PoWriterInterface {
|
||||
/**
|
||||
* Constructor, initialize empty items.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->_items = array();
|
||||
public function __construct() {
|
||||
$this->_items = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ class PoMemoryWriter implements PoWriterInterface {
|
||||
*
|
||||
* Not implemented. Not relevant for the MemoryWriter.
|
||||
*/
|
||||
function setLangcode($langcode) {
|
||||
public function setLangcode($langcode) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ class PoMemoryWriter implements PoWriterInterface {
|
||||
*
|
||||
* Not implemented. Not relevant for the MemoryWriter.
|
||||
*/
|
||||
function getLangcode() {
|
||||
public function getLangcode() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ class PoMemoryWriter implements PoWriterInterface {
|
||||
*
|
||||
* Not implemented. Not relevant for the MemoryWriter.
|
||||
*/
|
||||
function getHeader() {
|
||||
public function getHeader() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ class PoMemoryWriter implements PoWriterInterface {
|
||||
*
|
||||
* Not implemented. Not relevant for the MemoryWriter.
|
||||
*/
|
||||
function setHeader(PoHeader $header) {
|
||||
public function setHeader(PoHeader $header) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ interface PoMetadataInterface {
|
||||
/**
|
||||
* Get header metadata.
|
||||
*
|
||||
* @return \Drupal\Component\Gettext\PoHeader $header
|
||||
* @return \Drupal\Component\Gettext\PoHeader
|
||||
* Header instance representing metadata in a PO header.
|
||||
*/
|
||||
public function getHeader();
|
||||
|
||||
@@ -39,7 +39,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_current_item = array();
|
||||
private $_current_item = [];
|
||||
|
||||
/**
|
||||
* Current plural index for plural translations.
|
||||
@@ -261,14 +261,14 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$this->_line_number++;
|
||||
|
||||
// Initialize common values for error logging.
|
||||
$log_vars = array(
|
||||
$log_vars = [
|
||||
'%uri' => $this->getURI(),
|
||||
'%line' => $this->_line_number,
|
||||
);
|
||||
];
|
||||
|
||||
// Trim away the linefeed. \\n might appear at the end of the string if
|
||||
// another line continuing the same string follows. We can remove that.
|
||||
$line = trim(strtr($line, array("\\\n" => "")));
|
||||
$line = trim(strtr($line, ["\\\n" => ""]));
|
||||
|
||||
if (!strncmp('#', $line, 1)) {
|
||||
// Lines starting with '#' are comments.
|
||||
@@ -282,7 +282,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$this->setItemFromArray($this->_current_item);
|
||||
|
||||
// Start a new entry for the comment.
|
||||
$this->_current_item = array();
|
||||
$this->_current_item = [];
|
||||
$this->_current_item['#'][] = substr($line, 1);
|
||||
|
||||
$this->_context = 'COMMENT';
|
||||
@@ -319,7 +319,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
if (is_string($this->_current_item['msgid'])) {
|
||||
// The first value was stored as string. Now we know the context is
|
||||
// plural, it is converted to array.
|
||||
$this->_current_item['msgid'] = array($this->_current_item['msgid']);
|
||||
$this->_current_item['msgid'] = [$this->_current_item['msgid']];
|
||||
}
|
||||
$this->_current_item['msgid'][] = $quoted;
|
||||
|
||||
@@ -334,7 +334,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$this->setItemFromArray($this->_current_item);
|
||||
|
||||
// Start a new context for the msgid.
|
||||
$this->_current_item = array();
|
||||
$this->_current_item = [];
|
||||
}
|
||||
elseif ($this->_context == 'MSGID') {
|
||||
// We are currently already in the context, meaning we passed an id with no data.
|
||||
@@ -363,7 +363,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
|
||||
// We are currently in string context, save current item.
|
||||
$this->setItemFromArray($this->_current_item);
|
||||
$this->_current_item = array();
|
||||
$this->_current_item = [];
|
||||
}
|
||||
elseif (!empty($this->_current_item['msgctxt'])) {
|
||||
// A context cannot apply to another context.
|
||||
@@ -421,7 +421,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
return FALSE;
|
||||
}
|
||||
if (!isset($this->_current_item['msgstr']) || !is_array($this->_current_item['msgstr'])) {
|
||||
$this->_current_item['msgstr'] = array();
|
||||
$this->_current_item['msgstr'] = [];
|
||||
}
|
||||
|
||||
$this->_current_item['msgstr'][$this->_current_plural_index] = $quoted;
|
||||
@@ -500,7 +500,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
// Empty line read or EOF of PO stream, close out the last entry.
|
||||
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
|
||||
$this->setItemFromArray($this->_current_item);
|
||||
$this->_current_item = array();
|
||||
$this->_current_item = [];
|
||||
}
|
||||
elseif ($this->_context != 'COMMENT') {
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
|
||||
@@ -547,7 +547,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
* @return
|
||||
* The string parsed from inside the quotes.
|
||||
*/
|
||||
function parseQuoted($string) {
|
||||
public function parseQuoted($string) {
|
||||
if (substr($string, 0, 1) != substr($string, -1, 1)) {
|
||||
// Start and end quotes must be the same.
|
||||
return FALSE;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"drupal/core-utility": "~8.1"
|
||||
"drupal/core-utility": "~8.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -56,13 +56,13 @@ class Graph {
|
||||
* identifier.
|
||||
*/
|
||||
public function searchAndSort() {
|
||||
$state = array(
|
||||
$state = [
|
||||
// The order of last visit of the depth first search. This is the reverse
|
||||
// of the topological order if the graph is acyclic.
|
||||
'last_visit_order' => array(),
|
||||
'last_visit_order' => [],
|
||||
// The components of the graph.
|
||||
'components' => array(),
|
||||
);
|
||||
'components' => [],
|
||||
];
|
||||
// Perform the actual search.
|
||||
foreach ($this->graph as $start => $data) {
|
||||
$this->depthFirstSearch($state, $start);
|
||||
@@ -71,7 +71,7 @@ class Graph {
|
||||
// We do such a numbering that every component starts with 0. This is useful
|
||||
// for module installs as we can install every 0 weighted module in one
|
||||
// request, and then every 1 weighted etc.
|
||||
$component_weights = array();
|
||||
$component_weights = [];
|
||||
|
||||
foreach ($state['last_visit_order'] as $vertex) {
|
||||
$component = $this->graph[$vertex]['component'];
|
||||
@@ -108,7 +108,7 @@ class Graph {
|
||||
return;
|
||||
}
|
||||
// Mark $start as visited.
|
||||
$this->graph[$start]['paths'] = array();
|
||||
$this->graph[$start]['paths'] = [];
|
||||
|
||||
// Assign $start to the current component.
|
||||
$this->graph[$start]['component'] = $component;
|
||||
|
||||
@@ -68,7 +68,7 @@ class FileReadOnlyStorage implements PhpStorageInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function writeable() {
|
||||
public function writeable() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class FileReadOnlyStorage implements PhpStorageInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function listAll() {
|
||||
$names = array();
|
||||
$names = [];
|
||||
if (file_exists($this->directory)) {
|
||||
foreach (new \DirectoryIterator($this->directory) as $fileinfo) {
|
||||
if (!$fileinfo->isDot()) {
|
||||
|
||||
@@ -49,12 +49,7 @@ class FileStorage implements PhpStorageInterface {
|
||||
public function save($name, $code) {
|
||||
$path = $this->getFullPath($name);
|
||||
$directory = dirname($path);
|
||||
if ($this->ensureDirectory($directory)) {
|
||||
$htaccess_path = $directory . '/.htaccess';
|
||||
if (!file_exists($htaccess_path) && file_put_contents($htaccess_path, static::htaccessLines())) {
|
||||
@chmod($htaccess_path, 0444);
|
||||
}
|
||||
}
|
||||
$this->ensureDirectory($directory);
|
||||
return (bool) file_put_contents($path, $code);
|
||||
}
|
||||
|
||||
@@ -120,9 +115,6 @@ EOF;
|
||||
* The directory path.
|
||||
* @param int $mode
|
||||
* The mode, permissions, the directory should have.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the directory exists or has been created, FALSE otherwise.
|
||||
*/
|
||||
protected function ensureDirectory($directory, $mode = 0777) {
|
||||
if ($this->createDirectory($directory, $mode)) {
|
||||
@@ -246,7 +238,7 @@ EOF;
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function listAll() {
|
||||
$names = array();
|
||||
$names = [];
|
||||
if (file_exists($this->directory)) {
|
||||
foreach (new \DirectoryIterator($this->directory) as $fileinfo) {
|
||||
if (!$fileinfo->isDot()) {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Drupal\Component\PhpStorage;
|
||||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
|
||||
/**
|
||||
* Stores PHP code in files with securely hashed names.
|
||||
*
|
||||
@@ -130,7 +132,7 @@ class MTimeProtectedFastFileStorage extends FileStorage {
|
||||
if (!isset($directory_mtime)) {
|
||||
$directory_mtime = file_exists($directory) ? filemtime($directory) : 0;
|
||||
}
|
||||
return $directory . '/' . hash_hmac('sha256', $name, $this->secret . $directory_mtime) . '.php';
|
||||
return $directory . '/' . Crypt::hmacBase64($name, $this->secret . $directory_mtime) . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +227,7 @@ class MTimeProtectedFastFileStorage extends FileStorage {
|
||||
*/
|
||||
protected function tempnam($directory, $prefix) {
|
||||
do {
|
||||
$path = $directory . '/' . $prefix . substr(str_shuffle(hash('sha256', microtime())), 0, 10);
|
||||
$path = $directory . '/' . $prefix . Crypt::randomBytesBase64(20);
|
||||
} while (file_exists($path));
|
||||
return $path;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ interface PhpStorageInterface {
|
||||
* @param string $name
|
||||
* The virtual file name. Can be a relative path.
|
||||
*
|
||||
* @return string|FALSE
|
||||
* @return string|false
|
||||
* The full file path for the provided name. Return FALSE if the
|
||||
* implementation needs to prevent access to the file.
|
||||
*/
|
||||
|
||||
@@ -79,7 +79,7 @@ class Context implements ContextInterface {
|
||||
if (empty($this->contextDefinition['class'])) {
|
||||
throw new ContextException("An error was encountered while trying to validate the context.");
|
||||
}
|
||||
return array(new Type($this->contextDefinition['class']));
|
||||
return [new Type($this->contextDefinition['class'])];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace Drupal\Component\Plugin\Context;
|
||||
|
||||
/**
|
||||
* Interface for context definitions.
|
||||
* Interface used to define definition objects found in ContextInterface.
|
||||
*
|
||||
* @see \Drupal\Component\Plugin\Context\ContextInterface
|
||||
*
|
||||
* @todo WARNING: This interface is going to receive some additions as part of
|
||||
* https://www.drupal.org/node/2346999.
|
||||
|
||||
@@ -3,7 +3,14 @@
|
||||
namespace Drupal\Component\Plugin\Context;
|
||||
|
||||
/**
|
||||
* A generic context interface for wrapping data a plugin needs to operate.
|
||||
* Provides data and definitions for plugins during runtime and administration.
|
||||
*
|
||||
* Plugin contexts are satisfied by ContextInterface implementing objects.
|
||||
* These objects always contain a definition of what data they will provide
|
||||
* during runtime. During run time, ContextInterface implementing objects must
|
||||
* also provide the corresponding data value.
|
||||
*
|
||||
* @see \Drupal\Component\Plugin\Context\ContextDefinitionInterface
|
||||
*/
|
||||
interface ContextInterface {
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
|
||||
*/
|
||||
public function getContextDefinitions() {
|
||||
$definition = $this->getPluginDefinition();
|
||||
return !empty($definition['context']) ? $definition['context'] : array();
|
||||
return !empty($definition['context']) ? $definition['context'] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContextValues() {
|
||||
$values = array();
|
||||
$values = [];
|
||||
foreach ($this->getContextDefinitions() as $name => $definition) {
|
||||
$values[$name] = isset($this->context[$name]) ? $this->context[$name]->getContextValue() : NULL;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ interface ContextAwarePluginInterface extends PluginInspectionInterface {
|
||||
* @param string $name
|
||||
* The name of the context in the plugin definition.
|
||||
*
|
||||
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface.
|
||||
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface
|
||||
* The definition against which the context value must validate.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\PluginException
|
||||
@@ -103,7 +103,7 @@ interface ContextAwarePluginInterface extends PluginInspectionInterface {
|
||||
* The value to set the context to. The value has to validate against the
|
||||
* provided context definition.
|
||||
*
|
||||
* @return \Drupal\Component\Plugin\ContextAwarePluginInterface.
|
||||
* @return \Drupal\Component\Plugin\ContextAwarePluginInterface
|
||||
* A context aware plugin object for chaining.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\PluginException
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin\Definition;
|
||||
|
||||
/**
|
||||
* Provides an interface for a derivable plugin definition.
|
||||
*
|
||||
* @see \Drupal\Component\Plugin\Derivative\DeriverInterface
|
||||
*/
|
||||
interface DerivablePluginDefinitionInterface extends PluginDefinitionInterface {
|
||||
|
||||
/**
|
||||
* Gets the name of the deriver of this plugin definition, if it exists.
|
||||
*
|
||||
* @return string|null
|
||||
* Either the deriver class name, or NULL if the plugin is not derived.
|
||||
*/
|
||||
public function getDeriver();
|
||||
|
||||
/**
|
||||
* Sets the deriver of this plugin definition.
|
||||
*
|
||||
* @param string|null $deriver
|
||||
* Either the name of a class that implements
|
||||
* \Drupal\Component\Plugin\Derivative\DeriverInterface, or NULL.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDeriver($deriver);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin\Definition;
|
||||
|
||||
/**
|
||||
* Provides object-based plugin definitions.
|
||||
*/
|
||||
class PluginDefinition implements PluginDefinitionInterface {
|
||||
|
||||
/**
|
||||
* The plugin ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* A fully qualified class name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* The plugin provider.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function id() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setClass($class) {
|
||||
$this->class = $class;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getClass() {
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProvider() {
|
||||
return $this->provider;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,14 @@ namespace Drupal\Component\Plugin\Definition;
|
||||
*/
|
||||
interface PluginDefinitionInterface {
|
||||
|
||||
/**
|
||||
* Gets the unique identifier of the plugin.
|
||||
*
|
||||
* @return string
|
||||
* The unique identifier of the plugin.
|
||||
*/
|
||||
public function id();
|
||||
|
||||
/**
|
||||
* Sets the class.
|
||||
*
|
||||
@@ -32,4 +40,15 @@ interface PluginDefinitionInterface {
|
||||
*/
|
||||
public function getClass();
|
||||
|
||||
/**
|
||||
* Gets the plugin provider.
|
||||
*
|
||||
* The provider is the name of the module that provides the plugin, or "core',
|
||||
* or "component".
|
||||
*
|
||||
* @return string
|
||||
* The provider.
|
||||
*/
|
||||
public function getProvider();
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ abstract class DeriverBase implements DeriverInterface {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $derivatives = array();
|
||||
protected $derivatives = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Drupal\Component\Plugin\Discovery;
|
||||
|
||||
use Drupal\Component\Plugin\Definition\DerivablePluginDefinitionInterface;
|
||||
use Drupal\Component\Plugin\Exception\InvalidDeriverException;
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
|
||||
* @var \Drupal\Component\Plugin\Derivative\DeriverInterface[]
|
||||
* Keys are base plugin IDs.
|
||||
*/
|
||||
protected $derivers = array();
|
||||
protected $derivers = [];
|
||||
|
||||
/**
|
||||
* The decorated plugin discovery.
|
||||
@@ -93,7 +94,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
|
||||
* DiscoveryInterface::getDefinitions().
|
||||
*/
|
||||
protected function getDerivatives(array $base_plugin_definitions) {
|
||||
$plugin_definitions = array();
|
||||
$plugin_definitions = [];
|
||||
foreach ($base_plugin_definitions as $base_plugin_id => $plugin_definition) {
|
||||
$deriver = $this->getDeriver($base_plugin_id, $plugin_definition);
|
||||
if ($deriver) {
|
||||
@@ -136,7 +137,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
|
||||
return explode(':', $plugin_id, 2);
|
||||
}
|
||||
|
||||
return array($plugin_id, NULL);
|
||||
return [$plugin_id, NULL];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,12 +204,21 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
|
||||
*/
|
||||
protected function getDeriverClass($base_definition) {
|
||||
$class = NULL;
|
||||
if ((is_array($base_definition) || ($base_definition = (array) $base_definition)) && (isset($base_definition['deriver']) && $class = $base_definition['deriver'])) {
|
||||
$id = NULL;
|
||||
if ($base_definition instanceof DerivablePluginDefinitionInterface) {
|
||||
$class = $base_definition->getDeriver();
|
||||
$id = $base_definition->id();
|
||||
}
|
||||
if ((is_array($base_definition) || ($base_definition = (array) $base_definition)) && (isset($base_definition['deriver']))) {
|
||||
$class = $base_definition['deriver'];
|
||||
$id = $base_definition['id'];
|
||||
}
|
||||
if ($class) {
|
||||
if (!class_exists($class)) {
|
||||
throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" does not exist.', $base_definition['id'], $class));
|
||||
throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" does not exist.', $id, $class));
|
||||
}
|
||||
if (!is_subclass_of($class, '\Drupal\Component\Plugin\Derivative\DeriverInterface')) {
|
||||
throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" must implement \Drupal\Component\Plugin\Derivative\DeriverInterface.', $base_definition['id'], $class));
|
||||
throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" must implement \Drupal\Component\Plugin\Derivative\DeriverInterface.', $id, $class));
|
||||
}
|
||||
}
|
||||
return $class;
|
||||
@@ -229,7 +239,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
|
||||
// Use this definition as defaults if a plugin already defined itself as
|
||||
// this derivative, but filter out empty values first.
|
||||
$filtered_base = array_filter($base_plugin_definition);
|
||||
$derivative_definition = $filtered_base + ($derivative_definition ?: array());
|
||||
$derivative_definition = $filtered_base + ($derivative_definition ?: []);
|
||||
// Add back any empty keys that the derivative didn't have.
|
||||
return $derivative_definition + $base_plugin_definition;
|
||||
}
|
||||
@@ -238,7 +248,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
|
||||
* Passes through all unknown calls onto the decorated object.
|
||||
*/
|
||||
public function __call($method, $args) {
|
||||
return call_user_func_array(array($this->decorated, $method), $args);
|
||||
return call_user_func_array([$this->decorated, $method], $args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class StaticDiscovery implements DiscoveryInterface {
|
||||
*/
|
||||
public function getDefinitions() {
|
||||
if (!$this->definitions) {
|
||||
$this->definitions = array();
|
||||
$this->definitions = [];
|
||||
}
|
||||
return $this->definitions;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class StaticDiscoveryDecorator extends StaticDiscovery {
|
||||
* Passes through all unknown calls onto the decorated object
|
||||
*/
|
||||
public function __call($method, $args) {
|
||||
return call_user_func_array(array($this->decorated, $method), $args);
|
||||
return call_user_func_array([$this->decorated, $method], $args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class DefaultFactory implements FactoryInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createInstance($plugin_id, array $configuration = array()) {
|
||||
public function createInstance($plugin_id, array $configuration = []) {
|
||||
$plugin_definition = $this->discovery->getDefinition($plugin_id);
|
||||
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
|
||||
return new $plugin_class($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
@@ -21,6 +21,6 @@ interface FactoryInterface {
|
||||
* @throws \Drupal\Component\Plugin\Exception\PluginException
|
||||
* If the instance cannot be created, such as if the ID is invalid.
|
||||
*/
|
||||
public function createInstance($plugin_id, array $configuration = array());
|
||||
public function createInstance($plugin_id, array $configuration = []);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class ReflectionFactory extends DefaultFactory {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createInstance($plugin_id, array $configuration = array()) {
|
||||
public function createInstance($plugin_id, array $configuration = []) {
|
||||
$plugin_definition = $this->discovery->getDefinition($plugin_id);
|
||||
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
|
||||
|
||||
@@ -51,7 +51,7 @@ class ReflectionFactory extends DefaultFactory {
|
||||
*/
|
||||
protected function getInstanceArguments(\ReflectionClass $reflector, $plugin_id, $plugin_definition, array $configuration) {
|
||||
|
||||
$arguments = array();
|
||||
$arguments = [];
|
||||
foreach ($reflector->getMethod('__construct')->getParameters() as $param) {
|
||||
$param_name = $param->getName();
|
||||
|
||||
|
||||
@@ -18,6 +18,6 @@ interface FallbackPluginManagerInterface {
|
||||
* @return string
|
||||
* The id of an existing plugin to use when the plugin does not exist.
|
||||
*/
|
||||
public function getFallbackPluginId($plugin_id, array $configuration = array());
|
||||
public function getFallbackPluginId($plugin_id, array $configuration = []);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ abstract class LazyPluginCollection implements \IteratorAggregate, \Countable {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $pluginInstances = array();
|
||||
protected $pluginInstances = [];
|
||||
|
||||
/**
|
||||
* Stores the IDs of all potential plugin instances.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $instanceIDs = array();
|
||||
protected $instanceIDs = [];
|
||||
|
||||
/**
|
||||
* Initializes and stores a plugin.
|
||||
@@ -53,7 +53,7 @@ abstract class LazyPluginCollection implements \IteratorAggregate, \Countable {
|
||||
* Clears all instantiated plugins.
|
||||
*/
|
||||
public function clear() {
|
||||
$this->pluginInstances = array();
|
||||
$this->pluginInstances = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin;
|
||||
|
||||
/**
|
||||
* Provides an interface for objects that depend on a plugin.
|
||||
*/
|
||||
interface PluginAwareInterface {
|
||||
|
||||
/**
|
||||
* Sets the plugin for this object.
|
||||
*
|
||||
* @param \Drupal\Component\Plugin\PluginInspectionInterface $plugin
|
||||
* The plugin.
|
||||
*/
|
||||
public function setPlugin(PluginInspectionInterface $plugin);
|
||||
|
||||
}
|
||||
@@ -68,7 +68,7 @@ abstract class PluginManagerBase implements PluginManagerInterface {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createInstance($plugin_id, array $configuration = array()) {
|
||||
public function createInstance($plugin_id, array $configuration = []) {
|
||||
// If this PluginManager has fallback capabilities catch
|
||||
// PluginNotFoundExceptions.
|
||||
if ($this instanceof FallbackPluginManagerInterface) {
|
||||
|
||||
@@ -147,7 +147,7 @@ class FormattableMarkup implements MarkupInterface, \Countable {
|
||||
* A call like:
|
||||
* @code
|
||||
* $string = "%output_text";
|
||||
* $arguments = ['output_text' => 'text output here.'];
|
||||
* $arguments = ['%output_text' => 'text output here.'];
|
||||
* $this->placeholderFormat($string, $arguments);
|
||||
* @endcode
|
||||
* makes the following HTML code:
|
||||
@@ -227,11 +227,18 @@ class FormattableMarkup implements MarkupInterface, \Countable {
|
||||
default:
|
||||
// We do not trigger an error for placeholder that start with an
|
||||
// alphabetic character.
|
||||
// @todo https://www.drupal.org/node/2807743 Change to an exception
|
||||
// and always throw regardless of the first character.
|
||||
if (!ctype_alpha($key[0])) {
|
||||
// We trigger an error as we may want to introduce new placeholders
|
||||
// in the future without breaking backward compatibility.
|
||||
trigger_error('Invalid placeholder (' . $key . ') in string: ' . $string, E_USER_ERROR);
|
||||
}
|
||||
elseif (strpos($string, $key) !== FALSE) {
|
||||
trigger_error('Invalid placeholder (' . $key . ') in string: ' . $string, E_USER_DEPRECATED);
|
||||
}
|
||||
// No replacement possible therefore we can discard the argument.
|
||||
unset($args[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"license": "GPL-2.0+",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"drupal/core-utility": "~8.1"
|
||||
"drupal/core-utility": "~8.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -2,42 +2,37 @@
|
||||
|
||||
namespace Drupal\Component\Serialization;
|
||||
|
||||
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Dumper;
|
||||
|
||||
/**
|
||||
* Default serialization for YAML using the Symfony component.
|
||||
* Provides a YAML serialization implementation.
|
||||
*
|
||||
* Proxy implementation that will choose the best library based on availability.
|
||||
*/
|
||||
class Yaml implements SerializationInterface {
|
||||
|
||||
/**
|
||||
* The YAML implementation to use.
|
||||
*
|
||||
* @var \Drupal\Component\Serialization\SerializationInterface
|
||||
*/
|
||||
protected static $serializer;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function encode($data) {
|
||||
try {
|
||||
$yaml = new Dumper();
|
||||
$yaml->setIndentation(2);
|
||||
return $yaml->dump($data, PHP_INT_MAX, 0, TRUE, FALSE);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
// Instead of using \Drupal\Component\Serialization\Yaml::getSerializer(),
|
||||
// always using Symfony for writing the data, to reduce the risk of having
|
||||
// differences if different environments (like production and development)
|
||||
// do not match in terms of what YAML implementation is available.
|
||||
return YamlSymfony::encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function decode($raw) {
|
||||
try {
|
||||
$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);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
$serializer = static::getSerializer();
|
||||
return $serializer::decode($raw);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,4 +42,23 @@ class Yaml implements SerializationInterface {
|
||||
return 'yml';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which implementation to use for parsing YAML.
|
||||
*/
|
||||
protected static function getSerializer() {
|
||||
|
||||
if (!isset(static::$serializer)) {
|
||||
// Use the PECL YAML extension if it is available. It has better
|
||||
// performance for file reads and is YAML compliant.
|
||||
if (extension_loaded('yaml')) {
|
||||
static::$serializer = YamlPecl::class;
|
||||
}
|
||||
else {
|
||||
// Otherwise, fallback to the Symfony implementation.
|
||||
static::$serializer = YamlSymfony::class;
|
||||
}
|
||||
}
|
||||
return static::$serializer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Serialization;
|
||||
|
||||
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
|
||||
|
||||
/**
|
||||
* Provides default serialization for YAML using the PECL extension.
|
||||
*/
|
||||
class YamlPecl implements SerializationInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function encode($data) {
|
||||
static $init;
|
||||
if (!isset($init)) {
|
||||
ini_set('yaml.output_indent', 2);
|
||||
// Do not break lines at 80 characters.
|
||||
ini_set('yaml.output_width', -1);
|
||||
$init = TRUE;
|
||||
}
|
||||
return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function decode($raw) {
|
||||
static $init;
|
||||
if (!isset($init)) {
|
||||
// We never want to unserialize !php/object.
|
||||
ini_set('yaml.decode_php', 0);
|
||||
$init = TRUE;
|
||||
}
|
||||
// yaml_parse() will error with an empty value.
|
||||
if (!trim($raw)) {
|
||||
return NULL;
|
||||
}
|
||||
// @todo Use ErrorExceptions when https://drupal.org/node/1247666 is in.
|
||||
// yaml_parse() will throw errors instead of raising an exception. Until
|
||||
// such time as Drupal supports native PHP ErrorExceptions as the error
|
||||
// handler, we need to temporarily set the error handler as ::errorHandler()
|
||||
// and then restore it after decoding has occurred. This allows us to turn
|
||||
// parsing errors into a throwable exception.
|
||||
// @see Drupal\Component\Serialization\Exception\InvalidDataTypeException
|
||||
// @see http://php.net/manual/en/class.errorexception.php
|
||||
set_error_handler([__CLASS__, 'errorHandler']);
|
||||
$ndocs = 0;
|
||||
$data = yaml_parse($raw, 0, $ndocs, [
|
||||
YAML_BOOL_TAG => '\Drupal\Component\Serialization\YamlPecl::applyBooleanCallbacks',
|
||||
]);
|
||||
restore_error_handler();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles errors for \Drupal\Component\Serialization\YamlPecl::decode().
|
||||
*
|
||||
* @param int $severity
|
||||
* The severity level of the error.
|
||||
* @param string $message
|
||||
* The error message to display.
|
||||
*
|
||||
* @see \Drupal\Component\Serialization\YamlPecl::decode()
|
||||
*/
|
||||
public static function errorHandler($severity, $message) {
|
||||
restore_error_handler();
|
||||
throw new InvalidDataTypeException($message, $severity);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getFileExtension() {
|
||||
return 'yml';
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies callbacks after parsing to ignore 1.1 style booleans.
|
||||
*
|
||||
* @param mixed $value
|
||||
* Value from YAML file.
|
||||
* @param string $tag
|
||||
* Tag that triggered the callback.
|
||||
* @param int $flags
|
||||
* Scalar entity style flags.
|
||||
*
|
||||
* @return string|bool
|
||||
* FALSE, false, TRUE and true are returned as booleans, everything else is
|
||||
* returned as a string.
|
||||
*/
|
||||
public static function applyBooleanCallbacks($value, $tag, $flags) {
|
||||
// YAML 1.1 spec dictates that 'Y', 'N', 'y' and 'n' are booleans. But, we
|
||||
// want the 1.2 behavior, so we only consider 'false', 'FALSE', 'true' and
|
||||
// 'TRUE' as booleans.
|
||||
if (!in_array(strtolower($value), ['false', 'true'], TRUE)) {
|
||||
return $value;
|
||||
}
|
||||
$map = [
|
||||
'false' => FALSE,
|
||||
'true' => TRUE,
|
||||
];
|
||||
return $map[strtolower($value)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Serialization;
|
||||
|
||||
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Dumper;
|
||||
|
||||
/**
|
||||
* Default serialization for YAML using the Symfony component.
|
||||
*/
|
||||
class YamlSymfony implements SerializationInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function encode($data) {
|
||||
try {
|
||||
$yaml = new Dumper();
|
||||
$yaml->setIndentation(2);
|
||||
return $yaml->dump($data, PHP_INT_MAX, 0, TRUE, FALSE);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function decode($raw) {
|
||||
try {
|
||||
$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);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getFileExtension() {
|
||||
return 'yml';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class PhpTransliteration implements TransliterationInterface {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $languageOverrides = array();
|
||||
protected $languageOverrides = [];
|
||||
|
||||
/**
|
||||
* Non-language-specific transliteration tables.
|
||||
@@ -56,7 +56,7 @@ class PhpTransliteration implements TransliterationInterface {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $genericMap = array();
|
||||
protected $genericMap = [];
|
||||
|
||||
/**
|
||||
* Constructs a transliteration object.
|
||||
@@ -83,9 +83,9 @@ class PhpTransliteration implements TransliterationInterface {
|
||||
// few characters that aren't accented letters mixed in. So define the
|
||||
// ranges and the excluded characters.
|
||||
$range1 = $code > 0x00bf && $code < 0x017f;
|
||||
$exclusions_range1 = array(0x00d0, 0x00d7, 0x00f0, 0x00f7, 0x0138, 0x014a, 0x014b);
|
||||
$exclusions_range1 = [0x00d0, 0x00d7, 0x00f0, 0x00f7, 0x0138, 0x014a, 0x014b];
|
||||
$range2 = $code > 0x01cc && $code < 0x0250;
|
||||
$exclusions_range2 = array(0x01DD, 0x01f7, 0x021c, 0x021d, 0x0220, 0x0221, 0x0241, 0x0242, 0x0245);
|
||||
$exclusions_range2 = [0x01DD, 0x01f7, 0x021c, 0x021d, 0x0220, 0x0221, 0x0241, 0x0242, 0x0245];
|
||||
|
||||
$replacement = $character;
|
||||
if (($range1 && !in_array($code, $exclusions_range1)) || ($range2 && !in_array($code, $exclusions_range2))) {
|
||||
@@ -246,7 +246,7 @@ class PhpTransliteration implements TransliterationInterface {
|
||||
include $file;
|
||||
}
|
||||
if (!isset($overrides) || !is_array($overrides)) {
|
||||
$overrides = array($langcode => array());
|
||||
$overrides = [$langcode => []];
|
||||
}
|
||||
$this->languageOverrides[$langcode] = $overrides[$langcode];
|
||||
}
|
||||
@@ -274,7 +274,7 @@ class PhpTransliteration implements TransliterationInterface {
|
||||
include $file;
|
||||
}
|
||||
if (!isset($base) || !is_array($base)) {
|
||||
$base = array();
|
||||
$base = [];
|
||||
}
|
||||
|
||||
// Save this data.
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
* German transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$overrides['de'] = array(
|
||||
$overrides['de'] = [
|
||||
0xC4 => 'Ae',
|
||||
0xD6 => 'Oe',
|
||||
0xDC => 'Ue',
|
||||
0xE4 => 'ae',
|
||||
0xF6 => 'oe',
|
||||
0xFC => 'ue',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
* Danish transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$overrides['dk'] = array(
|
||||
$overrides['dk'] = [
|
||||
0xC5 => 'Aa',
|
||||
0xD8 => 'Oe',
|
||||
0xE5 => 'aa',
|
||||
0xF8 => 'oe',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Esperanto transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$overrides['eo'] = array(
|
||||
$overrides['eo'] = [
|
||||
0x18 => 'Cx',
|
||||
0x19 => 'cx',
|
||||
0x11C => 'Gx',
|
||||
@@ -18,4 +18,4 @@ $overrides['eo'] = array(
|
||||
0x15D => 'sx',
|
||||
0x16C => 'Ux',
|
||||
0x16D => 'ux',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Kyrgyz transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$overrides['kg'] = array(
|
||||
$overrides['kg'] = [
|
||||
0x41 => 'E',
|
||||
0x416 => 'C',
|
||||
0x419 => 'J',
|
||||
@@ -28,4 +28,4 @@ $overrides['kg'] = array(
|
||||
0x4AF => 'w',
|
||||
0x4E8 => 'Q',
|
||||
0x4E9 => 'q',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
// Note: to save memory plain ASCII mappings have been left out.
|
||||
0x80 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
0x90 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
@@ -15,4 +15,4 @@ $base = array(
|
||||
0xD0 => 'D', 'N', 'O', 'O', 'O', 'O', 'O', '*', 'O', 'U', 'U', 'U', 'U', 'Y', 'TH', 'ss',
|
||||
0xE0 => 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
|
||||
0xF0 => 'd', 'n', 'o', 'o', 'o', 'o', 'o', '/', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd',
|
||||
0x10 => 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g',
|
||||
0x20 => 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '@', 'A', 'a',
|
||||
0xE0 => 'A', 'a', 'AE', 'ae', 'G', 'g', 'G', 'g', 'K', 'k', 'O', 'o', 'O', 'o', 'ZH', 'zh',
|
||||
0xF0 => 'j', 'DZ', 'Dz', 'dz', 'G', 'g', 'HV', 'W', 'N', 'n', 'A', 'a', 'AE', 'ae', 'O', 'o',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'A', 'a', 'A', 'a', 'E', 'e', 'E', 'e', 'I', 'i', 'I', 'i', 'O', 'o', 'O', 'o',
|
||||
0x10 => 'R', 'r', 'R', 'r', 'U', 'u', 'U', 'u', 'S', 's', 'T', 't', 'Y', 'y', 'H', 'h',
|
||||
0x20 => 'N', 'd', 'OU', 'ou', 'Z', 'z', 'A', 'a', 'E', 'e', 'O', 'o', 'O', 'o', 'O', 'o',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => ':', '.', '`', '\'', '^', 'V', '+', '-', 'V', '.', '@', ',', '~', '"', 'R', 'X',
|
||||
0xE0 => 'G', 'l', 's', 'x', '?', '', '', '', '', '', '', '', 'V', '=', '"', NULL,
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
0x10 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
0x20 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'b', 'th', 'Y', 'Y', 'Y', 'ph', 'p', '&', NULL, NULL, 'St', 'st', 'W', 'w', 'Q', 'q',
|
||||
0xE0 => 'Sp', 'sp', 'Sh', 'sh', 'F', 'f', 'Kh', 'kh', 'H', 'h', 'G', 'g', 'CH', 'ch', 'Ti', 'ti',
|
||||
0xF0 => 'k', 'r', 's', 'j', 'TH', 'e', NULL, 'S', 's', 'S', 'S', 's', NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'E', 'E', 'D', 'G', 'E', 'Z', 'I', 'I', 'J', 'L', 'N', 'C', 'K', 'I', 'U', 'D',
|
||||
0x10 => 'A', 'B', 'V', 'G', 'D', 'E', 'Z', 'Z', 'I', 'I', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
0x20 => 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'C', 'S', 'S', '', 'Y', '', 'E', 'U', 'A',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'A', 'a', 'A', 'a', 'AE', 'ae', 'E', 'e', '@', '@', '@', '@', 'Z', 'z', 'Z', 'z',
|
||||
0xE0 => 'Dz', 'dz', 'I', 'i', 'I', 'i', 'O', 'o', 'O', 'o', 'O', 'o', 'E', 'e', 'U', 'u',
|
||||
0xF0 => 'U', 'u', 'U', 'u', 'C', 'c', NULL, NULL, 'Y', 'y', NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => '', 'b', 'g', 'd', 'h', 'w', 'z', 'h', 't', 'y', 'k', 'k', 'l', 'm', 'm', 'n',
|
||||
0xE0 => 'n', 's', '`', 'p', 'p', 'z', 'z', 'q', 'r', 's', 't', NULL, NULL, NULL, NULL, NULL,
|
||||
0xF0 => 'ww', 'wy', 'yy', '\'', '"', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ',', NULL, NULL, NULL,
|
||||
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ';', NULL, NULL, NULL, '?',
|
||||
0x20 => NULL, '', 'a', 'a', 'w', 'a', 'y', 'a', 'b', 't', 't', 'th', 'j', 'h', 'kh', 'd',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => '', '', 'y', 'y\'', '.', 'ae', '', '', '', '', '', '', '', '@', '#', '',
|
||||
0xE0 => '', '', '', '', '', '', '', '', '', '^', '', '', '', '', NULL, NULL,
|
||||
0xF0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Sh', 'D', 'Gh', '&', '+m', NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => '//', '/', ',', '!', '!', '-', ',', ',', ';', '?', '~', '{', '}', '*', NULL, '',
|
||||
0x10 => '\'', '', 'b', 'g', 'g', 'd', 'dr', 'h', 'w', 'z', 'h', 't', 't', 'y', 'yh', 'k',
|
||||
0x20 => 'l', 'm', 'n', 's', 's', '`', 'p', 'p', 's', 'q', 'r', 'sh', 't', NULL, NULL, NULL,
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, 'N', 'N', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', 'e', 'e', 'e',
|
||||
0x10 => 'ai', 'o', 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
|
||||
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', 'na', 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, '+', NULL, NULL, NULL, NULL, 'da', 'dha', NULL, 'ya',
|
||||
0xE0 => 'r', 'l', 'L', 'LL', NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
0xF0 => 'ra', 'ra', 'Rs', 'Rs', '1/', '2/', '3/', '4/', ' 1 - 1/', '/16', '', NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, NULL, 'N', NULL, NULL, 'a', 'a', 'i', 'i', 'u', 'u', NULL, NULL, NULL, NULL, 'e',
|
||||
0x10 => 'ai', NULL, NULL, 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
|
||||
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => '\'om', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xE0 => 'r', 'l', NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, 'N', 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, NULL, 'e',
|
||||
0x10 => 'ai', NULL, NULL, 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
|
||||
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, '+', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
0xF0 => '10', '100', '1000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, 'm', 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, 'e', 'e',
|
||||
0x10 => 'ai', NULL, 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
|
||||
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => NULL, NULL, NULL, NULL, NULL, '+', '+', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'la', NULL,
|
||||
0xE0 => 'r', 'l', NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, NULL, 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, 'e', 'e',
|
||||
0x10 => 'ai', NULL, 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
|
||||
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'ae', 'aae', 'i', 'ii', 'u', NULL, 'uu', NULL, 'R', 'e', 'ee', 'ai', 'o', 'oo', 'au', 'L',
|
||||
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xF0 => NULL, NULL, 'RR', 'LL', ' . ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, 'k', 'kh', 'kh', 'kh', 'kh', 'kh', 'ng', 'c', 'ch', 'ch', 's', 'ch', 'y', 'd', 't',
|
||||
0x10 => 'th', 'th', 'th', 'n', 'd', 't', 'th', 'th', 'th', 'n', 'b', 'p', 'ph', 'f', 'ph', 'f',
|
||||
0x20 => 'ph', 'm', 'y', 'r', 'v', 'l', 'l', 'w', 's', 's', 's', 'h', 'l', 'x', 'h', '~',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, 'hn', 'hm', NULL, NULL,
|
||||
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'AUM', '', '', '', '', '', '', '', ' // ', ' * ', '', '-', ' / ', ' / ', ' // ', ' -/ ',
|
||||
0x10 => ' +/ ', ' X/ ', ' /XX/ ', ' /X/ ', ',', '', '', '', '', '', '', '', '', '', '', '',
|
||||
0x20 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.5', '1.5', '2.5', '3.5', '4.5', '5.5',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'k', 'kh', 'g', 'gh', 'ng', 'c', 'ch', 'j', 'jh', 'ny', 'nny', 'tt', 'tth', 'dd', 'ddh', 'nn',
|
||||
0x10 => 'tt', 'th', 'd', 'dh', 'n', 'p', 'ph', 'b', 'bh', 'm', 'y', 'r', 'l', 'w', 's', 'h',
|
||||
0x20 => 'll', 'a', NULL, 'i', 'ii', 'u', 'uu', 'e', NULL, 'o', 'au', NULL, 'aa', 'i', 'ii', 'u',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'a', 'b', 'g', 'd', 'e', 'v', 'z', 't', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'zh',
|
||||
0xE0 => 'r', 's', 't', 'u', 'p', 'k', 'gh', 'q', 'sh', 'ch', 'ts', 'dz', 'c', 'ch', 'kh', 'j',
|
||||
0xF0 => 'h', 'e', 'y', 'ui', 'q', 'oe', 'f', NULL, NULL, NULL, NULL, ' // ', NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'g', 'kk', 'n', 'd', 'tt', 'l', 'm', 'b', 'pp', 's', 'ss', '', 'j', 'jj', 'ch', 'k',
|
||||
0x10 => 't', 'p', 'h', 'ng', 'nn', 'nd', 'nb', 'dg', 'rn', 'rr', 'rh', 'rN', 'mb', 'mN', 'bg', 'bn',
|
||||
0x20 => '', 'bs', 'bsg', 'bst', 'bsb', 'bss', 'bsj', 'bj', 'bc', 'bt', 'bp', 'bN', 'bbN', 'sg', 'sn', 'sd',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'll', 'lmg', 'lms', 'lbs', 'lbh', 'rNp', 'lss', 'lZ', 'lk', 'lQ', 'mg', 'ml', 'mb', 'ms', 'mss', 'mZ',
|
||||
0xE0 => 'mc', 'mh', 'mN', 'bl', 'bp', 'ph', 'pN', 'sg', 'sd', 'sl', 'sb', 'Z', 'g', 'ss', '', 'kh',
|
||||
0xF0 => 'N', 'Ns', 'NZ', 'pb', 'pN', 'hn', 'hl', 'hm', 'hb', 'Q', NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'ha', 'hu', 'hi', 'haa', 'hee', 'he', 'ho', NULL, 'la', 'lu', 'li', 'laa', 'lee', 'le', 'lo', 'lwa',
|
||||
0x10 => 'hha', 'hhu', 'hhi', 'hhaa', 'hhee', 'hhe', 'hho', 'hhwa', 'ma', 'mu', 'mi', 'maa', 'mee', 'me', 'mo', 'mwa',
|
||||
0x20 => 'sza', 'szu', 'szi', 'szaa', 'szee', 'sze', 'szo', 'szwa', 'ra', 'ru', 'ri', 'raa', 'ree', 're', 'ro', 'rwa',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => '`a', '`u', '`i', '`aa', '`ee', '`e', '`o', NULL, 'za', 'zu', 'zi', 'zaa', 'zee', 'ze', 'zo', 'zwa',
|
||||
0xE0 => 'zha', 'zhu', 'zhi', 'zhaa', 'zhee', 'zhe', 'zho', 'zhwa', 'ya', 'yu', 'yi', 'yaa', 'yee', 'ye', 'yo', NULL,
|
||||
0xF0 => 'da', 'du', 'di', 'daa', 'dee', 'de', 'do', 'dwa', 'dda', 'ddu', 'ddi', 'ddaa', 'ddee', 'dde', 'ddo', 'ddwa',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'ja', 'ju', 'ji', 'jaa', 'jee', 'je', 'jo', 'jwa', 'ga', 'gu', 'gi', 'gaa', 'gee', 'ge', 'go', NULL,
|
||||
0x10 => 'gwa', NULL, 'gwi', 'gwaa', 'gwee', 'gwe', NULL, NULL, 'gga', 'ggu', 'ggi', 'ggaa', 'ggee', 'gge', 'ggo', NULL,
|
||||
0x20 => 'tha', 'thu', 'thi', 'thaa', 'thee', 'the', 'tho', 'thwa', 'cha', 'chu', 'chi', 'chaa', 'chee', 'che', 'cho', 'chwa',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'so', 'su', 'sv', 'da', 'ta', 'de', 'te', 'di', 'ti', 'do', 'du', 'dv', 'dla', 'tla', 'tle', 'tli',
|
||||
0xE0 => 'tlo', 'tlu', 'tlv', 'tsa', 'tse', 'tsi', 'tso', 'tsu', 'tsv', 'wa', 'we', 'wi', 'wo', 'wu', 'wv', 'ya',
|
||||
0xF0 => 'ye', 'yi', 'yo', 'yu', 'yv', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, 'ai', 'aai', 'i', 'ii', 'u', 'uu', 'oo', 'ee', 'i', 'a', 'aa', 'we', 'we', 'wi', 'wi',
|
||||
0x10 => 'wii', 'wii', 'wo', 'wo', 'woo', 'woo', 'woo', 'wa', 'wa', 'waa', 'waa', 'waa', 'ai', 'w', '\'', 't',
|
||||
0x20 => 'k', 'sh', 's', 'n', 'w', 'n', NULL, 'w', 'c', '?', 'l', 'en', 'in', 'on', 'an', 'pai',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'n', 'ng', 'nh', 'lai', 'laai', 'li', 'lii', 'lu', 'luu', 'loo', 'la', 'laa', 'lwe', 'lwe', 'lwi', 'lwi',
|
||||
0xE0 => 'lwii', 'lwii', 'lwo', 'lwo', 'lwoo', 'lwoo', 'lwa', 'lwa', 'lwaa', 'lwaa', 'l', 'l', 'l', 'sai', 'saai', 'si',
|
||||
0xF0 => 'sii', 'su', 'suu', 'soo', 'sa', 'saa', 'swe', 'swe', 'swi', 'swi', 'swii', 'swii', 'swo', 'swo', 'swoo', 'swoo',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'swa', 'swa', 'swaa', 'swaa', 'swaa', 's', 's', 'sw', 's', 'sk', 'skw', 'sW', 'spwa', 'stwa', 'skwa', 'scwa',
|
||||
0x10 => 'she', 'shi', 'shii', 'sho', 'shoo', 'sha', 'shaa', 'shwe', 'shwe', 'shwi', 'shwi', 'shwii', 'shwii', 'shwo', 'shwo', 'shwoo',
|
||||
0x20 => 'shwoo', 'shwa', 'shwa', 'shwaa', 'shwaa', 'sh', 'jai', 'yaai', 'ji', 'jii', 'ju', 'juu', 'yoo', 'ja', 'jaa', 'ywe',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'wu', 'wo', 'we', 'wee', 'wi', 'wa', 'hwu', 'hwo', 'hwe', 'hwee', 'hwi', 'hwa', 'thu', 'tho', 'the', 'thee',
|
||||
0xE0 => 'thi', 'tha', 'ttu', 'tto', 'tte', 'ttee', 'tti', 'tta', 'pu', 'po', 'pe', 'pee', 'pi', 'pa', 'p', 'gu',
|
||||
0xF0 => 'go', 'ge', 'gee', 'gi', 'ga', 'khu', 'kho', 'khe', 'khee', 'khi', 'kha', 'kku', 'kko', 'kke', 'kkee', 'kki',
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'kka', 'kk', 'nu', 'no', 'ne', 'nee', 'ni', 'na', 'mu', 'mo', 'me', 'mee', 'mi', 'ma', 'yu', 'yo',
|
||||
0x10 => 'ye', 'yee', 'yi', 'ya', 'ju', 'ju', 'jo', 'je', 'jee', 'ji', 'ji', 'ja', 'jju', 'jjo', 'jje', 'jjee',
|
||||
0x20 => 'jji', 'jja', 'lu', 'lo', 'le', 'lee', 'li', 'la', 'dlu', 'dlo', 'dle', 'dlee', 'dli', 'dla', 'lhu', 'lho',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 't', 'd', 'b', 'b', 'p', 'p', 'e', 'm', 'm', 'm', 'l', 'l', 'ng', 'ng', 'd', 'o',
|
||||
0xE0 => 'ear', 'ior', 'qu', 'qu', 'qu', 's', 'yr', 'yr', 'yr', 'q', 'x', '.', ':', '+', '17', '18',
|
||||
0xF0 => '19', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => '', '', '', '', '.', ' // ', ':', '+', '++', ' * ', ' /// ', 'KR', '\'', NULL, NULL, NULL,
|
||||
0xE0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => ' @ ', ' ... ', ',', '. ', ': ', ' // ', '', '-', ',', '. ', '', '', '', '', '', NULL,
|
||||
0x10 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0x20 => 'a', 'e', 'i', 'o', 'u', 'O', 'U', 'ee', 'n', 'ng', 'b', 'p', 'q', 'g', 'm', 'l',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'A', 'AE', NULL, 'B', 'C', 'D', 'D', 'E', NULL, NULL, 'J', 'K', 'L', 'M', NULL, 'O',
|
||||
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'P', NULL, NULL, 'T', 'U', NULL, NULL, NULL,
|
||||
0x20 => 'V', 'W', 'Z', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
);
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Generic transliteration data for the PhpTransliteration class.
|
||||
*/
|
||||
|
||||
$base = array(
|
||||
$base = [
|
||||
0x00 => 'A', 'a', 'B', 'b', 'B', 'b', 'B', 'b', 'C', 'c', 'D', 'd', 'D', 'd', 'D', 'd',
|
||||
0x10 => 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'F', 'f',
|
||||
0x20 => 'G', 'g', 'H', 'h', 'H', 'h', 'H', 'h', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i',
|
||||
@@ -22,4 +22,4 @@ $base = array(
|
||||
0xD0 => 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o',
|
||||
0xE0 => 'O', 'o', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u',
|
||||
0xF0 => 'U', 'u', 'Y', 'y', 'Y', 'y', 'Y', 'y', 'Y', 'y', 'LL', 'll', 'V', 'v', 'Y', 'y',
|
||||
);
|
||||
];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user