These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | $requestApiDomain = (empty($_REQUEST['custom_canvas_api_domain']) ? false : $_REQUEST['custom_canvas_api_domain']); |
||
4 | |||
5 | require_once __DIR__ . '/vendor/autoload.php'; |
||
6 | require_once __DIR__ . '/constants.inc.php'; |
||
7 | |||
8 | use smtech\CanvasManagement\Toolbox; |
||
9 | use smtech\ReflexiveCanvasLTI\LTI\ToolProvider; |
||
10 | use Battis\DataUtilities; |
||
11 | |||
12 | @session_start(); // TODO suppressing warnings is wrong |
||
0 ignored issues
–
show
|
|||
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 | |||
20 | /* set the Tool Consumer's instance URL, if present */ |
||
21 | if (empty($_SESSION[CANVAS_INSTANCE_URL])) { |
||
22 | if (!empty($requestApiDomain)) { |
||
23 | $_SESSION[CANVAS_INSTANCE_URL] = "https://{$requestApiDomain}"; |
||
24 | } elseif (!empty($_SESSION[ToolProvider::class]['canvas']['api_domain'])) { |
||
25 | $_SESSION[CANVAS_INSTANCE_URL] = 'https://' . $_SESSION[ToolProvider::class]['canvas']['api_domain']; |
||
26 | } else { |
||
27 | $toolbox->log('Could not detect CANVAS_INSTANCE_URL'); |
||
28 | $_SESSION[CANVAS_INSTANCE_URL] = 'https://example.com'; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | /* cache per-instance */ |
||
33 | $toolbox->cache_pushKey(parse_url($_SESSION[CANVAS_INSTANCE_URL], PHP_URL_HOST)); |
||
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 cache_pushKey() does only exist in the following sub-classes of smtech\ReflexiveCanvasLTI\Toolbox : smtech\CanvasManagement\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.
![]() |
|||
34 | |||
35 | /* Configure smarty templating */ |
||
36 | /* FIXME this is sometimes superfluous overhead (e.g. action=config) */ |
||
37 | $toolbox->smarty_prependTemplateDir(__DIR__ . '/templates', basename(__DIR__)); |
||
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_prependTemplateDir() does only exist in the following sub-classes of smtech\ReflexiveCanvasLTI\Toolbox : smtech\CanvasManagement\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.
![]() |
|||
38 | $toolbox->getSmarty()->addStylesheet( |
||
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\CanvasManagement\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.
![]() |
|||
39 | DataUtilities::URLfromPath(__DIR__ . '/css/canvas-management.css'), |
||
40 | basename(__DIR__) |
||
41 | ); |
||
42 | |||
43 | $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\CanvasManagement\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.
![]() |
|||
44 | 'title' => $toolbox->config('TOOL_NAME'), |
||
45 | 'category' => DataUtilities::titleCase(preg_replace('/[\-_]+/', ' ', basename(__DIR__))), |
||
46 | 'APP_URL' => $toolbox->config('APP_URL'), |
||
47 | 'CANVAS_INSTANCE_URL' => $_SESSION[CANVAS_INSTANCE_URL], |
||
48 | 'navbarActive' => basename(dirname($_SERVER['REQUEST_URI'])), |
||
49 | 'menuItems' => $toolbox->buildMenu(__DIR__, [ |
||
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 buildMenu() does only exist in the following sub-classes of smtech\ReflexiveCanvasLTI\Toolbox : smtech\CanvasManagement\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.
![]() |
|||
50 | '.git', |
||
51 | 'build', |
||
52 | 'css', |
||
53 | 'docs', |
||
54 | 'examples', |
||
55 | 'images', |
||
56 | 'js', |
||
57 | 'logs', |
||
58 | 'node_modules', |
||
59 | 'src', |
||
60 | 'templates', |
||
61 | 'tests', |
||
62 | 'vendor' |
||
63 | ]) |
||
64 | ]); |
||
65 |
If you suppress an error, we recommend checking for the error condition explicitly: