Skip to content

Commit

Permalink
Fix all phpcs and phpstan tests
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanphp committed Jan 30, 2024
1 parent f9c34fc commit 50ac664
Show file tree
Hide file tree
Showing 42 changed files with 353 additions and 251 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,19 @@ jobs:
php-version: '8.2'
tools: phpstan

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist

- name: Run PHPStan
run: phpstan analyse --level=2 src tests
run: phpstan analyse --level=3 src tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
.idea/
.phpunit.result.cache
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"nunomaduro/phpinsights": "dev-master"
"nunomaduro/phpinsights": "dev-master",
"squizlabs/php_codesniffer": "3.*",
"phpstan/phpstan": "^1.10"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 5 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
</properties>
</rule>

<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

<!-- If string doesn't contain variables or single quotes, use single quotes. -->
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/>

<exclude-pattern>/vendor/*</exclude-pattern>

</ruleset>
6 changes: 2 additions & 4 deletions src/Passbook/ArrayableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

interface ArrayableInterface
{

/**
* Get the instance as an array.
*
* @return array
*/
public function toArray();

}
public function toArray();
}
2 changes: 1 addition & 1 deletion src/Passbook/Certificate/P12Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getPassword();
/**
* Sets p12 password
*
* @param string
* @param string $password
*/
public function setPassword($password);
}
2 changes: 1 addition & 1 deletion src/Passbook/Exception/PassInvalidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PassInvalidException extends \RuntimeException
public function __construct($message = '', array $errors = null)
{
parent::__construct($message);
$this->errors = $errors ? $errors : array();
$this->errors = $errors ? $errors : [];
}

/**
Expand Down
77 changes: 38 additions & 39 deletions src/Passbook/Pass.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Pass implements PassInterface
/**
* Pass structure
*
* @var Structure
* @var StructureInterface
*/
protected $structure;

Expand All @@ -74,7 +74,7 @@ class Pass implements PassInterface
*
* @var ImageInterface[]
*/
protected $images = array();
protected $images = [];

/**
* Beacons where the pass is relevant.
Expand All @@ -86,11 +86,10 @@ class Pass implements PassInterface
/**
* NFC where the pass is relevant.
*
* @var array
* @var NfcInterface[]
*/
protected $nfc = [];


/**
* A list of iTunes Store item identifiers (also known as Adam IDs) for the
* associated apps.
Expand Down Expand Up @@ -186,8 +185,6 @@ class Pass implements PassInterface
*/
protected $logoText;



/**
* If true, the strip image is displayed without a shine effect.
*
Expand Down Expand Up @@ -257,12 +254,12 @@ class Pass implements PassInterface
*/
protected $appLaunchURL;

/**
* Pass userInfo
*
* @var mixed
*/
protected $userInfo;
/**
* Pass userInfo
*
* @var mixed
*/
protected $userInfo;

/**
*
Expand All @@ -271,7 +268,7 @@ class Pass implements PassInterface
* @var bool
*
*/
protected bool $sharingProhibited = false;
protected bool $sharingProhibited = false;

public function __construct($serialNumber, $description)
{
Expand All @@ -289,7 +286,7 @@ public function toArray()
$array[$this->getType()] = $this->getStructure()->toArray();
}

$properties = array(
$properties = [
'serialNumber',
'description',
'formatVersion',
Expand All @@ -315,9 +312,9 @@ public function toArray()
'voided',
'appLaunchURL',
'associatedStoreIdentifiers',
'userInfo',
'userInfo',
'sharingProhibited'
);
];
foreach ($properties as $property) {
$method = 'is' . ucfirst($property);
if (!method_exists($this, $method)) {
Expand Down Expand Up @@ -539,6 +536,7 @@ public function getBeacons()
public function addNfc(NfcInterface $nfc)
{
$this->nfc[] = $nfc;

return $this;
}

Expand All @@ -550,7 +548,6 @@ public function getNfc()
return $this->nfc;
}


/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -599,15 +596,15 @@ public function setBarcode(BarcodeInterface $barcode)
}

/**
* {@inheritdoc}
* @deprecated please use addNfc() instead.
*/
public function setNfc(NfcInterface $nfc)
public function setNfc(array $nfc)
{
$this->nfc = $nfc;

return $this;
}


/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -890,31 +887,33 @@ public function getAppLaunchURL()
return $this->appLaunchURL;
}

/**
* {@inheritdoc}
*/
public function setUserInfo($userInfo) {
$this->userInfo = $userInfo;
/**
* {@inheritdoc}
*/
public function setUserInfo($userInfo)
{
$this->userInfo = $userInfo;

return $this;
}
return $this;
}

/**
* {@inheritdoc}
*/
public function getUserInfo() {
return $this->userInfo;
}
/**
* {@inheritdoc}
*/
public function getUserInfo()
{
return $this->userInfo;
}

public function setSharingProhibited(bool $value): self
public function setSharingProhibited(bool $value): self
{
$this->sharingProhibited = $value;
$this->sharingProhibited = $value;

return $this;
return $this;
}

public function getSharingProhibited(): bool {
return $this->sharingProhibited;
public function getSharingProhibited(): bool
{
return $this->sharingProhibited;
}

}
12 changes: 6 additions & 6 deletions src/Passbook/Pass/Barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ class Barcode implements BarcodeInterface
/**
* @var string
*/
const TYPE_QR = 'PKBarcodeFormatQR';
public const TYPE_QR = 'PKBarcodeFormatQR';

/**
* @var string
*/
const TYPE_PDF_417 = 'PKBarcodeFormatPDF417';
public const TYPE_PDF_417 = 'PKBarcodeFormatPDF417';

/**
* @var string
*/
const TYPE_AZTEC = 'PKBarcodeFormatAztec';
public const TYPE_AZTEC = 'PKBarcodeFormatAztec';

/**
* Available starting with iOS 9.
* @var string
*/
const TYPE_CODE_128 = 'PKBarcodeFormatCode128';
public const TYPE_CODE_128 = 'PKBarcodeFormatCode128';

/**
* Barcode format. Must be one of the following values:
Expand Down Expand Up @@ -80,11 +80,11 @@ public function __construct($format, $message, $messageEncoding = 'iso-8859-1')

public function toArray()
{
$array = array(
$array = [
'format' => $this->getFormat(),
'message' => $this->getMessage(),
'messageEncoding' => $this->getMessageEncoding()
);
];

if ($this->getAltText()) {
$array['altText'] = $this->getAltText();
Expand Down
8 changes: 4 additions & 4 deletions src/Passbook/Pass/BarcodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface BarcodeInterface extends ArrayableInterface
/**
* Sets barcode format
*
* @param string
* @param string $format
*/
public function setFormat($format);

Expand All @@ -37,7 +37,7 @@ public function getFormat();
/**
* Sets barcode message
*
* @param string
* @param string $message
*/
public function setMessage($message);

Expand All @@ -51,7 +51,7 @@ public function getMessage();
/**
* Sets barcode message encoding
*
* @param string
* @param string $messageEncoding
*/
public function setMessageEncoding($messageEncoding);

Expand All @@ -65,7 +65,7 @@ public function getMessageEncoding();
/**
* Sets barcode alt text
*
* @param string
* @param string $altText
*/
public function setAltText($altText);

Expand Down
5 changes: 2 additions & 3 deletions src/Passbook/Pass/Beacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function __construct($proximityUUID)

public function toArray()
{
$array = array(
$array = [
'proximityUUID' => $this->getProximityUUID()
);
];

if ($major = $this->getMajor()) {
$array['major'] = $major;
Expand Down Expand Up @@ -143,4 +143,3 @@ public function getRelevantText()
return $this->relevantText;
}
}

10 changes: 4 additions & 6 deletions src/Passbook/Pass/BeaconInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface BeaconInterface extends ArrayableInterface
/**
* Sets proximity UUID
*
* @param string
* @param string $uuid
*/
public function setProximityUUID($uuid);

Expand All @@ -37,7 +37,7 @@ public function getProximityUUID();
/**
* Sets major
*
* @param integer
* @param integer $major
*/
public function setMajor($major);

Expand All @@ -51,7 +51,7 @@ public function getMajor();
/**
* Sets minor
*
* @param integer
* @param integer $minor
*/
public function setMinor($minor);

Expand All @@ -72,9 +72,7 @@ public function getRelevantText();
/**
* Sets relevant text
*
* @param string
* @param string $relevantText
*/
public function setRelevantText($relevantText);

}

Loading

0 comments on commit 50ac664

Please sign in to comment.