Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.1 #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {
"php": ">=5.4.0"
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down
32 changes: 15 additions & 17 deletions src/FQB.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ class FQB

/**
* @param array $config An array of config options.
* @param string|null $graphEndpoint The name of the Graph API endpoint.
* @param string $graphEndpoint The name of the Graph API endpoint.
*/
public function __construct(array $config = [], $graphEndpoint = '')
public function __construct(array $config = [], string $graphEndpoint = '')
{
if (isset($graphEndpoint)) {
$this->graphNode = new GraphNode($graphEndpoint);
}
$this->graphNode = new GraphNode($graphEndpoint);

$this->config = $config;

Expand Down Expand Up @@ -87,7 +85,7 @@ public function __construct(array $config = [], $graphEndpoint = '')
*
* @return FQB
*/
public function node($graph_node_name)
public function node(string $graph_node_name): self
{
return new static($this->config, $graph_node_name);
}
Expand All @@ -100,7 +98,7 @@ public function node($graph_node_name)
*
* @return GraphEdge
*/
public function edge($edgeName, array $fields = [])
public function edge(string $edgeName, array $fields = []): GraphEdge
{
return new GraphEdge($edgeName, $fields);
}
Expand All @@ -112,7 +110,7 @@ public function edge($edgeName, array $fields = [])
*
* @return FQB
*/
public function fields($fields)
public function fields($fields): self
{
if (!is_array($fields)) {
$fields = func_get_args();
Expand All @@ -130,7 +128,7 @@ public function fields($fields)
*
* @return FQB
*/
public function accessToken($accessToken)
public function accessToken(string $accessToken): self
{
$this->graphNode->modifiers([
GraphNode::PARAM_ACCESS_TOKEN => $accessToken,
Expand All @@ -146,7 +144,7 @@ public function accessToken($accessToken)
*
* @return FQB
*/
public function graphVersion($graphVersion)
public function graphVersion(string $graphVersion): self
{
$this->graphVersion = $graphVersion;

Expand All @@ -160,7 +158,7 @@ public function graphVersion($graphVersion)
*
* @return FQB
*/
public function limit($limit)
public function limit(int $limit): self
{
$this->graphNode->limit($limit);

Expand All @@ -174,7 +172,7 @@ public function limit($limit)
*
* @return FQB
*/
public function modifiers(array $data)
public function modifiers(array $data): self
{
$this->graphNode->modifiers($data);

Expand All @@ -186,7 +184,7 @@ public function modifiers(array $data)
*
* @return string
*/
public function asUrl()
public function asUrl(): string
{
return $this->getHostname().$this->asEndpoint();
}
Expand All @@ -196,11 +194,11 @@ public function asUrl()
*
* @return string
*/
public function asEndpoint()
public function asEndpoint(): string
{
$graphVersionPrefix = '';
if ($this->graphVersion) {
$graphVersionPrefix = '/'.$this->graphVersion;
$graphVersionPrefix = "/{$this->graphVersion}";
}

return $graphVersionPrefix.$this->graphNode->asUrl($this->appSecret);
Expand All @@ -211,7 +209,7 @@ public function asEndpoint()
*
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->asUrl();
}
Expand All @@ -221,7 +219,7 @@ public function __toString()
*
* @return string
*/
private function getHostname()
private function getHostname(): string
{
if ($this->enableBetaMode === true) {
return static::BASE_GRAPH_URL_BETA;
Expand Down
13 changes: 7 additions & 6 deletions src/GraphEdge.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php namespace SammyK\FacebookQueryBuilder;
<?php
namespace SammyK\FacebookQueryBuilder;

class GraphEdge extends GraphNode
{
Expand All @@ -7,7 +8,7 @@ class GraphEdge extends GraphNode
*
* @return array
*/
public function toEndpoints()
public function toEndpoints(): array
{
$endpoints = [];

Expand All @@ -24,7 +25,7 @@ public function toEndpoints()
*
* @return array
*/
public function getChildEdges()
public function getChildEdges(): array
{
$edges = [];
$hasChildren = false;
Expand All @@ -51,7 +52,7 @@ public function getChildEdges()
/**
* Compile the modifier values.
*/
public function compileModifiers()
public function compileModifiers(): void
{
if (count($this->modifiers) === 0) {
return;
Expand All @@ -69,7 +70,7 @@ public function compileModifiers()
/**
* Compile the field values.
*/
public function compileFields()
public function compileFields(): void
{
if (count($this->fields) === 0) {
return;
Expand All @@ -89,7 +90,7 @@ public function compileFields()
*
* @return string
*/
public function compileUrl()
public function compileUrl(): string
{
$append = '';
if (count($this->compiledValues) > 0) {
Expand Down
32 changes: 16 additions & 16 deletions src/GraphNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class GraphNode
* @param array $fields
* @param int $limit
*/
public function __construct($name, $fields = [], $limit = 0)
public function __construct(string $name, array $fields = [], int $limit = 0)
{
$this->name = $name;
$this->fields($fields);
Expand All @@ -81,7 +81,7 @@ public function __construct($name, $fields = [], $limit = 0)
*
* @return GraphNode
*/
public function modifiers(array $data)
public function modifiers(array $data): self
{
$this->modifiers = array_merge($this->modifiers, $data);

Expand All @@ -93,7 +93,7 @@ public function modifiers(array $data)
*
* @return array
*/
public function getModifiers()
public function getModifiers(): array
{
return $this->modifiers;
}
Expand All @@ -105,9 +105,9 @@ public function getModifiers()
*
* @return mixed|null
*/
public function getModifier($key)
public function getModifier(string $key)
{
return isset($this->modifiers[$key]) ? $this->modifiers[$key] : null;
return $this->modifiers[$key] ?? null;
}

/**
Expand All @@ -117,7 +117,7 @@ public function getModifier($key)
*
* @return GraphNode
*/
public function limit($limit)
public function limit(int $limit): self
{
return $this->modifiers([
static::PARAM_LIMIT => $limit,
Expand All @@ -129,7 +129,7 @@ public function limit($limit)
*
* @return int|null
*/
public function getLimit()
public function getLimit(): ?int
{
return $this->getModifier(static::PARAM_LIMIT);
}
Expand All @@ -141,7 +141,7 @@ public function getLimit()
*
* @return GraphNode
*/
public function fields($fields)
public function fields($fields): self
{
if (!is_array($fields)) {
$fields = func_get_args();
Expand All @@ -157,23 +157,23 @@ public function fields($fields)
*
* @return array
*/
public function getFields()
public function getFields(): array
{
return $this->fields;
}

/**
* Clear the compiled values.
*/
public function resetCompiledValues()
public function resetCompiledValues(): void
{
$this->compiledValues = [];
}

/**
* Compile the modifier values.
*/
public function compileModifiers()
public function compileModifiers(): void
{
if (count($this->modifiers) === 0) {
return;
Expand All @@ -185,7 +185,7 @@ public function compileModifiers()
/**
* Compile the field values.
*/
public function compileFields()
public function compileFields(): void
{
if (count($this->fields) === 0) {
return;
Expand All @@ -199,7 +199,7 @@ public function compileFields()
*
* @return string
*/
public function compileUrl()
public function compileUrl(): string
{
$append = '';
if (count($this->compiledValues) > 0) {
Expand All @@ -216,7 +216,7 @@ public function compileUrl()
*
* @return string
*/
public function asUrl($appSecret = null)
public function asUrl(?string $appSecret = null): string
{
$this->resetCompiledValues();

Expand All @@ -235,7 +235,7 @@ public function asUrl($appSecret = null)
*
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->asUrl();
}
Expand All @@ -245,7 +245,7 @@ public function __toString()
*
* @param string $appSecret
*/
private function addAppSecretProofModifier($appSecret)
private function addAppSecretProofModifier(string $appSecret): void
{
$accessToken = $this->getModifier(static::PARAM_ACCESS_TOKEN);
if (!$accessToken) {
Expand Down