diff options
author | Romain d'Alverny <rdalverny@gmail.com> | 2022-01-11 12:36:17 +0100 |
---|---|---|
committer | Romain d'Alverny <rdalverny@gmail.com> | 2022-01-11 12:36:17 +0100 |
commit | 138865bbde25bb6193930c98e30c33913d19e367 (patch) | |
tree | 626e8e26dd4f4776ce9f8cd743987f08377127ed | |
parent | 5f2b708377aec4bc5f1d731dfbb50557552d0482 (diff) | |
download | planet-138865bbde25bb6193930c98e30c33913d19e367.tar planet-138865bbde25bb6193930c98e30c33913d19e367.tar.gz planet-138865bbde25bb6193930c98e30c33913d19e367.tar.bz2 planet-138865bbde25bb6193930c98e30c33913d19e367.tar.xz planet-138865bbde25bb6193930c98e30c33913d19e367.zip |
Install code QA helpers, enforce PSR2
Installs phpcs, phpmd, parallel-lint, phpstan.
-rwxr-xr-x | admin/index.php | 8 | ||||
-rwxr-xr-x | admin/login.php | 2 | ||||
-rw-r--r-- | admin/logout.php | 2 | ||||
-rw-r--r-- | admin/purgecache.php | 4 | ||||
-rwxr-xr-x | admin/subscriptions.php | 12 | ||||
-rwxr-xr-x | admin/template.php | 7 | ||||
-rwxr-xr-x | app/app.php | 3 | ||||
-rw-r--r-- | app/classes/Cache.php | 360 | ||||
-rw-r--r-- | app/classes/Opml.php | 42 | ||||
-rw-r--r-- | app/classes/OpmlManager.php | 6 | ||||
-rw-r--r-- | app/classes/Planet.php | 25 | ||||
-rw-r--r-- | app/classes/PlanetConfig.php | 4 | ||||
-rwxr-xr-x | app/classes/Simplel10n.php | 30 | ||||
-rw-r--r-- | app/helpers.php | 7 | ||||
-rwxr-xr-x | app/l10n/extract.php | 78 | ||||
-rw-r--r-- | atom.php | 11 | ||||
-rw-r--r-- | composer.json | 6 | ||||
-rw-r--r-- | composer.lock | 1113 | ||||
-rw-r--r-- | cron.php | 2 | ||||
-rwxr-xr-x | custom/views/archive/index.tpl.php | 24 | ||||
-rw-r--r-- | custom/views/default/index.tpl.php | 6 | ||||
-rw-r--r-- | custom/views/install.tpl.php | 3 | ||||
-rwxr-xr-x | index.php | 4 | ||||
-rwxr-xr-x | install.php | 18 | ||||
-rw-r--r-- | phpcs.xml | 11 | ||||
-rw-r--r-- | postload.php | 8 | ||||
-rw-r--r-- | tests/GuzzleHarness.php | 3 | ||||
-rw-r--r-- | tests/InstallTest.php | 5 | ||||
-rw-r--r-- | tests/PlanetErrorTest.php | 2 | ||||
-rw-r--r-- | tests/PlanetTest.php | 16 |
30 files changed, 1481 insertions, 341 deletions
diff --git a/admin/index.php b/admin/index.php index 0118923..3a9e259 100755 --- a/admin/index.php +++ b/admin/index.php @@ -6,7 +6,7 @@ require_once __DIR__ . '/inc/auth.inc.php'; //Load configuration $config_file = __DIR__ . '/../custom/config.yml'; -if (is_file($config_file)){ +if (is_file($config_file)) { $conf = Spyc::YAMLLoad($config_file); $PlanetConfig = new PlanetConfig($conf); } else { @@ -107,9 +107,9 @@ ob_start(); <tbody> <?php $i = 0; - foreach ($everyone as $opml_person){ - $i++; - ?> + foreach ($everyone as $opml_person) { + $i++; + ?> <tr class="<?=($i%2)?'odd':'even'; ?>"> <td><input type="checkbox" class="checkbox" name="opml[<?=$i; ?>][delete]" /></td> <td><input type="text" size="10" class="text" name="opml[<?=$i; ?>][name]" value="<?=$opml_person->getName(); ?>" /></td> diff --git a/admin/login.php b/admin/login.php index a95e59f..618cfb9 100755 --- a/admin/login.php +++ b/admin/login.php @@ -4,7 +4,7 @@ require_once __DIR__ . '/../app/app.php'; if (isset($_POST['password'])) { session_regenerate_id(); - setcookie('auth',md5($_POST['password'])); + setcookie('auth', md5($_POST['password'])); header('Location: index.php'); } diff --git a/admin/logout.php b/admin/logout.php index adb843f..88c60b3 100644 --- a/admin/logout.php +++ b/admin/logout.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/../app/app.php'; -setcookie('auth','', time()-3600); +setcookie('auth', '', time() - 3600); session_destroy(); session_regenerate_id(); diff --git a/admin/purgecache.php b/admin/purgecache.php index 23a5712..7b01c97 100644 --- a/admin/purgecache.php +++ b/admin/purgecache.php @@ -3,13 +3,13 @@ require_once __DIR__.'/../app/app.php'; require_once __DIR__.'/inc/auth.inc.php'; -if (isset($_POST['purge'])){ +if (isset($_POST['purge'])) { $dir = __DIR__.'/../cache/'; $dh = opendir($dir); while ($filename = readdir($dh)) { - if ($filename == '.' OR $filename == '..') { + if ($filename == '.' or $filename == '..') { continue; } diff --git a/admin/subscriptions.php b/admin/subscriptions.php index 0940168..313e5bd 100755 --- a/admin/subscriptions.php +++ b/admin/subscriptions.php @@ -3,7 +3,8 @@ require_once __DIR__ . '/../app/app.php'; require_once __DIR__ . '/inc/auth.inc.php'; -function removeSlashes(&$item, $key){ +function removeSlashes(&$item, $key) +{ $item = stripslashes($item); } @@ -12,7 +13,6 @@ if (!$csrf->verify($_POST['_csrf'], 'feedmanage')) { } if (isset($_POST['opml']) || isset($_POST['add'])) { - // Load old OPML $oldOpml = OpmlManager::load(__DIR__.'/../custom/people.opml'); if ($PlanetConfig->getName() === '') { @@ -26,11 +26,11 @@ if (isset($_POST['opml']) || isset($_POST['add'])) { array_walk_recursive($_POST['opml'], 'removeSlashes'); } // Delete/Save feeds - if (isset($_POST['delete']) || isset($_POST['save'])){ - foreach ($_POST['opml'] as $person){ + if (isset($_POST['delete']) || isset($_POST['save'])) { + foreach ($_POST['opml'] as $person) { if (isset($_POST['delete'])) { //delete mode, check if to be deleted - if (!isset($person['delete'])){ + if (!isset($person['delete'])) { $newOpml->entries[] = $person; } } else { @@ -40,7 +40,7 @@ if (isset($_POST['opml']) || isset($_POST['add'])) { } // Add feed - if (isset($_POST['add'])){ + if (isset($_POST['add'])) { if ('http://' != $_POST['url']) { //autodiscover feed $feed = new SimplePie(); diff --git a/admin/template.php b/admin/template.php index 7818bef..964c639 100755 --- a/admin/template.php +++ b/admin/template.php @@ -1,4 +1,6 @@ -<?php if(!isset($admin_access)) return; ?> +<?php if (!isset($admin_access)) { + return; +} ?> <!DOCTYPE html> <html lang="en"> <head> @@ -26,8 +28,7 @@ <p><a href="../"><?=_g('Back to main page')?></a></p> </header> - <?php if($admin_access == 1) : ?> - + <?php if ($admin_access == 1) : ?> <p class="logout"><a href="logout.php"><?=_g('Logout')?></a></p> <nav> <ul> diff --git a/app/app.php b/app/app.php index f82b262..4ae1947 100755 --- a/app/app.php +++ b/app/app.php @@ -13,7 +13,7 @@ if (is_installed()) { $conf = Spyc::YAMLLoad($savedConfig); // this is a check to upgrade older config file without l10n - if(!isset($conf['locale'])) { + if (!isset($conf['locale'])) { $resetPlanetConfig = new PlanetConfig($conf); file_put_contents($savedConfig, $resetPlanetConfig->toYaml()); $conf = Spyc::YAMLLoad($savedConfig); @@ -25,7 +25,6 @@ if (is_installed()) { if ($conf['debug']) { error_reporting(E_ALL); } - } $l10n = new Simplel10n($conf['locale']); diff --git a/app/classes/Cache.php b/app/classes/Cache.php index b73182e..f4b2dcf 100644 --- a/app/classes/Cache.php +++ b/app/classes/Cache.php @@ -13,242 +13,238 @@ * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* +* * © Copyright 2005 Richard Heyes */ /** * Caching Libraries for PHP5 -* +* * Handles data and output caching. Defaults to /dev/shm * (shared memory). All methods are static. -* +* * Eg: (output caching) -* +* * if (!OutputCache::Start('group', 'unique id', 600)) { -* +* * // ... Output -* +* * OutputCache::End(); * } -* +* * Eg: (data caching) -* +* * if (!$data = DataCache::Get('group', 'unique id')) { -* +* * $data = time(); -* +* * DataCache::Put('group', 'unique id', 10, $data); * } -* +* * echo $data; */ - class Cache - { - /** - * Whether caching is enabled - * @var bool - */ - public static $enabled = true; +class Cache +{ + /** + * Whether caching is enabled + * @var bool + */ + public static $enabled = true; - /** - * Place to store the cache files - * @var string - */ - protected static $store = '/dev/shm/'; + /** + * Place to store the cache files + * @var string + */ + protected static $store = '/dev/shm/'; - /** - * Prefix to use on cache files - * @var string - */ - protected static $prefix = 'cache_'; + /** + * Prefix to use on cache files + * @var string + */ + protected static $prefix = 'cache_'; - /** - * Stores data - * - * @param string $group Group to store data under - * @param string $id Unique ID of this data - * @param int $ttl How long to cache for (in seconds) - */ - protected static function write($group, $id, $ttl, $data) - { - $filename = self::getFilename($group, $id); - - if (self::$enabled && $fp = fopen($filename, 'xb')) { + /** + * Stores data + * + * @param string $group Group to store data under + * @param string $id Unique ID of this data + * @param int $ttl How long to cache for (in seconds) + */ + protected static function write($group, $id, $ttl, $data) + { + $filename = self::getFilename($group, $id); - if (flock($fp, LOCK_EX)) { - fwrite($fp, $data); - } - fclose($fp); - - // Set filemtime - touch($filename, time() + $ttl); + if (self::$enabled && $fp = fopen($filename, 'xb')) { + if (flock($fp, LOCK_EX)) { + fwrite($fp, $data); } + fclose($fp); + + // Set filemtime + touch($filename, time() + $ttl); } + } - /** - * Reads data - * - * @param string $group Group to store data under - * @param string $id Unique ID of this data - */ - protected static function read($group, $id) - { - $filename = self::getFilename($group, $id); + /** + * Reads data + * + * @param string $group Group to store data under + * @param string $id Unique ID of this data + */ + protected static function read($group, $id) + { + $filename = self::getFilename($group, $id); - return file_get_contents($filename); - } + return file_get_contents($filename); + } - /** - * Determines if an entry is cached - * - * @param string $group Group to store data under - * @param string $id Unique ID of this data - */ - protected static function isCached($group, $id) - { - $filename = self::getFilename($group, $id); + /** + * Determines if an entry is cached + * + * @param string $group Group to store data under + * @param string $id Unique ID of this data + */ + protected static function isCached($group, $id) + { + $filename = self::getFilename($group, $id); - if (self::$enabled && file_exists($filename) && filemtime($filename) > time()) { - return true; - } + if (self::$enabled && file_exists($filename) && filemtime($filename) > time()) { + return true; + } - @unlink($filename); + @unlink($filename); - return false; - } + return false; + } - /** - * Builds a filename/path from group, id and - * store. - * - * @param string $group Group to store data under - * @param string $id Unique ID of this data - */ - protected static function getFilename($group, $id) - { - $id = md5($id); + /** + * Builds a filename/path from group, id and + * store. + * + * @param string $group Group to store data under + * @param string $id Unique ID of this data + */ + protected static function getFilename($group, $id) + { + $id = md5($id); - return self::$store . self::$prefix . "{$group}_{$id}"; - } + return self::$store . self::$prefix . "{$group}_{$id}"; + } - /** - * Sets the filename prefix to use - * - * @param string $prefix Filename Prefix to use - */ - public static function setPrefix($prefix) - { - self::$prefix = $prefix; - } + /** + * Sets the filename prefix to use + * + * @param string $prefix Filename Prefix to use + */ + public static function setPrefix($prefix) + { + self::$prefix = $prefix; + } - /** - * Sets the store for cache files. Defaults to - * /dev/shm. Must have trailing slash. - * - * @param string $store The dir to store the cache data in - */ - public static function setStore($store) - { - self::$store = $store; - } + /** + * Sets the store for cache files. Defaults to + * /dev/shm. Must have trailing slash. + * + * @param string $store The dir to store the cache data in + */ + public static function setStore($store) + { + self::$store = $store; } +} /** * Output Cache extension of base caching class */ - class OutputCache extends Cache - { - /** - * Group of currently being recorded data - * @var string - */ - private static $group; +class OutputCache extends Cache +{ + /** + * Group of currently being recorded data + * @var string + */ + private static $group; - /** - * ID of currently being recorded data - * @var string - */ - private static $id; + /** + * ID of currently being recorded data + * @var string + */ + private static $id; - /** - * Ttl of currently being recorded data - * @var int - */ - private static $ttl; + /** + * Ttl of currently being recorded data + * @var int + */ + private static $ttl; - /** - * Starts caching off. Returns true if cached, and dumps - * the output. False if not cached and start output buffering. - * - * @param string $group Group to store data under - * @param string $id Unique ID of this data - * @param int $ttl How long to cache for (in seconds) - * @return bool True if cached, false if not - */ - public static function Start($group, $id, $ttl) - { - if (self::isCached($group, $id)) { - echo self::read($group, $id); - return true; - - } else { - - ob_start(); + /** + * Starts caching off. Returns true if cached, and dumps + * the output. False if not cached and start output buffering. + * + * @param string $group Group to store data under + * @param string $id Unique ID of this data + * @param int $ttl How long to cache for (in seconds) + * @return bool True if cached, false if not + */ + public static function Start($group, $id, $ttl) + { + if (self::isCached($group, $id)) { + echo self::read($group, $id); + return true; + } else { + ob_start(); - self::$group = $group; - self::$id = $id; - self::$ttl = $ttl; + self::$group = $group; + self::$id = $id; + self::$ttl = $ttl; - return false; - } + return false; } + } - /** - * Ends caching. Writes data to disk. - */ - public static function End() - { - $data = ob_get_contents(); - ob_end_flush(); + /** + * Ends caching. Writes data to disk. + */ + public static function End() + { + $data = ob_get_contents(); + ob_end_flush(); - self::write(self::$group, self::$id, self::$ttl, $data); - } + self::write(self::$group, self::$id, self::$ttl, $data); } +} /** * Data cache extension of base caching class */ - class DataCache extends Cache - { +class DataCache extends Cache +{ - /** - * Retrieves data from the cache - * - * @param string $group Group this data belongs to - * @param string $id Unique ID of the data - * @return mixed Either the resulting data, or null - */ - public static function Get($group, $id) - { - if (self::isCached($group, $id)) { - return unserialize(self::read($group, $id)); - } - - return null; + /** + * Retrieves data from the cache + * + * @param string $group Group this data belongs to + * @param string $id Unique ID of the data + * @return mixed Either the resulting data, or null + */ + public static function Get($group, $id) + { + if (self::isCached($group, $id)) { + return unserialize(self::read($group, $id)); } + + return null; + } - /** - * Stores data in the cache - * - * @param string $group Group this data belongs to - * @param string $id Unique ID of the data - * @param int $ttl How long to cache for (in seconds) - * @param mixed $data The data to store - */ - public static function Put($group, $id, $ttl, $data) - { - self::write($group, $id, $ttl, serialize($data)); - } + /** + * Stores data in the cache + * + * @param string $group Group this data belongs to + * @param string $id Unique ID of the data + * @param int $ttl How long to cache for (in seconds) + * @param mixed $data The data to store + */ + public static function Put($group, $id, $ttl, $data) + { + self::write($group, $id, $ttl, serialize($data)); } -?>
\ No newline at end of file +} diff --git a/app/classes/Opml.php b/app/classes/Opml.php index ae9e8b1..a9de2b0 100644 --- a/app/classes/Opml.php +++ b/app/classes/Opml.php @@ -2,12 +2,12 @@ class Opml { - var $_xml = null; - var $_currentTag = ''; + private $_xml = null; + private $_currentTag = ''; - var $title = ''; - var $entries = array(); - var $map = + public $title = ''; + public $entries = array(); + private $map = array( 'URL' => 'website', 'HTMLURL' => 'website', @@ -19,30 +19,28 @@ class Opml ); - function parse($data) + public function parse($data) { $this->_xml = xml_parser_create('UTF-8'); //xml_parser_set_option($this->_xml, XML_OPTION_CASE_FOLDING, false); //xml_parser_set_option($this->_xml, XML_OPTION_SKIP_WHITE, true); xml_set_object($this->_xml, $this); - xml_set_element_handler($this->_xml,'_openTag','_closeTag'); - xml_set_character_data_handler ($this->_xml, '_cData'); + xml_set_element_handler($this->_xml, '_openTag', '_closeTag'); + xml_set_character_data_handler($this->_xml, '_cData'); - xml_parse($this->_xml,$data); + xml_parse($this->_xml, $data); xml_parser_free($this->_xml); return $this->entries; } - function _openTag($p,$tag,$attrs) + private function _openTag($p, $tag, $attrs) { $this->_currentTag = $tag; - if ($tag == 'OUTLINE') - { + if ($tag == 'OUTLINE') { $i = count($this->entries); - foreach (array_keys($this->map) as $key) - { + foreach (array_keys($this->map) as $key) { if (isset($attrs[$key])) { $this->entries[$i][$this->map[$key]] = $attrs[$key]; } @@ -50,21 +48,25 @@ class Opml } } - function _closeTag($p, $tag){ + private function _closeTag($p, $tag) + { $this->_currentTag = ''; } - function _cData($p, $cdata){ - if ($this->_currentTag == 'TITLE'){ + private function _cData($p, $cdata) + { + if ($this->_currentTag == 'TITLE') { $this->title = $cdata; } } - function getTitle(){ + public function getTitle() + { return $this->title; } - function getPeople(){ + public function getPeople() + { return $this->entries; } -}
\ No newline at end of file +} diff --git a/app/classes/OpmlManager.php b/app/classes/OpmlManager.php index d3940b2..66de7c9 100644 --- a/app/classes/OpmlManager.php +++ b/app/classes/OpmlManager.php @@ -26,7 +26,8 @@ class OpmlManager * @param Opml $opml * @param string $file */ - public static function save($opml, $file){ + public static function save($opml, $file) + { $out = '<?xml version="1.0"?>'."\n"; $out.= '<opml version="1.1">'."\n"; $out.= '<head>'."\n"; @@ -44,7 +45,8 @@ class OpmlManager file_put_contents($file, $out); } - public static function backup($file){ + public static function backup($file) + { copy($file, $file.'.bak'); } } diff --git a/app/classes/Planet.php b/app/classes/Planet.php index d6007e5..898126f 100644 --- a/app/classes/Planet.php +++ b/app/classes/Planet.php @@ -51,7 +51,7 @@ class Planet * * @param PlanetConfig $config */ - public function __construct($config=null) + public function __construct($config = null) { $this->config = $config === null ? new PlanetConfig() : $config; @@ -87,7 +87,8 @@ class Planet { $this->items = $this->_filterItemsByCategory( $this->items, - $this->config->getCategories()); + $this->config->getCategories() + ); return $this->items; } @@ -122,7 +123,7 @@ class Planet $opml = OpmlManager::load($file); $opml_people = $opml->getPeople(); - foreach ($opml_people as $opml_person){ + foreach ($opml_people as $opml_person) { $person = new PlanetFeed( $opml_person['name'], $opml_person['feed'], @@ -146,7 +147,6 @@ class Planet $feed->init(); $this->items = array_merge($this->items, $feed->get_items()); } - } $this->sort(); } @@ -156,7 +156,7 @@ class Planet * * @param float $max_load Percentage of feeds to load */ - public function download($max_load=0.1) + public function download($max_load = 0.1) { $max_load_feeds = ceil(count($this->people) * $max_load); $opml = OpmlManager::load(__DIR__.'/../../custom/people.opml'); @@ -184,7 +184,7 @@ class Planet $isDown = ''; // http://simplepie.org/wiki/reference/simplepie/merge_items ? - if (($feed->data) && ($feed->get_item_quantity() > 0)){ + if (($feed->data) && ($feed->get_item_quantity() > 0)) { $items = $feed->get_items(); $this->items = array_merge($this->items, $items); } else { @@ -221,20 +221,21 @@ class Planet */ public function _filterItemsByCategory($items, $categories = null) { - if (is_null($categories) or empty(trim($categories))) - { + if (is_null($categories) or empty(trim($categories))) { return $items; } $categories = array_map('trim', explode(',', strtolower($categories))); $cb_category_filter = - function ($item) use ($categories) - { - if (!is_array($item_categories = $item->get_categories())) + function ($item) use ($categories) { + if (!is_array($item_categories = $item->get_categories())) { return false; + } $item_categories = array_map( - function ($i) { return strtolower($i->get_label()); }, + function ($i) { + return strtolower($i->get_label()); + }, $item_categories ); diff --git a/app/classes/PlanetConfig.php b/app/classes/PlanetConfig.php index f3928bc..257d1b9 100644 --- a/app/classes/PlanetConfig.php +++ b/app/classes/PlanetConfig.php @@ -52,7 +52,8 @@ class PlanetConfig return $this->conf['url']; } - public function getName(){ + public function getName() + { return $this->conf['name']; } @@ -190,5 +191,4 @@ class PlanetConfig $this->conf[$key] = $value; } - } diff --git a/app/classes/Simplel10n.php b/app/classes/Simplel10n.php index 79313b3..f84ef5c 100755 --- a/app/classes/Simplel10n.php +++ b/app/classes/Simplel10n.php @@ -1,24 +1,28 @@ <?php -class Simplel10n { +class Simplel10n +{ public $locale; public $l10nFolder; - public function __construct($locale='en') { + public function __construct($locale = 'en') + { $GLOBALS['locale'] = array(); $this->locale = $locale; $this->l10nFolder = __DIR__ . '/../l10n/'; $this->load($this->l10nFolder . $this->locale); } - public function setL1OnFolder($path) { + public function setL1OnFolder($path) + { $this->l10nFolder = $path; } - static function getString($str, $comment='') { - if(array_key_exists($str, $GLOBALS['locale'])) { + public static function getString($str, $comment = '') + { + if (array_key_exists($str, $GLOBALS['locale'])) { return trim(str_replace('{ok}', '', $GLOBALS['locale'][$str])); } else { return $str; @@ -29,23 +33,27 @@ class Simplel10n { * This is the same as getString except that we don't remove the {ok} string * This is needed only for the extraction script */ - static function extractString($str, $comment='') { - if(array_key_exists($str, $GLOBALS['locale'])) { + public static function extractString($str, $comment = '') + { + if (array_key_exists($str, $GLOBALS['locale'])) { return $GLOBALS['locale'][$str]; } else { return $str; } } - static function load($pathToFile) { + public static function load($pathToFile) + { - if (!file_exists($pathToFile . '.lang')) return false; + if (!file_exists($pathToFile . '.lang')) { + return false; + } $file = file($pathToFile . '.lang'); foreach ($file as $k => $v) { - if (substr($v,0,1) == ';' && !empty($file[$k+1])) { - $GLOBALS['locale'][trim(substr($v,1))] = trim($file[$k+1]); + if (substr($v, 0, 1) == ';' && !empty($file[$k+1])) { + $GLOBALS['locale'][trim(substr($v, 1))] = trim($file[$k+1]); } } } diff --git a/app/helpers.php b/app/helpers.php index 5f251e4..f3a9dfa 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -2,9 +2,9 @@ /** * Register polyfills for old PHP versions. - * + * * This way, the real function will only be called if it - * is available, and we won't force the use of our own + * is available, and we won't force the use of our own * implementation. */ function register_polyfills() @@ -63,7 +63,7 @@ function is_installed() * @param string $comment * @return string */ -function _g($str, $comment='') +function _g($str, $comment = '') { return Simplel10n::getString($str, $comment); } @@ -86,4 +86,3 @@ function removeCustomFiles() } } } - diff --git a/app/l10n/extract.php b/app/l10n/extract.php index 1384827..ef44912 100755 --- a/app/l10n/extract.php +++ b/app/l10n/extract.php @@ -29,41 +29,44 @@ $GLOBALS['english'] = array(); * */ -function extract_l10n_strings($file) { +function extract_l10n_strings($file) +{ $lines = file($file); $patterns = array('/_g\([\'"](.*?)[\'"]\)/', '/getString\([\'"](.*?)[\'"]\)/',); foreach ($lines as $line) { - // Skip comments - if($line[0] == '#' || $line[0] == '/') continue; + if ($line[0] == '#' || $line[0] == '/') { + continue; + } // parsing logic - foreach($patterns as $pattern) { - if(preg_match_all($pattern, $line, $matches, PREG_PATTERN_ORDER)) { - foreach($matches[1] as $val) { - + foreach ($patterns as $pattern) { + if (preg_match_all($pattern, $line, $matches, PREG_PATTERN_ORDER)) { + foreach ($matches[1] as $val) { // Do not extract php variables calls or empty strings - if($val[0] == '$' || $val == '') continue; + if ($val[0] == '$' || $val == '') { + continue; + } // Is there a localization comment ? $l10n_note = explode("',", $val); // Also test strings in double quotes - if(count($l10n_note) == 1) { + if (count($l10n_note) == 1) { $l10n_note = explode('",', $val); } // Extract cleaned up strings - if(count($l10n_note) == 2) { + if (count($l10n_note) == 2) { $l10n_str = trim($l10n_note[0]); - $l10n_note = trim(substr(trim($l10n_note[1]),1)); # Remove quote at begining of string + $l10n_note = trim(substr(trim($l10n_note[1]), 1)); # Remove quote at begining of string } else { $l10n_str = trim($val); $l10n_note = ''; } - if(!array_key_exists($l10n_str, $GLOBALS['english'])) { + if (!array_key_exists($l10n_str, $GLOBALS['english'])) { $GLOBALS['english'][$l10n_str] = array($l10n_str, $l10n_note); } } @@ -80,12 +83,13 @@ function extract_l10n_strings($file) { * show_l10n_strings() ; */ -function show_l10n_strings() { +function show_l10n_strings() +{ header('Content-Type:text/plain'); - foreach($GLOBALS['english'] as $val) { - if($val[1]) { + foreach ($GLOBALS['english'] as $val) { + if ($val[1]) { echo '# ' . $val[1] . "\n"; } echo ";$val[0]\n"; @@ -98,28 +102,28 @@ function show_l10n_strings() { * returns an array of file paths */ -function find_all_files($dir) { +function find_all_files($dir) +{ $result = array(); $root = scandir($dir); $ignore = array('.', '..', '.git', '.svn', '.hg', 'cache', '.gitignore', 'lib'); - foreach($root as $value) { - - if(in_array($value, $ignore)) { + foreach ($root as $value) { + if (in_array($value, $ignore)) { continue; } - if(is_file("$dir/$value")) { + if (is_file("$dir/$value")) { $split = explode('.', $value); - if(end($split) == 'php'){ + if (end($split) == 'php') { $result[] = "$dir/$value"; } continue; } - foreach(find_all_files("$dir/$value") as $value) { + foreach (find_all_files("$dir/$value") as $value) { $result[]=$value; } } @@ -127,11 +131,12 @@ function find_all_files($dir) { return $result; } -function update_lang_files($source, $dest) { +function update_lang_files($source, $dest) +{ $files = find_all_files($source); - foreach($files as $file) { + foreach ($files as $file) { extract_l10n_strings($file); } @@ -142,39 +147,38 @@ function update_lang_files($source, $dest) { // list locales $locales = array(); - foreach($files as $file) { - - if(in_array($file, $ignore)) { + foreach ($files as $file) { + if (in_array($file, $ignore)) { continue; } $split = explode('.', $file); - if($split[1] == 'lang') { + if ($split[1] == 'lang') { $locales[] = $split[0]; } - } + } - foreach($locales as $locale) { + foreach ($locales as $locale) { $status[$locale] = 0; $lang_file_path = $dest . '/' . $locale; Simplel10n::load($lang_file_path); ob_start(); - foreach($GLOBALS['english'] as $key => $val) { + foreach ($GLOBALS['english'] as $key => $val) { $warning = ''; $value = @Simplel10n::extractString($key); - if($value == $val[0]) { + if ($value == $val[0]) { $status[$locale]++; $warning = ' ** String needs translation **'; } - if($val[1]) { + if ($val[1]) { echo '# Translation note: ' . $val[1] . $warning . "\n"; - } elseif($warning != '') { + } elseif ($warning != '') { echo '# Translation note: ' . $warning . "\n"; } @@ -187,16 +191,16 @@ function update_lang_files($source, $dest) { file_put_contents($lang_file_path. '.lang', $content); unset($GLOBALS['locale']); - } + } // Display a short status report header('Content-Type:text/plain'); echo "Number of English strings: " . count($GLOBALS['english']) . "\n"; echo "Your installation has these languages installed: " . implode(', ', $locales) . "\n"; - foreach($locales as $val) { + foreach ($locales as $val) { echo $val . " has " . $status[$val] . " untranslated strings.\n"; - } + } } update_lang_files($root, $root . 'app/l10n'); @@ -2,7 +2,9 @@ include_once(__DIR__.'/app/app.php'); include_once(__DIR__.'/app/classes/Cache.php'); -if ($Planet->loadOpml(__DIR__.'/custom/people.opml') == 0) exit; +if ($Planet->loadOpml(__DIR__.'/custom/people.opml') == 0) { + exit; +} $Planet->loadFeeds(); $items = $Planet->getItems(); @@ -22,8 +24,7 @@ echo '<?xml version="1.0" encoding="UTF-8" ?>'; <author><name><?=htmlspecialchars($PlanetConfig->getName())?></name></author> <?php $count = 0; ?> -<?php foreach ($items as $item): ?> - +<?php foreach ($items as $item) : ?> <entry> <title type="html"><?=htmlspecialchars($item->get_feed()->getName())?> : <?=htmlspecialchars($item->get_title())?></title> <id><?=htmlspecialchars($item->get_permalink())?></id> @@ -35,7 +36,9 @@ echo '<?xml version="1.0" encoding="UTF-8" ?>'; <content type="html"><![CDATA[<?=$item->get_content()?>]]></content> </entry> -<?php if (++$count == $limit) break; ?> + <?php if (++$count == $limit) { + break; + } ?> <?php endforeach; ?> </feed> diff --git a/composer.json b/composer.json index ffa4c92..712094b 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,11 @@ }, "require-dev": { "guzzlehttp/guzzle": "^7.4", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^1.3", + "phpmd/phpmd": "^2.11", + "php-parallel-lint/php-parallel-lint": "^1.3", + "squizlabs/php_codesniffer": "^3.6" }, "scripts": { "test": "" diff --git a/composer.lock b/composer.lock index 3c48330..9abd6be 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fd5522c67bffd0ec8b237b5304cff933", + "content-hash": "319417453dfb2b52e702dd45f9ee6b8b", "packages": [ { "name": "mustangostang/spyc", @@ -180,6 +180,143 @@ ], "packages-dev": [ { + "name": "composer/pcre", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "3d322d715c43a1ac36c7fe215fa59336265500f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/3d322d715c43a1ac36c7fe215fa59336265500f2", + "reference": "3d322d715c43a1ac36c7fe215fa59336265500f2", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/1.0.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-12-06T15:17:27+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "0c1a3925ec58a4ec98e992b9c7d171e9e184be0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/0c1a3925ec58a4ec98e992b9c7d171e9e184be0a", + "reference": "0c1a3925ec58a4ec98e992b9c7d171e9e184be0a", + "shasum": "" + }, + "require": { + "composer/pcre": "^1", + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/2.0.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-01-04T17:06:45+00:00" + }, + { "name": "doctrine/instantiator", "version": "1.4.0", "source": { @@ -683,6 +820,63 @@ "time": "2021-11-30T19:35:32+00:00" }, { + "name": "pdepend/pdepend", + "version": "2.10.2", + "source": { + "type": "git", + "url": "https://github.com/pdepend/pdepend.git", + "reference": "c8c1d2af43fb8c2b5387d50e9c42a9c56de13686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/c8c1d2af43fb8c2b5387d50e9c42a9c56de13686", + "reference": "c8c1d2af43fb8c2b5387d50e9c42a9c56de13686", + "shasum": "" + }, + "require": { + "php": ">=5.3.7", + "symfony/config": "^2.3.0|^3|^4|^5", + "symfony/dependency-injection": "^2.3.0|^3|^4|^5", + "symfony/filesystem": "^2.3.0|^3|^4|^5" + }, + "require-dev": { + "easy-doc/easy-doc": "0.0.0|^1.2.3", + "gregwar/rst": "^1.0", + "phpunit/phpunit": "^4.8.36|^5.7.27", + "squizlabs/php_codesniffer": "^2.0.0" + }, + "bin": [ + "src/bin/pdepend" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "PDepend\\": "src/main/php/PDepend" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of pdepend to be handled with Composer", + "support": { + "issues": "https://github.com/pdepend/pdepend/issues", + "source": "https://github.com/pdepend/pdepend/tree/2.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/pdepend/pdepend", + "type": "tidelift" + } + ], + "time": "2021-11-16T20:05:32+00:00" + }, + { "name": "phar-io/manifest", "version": "2.0.3", "source": { @@ -794,6 +988,63 @@ "time": "2021-02-23T14:00:09+00:00" }, { + "name": "php-parallel-lint/php-parallel-lint", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", + "reference": "761f3806e30239b5fcd90a0a45d41dc2138de192" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/761f3806e30239b5fcd90a0a45d41dc2138de192", + "reference": "761f3806e30239b5fcd90a0a45d41dc2138de192", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=5.3.0" + }, + "replace": { + "grogy/php-parallel-lint": "*", + "jakub-onderka/php-parallel-lint": "*" + }, + "require-dev": { + "nette/tester": "^1.3 || ^2.0", + "php-parallel-lint/php-console-highlighter": "~0.3", + "squizlabs/php_codesniffer": "^3.6" + }, + "suggest": { + "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool check syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "support": { + "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", + "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.3.1" + }, + "time": "2021-08-13T05:35:13+00:00" + }, + { "name": "phpdocumentor/reflection-common", "version": "2.2.0", "source": { @@ -954,6 +1205,89 @@ "time": "2022-01-04T19:58:01+00:00" }, { + "name": "phpmd/phpmd", + "version": "2.11.1", + "source": { + "type": "git", + "url": "https://github.com/phpmd/phpmd.git", + "reference": "08b60a2eb7e14c23f46ff8865b510ae08b75d0fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/08b60a2eb7e14c23f46ff8865b510ae08b75d0fd", + "reference": "08b60a2eb7e14c23f46ff8865b510ae08b75d0fd", + "shasum": "" + }, + "require": { + "composer/xdebug-handler": "^1.0 || ^2.0", + "ext-xml": "*", + "pdepend/pdepend": "^2.10.2", + "php": ">=5.3.9" + }, + "require-dev": { + "easy-doc/easy-doc": "0.0.0 || ^1.3.2", + "ext-json": "*", + "ext-simplexml": "*", + "gregwar/rst": "^1.0", + "mikey179/vfsstream": "^1.6.8", + "phpunit/phpunit": "^4.8.36 || ^5.7.27", + "squizlabs/php_codesniffer": "^2.0" + }, + "bin": [ + "src/bin/phpmd" + ], + "type": "library", + "autoload": { + "psr-0": { + "PHPMD\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Manuel Pichler", + "email": "github@manuel-pichler.de", + "homepage": "https://github.com/manuelpichler", + "role": "Project Founder" + }, + { + "name": "Marc Würth", + "email": "ravage@bluewin.ch", + "homepage": "https://github.com/ravage84", + "role": "Project Maintainer" + }, + { + "name": "Other contributors", + "homepage": "https://github.com/phpmd/phpmd/graphs/contributors", + "role": "Contributors" + } + ], + "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", + "homepage": "https://phpmd.org/", + "keywords": [ + "mess detection", + "mess detector", + "pdepend", + "phpmd", + "pmd" + ], + "support": { + "irc": "irc://irc.freenode.org/phpmd", + "issues": "https://github.com/phpmd/phpmd/issues", + "source": "https://github.com/phpmd/phpmd/tree/2.11.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/phpmd/phpmd", + "type": "tidelift" + } + ], + "time": "2021-12-17T11:25:43+00:00" + }, + { "name": "phpspec/prophecy", "version": "v1.15.0", "source": { @@ -1021,6 +1355,70 @@ "time": "2021-12-08T12:19:24+00:00" }, { + "name": "phpstan/phpstan", + "version": "1.3.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "151a51f6149855785fbd883e79768c0abc96b75f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/151a51f6149855785fbd883e79768c0abc96b75f", + "reference": "151a51f6149855785fbd883e79768c0abc96b75f", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.3.3" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-01-07T09:49:03+00:00" + }, + { "name": "phpunit/php-code-coverage", "version": "9.2.10", "source": { @@ -1442,6 +1840,54 @@ "time": "2021-12-25T07:07:57+00:00" }, { + "name": "psr/container", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" + }, + { "name": "psr/http-client", "version": "1.0.1", "source": { @@ -1602,6 +2048,56 @@ "time": "2016-08-06T14:39:51+00:00" }, { + "name": "psr/log", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, + { "name": "ralouphie/getallheaders", "version": "3.0.3", "source": { @@ -2610,6 +3106,230 @@ "time": "2020-09-28T06:39:44+00:00" }, { + "name": "squizlabs/php_codesniffer", + "version": "3.6.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" + }, + { + "name": "symfony/config", + "version": "v5.4.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "2e082dae50da563c639119b7b52347a2a3db4ba5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/2e082dae50da563c639119b7b52347a2a3db4ba5", + "reference": "2e082dae50da563c639119b7b52347a2a3db4ba5", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/filesystem": "^4.4|^5.0|^6.0", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php81": "^1.22" + }, + "conflict": { + "symfony/finder": "<4.4" + }, + "require-dev": { + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/messenger": "^4.4|^5.0|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/yaml": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/config/tree/v5.4.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-12-15T11:06:13+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v5.4.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "ba94559be9738d77cd29e24b5d81cf3b89b7d628" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ba94559be9738d77cd29e24b5d81cf3b89b7d628", + "reference": "ba94559be9738d77cd29e24b5d81cf3b89b7d628", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1.1", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php81": "^1.22", + "symfony/service-contracts": "^1.1.6|^2" + }, + "conflict": { + "ext-psr": "<1.1|>=2", + "symfony/config": "<5.3", + "symfony/finder": "<4.4", + "symfony/proxy-manager-bridge": "<4.4", + "symfony/yaml": "<4.4" + }, + "provide": { + "psr/container-implementation": "1.0", + "symfony/service-implementation": "1.0|2.0" + }, + "require-dev": { + "symfony/config": "^5.3|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows you to standardize and centralize the way objects are constructed in your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/dependency-injection/tree/v5.4.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-12-29T10:10:35+00:00" + }, + { "name": "symfony/deprecation-contracts", "version": "v3.0.0", "source": { @@ -2677,6 +3397,70 @@ "time": "2021-11-01T23:48:49+00:00" }, { + "name": "symfony/filesystem", + "version": "v5.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "731f917dc31edcffec2c6a777f3698c33bea8f01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/731f917dc31edcffec2c6a777f3698c33bea8f01", + "reference": "731f917dc31edcffec2c6a777f3698c33bea8f01", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-28T13:39:27+00:00" + }, + { "name": "symfony/polyfill-ctype", "version": "v1.24.0", "source": { @@ -2759,6 +3543,333 @@ "time": "2021-10-20T20:35:02+00:00" }, { + "name": "symfony/polyfill-mbstring", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-30T18:21:41+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-09-13T13:58:33+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "5de4ba2d41b15f9bd0e19b2ab9674135813ec98f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/5de4ba2d41b15f9bd0e19b2ab9674135813ec98f", + "reference": "5de4ba2d41b15f9bd0e19b2ab9674135813ec98f", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.24.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-09-13T13:58:11+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.4.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "d664541b99d6fb0247ec5ff32e87238582236204" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d664541b99d6fb0247ec5ff32e87238582236204", + "reference": "d664541b99d6fb0247ec5ff32e87238582236204", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v2.4.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-04T16:37:19+00:00" + }, + { "name": "theseer/tokenizer", "version": "1.2.1", "source": { @@ -10,4 +10,4 @@ if ($conf['debug'] === true) { foreach ($Planet->errors as $error) { echo $error->toString() . "\n"; } -}
\ No newline at end of file +} diff --git a/custom/views/archive/index.tpl.php b/custom/views/archive/index.tpl.php index 16bc6ab..7dd2737 100755 --- a/custom/views/archive/index.tpl.php +++ b/custom/views/archive/index.tpl.php @@ -1,9 +1,9 @@ <?php $count = 0; -$today = Array(); -$week = Array(); -$month = Array(); -$older = Array(); +$today = array(); +$week = array(); +$month = array(); +$older = array(); $now = time(); foreach ($items as $item) { @@ -45,11 +45,11 @@ header('Content-type: text/html; charset=UTF-8'); <p class="article-content"><?=_g('No news, good news.')?></p> </div> <?php endif; ?> - <?php if (count($today)): ?> + <?php if (count($today)) : ?> <div class="article"> <h2><?=_g('Today')?></h2> <ul> - <?php foreach ($today as $item): ?> + <?php foreach ($today as $item) : ?> <?php $feed = $item->get_feed(); ?> <li> <a href="<?php echo $feed->getWebsite() ?>" class="source"><?php echo $feed->getName() ?></a> : @@ -60,11 +60,11 @@ header('Content-type: text/html; charset=UTF-8'); </div> <?php endif; ?> - <?php if (count($week)): ?> + <?php if (count($week)) : ?> <div class="article"> <h2><?=_g('This week')?></h2> <ul> - <?php foreach ($week as $item): ?> + <?php foreach ($week as $item) : ?> <?php $feed = $item->get_feed(); ?> <li> <a href="<?php echo $feed->getWebsite() ?>" class="source"><?php echo $feed->getName() ?></a> : @@ -75,11 +75,11 @@ header('Content-type: text/html; charset=UTF-8'); </div> <?php endif; ?> - <?php if (count($month)): ?> + <?php if (count($month)) : ?> <div class="article"> <h2><?=_g('This month')?></h2> <ul> - <?php foreach ($month as $item): ?> + <?php foreach ($month as $item) : ?> <?php $feed = $item->get_feed(); ?> <li> <a href="<?php echo $feed->getWebsite() ?>" class="source"><?php echo $feed->getName() ?></a> : @@ -90,11 +90,11 @@ header('Content-type: text/html; charset=UTF-8'); </div> <?php endif; ?> - <?php if (count($older)): ?> + <?php if (count($older)) : ?> <div class="article"> <h2><?=_g('Older items')?></h2> <ul> - <?php foreach ($older as $item): ?> + <?php foreach ($older as $item) : ?> <?php $feed = $item->get_feed(); ?> <li> <a href="<?php echo $feed->getWebsite() ?>" class="source"><?php echo $feed->getName() ?></a> : diff --git a/custom/views/default/index.tpl.php b/custom/views/default/index.tpl.php index c33ffa5..b3fa1e0 100644 --- a/custom/views/default/index.tpl.php +++ b/custom/views/default/index.tpl.php @@ -32,7 +32,7 @@ header('Content-type: text/html; charset=UTF-8'); <p class="article-content"><?=_g('No news, good news.')?></p> </div> <?php else : ?> - <?php foreach ($items as $item): ?> + <?php foreach ($items as $item) : ?> <?php $arParsedUrl = parse_url($item->get_feed()->getWebsite()); $host = 'from-' . preg_replace('/[^a-zA-Z0-9]/i', '-', $arParsedUrl['host']); @@ -60,7 +60,9 @@ header('Content-type: text/html; charset=UTF-8'); <?php echo $item->get_content(); ?> </div> </div> - <?php if (++$count == $limit) { break; } ?> + <?php if (++$count == $limit) { + break; + } ?> <?php endforeach; ?> <?php endif; ?> </div> diff --git a/custom/views/install.tpl.php b/custom/views/install.tpl.php index 9eaff65..8fbb99e 100644 --- a/custom/views/install.tpl.php +++ b/custom/views/install.tpl.php @@ -102,8 +102,7 @@ </form> </div> -<?php elseif ($status =='installed'): ?> - +<?php elseif ($status =='installed') : ?> <p><?=_g('Congratulations! Your moonmoon is ready.')?></p> <h3><?=_g("What's next?")?></h3> <ol> @@ -9,7 +9,7 @@ if (!isset($Planet)) { } //Load from cache -$items = Array(); +$items = array(); if (0 < $Planet->loadOpml(__DIR__.'/custom/people.opml')) { $Planet->loadFeeds(); $items = $Planet->getItems(); @@ -36,7 +36,7 @@ if (isset($_GET['type']) && $_GET['type'] == 'atom10') { //Go display if (!isset($_GET['type']) || !is_file(__DIR__.'/custom/views/'.$_GET['type'].'/index.tpl.php') || - strpos($_GET['type'], DIRECTORY_SEPARATOR) || strpos($GET['type'], '..')){ + strpos($_GET['type'], DIRECTORY_SEPARATOR) || strpos($GET['type'], '..')) { $_GET['type'] = 'default'; } diff --git a/install.php b/install.php index 1dc1837..5dc20bc 100755 --- a/install.php +++ b/install.php @@ -3,7 +3,8 @@ require_once __DIR__ . '/app/app.php'; // This is an helper function returning an html table row to avoid code duplication -function installStatus($str, $msg, $result) { +function installStatus($str, $msg, $result) +{ $class = ($result) ? 'ok' : 'fail'; return '<tr><td>' . $str . '</td><td class="' . $class . '">' . $msg . '</td></tr>'; } @@ -12,7 +13,6 @@ function installStatus($str, $msg, $result) { if (is_installed()) { $status = 'installed'; } elseif (isset($_POST['url'])) { - // Do no try to use the file of an invalid locale if (strstr($_POST['locale'], '..') !== false || !file_exists(__DIR__ . "/app/l10n/${_REQUEST['locale']}.lang")) { @@ -39,13 +39,12 @@ if (is_installed()) { $status = 'installed'; } } else { - // We start by malking sure we have PHP5 as a base requirement - if(version_compare(PHP_VERSION, '7.2.0') >= 0) { - $strInstall = installStatus('Server is running at least PHP 7.2', 'OK',true); + if (version_compare(PHP_VERSION, '7.2.0') >= 0) { + $strInstall = installStatus('Server is running at least PHP 7.2', 'OK', true); $strRecommendation = ''; } else { - $strInstall = installStatus('Server is running at least PHP 7.2', 'FAIL',false); + $strInstall = installStatus('Server is running at least PHP 7.2', 'FAIL', false); $strRecommendation = '<li>Check your server documentation to activate at least PHP 7.2</li>'; } @@ -79,18 +78,17 @@ if (is_installed()) { // We now test that all required files and directories are writable. foreach ($tests as $v) { - if(touch(__DIR__ . $v)) { + if (touch(__DIR__ . $v)) { $strInstall .= installStatus("<code>$v</code> is writable", 'OK', true); unlink(__DIR__.$v); } else { - $strInstall .= installStatus("<code>$v</code> is writable", 'FAIL',false); + $strInstall .= installStatus("<code>$v</code> is writable", 'FAIL', false); $strRecommendation .= "<li>Make <code>$v</code> writable with CHMOD</li>"; } } // We can now decide if we install moonmoon or not $status = ($strRecommendation != '') ? 'error' : 'install'; - } -require_once views_path('install.tpl.php');
\ No newline at end of file +require_once views_path('install.tpl.php'); diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..e741e42 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<ruleset> + <rule ref="PSR1"/> + <rule ref="PSR2"/> + <file>.</file> + <arg value="np"/> + <arg name="colors"/> + <arg name="extensions" value="php,inc"/> + <arg name="encoding" value="utf8"/> + <exclude-pattern>vendor/</exclude-pattern> +</ruleset>
\ No newline at end of file diff --git a/postload.php b/postload.php index 7341b82..f0f10fd 100644 --- a/postload.php +++ b/postload.php @@ -8,10 +8,8 @@ if (!is_installed()) { $xml = new SimpleXMLElement(file_get_contents(custom_path('people.opml'))); -foreach ($xml->xpath('/opml/body/outline[@xmlUrl]') as $element) -{ - if ($element->attributes()->xmlUrl == $_GET['url']) - { +foreach ($xml->xpath('/opml/body/outline[@xmlUrl]') as $element) { + if ($element->attributes()->xmlUrl == $_GET['url']) { $person = new PlanetFeed( '', $_GET['url'], @@ -27,4 +25,4 @@ foreach ($xml->xpath('/opml/body/outline[@xmlUrl]') as $element) } } -echo 'Updating this URL is not allowed.';
\ No newline at end of file +echo 'Updating this URL is not allowed.'; diff --git a/tests/GuzzleHarness.php b/tests/GuzzleHarness.php index 443235d..7273ba8 100644 --- a/tests/GuzzleHarness.php +++ b/tests/GuzzleHarness.php @@ -16,5 +16,4 @@ class GuzzleHarness extends TestCase 'timeout' => 1, ]); } - -}
\ No newline at end of file +} diff --git a/tests/InstallTest.php b/tests/InstallTest.php index e43f107..fe5dc4e 100644 --- a/tests/InstallTest.php +++ b/tests/InstallTest.php @@ -2,7 +2,8 @@ require_once 'GuzzleHarness.php'; -class InstallTest extends GuzzleHarness { +class InstallTest extends GuzzleHarness +{ public function setUp() : void { @@ -58,4 +59,4 @@ class InstallTest extends GuzzleHarness { $this->assertEquals(200, $res->getStatusCode()); $this->assertStringContainsString('Your moonmoon is ready.', (string) $res->getBody()); } -}
\ No newline at end of file +} diff --git a/tests/PlanetErrorTest.php b/tests/PlanetErrorTest.php index d2f4599..c2570ab 100644 --- a/tests/PlanetErrorTest.php +++ b/tests/PlanetErrorTest.php @@ -9,4 +9,4 @@ class PlanetErrorTest extends TestCase $error = new PlanetError(1, 'foo'); $this->assertEquals('notice: foo', $error->toString()); } -}
\ No newline at end of file +} diff --git a/tests/PlanetTest.php b/tests/PlanetTest.php index 17fdca8..d4b87b8 100644 --- a/tests/PlanetTest.php +++ b/tests/PlanetTest.php @@ -2,16 +2,17 @@ use PHPUnit\Framework\TestCase; -class FoolCategory { +class FoolCategory +{ protected $name; - function __construct($name) + public function __construct($name) { $this->name = $name; } - function get_label() + public function get_label() { return $this->name; } @@ -21,13 +22,15 @@ class FoolItem { protected $categories; - function __construct($categories) + public function __construct($categories) { - foreach ($categories as $c) + foreach ($categories as $c) { $this->categories[] = new FoolCategory($c); + } } - function get_categories() { + public function get_categories() + { return $this->categories; } } @@ -80,5 +83,4 @@ class PlanetTest extends TestCase $this->assertEquals(count($this->planet->_filterItemsByCategory($this->items, 'catA,catB,catC')), 4); $this->assertEquals(count($this->planet->_filterItemsByCategory($this->items, 'catA, catB')), 3); } - } |