Open Oleksii909 opened 3 years ago
<?php
namespace Drupal\Component\Utility;
/**
* Provides helper methods for reflection.
*/
final class Reflection {
/**
* Gets the parameter's class name.
*
* @param \ReflectionParameter $parameter
* The parameter.
*
* @return string|null
* The parameter's class name or NULL if the parameter is not a class.
*/
public static function getParameterClassName(\ReflectionParameter $parameter) : ?string {
$name = NULL;
if ($parameter->hasType() && !$parameter->getType()->isBuiltin()) {
$name = $parameter->getType()->getName();
$lc_name = strtolower($name);
switch ($lc_name) {
case 'self':
return $parameter->getDeclaringClass()->getName();
case 'parent':
return ($parent = $parameter->getDeclaringClass()->getParentClass()) ? $parent->name : NULL;
}
}
return $name;
}
}
Let us know more about type resource in php
@andypost Please provide a comment for this commit:
@andypost Please provide a comment for this commit:
<?php
/**
* {@inheritdoc}
*/
public function rollBack($savepoint_name = 'drupal_transaction') {
// MySQL will automatically commit transactions when tables are altered or
// created (DDL transactions are not supported). Prevent triggering an
// exception to ensure that the error that has caused the rollback is
// properly reported.
if (!$this->connection->inTransaction()) {
// On PHP 7 $this->connection->inTransaction() will return TRUE and
// $this->connection->rollback() does not throw an exception; the
// following code is unreachable.
// If \Drupal\Core\Database\Connection::rollBack() would throw an
// exception then continue to throw an exception.
if (!$this->inTransaction()) {
throw new TransactionNoActiveException();
}
// A previous rollback to an earlier savepoint may mean that the savepoint
// in question has already been accidentally committed.
if (!isset($this->transactionLayers[$savepoint_name])) {
throw new TransactionNoActiveException();
}
trigger_error('Rollback attempted when there is no active transaction. This can cause data integrity issues.', E_USER_WARNING);
return;
}
return parent::rollBack($savepoint_name);
}
/**
* {@inheritdoc}
*/
protected function doCommit() {
// MySQL will automatically commit transactions when tables are altered or
// created (DDL transactions are not supported). Prevent triggering an
// exception in this case as all statements have been committed.
if ($this->connection->inTransaction()) {
// On PHP 7 $this->connection->inTransaction() will return TRUE and
// $this->connection->commit() does not throw an exception.
$success = parent::doCommit();
}
else {
// Process the post-root (non-nested) transaction commit callbacks. The
// following code is copied from
// \Drupal\Core\Database\Connection::doCommit()
$success = TRUE;
if (!empty($this->rootTransactionEndCallbacks)) {
$callbacks = $this->rootTransactionEndCallbacks;
$this->rootTransactionEndCallbacks = [];
foreach ($callbacks as $callback) {
call_user_func($callback, $success);
}
}
}
return $success;
}
@andypost, Thank you for such clear comments in commit. Чи могли б ви прокоментувати цю контрибуцію на живо, тому що доить складно усвідомити цей кусок тесту:
Unescaped "@" in ContextProviderInterface doc comment Issue #3014969 by TR, longwave, Abhijith S, joachim, shimpy
Sort direction is not hidden when no sort field is selected
Refactor WHY??? Issue #2987980 by alexpott, longwave, Lendude, jibran: Refactor UncaughtExceptionTest to not use cUrl