Skip to content

Commit 41372f2

Browse files
committed
Checked types of return values, and modified.
1 parent 3f4a5b5 commit 41372f2

4 files changed

Lines changed: 41 additions & 41 deletions

File tree

samples/FMDataAPI_Sample.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// Instantiate the class FMDataAPI with database name, user name, password and host.
2020
// Although the port number and protocol can be set in parameters of constructor,
2121
// these parameters can be omitted with default values.
22-
$fmdb = new FMDataAPI("TestDB", "web", "password", "localhost");
22+
$fmdb = new FMDataAPI("TestDB", "web", "password", "10.211.57.4");
2323

2424
//==============================
2525
//$fmdb = new FMDataAPI("TestDB", "web", "password", "localserver");
@@ -40,7 +40,7 @@
4040
$fmdb->setDebug(true);
4141

4242
// If you call with true, the certificate from the server is going to verify.
43-
// In case of self-signed one (usually default situation), you don't have to call this method.
43+
// In the case of self-signed one (usually default situation), you don't have to call this method.
4444
//$fmdb->setCertValidating(true);
4545

4646
// Metadata API is the new feature of FMS18.

src/FMDataAPI.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function setAPIVersion(int $vNum): void
147147
*/
148148
public function setCertValidating(bool $value): void
149149
{
150-
$this->provider->isCertVaridating = $value;
150+
$this->provider->isCertValidating = $value;
151151
}
152152

153153
/**
@@ -207,7 +207,7 @@ public function curlErrorCode(): int
207207
* The error message of curl, text representation of code.
208208
* @return string The error message of curl.
209209
*/
210-
public function curlErrorMessage(): string
210+
public function curlErrorMessage(): null|string
211211
{
212212
return $this->provider->curlError;
213213
}
@@ -237,7 +237,7 @@ public function errorCode(): int
237237
* This error message is associated with FileMaker's error code.
238238
* @return string The error message.
239239
*/
240-
public function errorMessage(): string
240+
public function errorMessage(): null|string
241241
{
242242
return $this->provider->errorMessage;
243243
}
@@ -302,58 +302,58 @@ public function setGlobalField(array $fields): void
302302

303303
/**
304304
* Get the product information, such as the version, etc. This isn't required to authenticate.
305-
* @return object The information of this FileMaker product. Ex.:
305+
* @return null|object The information of this FileMaker product. Ex.:
306306
* {'name' => 'FileMaker Data API Engine', 'buildDate' => '03/27/2019', 'version' => '18.0.1.109',
307307
* 'dateFormat' => 'MM/dd/yyyy', 'timeFormat' => 'HH:mm:ss', 'timeStampFormat' => 'MM/dd/yyyy HH:mm:ss'}.
308308
* @throws Exception In case of any error, an exception arises.
309309
*/
310-
public function getProductInfo(): object
310+
public function getProductInfo(): null|object
311311
{
312312
return $this->provider->getProductInfo();
313313
}
314314

315315
/**
316316
* Get the information about hosting database. It includes the target database and others in FileMaker Server.
317317
* This is required to authenticate.
318-
* @return array The information of hosting databases. Every element is an object and just having 'name'
318+
* @return null|array The information of hosting databases. Every element is an object and just having 'name'
319319
* property.Ex.: [{"name": "TestDB"},{"name": "sample_db"}]
320320
* @throws Exception In case of any error, an exception arises.
321321
*/
322-
public function getDatabaseNames(): array
322+
public function getDatabaseNames(): null|array
323323
{
324324
return $this->provider->getDatabaseNames();
325325
}
326326

327327
/**
328328
* Get the list of layout name in a database.
329-
* @return array The information of layouts in the target database. Every element is an object and just having 'name'
329+
* @return null|array The information of layouts in the target database. Every element is an object and just having 'name'
330330
* property.
331331
* Ex.: [{"name": "person_layout"},{"name": "contact_to"},{"name": "history_to"}...]
332332
* @throws Exception In case of any error, an exception arises.
333333
*/
334-
public function getLayoutNames(): array
334+
public function getLayoutNames(): null|array
335335
{
336336
return $this->provider->getLayoutNames();
337337
}
338338

339339
/**
340340
* Get the list of script name in database.
341-
* @return array The information of scripts in the target database. Every element is an object and having 'name' property.
341+
* @return null|array The information of scripts in the target database. Every element is an object and having 'name' property.
342342
* The 'isFolder' property is true if it's a folder item, and it has the 'folderScriptNames' property and includes
343343
* an object with the same structure.
344344
* Ex.: [{"name": "TestScript1","isFolder": false},{"name": "TestScript2","isFolder": false},{"name": "Maintenance",
345345
* "isFolder": true, "folderScriptNames": [{"name": "DataImport","isFolder": false}]}]
346346
* @throws Exception In case of any error, an exception arises.
347347
*/
348-
public function getScriptNames(): array
348+
public function getScriptNames(): null|array
349349
{
350350
return $this->provider->getScriptNames();
351351
}
352352

353353
/**
354354
* Get the table occurrence name of just a previous query.
355355
* Usually this method returns the information of the FileMakerRelation class.
356-
* @return string The table name.
356+
* @return null|string The table name.
357357
* @see FileMakerRelation::getTargetTable()
358358
*/
359359
public function getTargetTable(): null|string
@@ -364,32 +364,32 @@ public function getTargetTable(): null|string
364364
/**
365365
* Get the total record count of just a previous query.
366366
* Usually this method returns the information of the FileMakerRelation class.
367-
* @return int The total record count.
367+
* @return null|int The total record count.
368368
* @see FileMakerRelation::getTotalCount()
369369
*/
370-
public function getTotalCount(): int
370+
public function getTotalCount(): null|int
371371
{
372372
return $this->provider->totalCount;
373373
}
374374

375375
/**
376376
* Get the founded record count of just a previous query.
377377
* Usually this method returns the information of the FileMakerRelation class.
378-
* @return int The founded record count.
379-
* @see FileMakerRelation::getFoundCount()
378+
* @return null|int The founded record count.
379+
* @see FileMakerRelation::getFoundCount(): null|int
380380
*/
381-
public function getFoundCount(): int
381+
public function getFoundCount(): null|int
382382
{
383383
return $this->provider->foundCount;
384384
}
385385

386386
/**
387387
* Get the returned record count of just a previous query.
388388
* Usually this method returns the information of the FileMakerRelation class.
389-
* @return int The returned record count.
389+
* @return null|int The returned record count.
390390
* @see FileMakerRelation::getReturnedCount()
391391
*/
392-
public function getReturnedCount(): int
392+
public function getReturnedCount(): null|int
393393
{
394394
return $this->provider->returnedCount;
395395
}

src/Supporting/CommunicationProvider.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class CommunicationProvider
156156
* @var bool
157157
* @ignore
158158
*/
159-
public bool $isCertVaridating;
159+
public bool $isCertValidating = false;
160160
/**
161161
* @var bool
162162
* @ignore
@@ -206,7 +206,7 @@ class CommunicationProvider
206206
* @var int
207207
* @ignore
208208
*/
209-
public int $timeout;
209+
public null|int $timeout = null;
210210
/**
211211
* @var bool
212212
* @ignore
@@ -376,13 +376,13 @@ public function justifyRequest(?array $request): array
376376
}
377377

378378
/**
379-
* @return array|false
379+
* @return object|null
380380
* @throws Exception In case of any error, an exception arises.
381381
* @ignore
382382
*/
383-
public function getProductInfo(): ?array
383+
public function getProductInfo(): object|null
384384
{
385-
$returnValue = false;
385+
$returnValue = null;
386386
$params = ["productInfo" => null];
387387
$request = [];
388388
try {
@@ -402,13 +402,13 @@ public function getProductInfo(): ?array
402402
}
403403

404404
/**
405-
* @return array|false
405+
* @return array|null
406406
* @throws Exception In case of any error, an exception arises.
407407
* @ignore
408408
*/
409-
public function getDatabaseNames(): array|false
409+
public function getDatabaseNames(): array|null
410410
{
411-
$returnValue = false;
411+
$returnValue = null;
412412
if ($this->useOAuth) {
413413
$headers = [
414414
"Content-Type" => "application/json",
@@ -436,13 +436,13 @@ public function getDatabaseNames(): array|false
436436
}
437437

438438
/**
439-
* @return array|false
439+
* @return null|array
440440
* @throws Exception In case of any error, an exception arises.
441441
* @ignore
442442
*/
443-
public function getLayoutNames(): array|false
443+
public function getLayoutNames(): null|array
444444
{
445-
$returnValue = false;
445+
$returnValue = null;
446446
if ($this->login()) {
447447
$params = ["layouts" => null];
448448
$request = [];
@@ -466,9 +466,9 @@ public function getLayoutNames(): array|false
466466
* @throws Exception In case of any error, an exception arises.
467467
* @ignore
468468
*/
469-
public function getScriptNames()
469+
public function getScriptNames(): null|array
470470
{
471-
$returnValue = false;
471+
$returnValue = null;
472472
if ($this->login()) {
473473
$params = ["scripts" => null];
474474
$request = [];
@@ -617,7 +617,7 @@ public function callRestAPI($params, $isAddToken, $method = 'GET', $request = nu
617617
} elseif (in_array($methodLower, ['put', 'patch', 'delete', 'get'], true)) {
618618
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($methodLower));
619619
}
620-
if ($this->isCertVaridating) {
620+
if ($this->isCertValidating) {
621621
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
622622
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
623623
// Use the OS native certificate authorities, if possible.
@@ -712,7 +712,7 @@ public function accessToContainer($url)
712712
$ch = curl_init($url); //visit the container URL to set the cookie
713713
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
714714
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
715-
if ($this->isCertVaridating) {
715+
if ($this->isCertValidating) {
716716
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
717717
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
718718
} else {
@@ -731,7 +731,7 @@ public function accessToContainer($url)
731731
$ch = curl_init($url); //visit container URL again
732732
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
733733
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
734-
if ($this->isCertVaridating) {
734+
if ($this->isCertValidating) {
735735
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
736736
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
737737
} else {

src/Supporting/FileMakerRelation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getDataInfo()
100100
*
101101
* @return null|string The table occurrence name.
102102
*/
103-
public function getTargetTable(): ?string
103+
public function getTargetTable(): null|string
104104
{
105105
return ($this->dataInfo) ? $this->dataInfo->table : null;
106106
}
@@ -111,7 +111,7 @@ public function getTargetTable(): ?string
111111
*
112112
* @return null|int The total record count.
113113
*/
114-
public function getTotalCount(): ?int
114+
public function getTotalCount(): null|int
115115
{
116116
return ($this->dataInfo && property_exists($this->dataInfo, 'totalRecordCount')) ?
117117
$this->dataInfo->totalRecordCount : null;
@@ -124,7 +124,7 @@ public function getTotalCount(): ?int
124124
*
125125
* @return null|int The founded record count.
126126
*/
127-
public function getFoundCount(): ?int
127+
public function getFoundCount(): null|int
128128
{
129129
return ($this->dataInfo) ? $this->dataInfo->foundCount : null;
130130
}
@@ -136,7 +136,7 @@ public function getFoundCount(): ?int
136136
*
137137
* @return null|int The returned record count.
138138
*/
139-
public function getReturnedCount(): ?int
139+
public function getReturnedCount(): null|int
140140
{
141141
return ($this->dataInfo) ? $this->dataInfo->returnedCount : null;
142142
}

0 commit comments

Comments
 (0)