Skip to content

Commit

Permalink
[CS] Fix some doc-comment and bad types
Browse files Browse the repository at this point in the history
  • Loading branch information
landrok committed Apr 6, 2024
1 parent 0f706e2 commit 40a39a5
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-versions }}"
coverage: xdebug2
coverage: xdebug
ini-values: "memory_limit=-1"
tools: phpunit, composer

Expand Down
1 change: 1 addition & 0 deletions src/ActivityPhp/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function cache(): ?CacheItemPoolInterface
* @return \ActivityPhp\Server\Configuration\LoggerConfiguration
* | \ActivityPhp\Server\Configuration\InstanceConfiguration
* | \ActivityPhp\Server\Configuration\HttpConfiguration
* | \ActivityPhp\Server\Configuration\CacheConfiguration
* | string
*/
public function config(string $parameter)
Expand Down
8 changes: 4 additions & 4 deletions src/ActivityPhp/Server/Actor/Outbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use ActivityPhp\Server\Actor;
use ActivityPhp\Server\Helper;
use ActivityPhp\Type;
use ActivityPhp\Type\AbstractObject;
use ActivityPhp\Type\Core\AbstractActivity;
use ActivityPhp\Type\Util;
use Exception;
Expand Down Expand Up @@ -46,10 +47,9 @@ public function __construct(Actor $actor, Server $server)
/**
* Get items from an outbox
*
* @param string $page
* @return array
* @param string $url A page URL
*/
public function getPage(string $url)
public function getPage(string $url): AbstractObject
{
$this->server->logger()->info(
$this->actor->webfinger()->getHandle() . ':' . __METHOD__,
Expand All @@ -62,7 +62,7 @@ public function getPage(string $url)
/**
* Fetch an outbox
*
* @return \ActivityPhp\Type\Core\OrderedCollection
* @return void|\ActivityPhp\Type\Core\OrderedCollection
*/
public function get()
{
Expand Down
1 change: 0 additions & 1 deletion tests/ActivityPhp/Server/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public static function getFailingInstanceScenarios()
* Check that all tests are failing
*
* @dataProvider getFailingInstanceScenarios
* #[DataProvider('getFailingInstanceScenarios')]
*/
public function testFailingInstanceScenarios($data)
{
Expand Down
1 change: 0 additions & 1 deletion tests/ActivityPhp/Server/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public static function getAcceptHeaderScenarios()

/**
* @dataProvider getAcceptHeaderScenarios
* #[DataProvider('getAcceptHeaderScenarios')]
*/
public function testAcceptHeaderScenarios($input, $expected)
{
Expand Down
74 changes: 37 additions & 37 deletions tests/ActivityPhp/Server/HttpSignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/*
* These scenarios are around verifying an HTTP signature
*
*
* Requests are sent from localhost:8001 (distant)
*/
class HttpSignatureTest extends TestCase
Expand All @@ -32,18 +32,18 @@ public function testValidSignature()
]);

$payload = json_encode([]);

/* ------------------------------------------------------------------
| Prepare signature
| ------------------------------------------------------------------ */
$date = gmdate('D, d M Y H:i:s T', time());
$date = gmdate('D, d M Y H:i:s T', time());
$host = 'localhost';
$path = '/my-path?q=ok';

$rsa = PublicKeyLoader::loadPrivateKey(
file_get_contents(
dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem'
)
)
)->withHash('sha256'); // private key

$plaintext = "(request-target) post $path\nhost: $host\ndate: $date";
Expand Down Expand Up @@ -93,42 +93,42 @@ public function testSplittingSignature()
'enabled' => false,
]
]);

$verifier = new HttpSignature($server);

// Split a signature with headers but no algorithm
$signature = 'keyId="http://localhost:8001/accounts/bob#main-key",headers="(request-target) host date",signature="FbVtmZhMWrfbqQpXf1v86+ie/fL8Ng4O67PePKvxChnUtV7J8N6lndQcNfXcDuKDJ4Nda6gKUQabAF2JK2qeYPNZNJ1AdAa5Lak3hQd+rAbdMJdvQpzGhAaSWK6atqOTH9v2CWdjAQbzvY0nOfGiw3ymtDSvTL0pVlIvq116uMtci0WOHeIbuBSyzM23liJmBomlm4EeB3/V1BVWY2MwaQ1cHVzxR7epP6XYts3C1KbZrdMKxhlWJFLdbLy0YGu5HRkYZepAh2q2NriSikNg8YTJ67owgQv/LqhFKnObgZU6np54fBMSpg7eAdWSIbhhg1a/WHtzFicc9cgoWMRhEg=="';

$split = $verifier->splitSignature($signature);
$this->assertEquals($split, [

$this->assertEquals($split, [
'keyId' => 'http://localhost:8001/accounts/bob#main-key',
'algorithm' => '',
'headers' => ' host date',
'signature' => 'FbVtmZhMWrfbqQpXf1v86+ie/fL8Ng4O67PePKvxChnUtV7J8N6lndQcNfXcDuKDJ4Nda6gKUQabAF2JK2qeYPNZNJ1AdAa5Lak3hQd+rAbdMJdvQpzGhAaSWK6atqOTH9v2CWdjAQbzvY0nOfGiw3ymtDSvTL0pVlIvq116uMtci0WOHeIbuBSyzM23liJmBomlm4EeB3/V1BVWY2MwaQ1cHVzxR7epP6XYts3C1KbZrdMKxhlWJFLdbLy0YGu5HRkYZepAh2q2NriSikNg8YTJ67owgQv/LqhFKnObgZU6np54fBMSpg7eAdWSIbhhg1a/WHtzFicc9cgoWMRhEg==',
]);

// Split a signature with headers and algorithm
$signature = 'keyId="http://localhost:8001/accounts/bob#main-key",algorithm="rsa-sha256",headers="(request-target) host date",signature="FbVtmZhMWrfbqQpXf1v86+ie/fL8Ng4O67PePKvxChnUtV7J8N6lndQcNfXcDuKDJ4Nda6gKUQabAF2JK2qeYPNZNJ1AdAa5Lak3hQd+rAbdMJdvQpzGhAaSWK6atqOTH9v2CWdjAQbzvY0nOfGiw3ymtDSvTL0pVlIvq116uMtci0WOHeIbuBSyzM23liJmBomlm4EeB3/V1BVWY2MwaQ1cHVzxR7epP6XYts3C1KbZrdMKxhlWJFLdbLy0YGu5HRkYZepAh2q2NriSikNg8YTJ67owgQv/LqhFKnObgZU6np54fBMSpg7eAdWSIbhhg1a/WHtzFicc9cgoWMRhEg=="';

$split = $verifier->splitSignature($signature);
$this->assertEquals($split, [

$this->assertEquals($split, [
'keyId' => 'http://localhost:8001/accounts/bob#main-key',
'algorithm' => 'rsa-sha256',
'headers' => ' host date',
'signature' => 'FbVtmZhMWrfbqQpXf1v86+ie/fL8Ng4O67PePKvxChnUtV7J8N6lndQcNfXcDuKDJ4Nda6gKUQabAF2JK2qeYPNZNJ1AdAa5Lak3hQd+rAbdMJdvQpzGhAaSWK6atqOTH9v2CWdjAQbzvY0nOfGiw3ymtDSvTL0pVlIvq116uMtci0WOHeIbuBSyzM23liJmBomlm4EeB3/V1BVWY2MwaQ1cHVzxR7epP6XYts3C1KbZrdMKxhlWJFLdbLy0YGu5HRkYZepAh2q2NriSikNg8YTJ67owgQv/LqhFKnObgZU6np54fBMSpg7eAdWSIbhhg1a/WHtzFicc9cgoWMRhEg==',
]);

// Split a signature with headers (headers contains hyphens), algorithm.
// Split a signature with headers (headers contains hyphens), algorithm.
// For informtion, the following signature is false, no problem here as
// we're only testing split HTTP signature component. Verification is
// we're only testing split HTTP signature component. Verification is
// made after
$signature = 'keyId="http://localhost:8001/accounts/bob#main-key",algorithm="rsa-sha256",headers="(request-target) host content-type digest date",signature="FbVtmZhMWrfbqQpXf1v86+ie/fL8Ng4O67PePKvxChnUtV7J8N6lndQcNfXcDuKDJ4Nda6gKUQabAF2JK2qeYPNZNJ1AdAa5Lak3hQd+rAbdMJdvQpzGhAaSWK6atqOTH9v2CWdjAQbzvY0nOfGiw3ymtDSvTL0pVlIvq116uMtci0WOHeIbuBSyzM23liJmBomlm4EeB3/V1BVWY2MwaQ1cHVzxR7epP6XYts3C1KbZrdMKxhlWJFLdbLy0YGu5HRkYZepAh2q2NriSikNg8YTJ67owgQv/LqhFKnObgZU6np54fBMSpg7eAdWSIbhhg1a/WHtzFicc9cgoWMRhEg=="';

$split = $verifier->splitSignature($signature);
$this->assertEquals($split, [

$this->assertEquals($split, [
'keyId' => 'http://localhost:8001/accounts/bob#main-key',
'algorithm' => 'rsa-sha256',
'headers' => ' host content-type digest date',
Expand All @@ -152,18 +152,18 @@ public function testValidSignatureWithFallbackHeaders()
]);

$payload = json_encode([]);

/* ------------------------------------------------------------------
| Prepare signature
| ------------------------------------------------------------------ */
$date = gmdate('D, d M Y H:i:s T', time());
$date = gmdate('D, d M Y H:i:s T', time());
$host = 'localhost';
$path = '/my-path?q=ok';

$rsa = PublicKeyLoader::loadPrivateKey(
file_get_contents(
dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem'
)
)
)->withHash("sha256"); // private key

$plaintext = "(request-target) post $path\ndate: $date";
Expand Down Expand Up @@ -199,7 +199,7 @@ public function testValidSignatureWithFallbackHeaders()
}

/**
* Check that it returns false when signature header is not
* Check that it returns false when signature header is not
* specified
*/
public function testWrongSignatureMissingSignatureHeader()
Expand All @@ -214,18 +214,18 @@ public function testWrongSignatureMissingSignatureHeader()
]);

$payload = json_encode([]);

/* ------------------------------------------------------------------
| Prepare signature
| ------------------------------------------------------------------ */
$date = gmdate('D, d M Y H:i:s T', time());
$date = gmdate('D, d M Y H:i:s T', time());
$host = 'localhost';
$path = '/my-path?q=ok';

$rsa = PublicKeyLoader::loadPrivateKey(
file_get_contents(
dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem'
)
)
)->withHash("sha256"); // private key

$plaintext = "(request-target) post $path\nhost: $host\ndate: $date";
Expand Down Expand Up @@ -274,18 +274,18 @@ public function testWrongSignatureMissingKeyId()
]);

$payload = json_encode([]);

/* ------------------------------------------------------------------
| Prepare signature
| ------------------------------------------------------------------ */
$date = gmdate('D, d M Y H:i:s T', time());
$date = gmdate('D, d M Y H:i:s T', time());
$host = 'localhost';
$path = '/my-path?q=ok';

$rsa = PublicKeyLoader::loadPrivateKey(
file_get_contents(
dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem'
)
)
)->withHash("sha256"); // private key

$plaintext = "(request-target) post $path\nhost: $host\ndate: $date";
Expand Down Expand Up @@ -335,18 +335,18 @@ public function testWrongSignatureMissingSignature()
]);

$payload = json_encode([]);

/* ------------------------------------------------------------------
| Prepare signature
| ------------------------------------------------------------------ */
$date = gmdate('D, d M Y H:i:s T', time());
$date = gmdate('D, d M Y H:i:s T', time());
$host = 'localhost';
$path = '/my-path?q=ok';

$rsa = PublicKeyLoader::loadPrivateKey(
file_get_contents(
dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem'
)
)
)->withHash("sha256"); // private key

$plaintext = "(request-target) post $path\nhost: $host\ndate: $date";
Expand Down Expand Up @@ -398,18 +398,18 @@ public function testWrongSignatureActorDoesNotExist()
]);

$payload = json_encode([]);

/* ------------------------------------------------------------------
| Prepare signature
| ------------------------------------------------------------------ */
$date = gmdate('D, d M Y H:i:s T', time());
$date = gmdate('D, d M Y H:i:s T', time());
$host = 'localhost';
$path = '/my-path?q=ok';

$rsa = PublicKeyLoader::loadPrivateKey(
file_get_contents(
dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem'
)
)
)->withHash("sha256"); // private key

$plaintext = "(request-target) post $path\nhost: $host\ndate: $date";
Expand Down Expand Up @@ -454,18 +454,18 @@ public function testWrongSignatureNotVerifiedSignature()
]);

$payload = json_encode([]);

/* ------------------------------------------------------------------
| Prepare signature
| ------------------------------------------------------------------ */
$date = gmdate('D, d M Y H:i:s T', time());
$date = gmdate('D, d M Y H:i:s T', time());
$host = 'localhost';
$path = '/my-path?q=ok';

$rsa = PublicKeyLoader::loadPrivateKey(
file_get_contents(
dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem'
)
)
)->withHash("sha256"); // private key

$plaintext = "(request-target) post $path\nhost: $host\ndate: $date";
Expand Down
1 change: 0 additions & 1 deletion tests/ActivityPhp/Server/OutboxPostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public static function getOutboxPostActivities()
* Check that all response are valid
*
* @dataProvider getOutboxPostActivities
* #[DataProvider('getOutboxPostActivities')]
*/
public function testOutboxPostActivities($payload, $accept = 'application/activity+json', $code = 201)
{
Expand Down
3 changes: 0 additions & 3 deletions tests/ActivityPhp/Server/WebFingerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public static function getFailingScenarios()
* Check that all response are valid
*
* @dataProvider getSuccessScenarios
* #[DataProvider('getSuccessScenarios')]
*/
public function testSuccessScenarios($handle, $method, $expected)
{
Expand Down Expand Up @@ -109,7 +108,6 @@ public function testSuccessScenarios($handle, $method, $expected)
* Check that all tests are failing
*
* @dataProvider getFailingScenarios
* #[DataProvider('getFailingScenarios')]
*/
public function testFailingScenarios($handle, $method, $expected)
{
Expand Down Expand Up @@ -194,7 +192,6 @@ public static function getFailingInstanceScenarios()
* Check that all tests are failing
*
* @dataProvider getFailingInstanceScenarios
* #[DataProvider('getFailingInstanceScenarios')]
*/
public function testFailingInstanceScenarios($data)
{
Expand Down
2 changes: 0 additions & 2 deletions tests/ActivityPhp/Type/AttributeFormatValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,6 @@ public static function getExceptionScenarios()
* It checks that getter is working well too.
*
* @dataProvider getValidAttributesScenarios
* #[DataProvider('getValidAttributesScenarios')]
*/
public function testValidAttributesScenarios($attr, $type, $value)
{
Expand Down Expand Up @@ -1399,7 +1398,6 @@ public function testValidAttributesScenarios($attr, $type, $value)

/**
* @dataProvider getExceptionScenarios
* #[DataProvider('getExceptionScenarios')]
*/
public function testExceptionScenarios($attr, $type, $value)
{
Expand Down
1 change: 0 additions & 1 deletion tests/ActivityPhp/Type/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public static function getShortTypes()
* Check that all core objects have a correct type property.
*
* @dataProvider getShortTypes
* #[DataProvider('getShortTypes')]
*/
public function testShortTypesInstanciation($type)
{
Expand Down
1 change: 0 additions & 1 deletion tests/ActivityPhp/Type/TypesTypeAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public static function getObjectTypeScenarios()
* It checks that getter is working well too.
*
* @dataProvider getObjectTypeScenarios
* #[DataProvider('getObjectTypeScenarios')]
*/
public function testObjectTypeScenarios($type, $attr, $value)
{
Expand Down

0 comments on commit 40a39a5

Please sign in to comment.