projects
/
mdref
/
mdref
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Generator: fix default values of ctor promoted props
[mdref/mdref]
/
mdref
/
Tree.php
diff --git
a/mdref/Tree.php
b/mdref/Tree.php
index 11cada07293495da26112af7c8e13b66d421bc04..68c5113b925b82b969f19fdaf114a21ec8fb03c0 100644
(file)
--- a/
mdref/Tree.php
+++ b/
mdref/Tree.php
@@
-2,7
+2,24
@@
namespace mdref;
namespace mdref;
-class Tree implements \RecursiveIterator {
+use Iterator;
+use RecursiveIterator;
+use function array_filter;
+use function array_search;
+use function basename;
+use function current;
+use function dirname;
+use function glob;
+use function is_dir;
+use function key;
+use function next;
+use function pathinfo;
+use function preg_match;
+use function reset;
+use function strcmp;
+use function usort;
+
+class Tree implements RecursiveIterator {
/**
* The repository
* @var \mdref\Repo
/**
* The repository
* @var \mdref\Repo
@@
-25,7
+42,7
@@
class Tree implements \RecursiveIterator {
* @param string $path
* @param \mdref\Repo $repo
*/
* @param string $path
* @param \mdref\Repo $repo
*/
- public function __construct($path, Repo $repo) {
+ public function __construct(
string
$path, Repo $repo) {
if (realpath($path)."/" === $repo->getPath()) {
$list = [$path ."/". $repo->getName() .".md"];
} elseif (!($list = glob("$path/*.md"))) {
if (realpath($path)."/" === $repo->getPath()) {
$list = [$path ."/". $repo->getName() .".md"];
} elseif (!($list = glob("$path/*.md"))) {
@@
-42,9
+59,9
@@
class Tree implements \RecursiveIterator {
* @param array $list
* @return callable
*/
* @param array $list
* @return callable
*/
- private function generateFilter(array $list) {
+ private function generateFilter(array $list)
: \Closure
{
return function($v) use($list) {
return function($v) use($list) {
- if ($v
{0}
=== ".") {
+ if ($v
[0]
=== ".") {
return false;
}
if (false !== array_search("$v.md", $list, true)) {
return false;
}
if (false !== array_search("$v.md", $list, true)) {
@@
-63,19
+80,19
@@
class Tree implements \RecursiveIterator {
/**
* @return callable
*/
/**
* @return callable
*/
- private function generateSorter() {
+ private function generateSorter()
: \Closure
{
return function($a, $b) {
$ab = basename($a, ".md");
$bb = basename($b, ".md");
return function($a, $b) {
$ab = basename($a, ".md");
$bb = basename($b, ".md");
- if ($ab
{0} === ":" && $bb{0}
=== ":") {
+ if ($ab
[0] === ":" && $bb[0]
=== ":") {
return strcmp($ab, $bb);
return strcmp($ab, $bb);
- } elseif ($ab
{0}
=== ":") {
+ } elseif ($ab
[0]
=== ":") {
return -1;
return -1;
- } elseif ($bb
{0}
=== ":") {
+ } elseif ($bb
[0]
=== ":") {
return 1;
}
return 1;
}
-
+/*
$ad = is_dir(dirname($a)."/$ab");
$bd = is_dir(dirname($b)."/$bb");
$ad = is_dir(dirname($a)."/$ab");
$bd = is_dir(dirname($b)."/$bb");
@@
-86,7
+103,7
@@
class Tree implements \RecursiveIterator {
} elseif ($bd) {
return 1;
}
} elseif ($bd) {
return 1;
}
-
+*/
$au = preg_match("/^\p{Lu}/", $ab);
$bu = preg_match("/^\p{Lu}/", $bb);
$au = preg_match("/^\p{Lu}/", $ab);
$bu = preg_match("/^\p{Lu}/", $bb);
@@
-106,14
+123,14
@@
class Tree implements \RecursiveIterator {
* Implements \Iterator
* @return \mdref\Entry
*/
* Implements \Iterator
* @return \mdref\Entry
*/
- public function current() {
+ public function current()
: Entry
{
return $this->repo->getEntry($this->repo->hasFile(current($this->iter)));
}
/**
* Implements \Iterator
*/
return $this->repo->getEntry($this->repo->hasFile(current($this->iter)));
}
/**
* Implements \Iterator
*/
- public function next() {
+ public function next()
: void
{
next($this->iter);
}
next($this->iter);
}
@@
-121,14
+138,14
@@
class Tree implements \RecursiveIterator {
* Implements \Iterator
* @return int
*/
* Implements \Iterator
* @return int
*/
- public function key() {
+ public function key()
: int
{
return key($this->iter);
}
/**
* Implements \Iterator
*/
return key($this->iter);
}
/**
* Implements \Iterator
*/
- public function rewind() {
+ public function rewind()
: void
{
$this->iter = $this->list;
reset($this->iter);
}
$this->iter = $this->list;
reset($this->iter);
}
@@
-137,7
+154,7
@@
class Tree implements \RecursiveIterator {
* Implements \Iterator
* @return bool
*/
* Implements \Iterator
* @return bool
*/
- public function valid() {
+ public function valid()
: bool
{
return null !== key($this->iter);
}
return null !== key($this->iter);
}
@@
-145,7
+162,7
@@
class Tree implements \RecursiveIterator {
* Implements \RecursiveIterator
* @return bool
*/
* Implements \RecursiveIterator
* @return bool
*/
- public function hasChildren() {
+ public function hasChildren()
: bool
{
return $this->current()->hasIterator();
}
return $this->current()->hasIterator();
}
@@
-153,7
+170,7
@@
class Tree implements \RecursiveIterator {
* Implements \RecursiveIterator
* @return \mdref\Tree
*/
* Implements \RecursiveIterator
* @return \mdref\Tree
*/
- public function getChildren() {
+ public function getChildren()
: Tree
{
return $this->current()->getIterator();
}
}
return $this->current()->getIterator();
}
}