Skip to content

Commit c051b54

Browse files
committed
PSR-2 codestyle
1 parent 1f158a0 commit c051b54

File tree

142 files changed

+7637
-7149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+7637
-7149
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ This project versioning adheres to [Semantic Versioning](http://semver.org/).
33

44
## Unreleased
55
- Fixed FirefoxProfile to support installation of extensions with custom namespace prefix in their manifest file
6+
- Comply codestyle with [PSR-2](http://www.php-fig.org/psr/psr-2/)
67

78
## 1.1.2 - 2016-06-04
89
- Added ext-curl to composer.json

lib/Chrome/ChromeDriver.php

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,72 +15,72 @@
1515

1616
namespace Facebook\WebDriver\Chrome;
1717

18+
use Facebook\WebDriver\Exception\WebDriverException;
1819
use Facebook\WebDriver\Remote\DesiredCapabilities;
1920
use Facebook\WebDriver\Remote\DriverCommand;
20-
use Facebook\WebDriver\Remote\Service\DriverCommandExecutor;
21-
use Facebook\WebDriver\Exception\WebDriverException;
2221
use Facebook\WebDriver\Remote\RemoteWebDriver;
22+
use Facebook\WebDriver\Remote\Service\DriverCommandExecutor;
2323
use Facebook\WebDriver\Remote\WebDriverCommand;
2424

25-
class ChromeDriver extends RemoteWebDriver {
25+
class ChromeDriver extends RemoteWebDriver
26+
{
27+
public static function start(DesiredCapabilities $desired_capabilities = null, ChromeDriverService $service = null)
28+
{
29+
if ($desired_capabilities === null) {
30+
$desired_capabilities = DesiredCapabilities::chrome();
31+
}
32+
if ($service === null) {
33+
$service = ChromeDriverService::createDefaultService();
34+
}
35+
$executor = new DriverCommandExecutor($service);
36+
$driver = new static();
37+
$driver->setCommandExecutor($executor)
38+
->startSession($desired_capabilities);
2639

27-
public static function start(
28-
DesiredCapabilities $desired_capabilities = null,
29-
ChromeDriverService $service = null
30-
) {
31-
if ($desired_capabilities === null) {
32-
$desired_capabilities = DesiredCapabilities::chrome();
40+
return $driver;
3341
}
34-
if ($service === null) {
35-
$service = ChromeDriverService::createDefaultService();
36-
}
37-
$executor = new DriverCommandExecutor($service);
38-
$driver = new static();
39-
$driver->setCommandExecutor($executor)
40-
->startSession($desired_capabilities);
41-
return $driver;
42-
}
4342

44-
public function startSession($desired_capabilities) {
45-
$command = new WebDriverCommand(
46-
null,
47-
DriverCommand::NEW_SESSION,
48-
array(
49-
'desiredCapabilities' => $desired_capabilities->toArray(),
50-
)
51-
);
52-
$response = $this->executor->execute($command);
53-
$this->setSessionID($response->getSessionID());
54-
}
43+
public function startSession($desired_capabilities)
44+
{
45+
$command = new WebDriverCommand(
46+
null,
47+
DriverCommand::NEW_SESSION,
48+
array(
49+
'desiredCapabilities' => $desired_capabilities->toArray(),
50+
)
51+
);
52+
$response = $this->executor->execute($command);
53+
$this->setSessionID($response->getSessionID());
54+
}
5555

56-
/**
57-
* Always throws an exception. Use ChromeDriver::start() instead.
58-
*
59-
* @throws WebDriverException
60-
*/
61-
public static function create(
62-
$url = 'http://localhost:4444/wd/hub',
63-
$desired_capabilities = null,
64-
$connection_timeout_in_ms = null,
65-
$request_timeout_in_ms = null,
66-
$http_proxy = null,
67-
$http_proxy_port = null
68-
) {
69-
throw new WebDriverException('Please use ChromeDriver::start() instead.');
70-
}
56+
/**
57+
* Always throws an exception. Use ChromeDriver::start() instead.
58+
*
59+
* @throws WebDriverException
60+
*/
61+
public static function create(
62+
$url = 'http://localhost:4444/wd/hub',
63+
$desired_capabilities = null,
64+
$connection_timeout_in_ms = null,
65+
$request_timeout_in_ms = null,
66+
$http_proxy = null,
67+
$http_proxy_port = null
68+
) {
69+
throw new WebDriverException('Please use ChromeDriver::start() instead.');
70+
}
7171

72-
/**
73-
* Always throws an exception. Use ChromeDriver::start() instead.
74-
*
75-
* @param string $session_id The existing session id
76-
* @param string $url The url of the remote server
77-
*
78-
* @throws WebDriverException
79-
*/
80-
public static function createBySessionID(
81-
$session_id,
82-
$url = 'http://localhost:4444/wd/hub'
83-
) {
84-
throw new WebDriverException('Please use ChromeDriver::start() instead.');
85-
}
72+
/**
73+
* Always throws an exception. Use ChromeDriver::start() instead.
74+
*
75+
* @param string $session_id The existing session id
76+
* @param string $url The url of the remote server
77+
*
78+
* @throws WebDriverException
79+
*/
80+
public static function createBySessionID(
81+
$session_id,
82+
$url = 'http://localhost:4444/wd/hub'
83+
) {
84+
throw new WebDriverException('Please use ChromeDriver::start() instead.');
85+
}
8686
}

lib/Chrome/ChromeDriverService.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@
1717

1818
use Facebook\WebDriver\Remote\Service\DriverService;
1919

20-
class ChromeDriverService extends DriverService {
20+
class ChromeDriverService extends DriverService
21+
{
22+
// The environment variable storing the path to the chrome driver executable.
23+
const CHROME_DRIVER_EXE_PROPERTY = 'webdriver.chrome.driver';
2124

22-
// The environment variable storing the path to the chrome driver executable.
23-
const CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver";
24-
25-
public static function createDefaultService() {
26-
$exe = getenv(self::CHROME_DRIVER_EXE_PROPERTY);
27-
$port = 9515; // TODO: Get another port if the default port is used.
28-
$args = array("--port=$port");
29-
$service = new ChromeDriverService($exe, $port, $args);
30-
return $service;
31-
}
25+
public static function createDefaultService()
26+
{
27+
$exe = getenv(self::CHROME_DRIVER_EXE_PROPERTY);
28+
$port = 9515; // TODO: Get another port if the default port is used.
29+
$args = array("--port=$port");
30+
$service = new self($exe, $port, $args);
3231

32+
return $service;
33+
}
3334
}

0 commit comments

Comments
 (0)