Horse | Implementations | Med./ns | Avg/ns | Dev/% |
---|---|---|---|---|
convert-only-firstclass | class.closure.traditional.array | 33.10 | 33.28 | 0.315 |
convert-only-firstclass | class.closure.firstclass.array | 33.12 | 33.17 | 0.272 |
convert-only-firstclass | class.closure.traditional.string | 33.13 | 33.22 | 0.260 |
convert-only-firstclass | class.closure.firstclass.1 | 33.15 | 33.31 | 0.340 |
convert-only-firstclass | function.closure.traditional | 33.18 | 33.33 | 0.303 |
convert-only-firstclass | class.closure.firstclass.0 | 33.23 | 33.31 | 0.273 |
convert-only-firstclass | function.closure.firstclass | 33.39 | 33.69 | 0.404 |
convert-only-traditional | class.closure.traditional.array | 36.07 | 36.30 | 0.242 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
if (!is_file('composer.lock')) { | |
print "File 'composer.lock' not found.\n"; | |
exit(1); | |
} | |
$orig = file_get_contents('composer.lock'); | |
$cleaned = preg_replace( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
div { | |
--varname: '5'; | |
unknown_property: '5'; | |
content: 'hello'; | |
float: left; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// A "stream" represents a CSV file or another data source. | |
// "streams" exist on different levels. And a higher-level stream can use a lower-level stream as a data source. | |
// Problem: Find better nomenclature. | |
// Currently: RowStream, (AssocRowStream), AssocStream, ObjectStream. | |
assert($rowStream instanceof RowStreamInterface); | |
$rows = []; | |
while (false !== $row = $rowStream->fetchRow()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// See http://stackoverflow.com/questions/4465046/whats-faster-ifreturnelse-return-or-ifreturn-return | |
function else1($x) { | |
if ($x === true) { | |
return true; | |
} | |
else { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { | |
[..] | |
if ($options['nomask'] === NULL | |
&& $options['recurse'] | |
// Detect patterns like '/\.tpl\.php$/' or '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\.module$/'. | |
// The first part is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Recursively scans a directory and its subdirectories, to collect all files | |
* that end with the specified extension. | |
* | |
* The result is keyed by file basename. | |
* | |
* @param string $dir | |
* E.g. 'sites/all/modules' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @return string[][] | |
* Format: $[$suffix][$prefix] = $function | |
* Example: $['menu_alter']['system'] = 'system_menu_alter' | |
*/ | |
function _drupal_get_structured_function_list() { | |
static $functions_by_suffix_and_prefix = array(); |
Currently we have some confusing circular dependencies in D8 core.
- A lot of things spawn from the generated DIC.
- Expecially, ModuleHandler is provided by the generated DIC.
- The generated DIC depends on enabled modules.
- Enabled modules are managed with ModuleHandler.
- ModuleHandler::getImplementations() and friends depend on enabled modules.
- Available modules depend on hook_system_info_alter(), which depends on enabled modules.
- If you call ModuleHandler->install(), the instance of Drupal::moduleHandler() and even the entire DIC will be replaced. This is dangerous, we need to deal with outdated services etc.
- Bootstrap is still a mess with lots of legacy code from D7.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Old, see https://github.com/donquixote/drupal/blob/8.x/core/lib/Drupal/Core/Entity/EntityManager.php#L142 | |
$this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); | |
$this->discovery = new InfoHookDecorator($this->discovery, 'entity_type_build'); | |
$this->discovery = new AlterDecorator($this->discovery, 'entity_type'); | |
$this->discovery = new CacheDecorator($this->discovery, 'entity_type:' . $this->languageManager->getCurrentLanguage()->id, 'cache', Cache::PERMANENT, array('entity_types' => TRUE)); | |
// New, factory option chaining |
NewerOlder