summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.php_cs6
-rw-r--r--app/Family.php21
-rw-r--r--app/File.php6
-rw-r--r--app/GedcomRecord.php12
-rw-r--r--app/Individual.php23
-rw-r--r--app/Media.php21
-rw-r--r--app/Note.php21
-rw-r--r--app/Place.php8
-rw-r--r--app/Repository.php21
-rw-r--r--app/Source.php21
-rw-r--r--app/User.php12
11 files changed, 26 insertions, 146 deletions
diff --git a/.php_cs b/.php_cs
index 6f2d664e26..0daf236df2 100644
--- a/.php_cs
+++ b/.php_cs
@@ -35,14 +35,14 @@ return Symfony\CS\Config\Config::create()
'duplicate_semicolons',
'--empty_return',
'extra_empty_lines',
- '--include', // WHAT IS THIS?
+ 'include',
'join_function',
'list_commas',
'multiline_array_trailing_comma',
'namespace_no_leading_whitespace',
'--new_with_braces',
'no_blank_lines_after_class_opening',
- '--object_operator', // WE WANT THIS?
+ 'object_operator',
'operators_spaces',
'phpdoc_indent',
'phpdoc_no_access',
@@ -59,7 +59,7 @@ return Symfony\CS\Config\Config::create()
'remove_leading_slash_use',
'remove_lines_between_uses',
'return',
- '--self_accessor', // WE WANT THIS?
+ 'self_accessor',
'single_array_no_trailing_comma',
'--single_blank_line_before_namespace',
'--single_quote', // WE WANT THIS?
diff --git a/app/Family.php b/app/Family.php
index 11992c4f91..f6705eb177 100644
--- a/app/Family.php
+++ b/app/Family.php
@@ -51,27 +51,6 @@ class Family extends GedcomRecord {
}
}
- /**
- * Get an instance of a family object. For single records,
- * we just receive the XREF. For bulk records (such as lists
- * and search results) we can receive the GEDCOM data as well.
- *
- * @param string $xref
- * @param Tree $tree
- * @param string|null $gedcom
- *
- * @return Family|null
- */
- public static function getInstance($xref, Tree $tree, $gedcom = null) {
- $record = parent::getInstance($xref, $tree, $gedcom);
-
- if ($record instanceof Family) {
- return $record;
- } else {
- return null;
- }
- }
-
/** {@inheritdoc} */
protected function createPrivateGedcomRecord($access_level) {
$SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
diff --git a/app/File.php b/app/File.php
index ba076674f0..a1e324b9d3 100644
--- a/app/File.php
+++ b/app/File.php
@@ -57,7 +57,7 @@ class File {
if (preg_match('/^HTTP\/1.[01] 30[123].+\nLocation: ([^\r\n]+)/s', $response, $match)) {
fclose($fp);
- return File::fetchUrl($match[1], $stream);
+ return self::fetchUrl($match[1], $stream);
} else {
// The response includes headers, a blank line, then the content
$response = substr($response, strpos($response, "\r\n\r\n") + 4);
@@ -96,7 +96,7 @@ class File {
$dir = opendir($path);
while ($dir !== false && (($file = readdir($dir)) !== false)) {
if ($file !== '.' && $file !== '..') {
- File::delete($path . DIRECTORY_SEPARATOR . $file);
+ self::delete($path . DIRECTORY_SEPARATOR . $file);
}
}
closedir($dir);
@@ -128,7 +128,7 @@ class File {
return true;
} else {
if (dirname($path) && !is_dir(dirname($path))) {
- File::mkdir(dirname($path));
+ self::mkdir(dirname($path));
}
try {
mkdir($path);
diff --git a/app/GedcomRecord.php b/app/GedcomRecord.php
index 31626eeaa2..30d60d32c9 100644
--- a/app/GedcomRecord.php
+++ b/app/GedcomRecord.php
@@ -132,9 +132,15 @@ class GedcomRecord {
public static function getInstance($xref, Tree $tree, $gedcom = null) {
$tree_id = $tree->getTreeId();
- // Is this record already in the cache?
+ // Is this record already in the cache, and of the correct type?
if (isset(self::$gedcom_record_cache[$xref][$tree_id])) {
- return self::$gedcom_record_cache[$xref][$tree_id];
+ $record = self::$gedcom_record_cache[$xref][$tree_id];
+
+ if ($record instanceof static) {
+ return $record;
+ } else {
+ null;
+ }
}
// Do we need to fetch the record from the database?
@@ -207,7 +213,7 @@ class GedcomRecord {
$record = new Note($xref, $gedcom, $pending, $tree);
break;
default:
- $record = new GedcomRecord($xref, $gedcom, $pending, $tree);
+ $record = new self($xref, $gedcom, $pending, $tree);
break;
}
diff --git a/app/Individual.php b/app/Individual.php
index 43762db667..0949ab721a 100644
--- a/app/Individual.php
+++ b/app/Individual.php
@@ -35,27 +35,6 @@ class Individual extends GedcomRecord {
private $_getEstimatedDeathDate;
/**
- * Get an instance of an individual object. For single records,
- * we just receive the XREF. For bulk records (such as lists
- * and search results) we can receive the GEDCOM data as well.
- *
- * @param string $xref
- * @param Tree $tree
- * @param string|null $gedcom
- *
- * @return Individual|null
- */
- public static function getInstance($xref, Tree $tree, $gedcom = null) {
- $record = parent::getInstance($xref, $tree, $gedcom);
-
- if ($record instanceof Individual) {
- return $record;
- } else {
- return null;
- }
- }
-
- /**
* Sometimes, we'll know in advance that we need to load a set of records.
* Typically when we load families and their members.
*
@@ -162,7 +141,7 @@ class Individual extends GedcomRecord {
private static function isRelated(Individual $target, $distance) {
static $cache = null;
- $user_individual = Individual::getInstance($target->tree->getUserPreference(Auth::user(), 'gedcomid'), $target->tree);
+ $user_individual = self::getInstance($target->tree->getUserPreference(Auth::user(), 'gedcomid'), $target->tree);
if ($user_individual) {
if (!$cache) {
$cache = array(
diff --git a/app/Media.php b/app/Media.php
index a4b9333044..c2de979ea3 100644
--- a/app/Media.php
+++ b/app/Media.php
@@ -47,27 +47,6 @@ class Media extends GedcomRecord {
}
}
- /**
- * Get an instance of a media object. For single records,
- * we just receive the XREF. For bulk records (such as lists
- * and search results) we can receive the GEDCOM data as well.
- *
- * @param string $xref
- * @param Tree $tree
- * @param string|null $gedcom
- *
- * @return null|Media
- */
- public static function getInstance($xref, Tree $tree, $gedcom = null) {
- $record = parent::getInstance($xref, $tree, $gedcom);
-
- if ($record instanceof Media) {
- return $record;
- } else {
- return null;
- }
- }
-
/** {@inheritdoc} */
protected function canShowByType($access_level) {
// Hide media objects if they are attached to private records
diff --git a/app/Note.php b/app/Note.php
index fabd791332..283335743e 100644
--- a/app/Note.php
+++ b/app/Note.php
@@ -24,27 +24,6 @@ class Note extends GedcomRecord {
const URL_PREFIX = 'note.php?nid=';
/**
- * Get an instance of a note object. For single records,
- * we just receive the XREF. For bulk records (such as lists
- * and search results) we can receive the GEDCOM data as well.
- *
- * @param string $xref
- * @param Tree $tree
- * @param string|null $gedcom
- *
- * @return Note|null
- */
- public static function getInstance($xref, Tree $tree, $gedcom = null) {
- $record = parent::getInstance($xref, $tree, $gedcom);
-
- if ($record instanceof Note) {
- return $record;
- } else {
- return null;
- }
- }
-
- /**
* Get the text contents of the note
*
* @return string|null
diff --git a/app/Place.php b/app/Place.php
index f21e1b2565..5c9c51d996 100644
--- a/app/Place.php
+++ b/app/Place.php
@@ -68,7 +68,7 @@ class Place {
* @return Place
*/
public function getParentPlace() {
- return new Place(implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, 1)), $this->tree);
+ return new self(implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, 1)), $this->tree);
}
/**
@@ -92,7 +92,7 @@ class Place {
'collation' => I18N::collation(),
))->fetchOneColumn();
foreach ($rows as $row) {
- $children[] = new Place($row . $parent_text, $this->tree);
+ $children[] = new self($row . $parent_text, $this->tree);
}
return $children;
@@ -223,7 +223,7 @@ class Place {
'collate' => I18N::collation(),
))->fetchOneColumn();
foreach ($rows as $row) {
- $places[] = new Place($row, $tree);
+ $places[] = new self($row, $tree);
}
return $places;
@@ -258,7 +258,7 @@ class Place {
'collation' => I18N::collation(),
))->fetchOneColumn();
foreach ($rows as $row) {
- $places[] = new Place($row, $tree);
+ $places[] = new self($row, $tree);
}
return $places;
diff --git a/app/Repository.php b/app/Repository.php
index 7cb68d46ed..49600823e2 100644
--- a/app/Repository.php
+++ b/app/Repository.php
@@ -23,27 +23,6 @@ class Repository extends GedcomRecord {
const RECORD_TYPE = 'REPO';
const URL_PREFIX = 'repo.php?rid=';
- /**
- * Get an instance of a repository object. For single records,
- * we just receive the XREF. For bulk records (such as lists
- * and search results) we can receive the GEDCOM data as well.
- *
- * @param string $xref
- * @param Tree $tree
- * @param string|null $gedcom
- *
- * @return Repository|null
- */
- public static function getInstance($xref, Tree $tree, $gedcom = null) {
- $record = parent::getInstance($xref, $tree, $gedcom);
-
- if ($record instanceof Repository) {
- return $record;
- } else {
- return null;
- }
- }
-
/** {@inheritdoc} */
protected static function fetchGedcomRecord($xref, $tree_id) {
return Database::prepare(
diff --git a/app/Source.php b/app/Source.php
index ccf483a66e..4273e882c9 100644
--- a/app/Source.php
+++ b/app/Source.php
@@ -23,27 +23,6 @@ class Source extends GedcomRecord {
const RECORD_TYPE = 'SOUR';
const URL_PREFIX = 'source.php?sid=';
- /**
- * Get an instance of a source object. For single records,
- * we just receive the XREF. For bulk records (such as lists
- * and search results) we can receive the GEDCOM data as well.
- *
- * @param string $xref
- * @param Tree $tree
- * @param string|null $gedcom
- *
- * @return Source|null
- */
- public static function getInstance($xref, Tree $tree, $gedcom = null) {
- $record = parent::getInstance($xref, $tree, $gedcom);
-
- if ($record instanceof Source) {
- return $record;
- } else {
- return null;
- }
- }
-
/** {@inheritdoc} */
protected function canShowByType($access_level) {
// Hide sources if they are attached to private repositories ...
diff --git a/app/User.php b/app/User.php
index 224c62eef1..221c2a742b 100644
--- a/app/User.php
+++ b/app/User.php
@@ -51,7 +51,7 @@ class User {
"SELECT SQL_CACHE user_id, user_name, real_name, email FROM `##user` WHERE user_id = ?"
)->execute(array($user_id))->fetchOneRow();
if ($row) {
- self::$cache[$user_id] = new User($row);
+ self::$cache[$user_id] = new self($row);
} else {
self::$cache[$user_id] = null;
}
@@ -135,7 +135,7 @@ class User {
));
// Set default blocks for this user
- $user = User::findByIdentifier($user_name);
+ $user = self::findByIdentifier($user_name);
Database::prepare(
"INSERT INTO `##block` (`user_id`, `location`, `block_order`, `module_name`)" .
" SELECT :user_id , `location`, `block_order`, `module_name` FROM `##block` WHERE `user_id` = -1"
@@ -173,7 +173,7 @@ class User {
)->fetchAll();
foreach ($rows as $row) {
- $users[] = new User($row);
+ $users[] = new self($row);
}
return $users;
@@ -196,7 +196,7 @@ class User {
$users = array();
foreach ($rows as $row) {
- $users[] = new User($row);
+ $users[] = new self($row);
}
return $users;
@@ -219,7 +219,7 @@ class User {
$users = array();
foreach ($rows as $row) {
- $users[] = new User($row);
+ $users[] = new self($row);
}
return $users;
@@ -239,7 +239,7 @@ class User {
$users = array();
foreach ($rows as $row) {
- $users[] = new User($row);
+ $users[] = new self($row);
}
return $users;