From eb3392db82337d0db051d5218016f7735d8bf4e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= <pierre.maziere@gmx.com>
Date: Tue, 23 Aug 2016 14:29:53 +0200
Subject: [PATCH] [core] simplify dynamic formats discovery
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
---
 formats/AtomFormat.php      |  2 --
 formats/HtmlFormat.php      |  6 ------
 formats/JsonFormat.php      |  2 --
 formats/MrssFormat.php      |  2 --
 formats/PlaintextFormat.php |  2 --
 lib/Format.php              | 26 +++++---------------------
 6 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php
index 7ec7d504..56c36963 100644
--- a/formats/AtomFormat.php
+++ b/formats/AtomFormat.php
@@ -2,8 +2,6 @@
 /**
 * Atom
 * Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
-*
-* @name Atom
 */
 class AtomFormat extends FormatAbstract{
 
diff --git a/formats/HtmlFormat.php b/formats/HtmlFormat.php
index 211a1371..c0f88557 100644
--- a/formats/HtmlFormat.php
+++ b/formats/HtmlFormat.php
@@ -1,10 +1,4 @@
 <?php
-/**
-* Html
-* Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
-*
-* @name Html
-*/
 class HtmlFormat extends FormatAbstract{
 
     public function stringify(){
diff --git a/formats/JsonFormat.php b/formats/JsonFormat.php
index e765ef54..c1b076ee 100644
--- a/formats/JsonFormat.php
+++ b/formats/JsonFormat.php
@@ -2,8 +2,6 @@
 /**
 * Json
 * Builds a JSON string from $this->items and return it to browser.
-*
-* @name Json
 */
 class JsonFormat extends FormatAbstract{
 
diff --git a/formats/MrssFormat.php b/formats/MrssFormat.php
index 7d939f36..d7cb682e 100644
--- a/formats/MrssFormat.php
+++ b/formats/MrssFormat.php
@@ -2,8 +2,6 @@
 /**
 * Mrss
 * Documentation Source http://www.rssboard.org/media-rss
-*
-* @name Media RSS
 */
 class MrssFormat extends FormatAbstract{
 
diff --git a/formats/PlaintextFormat.php b/formats/PlaintextFormat.php
index 32b4e020..7916bc61 100644
--- a/formats/PlaintextFormat.php
+++ b/formats/PlaintextFormat.php
@@ -2,8 +2,6 @@
 /**
 * Plaintext
 * Returns $this->items as raw php data.
-*
-* @name Plaintext
 */
 class PlaintextFormat extends FormatAbstract{
 
diff --git a/lib/Format.php b/lib/Format.php
index 0391606f..f3b053b2 100644
--- a/lib/Format.php
+++ b/lib/Format.php
@@ -168,29 +168,13 @@ class Format{
 
         $dirFiles = scandir($pathDirFormat);
         if( $dirFiles !== false ){
-            foreach( $dirFiles as $fileName ){
-                if( preg_match('@([^.]+)\.php@U', $fileName, $out) ){ // Is PHP file ?
-                    $infos = array(); // Information about the bridge
-                    $resParse = token_get_all(file_get_contents($pathDirFormat . $fileName)); // Parse PHP file
-                    foreach($resParse as $v){
-                        if( is_array($v) && $v[0] == T_DOC_COMMENT ){ // Lexer node is COMMENT ?
-                            $commentary = $v[1];
-                            foreach( $searchCommonPattern as $name){ // Catch information with common pattern
-                                preg_match('#@' . preg_quote($name, '#') . '\s+(.+)#', $commentary, $outComment);
-                                if( isset($outComment[1]) ){
-                                    $infos[$name] = $outComment[1];
-                                }
-                            }
-                        }
-                    }
-
-                    if( isset($infos['name']) ){ // If informations containt at least a name
-                        $listFormat[$out[1]] = $infos;
-                    }
-                }
+          foreach( $dirFiles as $fileName ){
+            if( preg_match('@^([^.]+)\.php$@U', $fileName, $out) ){ // Is PHP file ?
+              $listFormat[] = $out[1];
             }
+          }
         }
 
         return $listFormat;
     }
-}
\ No newline at end of file
+}