-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent PHP errors using more strict filters
- Loading branch information
Showing
9 changed files
with
162 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
namespace Arachne\EntityLoader\FilterIn; | ||
|
||
use Arachne\EntityLoader\FilterInInterface; | ||
use Nette\Application\BadRequestException; | ||
|
||
/** | ||
* @author Jáchym Toušek <[email protected]> | ||
|
@@ -22,6 +23,10 @@ class BooleanFilterIn implements FilterInInterface | |
*/ | ||
public function filterIn($value) | ||
{ | ||
if (!is_string($value)) { | ||
throw new BadRequestException(); | ||
} | ||
|
||
return (bool) $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
namespace Arachne\EntityLoader\FilterIn; | ||
|
||
use Arachne\EntityLoader\FilterInInterface; | ||
use Nette\Application\BadRequestException; | ||
|
||
/** | ||
* @author Jáchym Toušek <[email protected]> | ||
|
@@ -22,6 +23,10 @@ class FloatFilterIn implements FilterInInterface | |
*/ | ||
public function filterIn($value) | ||
{ | ||
if (!is_string($value)) { | ||
throw new BadRequestException(); | ||
} | ||
|
||
return (float) $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
namespace Arachne\EntityLoader\FilterIn; | ||
|
||
use Arachne\EntityLoader\FilterInInterface; | ||
use Nette\Application\BadRequestException; | ||
|
||
/** | ||
* @author Jáchym Toušek <[email protected]> | ||
|
@@ -22,6 +23,10 @@ class IntegerFilterIn implements FilterInInterface | |
*/ | ||
public function filterIn($value) | ||
{ | ||
if (!is_string($value)) { | ||
throw new BadRequestException(); | ||
} | ||
|
||
return (int) $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
namespace Arachne\EntityLoader\FilterIn; | ||
|
||
use Arachne\EntityLoader\FilterInInterface; | ||
use Nette\Application\BadRequestException; | ||
|
||
/** | ||
* @author Jáchym Toušek <[email protected]> | ||
|
@@ -22,6 +23,10 @@ class StringFilterIn implements FilterInInterface | |
*/ | ||
public function filterIn($value) | ||
{ | ||
return (string) $value; | ||
if (!is_string($value)) { | ||
throw new BadRequestException(); | ||
} | ||
|
||
return $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters