for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace FLAIRUK\GoodTillSystem;
use Illuminate\Support\Facades\Http;
use FLAIRUK\GoodTillSystem\Authorize;
use Illuminate\Support\Facades\Config;
use FLAIRUK\GoodTillSystem\RESTInterface;
use Illuminate\Http\Client\PendingRequest;
class API implements RESTInterface {
protected $url;
protected $payload;
/**
* Create a new GoodTill instance.
*
* @return void
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
*/
public function __construct($user, $url, $id = null)
$id
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
{
$this->url = $url;
$this->user = $user;
user
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Good Till API: Access
* @return PendingRequest
public function access(): PendingRequest {
return Http::withToken($this->user['token']);
* Good Till API: Get Outlet Model
* @return array
public function get(): array {
// dump($this->url, $this->user['token']); die;
return $this->access()->get($this->url)->json();
* Good Till API: Create
* @param array $data
public function create(array $data = []): array {
return $this->access()->post($this->url, $data)->json();
* Good Till API: Update
public function update(array $data): array {
return $this->access()->patch($this->url, $data)->json();
* Good Till API: Delete
$data
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
public function delete(): array {
return $this->access()->post($this->url . 'delete/' . $this->id)->json();
id
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.