Skip to content
22 changes: 12 additions & 10 deletions src/Supporting/CommunicationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,19 +596,21 @@ public function callRestAPI($params, $isAddToken, $method = 'GET', $request = nu
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
if ($methodLower == 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
} else
if ($methodLower == 'put') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
} else if ($methodLower == 'patch') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
} else if ($methodLower == 'delete') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
} else {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
}
} elseif (in_array($methodLower, ['put', 'patch', 'delete', 'get'], true)) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($methodLower));
}
if ($this->isCertVaridating) {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
// Use the OS native certificate authorities, if possible.
// This fixes SSL validation errors if `php.ini` doesn't have
// [curl] `curl.cainfo` set properly of if this PEM file isn't
// up to date. Better rely on the OS certificate authorities, which
// is maintained automatically.
if (defined('CURLSSLOPT_NATIVE_CA')
&& version_compare(curl_version()['version'], '7.71', '>=')) {
curl_setopt($ch, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);
}
} else {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
Expand Down
44 changes: 22 additions & 22 deletions src/Supporting/FileMakerRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class FileMakerRelation implements Iterator
{
/**
* @var null
* @var null|array
* @ignore
*/
private $data = null;
Expand Down Expand Up @@ -98,19 +98,19 @@ public function getDataInfo()
/**
* Get the table occurrence name of query to get this relation.
*
* @return string The table occurrence name.
* @return string The table occurrence name.
*/
public function getTargetTable()
public function getTargetTable(): string
{
return ($this->dataInfo) ? $this->dataInfo->table : null;
}

/**
* Get the total record count of query to get this relation. Portal relation doesn't have this information and returns NULL.
*
* @return integer The total record count.
* @return int The total record count.
*/
public function getTotalCount()
public function getTotalCount(): ?int
{
return ($this->dataInfo && property_exists($this->dataInfo, 'totalRecordCount')) ?
$this->dataInfo->totalRecordCount : null;
Expand All @@ -120,9 +120,9 @@ public function getTotalCount()
* Get the founded record count of query to get this relation. If the relation comes from getRecord() method,
* this method returns 1.
*
* @return integer The founded record count.
* @return int The founded record count.
*/
public function getFoundCount()
public function getFoundCount(): ?int
{
return ($this->dataInfo) ? $this->dataInfo->foundCount : null;
}
Expand All @@ -131,9 +131,9 @@ public function getFoundCount()
* Get the returned record count of query to get this relation. If the relation comes from getRecord() method,
* this method returns 1.
*
* @return integer The rreturned record count.
* @return int The returned record count.
*/
public function getReturnedCount()
public function getReturnedCount(): ?int
{
return ($this->dataInfo) ? $this->dataInfo->returnedCount : null;
}
Expand All @@ -143,7 +143,7 @@ public function getReturnedCount()
*
* @param string $name The portal name.
*/
public function setPortalName($name): void
public function setPortalName(string $name): void
{
$this->portalName = $name;
}
Expand Down Expand Up @@ -254,7 +254,7 @@ public function getFieldNames(): array
return $list;
}

private function getNumberedRecord($num)
private function getNumberedRecord($num): ?FileMakerRelation
{
$value = null;
if (isset($this->data) && isset($this->data[$num])) {
Expand All @@ -276,7 +276,7 @@ private function getNumberedRecord($num)
*
* @return FileMakerRelation|null The record set of the record.
*/
public function getFirstRecord()
public function getFirstRecord(): ?FileMakerRelation
{
return $this->getNumberedRecord(0);
}
Expand All @@ -286,17 +286,17 @@ public function getFirstRecord()
*
* @return FileMakerRelation|null The record set of the record.
*/
public function getLastRecord()
public function getLastRecord(): ?FileMakerRelation
{
return $this->getNumberedRecord(count($this->data) - 1);
}

/**
* Returns the array of the query result. Usually iterating by using foreach is a better way.
*
* @return array|null The FileMakerRelation objects of the records.
* @return array The FileMakerRelation objects of the records.
*/
public function getRecords()
public function getRecords(): array
{
$records = [];
foreach ($this as $record) {
Expand All @@ -308,7 +308,7 @@ public function getRecords()
/**
* Export to array
*
* @return void
* @return array
*/
public function toArray(): array
{
Expand Down Expand Up @@ -340,7 +340,7 @@ public function toArray(): array
*
* @return array List of portal names
*/
public function getPortalNames()
public function getPortalNames(): array
{
$list = [];
if (isset($this->data)) {
Expand All @@ -367,7 +367,7 @@ public function getPortalNames()
}

/**
* The field value of the first parameter. Or the FileMakerRelation object associated with the the first paramenter.
* The field value of the first parameter. Or the FileMakerRelation object associated with the the first parameter.
*
* @param string $name The field or portal name.
* The table occurrence name of the portal can be the portal name, and also the object name of the portal.
Expand Down Expand Up @@ -444,7 +444,7 @@ public function field($name, $toName = null)
*
* @return int The value of special field recordId.
*/
public function getRecordId()
public function getRecordId(): int
{
$value = null;
switch ($this->result) {
Expand Down Expand Up @@ -479,7 +479,7 @@ public function getRecordId()
*
* @return int The value of special field modId.
*/
public function getModId()
public function getModId(): int
{
$value = null;
switch ($this->result) {
Expand Down Expand Up @@ -518,9 +518,9 @@ public function getModId()
* The table occurrence name of the portal can be the portal name, and also the object name of the portal.
* @param string $toName The table occurrence name of the portal as the prefix of the field name.
*
* @return string The base64 encoded data in container field.
* @return string|null The base64 encoded data in container field.
*/
public function getContainerData($name, $toName = null)
public function getContainerData($name, $toName = null): ?string
{
$fieldValue = $this->field($name, $toName);
if (strpos($fieldValue, "https://") !== 0) {
Expand Down