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 |
||
2 | |||
3 | namespace Victoire\Tests\Features\Context; |
||
4 | |||
5 | use Behat\Behat\Context\Context; |
||
6 | use Behat\Behat\Context\SnippetAcceptingContext; |
||
7 | use Behat\Behat\Hook\Scope\AfterStepScope; |
||
8 | use Behat\Mink\Driver\Selenium2Driver; |
||
9 | use Behat\Mink\Element\Element; |
||
10 | use Behat\Mink\Exception\UnsupportedDriverActionException; |
||
11 | use Behat\Symfony2Extension\Context\KernelAwareContext; |
||
12 | use Behat\Symfony2Extension\Context\KernelDictionary; |
||
13 | use Behat\Symfony2Extension\Driver\KernelDriver; |
||
14 | use Knp\FriendlyContexts\Context\RawMinkContext; |
||
15 | |||
16 | /** |
||
17 | * Feature context. |
||
18 | */ |
||
19 | class FeatureContext extends RawMinkContext implements Context, SnippetAcceptingContext, KernelAwareContext |
||
0 ignored issues
–
show
|
|||
20 | { |
||
21 | use KernelDictionary; |
||
22 | |||
23 | /** |
||
0 ignored issues
–
show
|
|||
24 | * @Given /^I wait (\d+) second$/ |
||
25 | * @Given /^I wait (\d+) seconds$/ |
||
26 | */ |
||
27 | public function iWaitSeconds($nbr) |
||
28 | { |
||
29 | $this->getSession()->wait($nbr * 1000); |
||
30 | } |
||
31 | |||
32 | public function getSymfonyProfile() |
||
0 ignored issues
–
show
|
|||
33 | { |
||
34 | $driver = $this->getSession()->getDriver(); |
||
35 | if (!$driver instanceof KernelDriver) { |
||
36 | throw new UnsupportedDriverActionException( |
||
37 | 'You need to tag the scenario with '. |
||
0 ignored issues
–
show
|
|||
38 | '"@mink:symfony2". Using the profiler is not '. |
||
0 ignored issues
–
show
|
|||
39 | 'supported by %s', $driver |
||
40 | ); |
||
41 | } |
||
42 | |||
43 | $profile = $driver->getClient()->getProfile(); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
Symfony\Component\BrowserKit\Client as the method getProfile() does only exist in the following sub-classes of Symfony\Component\BrowserKit\Client : Symfony\Bundle\FrameworkBundle\Client . 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 | if (false === $profile) { |
||
45 | throw new \RuntimeException( |
||
46 | 'The profiler is disabled. Activate it by setting '. |
||
0 ignored issues
–
show
|
|||
47 | 'framework.profiler.only_exceptions to false in '. |
||
0 ignored issues
–
show
|
|||
48 | 'your config' |
||
49 | ); |
||
50 | } |
||
51 | |||
52 | return $profile; |
||
53 | } |
||
54 | |||
55 | /** |
||
0 ignored issues
–
show
|
|||
56 | * @Then /^I should see the css property "(.+)" of "(.+)" with "(.+)"$/ |
||
57 | * |
||
58 | * @param string $property |
||
59 | * @param string $value |
||
0 ignored issues
–
show
|
|||
60 | */ |
||
61 | public function iShouldSeeCssOfWith($property, $elementId, $value) |
||
62 | { |
||
63 | $script = "return $('#".$elementId."').css('".$property."') === '".$value."';"; |
||
64 | $evaluated = $this->getSession()->evaluateScript($script); |
||
65 | if (!$evaluated) { |
||
66 | throw new \RuntimeException('The element with id "'.$elementId.'" and css property "'.$property.': '.$value.';" not found.'); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | /** |
||
0 ignored issues
–
show
|
|||
71 | * @Then I should see background-image of :id with relative url :url |
||
72 | */ |
||
73 | public function iShouldSeeBackgroundImageWithRelativeUrl($id, $url) |
||
74 | { |
||
75 | $session = $this->getSession(); |
||
76 | $base_url = $session->getCurrentUrl(); |
||
0 ignored issues
–
show
|
|||
77 | $parse_url = parse_url($base_url); |
||
0 ignored issues
–
show
|
|||
78 | $base_url = rtrim($base_url, $parse_url['path']); |
||
0 ignored issues
–
show
|
|||
79 | $url = rtrim($base_url, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.ltrim($url, DIRECTORY_SEPARATOR); |
||
0 ignored issues
–
show
|
|||
80 | $this->iShouldSeeCssOfWith('background-image', $id, 'url("'.$url.'")'); |
||
81 | } |
||
82 | |||
83 | /** |
||
0 ignored issues
–
show
|
|||
84 | * @Then the title should be :title |
||
85 | */ |
||
86 | public function theTitleShouldBe($title) |
||
87 | { |
||
88 | $element = $this->getSession()->getPage()->find( |
||
89 | 'xpath', |
||
90 | sprintf('//title[normalize-space(text()) = "%s"]', $title) |
||
91 | ); |
||
92 | |||
93 | if (null === $element) { |
||
94 | $message = sprintf('"%s" is not the title of the page', $title); |
||
95 | throw new \Behat\Mink\Exception\ResponseTextException($message, $this->getSession()); |
||
96 | } |
||
97 | } |
||
98 | |||
99 | /** |
||
0 ignored issues
–
show
|
|||
100 | * @AfterStep |
||
101 | */ |
||
102 | public function printLastResponseOnError(AfterStepScope $event) |
||
103 | { |
||
104 | if (!$event->getTestResult()->isPassed()) { |
||
105 | $this->saveDebugScreenshot(); |
||
106 | } |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @Then /^save screenshot$/ |
||
111 | */ |
||
112 | public function saveDebugScreenshot() |
||
113 | { |
||
114 | $driver = $this->getSession()->getDriver(); |
||
115 | |||
116 | if (!$driver instanceof Selenium2Driver) { |
||
117 | return; |
||
118 | } |
||
119 | |||
120 | if (!getenv('BEHAT_SCREENSHOTS')) { |
||
121 | return; |
||
122 | } |
||
123 | |||
124 | $filename = microtime(true).'.png'; |
||
125 | $path = $this->getContainer() |
||
126 | ->getParameter('kernel.root_dir').'/../behat_screenshots'; |
||
127 | |||
128 | if (!file_exists($path)) { |
||
129 | mkdir($path); |
||
130 | } |
||
131 | |||
132 | $this->saveScreenshot($filename, $path); |
||
0 ignored issues
–
show
The method
saveScreenshot() does not seem to exist on object<Victoire\Tests\Fe...Context\FeatureContext> .
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. ![]() |
|||
133 | } |
||
134 | } |
||
135 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.