[web-master] main: Add a PSR-4 root

From: Date: Sun, 11 Apr 2021 18:16:56 +0000
Subject: [web-master] main: Add a PSR-4 root
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-29215@lists.php.net to get a copy of this message
Author: Nikita Popov (nikic) Date: 2021-04-11T20:16:19+02:00 Commit: https://github.com/php/web-master/commit/6d94ee66d392e36e925e984dc43058e71e86c8a4 Raw diff: https://github.com/php/web-master/commit/6d94ee66d392e36e925e984dc43058e71e86c8a4.diff Add a PSR-4 root Following the convention of other php.net projects, use App\ as the top-level namespace. Changed paths: A src/Query.php M composer.json M composer.lock M include/functions.inc M public/fetch/user-notes-rss.php M public/manage/event.php M public/manage/user-notes.php M public/manage/users.php M vendor/composer/InstalledVersions.php M vendor/composer/autoload_psr4.php M vendor/composer/autoload_static.php M vendor/composer/installed.php M vendor/composer/platform_check.php Diff: diff --git a/composer.json b/composer.json index 0239699..e3f666f 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,13 @@ "type": "project", "homepage": "https://github.com/php/web-master", "require": { + "php": ">=8.0", "michelf/php-markdown": "^1.9", "phpmailer/phpmailer": "^6.4" + }, + "autoload": { + "psr-4": { + "App\\": "src/" + } } } diff --git a/composer.lock b/composer.lock index acf9c18..4b87d40 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": "a0820e15db1325c5a8e337b29fd80aee", + "content-hash": "b4a4a4e6345d8c4cc0be432eb5bbc1bd", "packages": [ { "name": "michelf/php-markdown", @@ -53,6 +53,10 @@ "keywords": [ "markdown" ], + "support": { + "issues": "https://github.com/michelf/php-markdown/issues", + "source": "https://github.com/michelf/php-markdown/tree/1.9.0" + }, "time": "2019-12-02T02:32:27+00:00" }, { @@ -138,7 +142,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=8.0" + }, "platform-dev": [], "plugin-api-version": "2.0.0" } diff --git a/include/functions.inc b/include/functions.inc index 97cab86..9528f5d 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -1,5 +1,6 @@ <?php -// $Id$ + +require_once __DIR__ . '/../vendor/autoload.php'; $ts = $_SERVER['REQUEST_TIME']; @@ -106,38 +107,7 @@ function db_connect($dieonerror = TRUE) return TRUE; } -class Query { - private $query = ''; - - public function __construct($str = '', $params = []) { - $this->add($str, $params); - } - - public function add($str, $params = []) { - if (substr_count($str, '?') !== count($params)) { - die("Incorrect number of parameters to query."); - } - - $i = 0; - $this->query .= preg_replace_callback('/\?(int)?/', function($matches) use ($params, &$i) { - if (isset($matches[1]) && $matches[1] === 'int') { - return (int) $params[$i++]; - } else { - return "'" . mysql_real_escape_string($params[$i++]) . "'"; - } - }, $str); - } - - public function addQuery(Query $q) { - $this->query .= $q->get(); - } - - public function get() { - return $this->query; - } -} - -function db_query(Query $query) +function db_query(App\Query $query) { $query = $query->get(); //var_dump($query); @@ -151,7 +121,7 @@ function db_query(Query $query) function db_query_safe($query, array $params = []) { - return db_query(new Query($query, $params)); + return db_query(new App\Query($query, $params)); } function db_get_one($query) @@ -272,9 +242,6 @@ function get_ssh_keys($string) { return $results; } -// We use markdown for people profiles -include_once __DIR__ . '/../vendor/autoload.php'; - // ----------------------------------------------------------------------------------- // diff --git a/public/fetch/user-notes-rss.php b/public/fetch/user-notes-rss.php index b4b9f13..6bf03ae 100644 --- a/public/fetch/user-notes-rss.php +++ b/public/fetch/user-notes-rss.php @@ -1,5 +1,7 @@ <?php +use App\Query; + require_once __DIR__ . '/../../include/functions.inc'; db_connect(); diff --git a/public/manage/event.php b/public/manage/event.php index dbec990..5c1b1ce 100644 --- a/public/manage/event.php +++ b/public/manage/event.php @@ -1,4 +1,7 @@ <?php + +use App\Query; + require __DIR__ . '/../../include/login.inc'; require __DIR__ . '/../../include/email-validation.inc'; diff --git a/public/manage/user-notes.php b/public/manage/user-notes.php index a443257..a0234c2 100644 --- a/public/manage/user-notes.php +++ b/public/manage/user-notes.php @@ -2,6 +2,8 @@ // $Id$ // Force login before action can be taken +use App\Query; + include __DIR__ . '/../../include/login.inc'; include __DIR__ . '/../../include/email-validation.inc'; include __DIR__ . '/../../include/note-reasons.inc'; diff --git a/public/manage/users.php b/public/manage/users.php index c838989..3962a62 100644 --- a/public/manage/users.php +++ b/public/manage/users.php @@ -4,6 +4,8 @@ # acls # handle flipping of the sort views +use App\Query; + require __DIR__ . '/../../include/login.inc'; require __DIR__ . '/../../include/email-validation.inc'; require __DIR__ . '/../../include/email-templates.inc'; diff --git a/src/Query.php b/src/Query.php new file mode 100644 index 0000000..72a6f5f --- /dev/null +++ b/src/Query.php @@ -0,0 +1,34 @@ +<?php + +namespace App; + +class Query { + private $query = ''; + + public function __construct($str = '', $params = []) { + $this->add($str, $params); + } + + public function add($str, $params = []) { + if (substr_count($str, '?') !== count($params)) { + die("Incorrect number of parameters to query."); + } + + $i = 0; + $this->query .= preg_replace_callback('/\?(int)?/', function ($matches) use ($params, &$i) { + if (isset($matches[1]) && $matches[1] === 'int') { + return (int)$params[$i++]; + } else { + return "'" . mysql_real_escape_string($params[$i++]) . "'"; + } + }, $str); + } + + public function addQuery(Query $q) { + $this->query .= $q->get(); + } + + public function get() { + return $this->query; + } +} \ No newline at end of file diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index 872011d..7937cdc 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -30,7 +30,7 @@ class InstalledVersions 'aliases' => array ( ), - 'reference' => 'fd6f330637290e93968a7cf20a65ad103b7bd884', + 'reference' => '9117dcd75112492365254c93ea40f0137916a851', 'name' => 'php/web-master', ), 'versions' => @@ -51,7 +51,7 @@ class InstalledVersions 'aliases' => array ( ), - 'reference' => 'fd6f330637290e93968a7cf20a65ad103b7bd884', + 'reference' => '9117dcd75112492365254c93ea40f0137916a851', ), 'phpmailer/phpmailer' => array ( diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index b77a145..32a026e 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -8,4 +8,5 @@ return array( 'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'), 'Michelf\\' => array($vendorDir . '/michelf/php-markdown/Michelf'), + 'App\\' => array($baseDir . '/src'), ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 9f25aa3..3cc16a5 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -15,6 +15,10 @@ class ComposerStaticInit555eac2be6304e201001ec17b2028db4 array ( 'Michelf\\' => 8, ), + 'A' => + array ( + 'App\\' => 4, + ), ); public static $prefixDirsPsr4 = array ( @@ -26,6 +30,10 @@ class ComposerStaticInit555eac2be6304e201001ec17b2028db4 array ( 0 => __DIR__ . '/..' . '/michelf/php-markdown/Michelf', ), + 'App\\' => + array ( + 0 => __DIR__ . '/../..' . '/src', + ), ); public static $classMap = array ( diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index dec3cfa..f61dbad 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -6,7 +6,7 @@ 'aliases' => array ( ), - 'reference' => 'fd6f330637290e93968a7cf20a65ad103b7bd884', + 'reference' => '9117dcd75112492365254c93ea40f0137916a851', 'name' => 'php/web-master', ), 'versions' => @@ -27,7 +27,7 @@ 'aliases' => array ( ), - 'reference' => 'fd6f330637290e93968a7cf20a65ad103b7bd884', + 'reference' => '9117dcd75112492365254c93ea40f0137916a851', ), 'phpmailer/phpmailer' => array ( diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index 454eefd..adfb472 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 50500)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 5.5.0". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80000)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.'; } if ($issues) {

« previous php.webmaster (#29215) next »