These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | require_once __DIR__ . '/vendor/autoload.php'; |
||
4 | |||
5 | use smtech\CanvasHack\Toolbox; |
||
6 | use smtech\ReflexiveCanvasLTI\LTI\ToolProvider; |
||
7 | use Battis\DataUtilities; |
||
8 | |||
9 | define('CONFIG_FILE', __DIR__ . '/config.xml'); |
||
10 | define('CANVAS_INSTANCE_URL', 'canvasInstanceUrl'); |
||
11 | |||
12 | @session_start(); // TODO I don't feel good about suppressing warnings |
||
13 | |||
14 | /* prepare the toolbox */ |
||
15 | if (empty($_SESSION[Toolbox::class])) { |
||
16 | $_SESSION[Toolbox::class] =& Toolbox::fromConfiguration(CONFIG_FILE); |
||
17 | } |
||
18 | $toolbox =& $_SESSION[Toolbox::class]; |
||
19 | $toolbox->smarty_prependTemplateDir(__DIR__ . '/templates', basename(__DIR__)); |
||
0 ignored issues
–
show
|
|||
20 | $toolbox->smarty_assign([ |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
smtech\ReflexiveCanvasLTI\Toolbox as the method smarty_assign() does only exist in the following sub-classes of smtech\ReflexiveCanvasLTI\Toolbox : smtech\CanvasHack\Toolbox , smtech\StMarksReflexiveCanvasLTI\Toolbox . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
21 | 'category' => DataUtilities::titleCase(preg_replace('/[\-_]+/', ' ', basename(__DIR__))) |
||
22 | ]); |
||
23 | |||
24 | /* |
||
25 | * FIXME convience variables until plugins are all updated |
||
26 | */ |
||
27 | $api =& $toolbox->getAPI(); |
||
28 | $sql =& $toolbox->getMySQL(); |
||
29 | $smarty =& $toolbox->getSmarty(); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
smtech\ReflexiveCanvasLTI\Toolbox as the method getSmarty() does only exist in the following sub-classes of smtech\ReflexiveCanvasLTI\Toolbox : smtech\CanvasHack\Toolbox , smtech\StMarksReflexiveCanvasLTI\Toolbox . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
30 | $customPrefs =& $toolbox->getCustomPrefs(); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
smtech\ReflexiveCanvasLTI\Toolbox as the method getCustomPrefs() does only exist in the following sub-classes of smtech\ReflexiveCanvasLTI\Toolbox : smtech\CanvasHack\Toolbox . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
31 | |||
32 | /* set the Tool Consumer's instance URL, if present */ |
||
33 | if (empty($_SESSION[CANVAS_INSTANCE_URL]) && |
||
34 | !empty($_SESSION[ToolProvider::class]['canvas']['api_domain']) |
||
35 | ) { |
||
36 | $_SESSION[CANVAS_INSTANCE_URL] = 'https://' . $_SESSION[ToolProvider::class]['canvas']['api_domain']; |
||
37 | } |
||
38 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: