Skip to content

Commit d74ced0

Browse files
committed
Removed deprecated features
1 parent f45ec77 commit d74ced0

14 files changed

Lines changed: 13 additions & 354 deletions

src/Element/Element.php

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
namespace Behat\Mink\Element;
1212

1313
use Behat\Mink\Driver\DriverInterface;
14-
use Behat\Mink\Exception\ElementNotFoundException;
1514
use Behat\Mink\Selector\SelectorsHandler;
1615
use Behat\Mink\Selector\Xpath\Manipulator;
1716
use Behat\Mink\Session;
@@ -23,11 +22,6 @@
2322
*/
2423
abstract class Element implements ElementInterface
2524
{
26-
/**
27-
* @var Session
28-
*/
29-
private $session;
30-
3125
/**
3226
* Driver.
3327
*
@@ -53,26 +47,11 @@ abstract class Element implements ElementInterface
5347
public function __construct(Session $session)
5448
{
5549
$this->xpathManipulator = new Manipulator();
56-
$this->session = $session;
5750

5851
$this->driver = $session->getDriver();
5952
$this->selectorsHandler = $session->getSelectorsHandler();
6053
}
6154

62-
/**
63-
* Returns element session.
64-
*
65-
* @return Session
66-
*
67-
* @deprecated Accessing the session from the element is deprecated as of 1.6 and will be impossible in 2.0.
68-
*/
69-
public function getSession()
70-
{
71-
@trigger_error(sprintf('The method %s is deprecated as of 1.6 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED);
72-
73-
return $this->session;
74-
}
75-
7655
/**
7756
* Returns element's driver.
7857
*
@@ -83,20 +62,6 @@ protected function getDriver()
8362
return $this->driver;
8463
}
8564

86-
/**
87-
* Returns selectors handler.
88-
*
89-
* @return SelectorsHandler
90-
*
91-
* @deprecated Accessing the selectors handler in the element is deprecated as of 1.7 and will be impossible in 2.0.
92-
*/
93-
protected function getSelectorsHandler()
94-
{
95-
@trigger_error(sprintf('The method %s is deprecated as of 1.7 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED);
96-
97-
return $this->selectorsHandler;
98-
}
99-
10065
/**
10166
* {@inheritdoc}
10267
*/
@@ -193,22 +158,4 @@ public function getOuterHtml()
193158
{
194159
return $this->getDriver()->getOuterHtml($this->getXpath());
195160
}
196-
197-
/**
198-
* Builds an ElementNotFoundException.
199-
*
200-
* @param string $type
201-
* @param string|null $selector
202-
* @param string|null $locator
203-
*
204-
* @return ElementNotFoundException
205-
*
206-
* @deprecated as of 1.7, to be removed in 2.0
207-
*/
208-
protected function elementNotFound($type, $selector = null, $locator = null)
209-
{
210-
@trigger_error(sprintf('The method %s is deprecated as of 1.7 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED);
211-
212-
return new ElementNotFoundException($this->driver, $type, $selector, $locator);
213-
}
214161
}

src/Element/ElementInterface.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
namespace Behat\Mink\Element;
1212

13-
use Behat\Mink\Session;
14-
1513
/**
1614
* Element interface.
1715
*
@@ -26,15 +24,6 @@ interface ElementInterface
2624
*/
2725
public function getXpath();
2826

29-
/**
30-
* Returns element's session.
31-
*
32-
* @return Session
33-
*
34-
* @deprecated Accessing the session from the element is deprecated as of 1.6 and will be impossible in 2.0.
35-
*/
36-
public function getSession();
37-
3827
/**
3928
* Checks whether element with specified selector exists inside the current element.
4029
*

src/Exception/ElementException.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/Exception/ElementHtmlException.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
use Behat\Mink\Driver\DriverInterface;
1414
use Behat\Mink\Element\Element;
15-
use Behat\Mink\Session;
1615

1716
/**
1817
* Exception thrown when an expectation on the HTML of an element fails.
@@ -31,12 +30,12 @@ class ElementHtmlException extends ExpectationException
3130
/**
3231
* Initializes exception.
3332
*
34-
* @param string $message optional message
35-
* @param DriverInterface|Session $driver driver instance
36-
* @param Element $element element
33+
* @param string $message optional message
34+
* @param DriverInterface $driver driver instance
35+
* @param Element $element element
3736
* @param \Exception|null $exception expectation exception
3837
*/
39-
public function __construct($message, $driver, Element $element, \Exception $exception = null)
38+
public function __construct($message, DriverInterface $driver, Element $element, \Exception $exception = null)
4039
{
4140
$this->element = $element;
4241

src/Exception/ElementNotFoundException.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
namespace Behat\Mink\Exception;
1212

1313
use Behat\Mink\Driver\DriverInterface;
14-
use Behat\Mink\Session;
1514

1615
/**
1716
* Exception thrown when an expected element is not found.
@@ -23,12 +22,12 @@ class ElementNotFoundException extends ExpectationException
2322
/**
2423
* Initializes exception.
2524
*
26-
* @param DriverInterface|Session $driver driver instance
27-
* @param string|null $type element type
28-
* @param string|null $selector element selector type
25+
* @param DriverInterface $driver driver instance
26+
* @param string|null $type element type
27+
* @param string|null $selector element selector type
2928
* @param string|null $locator element locator
3029
*/
31-
public function __construct($driver, $type = null, $selector = null, $locator = null)
30+
public function __construct(DriverInterface $driver, $type = null, $selector = null, $locator = null)
3231
{
3332
$message = '';
3433

src/Exception/ExpectationException.php

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
namespace Behat\Mink\Exception;
1212

1313
use Behat\Mink\Driver\DriverInterface;
14-
use Behat\Mink\Session;
1514

1615
/**
1716
* Exception thrown for failed expectations.
@@ -22,10 +21,6 @@
2221
*/
2322
class ExpectationException extends Exception
2423
{
25-
/**
26-
* @var Session|null
27-
*/
28-
private $session;
2924
/**
3025
* @var DriverInterface
3126
*/
@@ -34,23 +29,13 @@ class ExpectationException extends Exception
3429
/**
3530
* Initializes exception.
3631
*
37-
* @param string $message optional message
38-
* @param DriverInterface|Session $driver driver instance (or session for BC)
39-
* @param \Exception|null $exception expectation exception
32+
* @param string $message optional message
33+
* @param DriverInterface $driver driver instance
34+
* @param \Exception|null $exception expectation exception
4035
*/
41-
public function __construct($message, $driver, \Exception $exception = null)
36+
public function __construct($message, DriverInterface $driver, \Exception $exception = null)
4237
{
43-
if ($driver instanceof Session) {
44-
@trigger_error('Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.', E_USER_DEPRECATED);
45-
46-
$this->session = $driver;
47-
$this->driver = $driver->getDriver();
48-
} elseif (!$driver instanceof DriverInterface) {
49-
// Trigger an exception as we cannot typehint a disjunction
50-
throw new \InvalidArgumentException('The ExpectationException constructor expects a DriverInterface or a Session.');
51-
} else {
52-
$this->driver = $driver;
53-
}
38+
$this->driver = $driver;
5439

5540
if (!$message && null !== $exception) {
5641
$message = $exception->getMessage();
@@ -96,24 +81,6 @@ protected function getDriver()
9681
return $this->driver;
9782
}
9883

99-
/**
100-
* Returns exception session.
101-
*
102-
* @return Session
103-
*
104-
* @deprecated since 1.7, to be removed in 2.0. Use getDriver and the driver API instead.
105-
*/
106-
protected function getSession()
107-
{
108-
if (null === $this->session) {
109-
throw new \LogicException(sprintf('The deprecated method %s cannot be used when passing a driver in the constructor', __METHOD__));
110-
}
111-
112-
@trigger_error(sprintf('The method %s is deprecated as of Mink 1.7 and will be removed in 2.0. Use getDriver and the driver API instead.', __METHOD__), E_USER_DEPRECATED);
113-
114-
return $this->session;
115-
}
116-
11784
/**
11885
* Prepends every line in a string with pipe (|).
11986
*

src/Selector/NamedSelector.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,6 @@ public function registerReplacement($from, $to)
272272

273273
private function escapeLocator(string $locator): string
274274
{
275-
// If the locator looks like an escaped one, don't escape it again for BC reasons.
276-
if (
277-
preg_match('/^\'[^\']*+\'$/', $locator)
278-
|| (false !== strpos($locator, '\'') && preg_match('/^"[^"]*+"$/', $locator))
279-
|| ((8 < $length = strlen($locator)) && 'concat(' === substr($locator, 0, 7) && ')' === $locator[$length - 1])
280-
) {
281-
@trigger_error(
282-
'Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0.'
283-
.' Pass the raw value instead.',
284-
E_USER_DEPRECATED
285-
);
286-
287-
return $locator;
288-
}
289-
290275
return $this->xpathEscaper->escapeLiteral($locator);
291276
}
292277
}

src/Selector/SelectorsHandler.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
namespace Behat\Mink\Selector;
1212

13-
use Behat\Mink\Selector\Xpath\Escaper;
14-
1513
/**
1614
* Selectors handler.
1715
*
@@ -23,10 +21,6 @@ class SelectorsHandler
2321
* @var array<string, SelectorInterface>
2422
*/
2523
private $selectors = [];
26-
/**
27-
* @var Escaper
28-
*/
29-
private $escaper;
3024

3125
/**
3226
* Initializes selectors handler.
@@ -35,8 +29,6 @@ class SelectorsHandler
3529
*/
3630
public function __construct(array $selectors = array())
3731
{
38-
$this->escaper = new Escaper();
39-
4032
$this->registerSelector('named_partial', new PartialNamedSelector());
4133
$this->registerSelector('named_exact', new ExactNamedSelector());
4234
$this->registerSelector('css', new CssSelector());
@@ -82,15 +74,6 @@ public function isSelectorRegistered($name)
8274
*/
8375
public function getSelector($name)
8476
{
85-
if ('named' === $name) {
86-
@trigger_error(
87-
'Using the "named" selector directly from the handler is deprecated as of 1.6 and will be removed in 2.0.'
88-
.' Use the "named_partial" or use the "named" selector through the Element API instead.',
89-
E_USER_DEPRECATED
90-
);
91-
$name = 'named_partial';
92-
}
93-
9477
if (!$this->isSelectorRegistered($name)) {
9578
throw new \InvalidArgumentException("Selector \"$name\" is not registered.");
9679
}
@@ -118,26 +101,4 @@ public function selectorToXpath($selector, $locator)
118101

119102
return $this->getSelector($selector)->translateToXPath($locator);
120103
}
121-
122-
/**
123-
* Translates string to XPath literal.
124-
*
125-
* @deprecated since Mink 1.7. Use \Behat\Mink\Selector\Xpath\Escaper::escapeLiteral when building Xpath
126-
* or pass the unescaped value when using the named selector.
127-
*
128-
* @param string $s
129-
*
130-
* @return string
131-
*/
132-
public function xpathLiteral($s)
133-
{
134-
@trigger_error(
135-
'The '.__METHOD__.' method is deprecated as of 1.7 and will be removed in 2.0.'
136-
.' Use \Behat\Mink\Selector\Xpath\Escaper::escapeLiteral instead when building Xpath'
137-
.' or pass the unescaped value when using the named selector.',
138-
E_USER_DEPRECATED
139-
);
140-
141-
return $this->escaper->escapeLiteral($s);
142-
}
143104
}

0 commit comments

Comments
 (0)