diff --git a/.github/workflows/php70.yml b/.github/workflows/php70.yml
deleted file mode 100644
index 8ca7cc5..0000000
--- a/.github/workflows/php70.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-name: Build PHP 7.0
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [7.0]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- coverage: none
- tools: phpunit:5.7.27, composer
- - name: Show PHP V
- run: php -v
-
- - name: Install Dependencies
- run: composer install --prefer-source --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/php71.yml b/.github/workflows/php71.yml
deleted file mode 100644
index 3bc72e8..0000000
--- a/.github/workflows/php71.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-name: Build PHP 7.1
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [7.1]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- coverage: none
- tools: phpunit:5.7.27, composer
-
- - name: Install Dependencies
- run: composer install --prefer-source --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/php72.yml b/.github/workflows/php72.yml
deleted file mode 100644
index 13d1ee6..0000000
--- a/.github/workflows/php72.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-name: Build PHP 7.2
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [7.2]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- tools: phpunit:8.5.13
-
- - name: Install Dependencies
- run: composer install --prefer-source --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
-
-
diff --git a/.github/workflows/php73.yml b/.github/workflows/php73.yml
deleted file mode 100644
index 565d783..0000000
--- a/.github/workflows/php73.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-name: Build PHP 7.3
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [7.3]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- tools: phpunit:8.5.13
-
- - name: Install Dependencies
- run: composer install --prefer-source --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
-
-
-
diff --git a/.github/workflows/php74.yml b/.github/workflows/php74.yml
deleted file mode 100644
index 4920e75..0000000
--- a/.github/workflows/php74.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-name: Build PHP 7.4
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- test:
- runs-on: ${{ matrix.os }}
-
- strategy:
- fail-fast: true
- matrix:
- os: [ ubuntu-latest ]
- php: [7.4]
-
- name: PHP${{matrix.php}} - ${{matrix.os}}
-
- steps:
- - name: Clone Repo
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: mysqli, mbstring, sqlsrv
- tools: phpunit:8.5.13
-
- - name: Install Dependencies
- run: composer install --prefer-source --no-interaction --no-dev
-
- - name: Execute Tests
- run: phpunit --configuration tests/phpunit.xml
-
- - name: CodeCov
- uses: codecov/codecov-action@v4
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
-
-
-
diff --git a/.github/workflows/php80.yml b/.github/workflows/php80.yml
index a407db0..c7d2fcb 100644
--- a/.github/workflows/php80.yml
+++ b/.github/workflows/php80.yml
@@ -28,9 +28,6 @@ jobs:
extensions: mysqli, mbstring, sqlsrv
tools: phpunit:8.5.13
- - name: Shutdown Ubuntu MySQL
- run: sudo service mysql stop
-
- name: Install Dependencies
run: composer install --prefer-source --no-interaction --no-dev
diff --git a/.github/workflows/php82.yml b/.github/workflows/php82.yml
index c276ab6..ffa5928 100644
--- a/.github/workflows/php82.yml
+++ b/.github/workflows/php82.yml
@@ -29,8 +29,6 @@ jobs:
extensions: mysqli, mbstring, sqlsrv
tools: phpunit:9.5.20, composer
- - name: Shutdown Ubuntu MySQL
- run: sudo service mysql stop
- name: Install Dependencies
run: composer install --prefer-source --no-interaction --no-dev
diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml
index 5255f02..8003948 100644
--- a/.github/workflows/php83.yml
+++ b/.github/workflows/php83.yml
@@ -28,9 +28,6 @@ jobs:
php-version: ${{ matrix.php }}
extensions: mysqli, mbstring, sqlsrv
tools: phpunit:9.5.20, composer
-
- - name: Shutdown Ubuntu MySQL
- run: sudo service mysql stop
- name: Install Dependencies
run: composer install --prefer-source --no-interaction --no-dev
diff --git a/.github/workflows/php84.yml b/.github/workflows/php84.yml
index 7a9480d..a6cbc9f 100644
--- a/.github/workflows/php84.yml
+++ b/.github/workflows/php84.yml
@@ -4,7 +4,7 @@ on:
push:
branches: [ master, dev ]
pull_request:
- branches: [ master ]
+ branches: [ master, dev ]
jobs:
test:
@@ -28,9 +28,6 @@ jobs:
php-version: ${{ matrix.php }}
extensions: mysqli, mbstring, sqlsrv
tools: phpunit:9.5.20, composer
-
- - name: Shutdown Ubuntu MySQL
- run: sudo service mysql stop
- name: Install Dependencies
run: composer install --prefer-source --no-interaction --no-dev
diff --git a/README.md b/README.md
index e6f4654..819f42d 100644
--- a/README.md
+++ b/README.md
@@ -23,11 +23,6 @@ It includes inputs feltering and data validation in addion to creating user-defi
## Supported PHP Versions
| Build Status |
|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
-| |
-| |
-| |
-| |
-| |
| |
| |
| |
diff --git a/tests/webfiori/tests/http/ResponseTest.php b/tests/webfiori/tests/http/ResponseTest.php
index 42b1a45..8281919 100644
--- a/tests/webfiori/tests/http/ResponseTest.php
+++ b/tests/webfiori/tests/http/ResponseTest.php
@@ -18,7 +18,7 @@ class ResponseTest extends TestCase {
* @test
*/
public function testAddHeader00() {
- $this->assertFalse(Response::hasHeader('content-type'));
+ $this->assertFalse(Response::hasHeader('content-type', null));
$this->assertTrue(Response::addHeader('content-type', 'application/json'));
$this->assertTrue(Response::hasHeader('content-type', 'application/json'));
$this->assertFalse(Response::hasHeader('content-type', 'text/js'));
@@ -27,9 +27,9 @@ public function testAddHeader00() {
* @test
*/
public function testAddHeader01() {
- $this->assertFalse(Response::hasHeader('Set-Cookie'));
+ $this->assertFalse(Response::hasHeader('Set-Cookie', null));
$this->assertTrue(Response::addHeader('Set-Cookie', 'name=ok'));
- $this->assertTrue(Response::hasHeader('Set-Cookie'));
+ $this->assertTrue(Response::hasHeader('Set-Cookie', null));
$this->assertTrue(Response::hasHeader('Set-Cookie','name=ok'));
$this->assertTrue(Response::addHeader('Set-Cookie', 'name=good'));
@@ -122,7 +122,7 @@ public function testSetResponseCode() {
* @test
*/
public function testBeforeSend00() {
- $this->assertFalse(Response::hasHeader('super'));
+ $this->assertFalse(Response::hasHeader('super', null));
Response::beforeSend(function () {
Response::addHeader('super', 'yes');
});
diff --git a/webfiori/http/AbstractWebService.php b/webfiori/http/AbstractWebService.php
index d841025..3529966 100644
--- a/webfiori/http/AbstractWebService.php
+++ b/webfiori/http/AbstractWebService.php
@@ -125,7 +125,7 @@ abstract class AbstractWebService implements JsonI {
* @param WebServicesManager|null $owner The manager which is used to
* manage the web service.
*/
- public function __construct(string $name, WebServicesManager $owner = null) {
+ public function __construct(string $name) {
if (!$this->setName($name)) {
$this->setName('new-service');
}
@@ -135,8 +135,6 @@ public function __construct(string $name, WebServicesManager $owner = null) {
$this->requireAuth = true;
$this->sinceVersion = '1.0.0';
$this->serviceDesc = '';
-
- $this->setManager($owner);
}
/**
* Returns an array that contains all possible requests methods at which the
@@ -726,7 +724,7 @@ public function send(string $contentType, $data, int $code = 200) {
*
* @since 1.0.1
*/
- public function sendResponse(string $message, string $type = '', int $code = 200, $otherInfo = null) {
+ public function sendResponse(string $message, string $type = '', int $code = 200, mixed $otherInfo = '') {
$manager = $this->getManager();
if ($manager !== null) {
@@ -770,7 +768,7 @@ public function setIsAuthRequired(bool $bool) {
* the service was associated with a manager.
*
*/
- public function setManager(WebServicesManager $manager = null) {
+ public function setManager(?WebServicesManager $manager) {
if ($manager === null) {
$this->owner = null;
} else {
diff --git a/webfiori/http/HeadersPool.php b/webfiori/http/HeadersPool.php
index 5a8104a..0fe5266 100644
--- a/webfiori/http/HeadersPool.php
+++ b/webfiori/http/HeadersPool.php
@@ -39,7 +39,7 @@ public function __construct() {
*
* @since 1.0
*/
- public function addHeader(string $headerName, string $headerVal, string $replaceValue = null) : bool {
+ public function addHeader(string $headerName, string $headerVal, ?string $replaceValue = '') : bool {
$trimmedHeader = strtolower(trim($headerName));
$retVal = false;
$header = new HttpHeader();
@@ -47,7 +47,7 @@ public function addHeader(string $headerName, string $headerVal, string $replace
if ($header->setName($headerName)) {
$header->setValue($headerVal);
- if ($replaceValue !== null) {
+ if ($replaceValue !== null && strlen($replaceValue) != 0) {
$hasHeader = $this->hasHeader($trimmedHeader, $replaceValue);
} else {
$hasHeader = false;
@@ -132,15 +132,15 @@ public function getHeaders() : array {
*
* @since 1.0
*/
- public function hasHeader(string $name, string $val = null) : bool {
+ public function hasHeader(string $name, ?string $val) : bool {
$headers = $this->getHeaderAsObj($name);
-
- if ($val === null) {
+ $trimmedVal = trim($val.'');
+ if ($val === null || strlen($trimmedVal) == 0) {
return count($headers) !== 0;
}
foreach ($headers as $obj) {
- if ($obj->getValue() == $val) {
+ if ($obj->getValue() == $trimmedVal) {
return true;
}
}
@@ -158,14 +158,14 @@ public function hasHeader(string $name, string $val = null) : bool {
*
* @return bool If removed, true is returned. False otherwise.
*/
- public function removeHeader(string $name, string $val = null) : bool {
+ public function removeHeader(string $name, ?string $val = '') : bool {
$tempArr = [];
$trimmed = strtolower(trim($name));
$removed = false;
foreach ($this->getHeaders() as $headerObj) {
if ($headerObj->getName() == $trimmed) {
- if ($val !== null && $headerObj->getValue() != $val) {
+ if ($val !== null && strlen($val) != 0 && $headerObj->getValue() != $val) {
$tempArr[] = $headerObj;
} else {
$removed = true;
diff --git a/webfiori/http/ObjectMapper.php b/webfiori/http/ObjectMapper.php
index 64be137..23fdc09 100644
--- a/webfiori/http/ObjectMapper.php
+++ b/webfiori/http/ObjectMapper.php
@@ -56,7 +56,7 @@ public function __construct(string $clazz, AbstractWebService $service) {
* after the underscore.
*
*/
- public function addSetterMap(string $paramName, string $methodName = null) {
+ public function addSetterMap(string $paramName, ?string $methodName) {
$trimmedParamName = trim($paramName);
if (strlen($trimmedParamName) == 0) {
@@ -145,11 +145,11 @@ public function setClass(string $clazz) {
private function extractMethodsNames($inputs) {
if ($inputs instanceof Json) {
foreach ($inputs->getProperties() as $prop) {
- $this->addSetterMap($prop->getName());
+ $this->addSetterMap($prop->getName(), null);
}
} else if (gettype($inputs) == 'array') {
foreach (array_keys($inputs) as $name) {
- $this->addSetterMap($name);
+ $this->addSetterMap($name, null);
}
}
}
diff --git a/webfiori/http/Request.php b/webfiori/http/Request.php
index af24be6..7f87763 100644
--- a/webfiori/http/Request.php
+++ b/webfiori/http/Request.php
@@ -361,7 +361,7 @@ private static function extractHeaders() {
$headersArr = self::getRequestHeadersFromServer();
foreach ($headersArr as $header) {
- self::get()->headersPool->addHeader($header->getName(), $header->getValue());
+ self::get()->headersPool->addHeader($header->getName(), $header->getValue(), null);
}
}
}
diff --git a/webfiori/http/Response.php b/webfiori/http/Response.php
index 4ceae78..e0bd18c 100644
--- a/webfiori/http/Response.php
+++ b/webfiori/http/Response.php
@@ -110,7 +110,7 @@ public static function addCookie(HttpCookie $cookie) {
*
* @since 1.0
*/
- public static function addHeader(string $headerName, string $headerVal, string $replaceValue = null) : bool {
+ public static function addHeader(string $headerName, string $headerVal, ?string $replaceValue = '') : bool {
return self::getHeadersPool()->addHeader($headerName, $headerVal, $replaceValue);
}
/**
@@ -304,7 +304,7 @@ public static function hasCookie(string $cookieName) : bool {
*
* @since 1.0
*/
- public static function hasHeader(string $headerName, string $headerVal = null) : bool {
+ public static function hasHeader(string $headerName, ?string $headerVal = '') : bool {
return self::getHeadersPool()->hasHeader($headerName, $headerVal);
}
/**
@@ -332,7 +332,7 @@ public static function isSent() : bool {
*
* @since 1.0
*/
- public static function removeHeader(string $headerName, string $headerVal = null) : bool {
+ public static function removeHeader(string $headerName, ?string $headerVal = '') : bool {
return self::getHeadersPool()->removeHeader($headerName, $headerVal);
}
diff --git a/webfiori/http/WebServicesManager.php b/webfiori/http/WebServicesManager.php
index 3ebcf19..f388e93 100644
--- a/webfiori/http/WebServicesManager.php
+++ b/webfiori/http/WebServicesManager.php
@@ -526,7 +526,7 @@ public function removeService(string $name) {
$service = $this->getServiceByName($trimmed);
if ($service !== null) {
- $service->setManager();
+ $service->setManager(null);
unset($this->services[$trimmed]);
}
@@ -593,7 +593,7 @@ public function send(string $contentType, $data, int $code = 200) {
*/
public function sendHeaders(array $headersArr) {
foreach ($headersArr as $header => $val) {
- Response::addHeader($header, $val);
+ Response::addHeader($header, $val, null);
}
}
/**
@@ -625,7 +625,7 @@ public function sendHeaders(array $headersArr) {
*
* @since 1.0
*/
- public function sendResponse(string $message, string $type = '', int $code = 200, $otherInfo = null) {
+ public function sendResponse(string $message, string $type = '', int $code = 200, mixed $otherInfo = '') {
$json = new Json();
$json->add('message', $message);
$typeTrimmed = trim($type);
@@ -636,7 +636,9 @@ public function sendResponse(string $message, string $type = '', int $code = 200
$json->add('http-code', $code);
if ($otherInfo !== null) {
- $json->add('more-info', $otherInfo);
+ if (gettype($otherInfo) != 'string' || strlen($otherInfo) != 0) {
+ $json->add('more-info', $otherInfo);
+ }
}
if ($this->getOutputStream() !== null) {