Use short array declaration

This commit is contained in:
Romain Neutron
2013-11-18 11:58:12 +01:00
parent 2898b317c4
commit 56b373ee6e
723 changed files with 8350 additions and 8352 deletions

View File

@@ -56,7 +56,7 @@ class caption_Field_Value implements cache_cacheableInterface
protected $record;
protected $app;
protected static $localCache = array();
protected static $localCache = [];
/**
*
@@ -96,7 +96,7 @@ class caption_Field_Value implements cache_cacheableInterface
FROM metadatas WHERE id = :id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->execute([':id' => $this->id]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -133,11 +133,11 @@ class caption_Field_Value implements cache_cacheableInterface
}
}
$datas = array(
$datas = [
'value' => $this->value,
'vocabularyId' => $this->VocabularyId,
'vocabularyType' => $this->VocabularyType ? $this->VocabularyType->getType() : null,
);
];
$this->set_data_to_cache($datas);
@@ -185,7 +185,7 @@ class caption_Field_Value implements cache_cacheableInterface
$sql = 'DELETE FROM metadatas WHERE id = :id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->execute([':id' => $this->id]);
$stmt->closeCursor();
$this->delete_data_from_cache();
@@ -200,11 +200,11 @@ class caption_Field_Value implements cache_cacheableInterface
{
$connbas = $this->databox_field->get_connection();
$params = array(
$params = [
':VocabType' => null
, ':VocabularyId' => null
, ':meta_id' => $this->getId()
);
];
$sql_up = 'UPDATE metadatas
SET VocabularyType = :VocabType, VocabularyId = :VocabularyId
@@ -224,11 +224,11 @@ class caption_Field_Value implements cache_cacheableInterface
{
$connbas = $this->databox_field->get_connection();
$params = array(
$params = [
':VocabType' => $vocabulary->getType()
, ':VocabularyId' => $vocab_id
, ':meta_id' => $this->getId()
);
];
$sql_up = 'UPDATE metadatas
SET VocabularyType = :VocabType, VocabularyId = :VocabularyId
@@ -248,10 +248,10 @@ class caption_Field_Value implements cache_cacheableInterface
$connbas = $this->databox_field->get_connection();
$params = array(
$params = [
':meta_id' => $this->id
, ':value' => $value
);
];
$sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id';
$stmt_up = $connbas->prepare($sql_up);
@@ -309,13 +309,13 @@ class caption_Field_Value implements cache_cacheableInterface
VALUES
(null, :record_id, :field, :value, :VocabType, :VocabId)';
$params = array(
$params = [
':record_id' => $record->get_record_id(),
':field' => $databox_field->get_id(),
':value' => $value,
':VocabType' => $vocabulary ? $vocabulary->getType() : null,
':VocabId' => $vocabulary ? $vocabularyId : null,
);
];
$stmt_ins = $connbas->prepare($sql_ins);
$stmt_ins->execute($params);
@@ -355,7 +355,7 @@ class caption_Field_Value implements cache_cacheableInterface
$fvalue = $value;
$cleanvalue = str_replace(array("<em>", "</em>", "'"), array("", "", "&apos;"), $fvalue);
$cleanvalue = str_replace(["<em>", "</em>", "'"], ["", "", "&apos;"], $fvalue);
list($term_noacc, $context_noacc) = $this->splitTermAndContext($cleanvalue);
$term_noacc = $this->app['unicode']->remove_indexer_chars($term_noacc);
@@ -375,8 +375,8 @@ class caption_Field_Value implements cache_cacheableInterface
if ($node->getAttribute("lng") == $this->app['locale.I18n']) {
// le terme est dans la bonne langue, on le rend cliquable
list($term, $context) = $this->splitTermAndContext($fvalue);
$term = str_replace(array("<em>", "</em>"), array("", ""), $term);
$context = str_replace(array("<em>", "</em>"), array("", ""), $context);
$term = str_replace(["<em>", "</em>"], ["", ""], $term);
$context = str_replace(["<em>", "</em>"], ["", ""], $context);
$qjs = $term;
if ($context) {
$qjs .= " [" . $context . "]";
@@ -400,8 +400,8 @@ class caption_Field_Value implements cache_cacheableInterface
}
if (! $lngfound) {
list($term, $context) = $this->splitTermAndContext($fvalue);
$term = str_replace(array("<em>", "</em>"), array("", ""), $term);
$context = str_replace(array("<em>", "</em>"), array("", ""), $context);
$term = str_replace(["<em>", "</em>"], ["", ""], $term);
$context = str_replace(["<em>", "</em>"], ["", ""], $context);
$qjs = $term;
if ($context) {
$qjs .= " [" . $context . "]";
@@ -439,7 +439,7 @@ class caption_Field_Value implements cache_cacheableInterface
}
}
return array($term, $context);
return [$term, $context];
}
/**

View File

@@ -38,7 +38,7 @@ class caption_field implements cache_cacheableInterface
protected $record;
protected $app;
protected static $localCache = array();
protected static $localCache = [];
/**
*
@@ -53,7 +53,7 @@ class caption_field implements cache_cacheableInterface
$this->app = $app;
$this->record = $record;
$this->databox_field = $databox_field;
$this->values = array();
$this->values = [];
$rs = $this->get_metadatas_ids();
@@ -85,10 +85,10 @@ class caption_field implements cache_cacheableInterface
WHERE record_id = :record_id
AND meta_struct_id = :meta_struct_id';
$params = array(
$params = [
':record_id' => $this->record->get_record_id()
, ':meta_struct_id' => $this->databox_field->get_id()
);
];
$stmt = $connbas->prepare($sql);
$stmt->execute($params);
@@ -166,7 +166,7 @@ class caption_field implements cache_cacheableInterface
else
$separator = ' ' . $separator . ' ';
$array_values = array();
$array_values = [];
foreach ($values as $value) {
if ($highlight)
@@ -281,7 +281,7 @@ class caption_field implements cache_cacheableInterface
*/
public static function get_multi_values($serialized_value, $separator)
{
$values = array();
$values = [];
if (strlen($separator) == 1) {
$values = explode($separator, $serialized_value);
} else {
@@ -304,9 +304,9 @@ class caption_field implements cache_cacheableInterface
$sql = 'SELECT count(id) as count_id FROM metadatas
WHERE meta_struct_id = :meta_struct_id';
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
$params = array(
$params = [
':meta_struct_id' => $databox_field->get_id()
);
];
$stmt->execute($params);
$rowcount = $stmt->rowCount();
@@ -319,9 +319,9 @@ class caption_field implements cache_cacheableInterface
$sql = 'SELECT record_id, id FROM metadatas
WHERE meta_struct_id = :meta_struct_id LIMIT ' . $n . ', ' . $increment;
$params = array(
$params = [
':meta_struct_id' => $databox_field->get_id()
);
];
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -333,7 +333,7 @@ class caption_field implements cache_cacheableInterface
foreach ($rs as $row) {
try {
$record = $databox_field->get_databox()->get_record($row['record_id']);
$record->set_metadatas(array());
$record->set_metadatas([]);
/**
* TODO NEUTRON add App
@@ -357,9 +357,9 @@ class caption_field implements cache_cacheableInterface
WHERE meta_struct_id = :meta_struct_id';
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
$params = array(
$params = [
':meta_struct_id' => $databox_field->get_id()
);
];
$stmt->execute($params);
$rowcount = $stmt->rowCount();
@@ -373,9 +373,9 @@ class caption_field implements cache_cacheableInterface
WHERE meta_struct_id = :meta_struct_id
LIMIT ' . $n . ', ' . $increment;
$params = array(
$params = [
':meta_struct_id' => $databox_field->get_id()
);
];
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -389,7 +389,7 @@ class caption_field implements cache_cacheableInterface
$record = $databox_field->get_databox()->get_record($row['record_id']);
$caption_field = new caption_field($app, $databox_field, $record);
$caption_field->delete();
$record->set_metadatas(array());
$record->set_metadatas([]);
$app['phraseanet.SE']->updateRecord($record);
unset($caption_field);

View File

@@ -95,13 +95,13 @@ class caption_record implements caption_interface, cache_cacheableInterface
protected function toArray($includeBusinessFields)
{
$buffer = array();
$buffer = [];
foreach ($this->get_fields(array(), $includeBusinessFields) as $field) {
foreach ($this->get_fields([], $includeBusinessFields) as $field) {
$vi = $field->get_values();
if ($field->is_multi()) {
$buffer[$field->get_name()] = array();
$buffer[$field->get_name()] = [];
foreach ($vi as $value) {
$val = $value->getValue();
$buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $this->sanitizeSerializedValue($val);
@@ -113,7 +113,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
}
}
return array('record' => array('description' => $buffer));
return ['record' => ['description' => $buffer]];
}
protected function serializeXML($includeBusinessFields)
@@ -128,7 +128,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
$description = $dom_doc->createElement('description');
$record->appendChild($description);
foreach ($this->get_fields(array(), $includeBusinessFields) as $field) {
foreach ($this->get_fields([], $includeBusinessFields) as $field) {
$values = $field->get_values();
foreach ($values as $value) {
@@ -155,7 +155,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
private function sanitizeSerializedValue($value)
{
return str_replace(array(
return str_replace([
"\x00", //null
"\x01", //start heading
"\x02", //start text
@@ -184,7 +184,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
"\x1D", //group sep
"\x1E", //record sep
"\x1F", //unit sep
), '', $value);
], '', $value);
}
protected function retrieve_fields()
@@ -193,7 +193,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
return $this->fields;
}
$fields = array();
$fields = [];
try {
$fields = $this->get_data_from_cache();
} catch (Exception $e) {
@@ -202,13 +202,13 @@ class caption_record implements caption_interface, cache_cacheableInterface
WHERE m.record_id = :record_id AND s.id = m.meta_struct_id
ORDER BY s.sorter ASC";
$stmt = $this->databox->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => $this->record->get_record_id()));
$stmt->execute([':record_id' => $this->record->get_record_id()]);
$fields = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$this->set_data_to_cache($fields);
}
$rec_fields = array();
$rec_fields = [];
foreach ($fields as $row) {
$databox_meta_struct = databox_field::get_instance($this->app, $this->databox, $row['structure_id']);
$metadata = new caption_field($this->app, $databox_meta_struct, $this->record);
@@ -229,7 +229,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/
public function get_fields(Array $grep_fields = null, $IncludeBusiness = false)
{
$fields = array();
$fields = [];
foreach ($this->retrieve_fields() as $meta_struct_id => $field) {
if ($grep_fields && ! in_array($field->get_name(), $grep_fields)) {
@@ -304,7 +304,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/
protected function highlight_fields($highlight, Array $grep_fields = null, SearchEngineInterface $searchEngine = null, $includeBusiness = false)
{
$fields = array();
$fields = [];
foreach ($this->get_fields($grep_fields, $includeBusiness) as $meta_struct_id => $field) {
@@ -314,11 +314,11 @@ class caption_record implements caption_interface, cache_cacheableInterface
, $highlight ? $field->highlight_thesaurus() : $field->get_serialized_values(false, false)
);
$fields[$field->get_name()] = array(
$fields[$field->get_name()] = [
'value' => $value,
'label' => $field->get_databox_field()->get_label($this->app['locale.I18n']),
'separator' => $field->get_databox_field()->get_separator(),
);
];
}
if ($searchEngine instanceof SearchEngineInterface) {