Skip to content

Commit

Permalink
Fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelWei committed Aug 30, 2023
1 parent 4c4a96c commit 08a7dbc
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 66 deletions.
7 changes: 3 additions & 4 deletions src/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
use BigBlueButton\Responses\PutRecordingTextTrackResponse;
use BigBlueButton\Responses\UpdateRecordingsResponse;
use BigBlueButton\Util\UrlBuilder;
use SimpleXMLElement;

/**
* Class BigBlueButton.
Expand Down Expand Up @@ -113,7 +112,7 @@ class BigBlueButton
*
* @throws ConfigException
*/
public function __construct(?string $baseUrl = null, ?string $secret = null, ?TransportInterface $transport = null, string $hashAlgorithm = 'sha1')
public function __construct(string $baseUrl = null, string $secret = null, TransportInterface $transport = null, string $hashAlgorithm = 'sha1')
{
// Keeping backward compatibility with older deployed versions
$this->securitySecret = $secret ?: getenv('BBB_SECURITY_SALT') ?: getenv('BBB_SECRET');
Expand Down Expand Up @@ -485,10 +484,10 @@ public function setJSessionId(string $jSessionId): void
* @throws ParsingException
* @throws RuntimeException
*/
private function processXmlResponse(string $url, string $payload = '', string $contentType = 'application/xml'): SimpleXMLElement
private function processXmlResponse(string $url, string $payload = '', string $contentType = 'application/xml'): \SimpleXMLElement
{
try {
return new SimpleXMLElement($this->requestUrl($url, $payload, $contentType));
return new \SimpleXMLElement($this->requestUrl($url, $payload, $contentType));
} catch (NetworkException|RuntimeException $e) {
throw $e;
} catch (\Throwable $e) {
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/BaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

namespace BigBlueButton\Exceptions;

use Exception;

/**
* @abstract since 4.0.
*/
class BaseException extends Exception
class BaseException extends \Exception
{
}
4 changes: 2 additions & 2 deletions src/Http/SetCookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function fromString(string $cookie): self
// Explode the cookie string using a series of semicolons
$pieces = array_filter(array_map('trim', explode(';', $cookie)));
// The name of the cookie (first kvp) must exist and include an equal sign.
if (!isset($pieces[0]) || strpos($pieces[0], '=') === false) {
if (!isset($pieces[0]) || !str_contains($pieces[0], '=')) {
return new self($data);
}

Expand Down Expand Up @@ -330,7 +330,7 @@ public function matchesPath(string $requestPath): bool
}

// Ensure that the cookie-path is a prefix of the request path.
if (0 !== strpos($requestPath, $cookiePath)) {
if (!str_starts_with($requestPath, $cookiePath)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ public function __construct(
$this->defaultHeaders = $defaultHeaders;
}

/**
* {@inheritDoc}
*/
public function request(TransportRequest $request): TransportResponse
{
if ('' !== $payload = $request->getPayload()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ public static function create(array $defaultHeaders = [], array $defaultOptions
// @codeCoverageIgnoreEnd
}

/**
* {@inheritDoc}
*/
public function request(TransportRequest $request): TransportResponse
{
$headers = $this->defaultHeaders;
Expand Down
5 changes: 1 addition & 4 deletions src/Http/Transport/CurlTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ public static function createWithDefaultOptions(array $additionalCurlOptions = [
// @codeCoverageIgnoreEnd
}

/**
* {@inheritDoc}
*/
public function request(TransportRequest $request): TransportResponse
{
// @codeCoverageIgnoreStart
Expand Down Expand Up @@ -202,7 +199,7 @@ private static function getHeadersAndContentFromCurlHandle($curlHandle): array
/* @noinspection PhpElementIsNotAvailableInCurrentPhpVersionInspection */
throw new \InvalidArgumentException(sprintf('$curlHandle must be "%s". "%s" given.', \CurlHandle::class, get_debug_type($curlHandle)));
} elseif (\PHP_VERSION_ID < 80000 && !\is_resource($curlHandle)) {
throw new \InvalidArgumentException(sprintf('$curlHandle must be resource. "%s" given.', \is_object($curlHandle) ? \get_class($curlHandle) : \gettype($curlHandle)));
throw new \InvalidArgumentException(sprintf('$curlHandle must be resource. "%s" given.', \is_object($curlHandle) ? $curlHandle::class : \gettype($curlHandle)));
}
// @codeCoverageIgnoreEnd

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Transport/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function mergeCurlHeaders(array ...$headers): array
if (!\is_string($header)) {
throw new \InvalidArgumentException(sprintf(
'Non-string header with type "%s" passed.',
\is_object($header) ? \get_class($header) : \gettype($header)
\is_object($header) ? $header::class : \gettype($header)
));
}

Expand Down
9 changes: 3 additions & 6 deletions src/Parameters/BaseParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,17 @@ public function __call(string $name, array $arguments)
if (!preg_match('/^(get|is|set)[A-Z]/', $name)) {
throw new \BadFunctionCallException($name.' does not exist');
}
if (strpos($name, 'get') === 0) {
if (str_starts_with($name, 'get')) {
return $this->getter(lcfirst(substr($name, 3)));
} elseif (strpos($name, 'is') === 0) {
} elseif (str_starts_with($name, 'is')) {
return $this->booleanGetter(lcfirst(substr($name, 2)));
} elseif (strpos($name, 'set') === 0) {
} elseif (str_starts_with($name, 'set')) {
return $this->setter(lcfirst(substr($name, 3)), $arguments);
}

return null;
}

/**
* @return mixed
*/
protected function getter(string $name)
{
if (property_exists($this, $name)) {
Expand Down
7 changes: 2 additions & 5 deletions src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public function setGuestPolicyAlwaysAccept(): self
return $this;
}

public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null): self
public function addPresentation(string $nameOrUrl, string $content = null, string $filename = null): self
{
if (!$filename) {
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
Expand All @@ -492,9 +492,6 @@ public function getPresentations(): array
return $this->presentations;
}

/**
* @return mixed
*/
public function getPresentationsAsXML()
{
$result = '';
Expand All @@ -505,7 +502,7 @@ public function getPresentationsAsXML()
$module->addAttribute('name', 'presentation');

foreach ($this->presentations as $nameOrUrl => $content) {
if (strpos($nameOrUrl, 'http') === 0) {
if (str_starts_with($nameOrUrl, 'http')) {
$presentation = $module->addChild('document');
$presentation->addAttribute('url', $nameOrUrl);
if (\is_string($content)) {
Expand Down
5 changes: 1 addition & 4 deletions src/Parameters/InsertDocumentParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(string $meetingID)
$this->meetingID = $meetingID;
}

public function addPresentation(string $url, string $filename, ?bool $downloadable = null, ?bool $removable = null): self
public function addPresentation(string $url, string $filename, bool $downloadable = null, bool $removable = null): self
{
$this->presentations[$url] = [
'filename' => $filename,
Expand All @@ -60,9 +60,6 @@ public function removePresentation(string $url): self
return $this;
}

/**
* @return mixed
*/
public function getPresentationsAsXML()
{
$result = '';
Expand Down
3 changes: 0 additions & 3 deletions src/Parameters/PutRecordingTextTrackParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ class PutRecordingTextTrackParameters extends BaseParameters
*/
protected $contentType;

/**
* @var mixed
*/
protected $file;

/**
Expand Down
3 changes: 0 additions & 3 deletions src/Responses/BaseResponseAsJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ abstract class BaseResponseAsJson
public const FAILED = 'FAILED';
public const CHECKSUM_ERROR = 'checksumError';

/**
* @var mixed
*/
protected $data;

/**
Expand Down
3 changes: 0 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class TestCase extends \PHPUnit\Framework\TestCase
*/
protected $faker;

/**
* {@inheritdoc}
*/
protected function setUp(): void
{
parent::setUp();
Expand Down
3 changes: 0 additions & 3 deletions tests/functional/BigBlueButtonWithCurlTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

final class BigBlueButtonWithCurlTransportTest extends AbstractBigBlueButtonFunctionalTest
{
/**
* {@inheritDoc}
*/
protected static function createTransport(): TransportInterface
{
return CurlTransport::createWithDefaultOptions();
Expand Down
3 changes: 0 additions & 3 deletions tests/functional/BigBlueButtonWithPsrHttpClientTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@

final class BigBlueButtonWithPsrHttpClientTransport extends AbstractBigBlueButtonFunctionalTest
{
/**
* {@inheritDoc}
*/
protected static function createTransport(): TransportInterface
{
$psr17Factory = new Psr17Factory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

final class BigBlueButtonWithSymfonyHttpClientTransportTest extends AbstractBigBlueButtonFunctionalTest
{
/**
* {@inheritDoc}
*/
protected static function createTransport(): TransportInterface
{
return SymfonyHttpClientTransport::create();
Expand Down
9 changes: 3 additions & 6 deletions tests/integration/Http/Transport/CurlTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
*/
final class CurlTransportTest extends TestCase
{
/**
* {@inheritDoc}
*/
public static function setUpBeforeClass(): void
{
TestHttpServer::start();
Expand All @@ -45,9 +42,9 @@ public static function setUpBeforeClass(): void
public function provideBadResponseCodes(): iterable
{
// cURL does not understand codes below 200 properly.
// foreach (range(100, 199) as $badCode) {
// yield 'HTTP code ' . $badCode => [$badCode];
// }
// foreach (range(100, 199) as $badCode) {
// yield 'HTTP code ' . $badCode => [$badCode];
// }

foreach (range(300, 599) as $badCode) {
yield 'HTTP code '.$badCode => [$badCode];
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/Http/Transport/Fixtures/web/dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
foreach ($_SERVER as $k => $v) {
switch ($k) {
default:
if (0 !== strpos($k, 'HTTP_')) {
if (!str_starts_with($k, 'HTTP_')) {
continue 2;
}
// no break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ final class PsrHttpClientTransportTest extends TestCase
*/
private $streamFactoryMock;

/**
* {@inheritDoc}
*/
protected function setUp(): void
{
$this->transport = $this->createTransport();
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/Http/Transport/HeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ public function provideNonStringHeaders(): iterable

/**
* @dataProvider provideNonStringHeaders
*
* @param mixed $badHeader
*/
public function testMergeCurlHeadersWithNonStringHeaders($badHeader): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(sprintf(
'Non-string header with type "%s" passed.',
\is_object($badHeader) ? \get_class($badHeader) : \gettype($badHeader)
\is_object($badHeader) ? $badHeader::class : \gettype($badHeader)
));

Header::mergeCurlHeaders([$badHeader]);
Expand Down

0 comments on commit 08a7dbc

Please sign in to comment.