-
Notifications
You must be signed in to change notification settings - Fork 10
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
Upgrade to modern PHP #7
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
vendor/* | ||
*.lock | ||
index.php | ||
.phpunit.result.cache |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Vouchers; | ||
|
||
|
@@ -46,7 +46,7 @@ public function __construct(\Vouchers\Voucher\Model $model = null) | |
* | ||
* @return void | ||
*/ | ||
public function fill($number = 0) | ||
public function fill($number = 0) :void | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing is it a little off here... ideally "): void" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we had |
||
{ | ||
for ($i = 0; $i < $number; $i++) { | ||
$this->add(new Voucher()); | ||
|
@@ -77,7 +77,7 @@ public function pick(callable $callback = null) | |
* | ||
* @return Voucher $voucher | ||
*/ | ||
public function pickWithCallback(callable $callback) | ||
public function pickWithCallback(callable $callback) :Voucher | ||
{ | ||
foreach ($this->values as $voucher) { | ||
if ($callback($voucher)) { | ||
|
@@ -96,7 +96,7 @@ public function pickWithCallback(callable $callback) | |
* | ||
* @return void | ||
*/ | ||
public function map(array $data, callable $callback) | ||
public function map(array $data, callable $callback) :void | ||
{ | ||
foreach ($data as $item) { | ||
$result = $callback($item); | ||
|
@@ -114,7 +114,7 @@ public function map(array $data, callable $callback) | |
* | ||
* @return bool | ||
*/ | ||
public function pickValid() | ||
public function pickValid() :Voucher | ||
{ | ||
$voucher = null; | ||
foreach ($this->values as $value) { | ||
|
@@ -144,7 +144,7 @@ public function pickValid() | |
* | ||
* @return bool | ||
*/ | ||
public function validate($code) | ||
public function validate($code) :bool | ||
{ | ||
foreach ($this->validators as $rule) { | ||
$callback = $rule['callback']; | ||
|
@@ -166,7 +166,7 @@ public function validate($code) | |
* | ||
* @return void | ||
*/ | ||
public function validator(callable $callback, $message = self::VALIDATION_MESSAGE) | ||
public function validator(callable $callback, $message = self::VALIDATION_MESSAGE) :void | ||
{ | ||
$rule = [ | ||
'message' => $message, | ||
|
@@ -182,7 +182,7 @@ public function validator(callable $callback, $message = self::VALIDATION_MESSAG | |
* | ||
* @return void | ||
*/ | ||
public function add(Voucher $voucher) | ||
public function add(Voucher $voucher) :void | ||
{ | ||
if ($this->model) { | ||
$this->model->validate($voucher->toArray()); | ||
|
@@ -196,9 +196,9 @@ public function add(Voucher $voucher) | |
* | ||
* @param string $code | ||
* | ||
* @return string|Voucher | ||
* @return bool|Voucher | ||
*/ | ||
public function find($code) | ||
public function find($code) :bool|Voucher | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be great to add |
||
{ | ||
foreach ($this->values as $key => $voucher) { | ||
if ($code == (string) $voucher) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Vouchers\Exceptions; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Vouchers\Exceptions; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Vouchers\Exceptions; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Vouchers\Exceptions; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Vouchers\Exceptions; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to add
"php": 8
to ensure that composer would complain given any package in the future isn't compatible.