Skip to content

Commit

Permalink
Types - Add strict types, missing types and fix some CS
Browse files Browse the repository at this point in the history
  • Loading branch information
landrok committed May 15, 2021
1 parent 6ec4d41 commit c812db8
Show file tree
Hide file tree
Showing 134 changed files with 941 additions and 701 deletions.
22 changes: 11 additions & 11 deletions src/ActivityPhp/Server/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

/**
* Server configuration dispatcher
*/
*/
class Configuration
{
const CONFIG_NS_PATTERN = '\ActivityPhp\Server\Configuration\%sConfiguration';
private const CONFIG_NS_PATTERN = '\ActivityPhp\Server\Configuration\%sConfiguration';

/**
* @var \ActivityPhp\Server\Configuration\HttpConfiguration
Expand Down Expand Up @@ -66,10 +66,10 @@ public function dispatchParameters(array $params): void
] as $config
) {

if (isset($params[$config]) && !is_array($params[$config])) {
if (isset($params[$config]) && ! is_array($params[$config])) {
throw new Exception(
"Configuration value for '$config' must be an array"
);
"Configuration value for '{$config}' must be an array"
);
}

if (is_null($this->$config)) {
Expand All @@ -95,12 +95,12 @@ public function dispatchParameters(array $params): void
throw new Exception(
"Following configuration parameters have been ignored:\n"
. json_encode($params, JSON_PRETTY_PRINT)
);
}
);
}
}
/**
* Get a configuration dedicated handler
*
*
* @return \ActivityPhp\Server\Configuration\LoggerConfiguration
* | \ActivityPhp\Server\Configuration\InstanceConfiguration
* | \ActivityPhp\Server\Configuration\HttpConfiguration
Expand All @@ -111,16 +111,16 @@ public function getConfig(string $parameter)
{
// Get configuration identifier
$xpt = explode('.', $parameter, 2);

if (isset($this->{$xpt[0]})) {
if (!isset($xpt[1])) {
if (! isset($xpt[1])) {
return $this->{$xpt[0]};
}
return $this->{$xpt[0]}->get($xpt[1]);
}

throw new Exception(
"Configuration handler '{$xpt[0]}' does not exist"
);
);
}
}
68 changes: 35 additions & 33 deletions src/ActivityPhp/Type/Core/AbstractActivity.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ActivityPhp package.
*
Expand All @@ -16,9 +18,9 @@
* attributes between Activity and IntransitiveActivity.
*
* It SHOULD NOT be used as if.
*
*
* Please use IntransitiveActivity or Activity instead.
*
*
* @see https://www.w3.org/TR/activitystreams-core/#activities
* @see https://www.w3.org/TR/activitystreams-core/#intransitiveactivities
*/
Expand All @@ -30,82 +32,82 @@ abstract class AbstractActivity extends ObjectType
protected $id;

/**
* Describes one or more entities that either performed or are
* Describes one or more entities that either performed or are
* expected to perform the activity.
* Any single activity can have multiple actors.
* The actor MAY be specified using an indirect Link.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-actor
*
*
* @var string
* | \ActivityPhp\Type\Extended\AbstractActor
* | \ActivityPhp\Type\Core\Actor[]
* | \ActivityPhp\Type\Core\Link
* | \ActivityPhp\Type\Core\Link[]
* | array<Actor>
* | array<Link>
* | Link
*/
protected $actor;

/**
* The indirect object, or target, of the activity.
* The precise meaning of the target is largely dependent on the
* The precise meaning of the target is largely dependent on the
* type of action being described but will often be the object of
* the English preposition "to".
* For instance, in the activity "John added a movie to his
* For instance, in the activity "John added a movie to his
* wishlist", the target of the activity is John's wishlist.
* An activity can have more than one target.
* An activity can have more than one target.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-target
*
*
* @var string
* | \ActivityPhp\Type\Core\ObjectType
* | \ActivityPhp\Type\Core\ObjectType[]
* | \ActivityPhp\Type\Core\Link
* | \ActivityPhp\Type\Core\Link[]
* | ObjectType
* | array<ObjectType>
* | Link
* | array<Link>
*/
protected $target;

/**
* Describes the result of the activity.
* For instance, if a particular action results in the creation of
* a new resource, the result property can be used to describe
* For instance, if a particular action results in the creation of
* a new resource, the result property can be used to describe
* that new resource.
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-result
*
*
* @var string
* | ObjectType
* | Link
* | null
* | \ActivityPhp\Type\Core\ObjectType
* | \ActivityPhp\Type\Core\Link
*/
protected $result;

/**
* An indirect object of the activity from which the
* An indirect object of the activity from which the
* activity is directed.
* The precise meaning of the origin is the object of the English
* The precise meaning of the origin is the object of the English
* preposition "from".
* For instance, in the activity "John moved an item to List B
* For instance, in the activity "John moved an item to List B
* from List A", the origin of the activity is "List A".
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-origin
*
*
* @var string
* | ObjectType
* | Link
* | null
* | \ActivityPhp\Type\Core\ObjectType
* | \ActivityPhp\Type\Core\Link
*/
protected $origin;

/**
* One or more objects used (or to be used) in the completion of an
* One or more objects used (or to be used) in the completion of an
* Activity.
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-instrument
*
*
* @var string
* | ObjectType
* | Link
* | null
* | \ActivityPhp\Type\Core\ObjectType
* | \ActivityPhp\Type\Core\Link
*/
protected $instrument;
}
16 changes: 9 additions & 7 deletions src/ActivityPhp/Type/Core/Activity.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ActivityPhp package.
*
Expand All @@ -12,11 +14,11 @@
namespace ActivityPhp\Type\Core;

/**
* \ActivityPhp\Type\Core\Activity is an implementation of one of the
* \ActivityPhp\Type\Core\Activity is an implementation of one of the
* Activity Streams Core Types.
*
* Activity objects are specializations of the base Object type that
* provide information about actions that have either already occurred,
* provide information about actions that have either already occurred,
* are in the process of occurring, or may occur in the future.
*
* @see https://www.w3.org/TR/activitystreams-core/#activities
Expand All @@ -30,15 +32,15 @@ class Activity extends AbstractActivity

/**
* Describes the direct object of the activity.
* For instance, in the activity "John added a movie to his
* For instance, in the activity "John added a movie to his
* wishlist", the object of the activity is the movie added.
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object-term
*
*
* @var string
* | ObjectType
* | Link
* | null
* | \ActivityPhp\Type\Core\Object
* | \ActivityPhp\Type\Core\Link
*/
protected $object;
}
60 changes: 32 additions & 28 deletions src/ActivityPhp/Type/Core/Collection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ActivityPhp package.
*
Expand All @@ -12,7 +14,7 @@
namespace ActivityPhp\Type\Core;

/**
* \ActivityPhp\Type\Core\Collection is an implementation of one of the
* \ActivityPhp\Type\Core\Collection is an implementation of one of the
* Activity Streams Core Types.
*
* Collection objects are a specialization of the base Object that serve
Expand All @@ -33,75 +35,77 @@ class Collection extends ObjectType
protected $id;

/**
* A non-negative integer specifying the total number of objects
* A non-negative integer specifying the total number of objects
* contained by the logical view of the collection.
* This number might not reflect the actual number of items
* This number might not reflect the actual number of items
* serialized within the Collection object instance.
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-totalitems
*
* @var int
*/
protected $totalItems;

/**
* In a paged Collection, indicates the page that contains the most
* recently updated member items.
*
* In a paged Collection, indicates the page that contains the most
* recently updated member items.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-current
*
*
* @var string
* | Link
* | CollectionPage
* | null
* | \ActivityPhp\Type\Core\Link
* | \ActivityPhp\Type\Core\CollectionPage
*/
protected $current;

/**
* The furthest preceeding page of items in the collection.
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-last
*
*
* @var string
* | Link
* | CollectionPage
* | null
* | \ActivityPhp\Type\Core\Link
* | \ActivityPhp\Type\Core\CollectionPage
*/
protected $first;

/**
* The furthest proceeding page of the collection.
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-last
*
*
* @var string
* | Link
* | CollectionPage
* | null
* | \ActivityPhp\Type\Core\Link
* | \ActivityPhp\Type\Core\CollectionPage
*/
protected $last;

/**
* The items contained in a collection.
* The items contained in a collection.
* The items are considered as unordered.
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-items
*
*
* @var array
* | \ActivityPhp\Type\Core\Link
* | \ActivityPhp\Type\Core\ObjectType[]
* | Link
* | array<Link>
* | array<ObjectType>
*/
protected $items = [];

/**
* The items contained in a collection.
* The items contained in a collection.
* The items are considered as ordered.
*
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-items
*
*
* @var array
* | \ActivityPhp\Type\Core\Link
* | \ActivityPhp\Type\Core\ObjectType[]
* | Link
* | array<Link>
* | array<ObjectType>
*/
protected $orderedItems = [];
}
Loading

0 comments on commit c812db8

Please sign in to comment.