This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | if (!class_exists('Blog')) { |
||
4 | return; |
||
5 | } |
||
6 | |||
7 | class RecentBlogPostsBlockTest extends SapphireTest |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml'; |
||
13 | |||
14 | /** |
||
15 | * |
||
16 | */ |
||
17 | public function testGetCMSFields() |
||
18 | { |
||
19 | $object = $this->objFromFixture('RecentBlogPostsBlock', 'one'); |
||
20 | $fields = $object->getCMSFields(); |
||
21 | $this->assertInstanceOf('FieldList', $fields); |
||
22 | $this->assertNull($fields->dataFieldByName('SortOrder')); |
||
0 ignored issues
–
show
The method
assertNull() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
23 | } |
||
24 | |||
25 | /** |
||
26 | * |
||
27 | */ |
||
28 | View Code Duplication | public function testCanView() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
29 | { |
||
30 | $object = $this->objFromFixture('RecentBlogPostsBlock', 'one'); |
||
31 | $admin = $this->objFromFixture('Member', 'admin'); |
||
32 | $member = $this->objFromFixture('Member', 'default'); |
||
33 | if (class_exists('Blog')) { |
||
34 | $this->assertTrue($object->canView($admin)); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() It seems like
$admin defined by $this->objFromFixture('Member', 'admin') on line 31 can also be of type object<DataObject> ; however, DataObject::canView() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
35 | $this->assertTrue($object->canView($member)); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() It seems like
$member defined by $this->objFromFixture('Member', 'default') on line 32 can also be of type object<DataObject> ; however, DataObject::canView() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
36 | } else { |
||
37 | $this->assertFalse($object->canView($admin)); |
||
0 ignored issues
–
show
It seems like
$admin defined by $this->objFromFixture('Member', 'admin') on line 31 can also be of type object<DataObject> ; however, DataObject::canView() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() The method
assertFalse() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
38 | $this->assertFalse($object->canView($member)); |
||
0 ignored issues
–
show
It seems like
$member defined by $this->objFromFixture('Member', 'default') on line 32 can also be of type object<DataObject> ; however, DataObject::canView() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() The method
assertFalse() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
39 | } |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * |
||
44 | */ |
||
45 | View Code Duplication | public function testCanCreate() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
46 | { |
||
47 | $object = $this->objFromFixture('RecentBlogPostsBlock', 'one'); |
||
48 | $admin = $this->objFromFixture('Member', 'admin'); |
||
49 | $member = $this->objFromFixture('Member', 'default'); |
||
50 | if (class_exists('Blog')) { |
||
51 | $this->assertTrue($object->canCreate($admin)); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() It seems like
$admin defined by $this->objFromFixture('Member', 'admin') on line 48 can also be of type object<DataObject> ; however, DataObject::canCreate() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
52 | $this->assertTrue($object->canCreate($member)); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() It seems like
$member defined by $this->objFromFixture('Member', 'default') on line 49 can also be of type object<DataObject> ; however, DataObject::canCreate() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
53 | } else { |
||
54 | $this->assertFalse($object->canCreate($admin)); |
||
0 ignored issues
–
show
It seems like
$admin defined by $this->objFromFixture('Member', 'admin') on line 48 can also be of type object<DataObject> ; however, DataObject::canCreate() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() The method
assertFalse() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
55 | $this->assertFalse($object->canCreate($member)); |
||
0 ignored issues
–
show
It seems like
$member defined by $this->objFromFixture('Member', 'default') on line 49 can also be of type object<DataObject> ; however, DataObject::canCreate() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() The method
assertFalse() does not seem to exist on object<RecentBlogPostsBlockTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
56 | } |
||
57 | } |
||
58 | } |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.