Skip to content

Commit

Permalink
fix namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
sveneld committed Feb 25, 2024
1 parent fd9026b commit 58efd13
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 40 deletions.
7 changes: 5 additions & 2 deletions actions-sms.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

require_once 'vendor/autoload.php';
require("common.php");

Expand Down Expand Up @@ -499,9 +502,9 @@ function log_sms($sms_uuid, $sender, $receive_time, $sms_text, $ip)
{
global $dbserver, $dbuser, $dbpassword, $dbname;
/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$localdb = new \Bikeshare\Db\MysqliDb($dbserver, $dbuser, $dbpassword, $dbname);
$localdb = new MysqliDb($dbserver, $dbuser, $dbpassword, $dbname);
$localdb->connect();

#TODO does it needed???
Expand Down
5 changes: 3 additions & 2 deletions admin.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

use Bikeshare\Db\MysqliDb;
use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

require_once 'vendor/autoload.php';
require("config.php");
require('actions-web.php');

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();
Expand Down
5 changes: 3 additions & 2 deletions agree.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

use Bikeshare\Db\MysqliDb;
use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

require_once 'vendor/autoload.php';
require("config.php");
require('actions-web.php');

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();
Expand Down
5 changes: 3 additions & 2 deletions command.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

use Bikeshare\Db\MysqliDb;
use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

require_once 'vendor/autoload.php';
require("config.php");
require('actions-web.php');

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();
Expand Down
14 changes: 8 additions & 6 deletions common.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;
use BikeShare\SmsConnector\SmsConnectorFactory;

require_once 'vendor/autoload.php';
Expand Down Expand Up @@ -95,9 +97,9 @@ function log_sendsms($number, $text)
{
global $dbserver, $dbuser, $dbpassword, $dbname;
/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$localdb = new \Bikeshare\Db\MysqliDb($dbserver, $dbuser, $dbpassword, $dbname);
$localdb = new MysqliDb($dbserver, $dbuser, $dbpassword, $dbname);
$localdb->connect();

#TODO does it needed???
Expand Down Expand Up @@ -226,9 +228,9 @@ function logrequest($userid)
{
global $dbserver,$dbuser,$dbpassword,$dbname;
/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$localdb = new \Bikeshare\Db\MysqliDb($dbserver, $dbuser, $dbpassword, $dbname);
$localdb = new MysqliDb($dbserver, $dbuser, $dbpassword, $dbname);
$localdb->connect();

#TODO does it needed???
Expand All @@ -245,9 +247,9 @@ function logresult($userid,$text)
global $dbserver,$dbuser,$dbpassword,$dbname;

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$localdb = new \Bikeshare\Db\MysqliDb($dbserver, $dbuser, $dbpassword, $dbname);
$localdb = new MysqliDb($dbserver, $dbuser, $dbpassword, $dbname);
$localdb->connect();

#TODO does it needed???
Expand Down
7 changes: 5 additions & 2 deletions cron.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php

use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

require_once 'vendor/autoload.php';
require("config.php");
require("actions-web.php");

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();

checklongrental();
Expand Down
5 changes: 3 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

use Bikeshare\Db\MysqliDb;
use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

require_once 'vendor/autoload.php';
require "config.php";
require "actions-web.php";

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();
Expand Down
7 changes: 5 additions & 2 deletions install/generate.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

require_once '../vendor/autoload.php';
if (file_exists("../config.php")) {
require "../config.php";
Expand All @@ -8,9 +11,9 @@
}

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();

// create new PDF document
Expand Down
23 changes: 13 additions & 10 deletions install/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
//@TODO ANaLYTICS!!!

use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

if (file_exists("../config.php")) {
exit("Project already installed. If you want to reinstall, please remove config.php file.");
}
Expand Down Expand Up @@ -205,9 +208,9 @@ function return_bytes($val) {
$newconfig=implode($configfile);
file_put_contents($configfilename,$newconfig);
/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($_POST["dbserver"],$_POST["dbuser"],$_POST["dbpassword"],$_POST["dbname"]);
$db=new MysqliDb($_POST["dbserver"],$_POST["dbuser"],$_POST["dbpassword"],$_POST["dbname"]);
$db->connect();
$sql=file_get_contents("../docker-data/mysql/create-database.sql");
$sql=explode(";",$sql);
Expand Down Expand Up @@ -236,9 +239,9 @@ function return_bytes($val) {
<?php endif; ?>
<?php if ($step==3):
/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();
$result=$db->query("REPLACE INTO users SET userName='".$_POST["username"]."',password=SHA2('".$_POST["password"]."',512),mail='".$_POST["email"]."',number='".$_POST["phone"]."',privileges=7");
$userid=$db->getLastInsertId();
Expand All @@ -260,9 +263,9 @@ function return_bytes($val) {
<?php endif; ?>
<?php if ($step==4):
/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();
$stands=explode(",",$_POST["stands"]);
foreach ($stands as $stand)
Expand Down Expand Up @@ -326,9 +329,9 @@ function return_bytes($val) {
<?php endif; ?>
<?php if ($step==5):
/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();
?>
<h2>Set system options</h2>
Expand Down Expand Up @@ -398,9 +401,9 @@ function return_bytes($val) {
<?php endif; ?>
<?php if ($step==6):
/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();
$configfile=file($configfilename);
foreach ($_POST as $variable=>$value)
Expand Down
6 changes: 4 additions & 2 deletions receive.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;
use BikeShare\SmsConnector\SmsConnectorInterface;

require_once 'vendor/autoload.php';
require("config.php");

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();

require("actions-sms.php");
Expand Down
7 changes: 5 additions & 2 deletions scan.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php

use BikeShare\Db\DbInterface;
use BikeShare\Db\MysqliDb;

require_once 'vendor/autoload.php';
require("config.php");
require('actions-qrcode.php');

/**
* @var \Bikeshare\Db\DbInterface
* @var DbInterface
*/
$db=new \Bikeshare\Db\MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db=new MysqliDb($dbserver,$dbuser,$dbpassword,$dbname);
$db->connect();

if (isset($_COOKIE["loguserid"])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Db/DbInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Bikeshare\Db;
namespace BikeShare\Db;

interface DbInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Db/MysqliDb.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Bikeshare\Db;
namespace BikeShare\Db;

class MysqliDb implements DbInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/SmsConnector/SmsGatewayConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace BikeShare\SmsConnector;

use Bikeshare\SmsConnector\SmsGateway\SmsGateway;
use BikeShare\SmsConnector\SmsGateway\SmsGateway;

class SmsGatewayConnector extends AbstractConnector
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Db/MysqliDbTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Test\Bikeshare\Db;
namespace Test\BikeShare\Db;

use Bikeshare\Db\MysqliDb;
use BikeShare\Db\MysqliDb;
use PHPUnit\Framework\TestCase;

class MysqliDbTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/SmsConnector/SmsConnectorFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Test\Bikeshare\SmsConnector;
namespace Test\BikeShare\SmsConnector;

use BikeShare\SmsConnector\DisabledConnector;
use BikeShare\SmsConnector\EuroSmsConnector;
Expand Down

0 comments on commit 58efd13

Please sign in to comment.