Przeglądaj źródła

merged branch gajdaw/2_0_component_domcrawler_cs (PR #4091)

Commits
-------

25fed13 [2.0][Component][DomCrawler] cs

Discussion
----------

[2.0][Component][DomCrawler] cs

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: [![Build Status](https://secure.travis-ci.org/gajdaw/symfony.png?branch=2_0_component_domcrawler_cs)](http://travis-ci.org/gajdaw/symfony)
Fixes the following tickets: -
Todo: -

Code standard fix + some documentation.
Fabien Potencier 13 lat temu
rodzic
commit
abf39fd282
1 zmienionych plików z 27 dodań i 5 usunięć
  1. 27 5
      src/Symfony/Component/DomCrawler/Crawler.php

+ 27 - 5
src/Symfony/Component/DomCrawler/Crawler.php

@@ -523,7 +523,7 @@ class Crawler extends \SplObjectStorage
     /**
      * Selects links by name or alt value for clickable images.
      *
-     * @param  string $value The link text
+     * @param string $value The link text
      *
      * @return Crawler A new instance of Crawler with the filtered list of nodes
      *
@@ -540,7 +540,7 @@ class Crawler extends \SplObjectStorage
     /**
      * Selects a button by name or alt value for images.
      *
-     * @param  string $value The button text
+     * @param string $value The button text
      *
      * @return Crawler A new instance of Crawler with the filtered list of nodes
      *
@@ -558,7 +558,7 @@ class Crawler extends \SplObjectStorage
     /**
      * Returns a Link object for the first node in the list.
      *
-     * @param  string $method The method for the link (get by default)
+     * @param string $method The method for the link (get by default)
      *
      * @return Link   A Link instance
      *
@@ -597,8 +597,8 @@ class Crawler extends \SplObjectStorage
     /**
      * Returns a Form object for the first node in the list.
      *
-     * @param  array  $values An array of values for the form fields
-     * @param  string $method The method for the form
+     * @param array  $values An array of values for the form fields
+     * @param string $method The method for the form
      *
      * @return Form   A Form instance
      *
@@ -621,6 +621,28 @@ class Crawler extends \SplObjectStorage
         return $form;
     }
 
+    /**
+     * Converts string for XPath expressions.
+     *
+     * Escaped characters are: quotes (") and apostrophe (').
+     *
+     *  Examples:
+     *  <code>
+     *     echo Crawler::xpathLiteral('foo " bar');
+     *     //prints 'foo " bar'
+     *
+     *     echo Crawler::xpathLiteral("foo ' bar");
+     *     //prints "foo ' bar"
+     *
+     *     echo Crawler::xpathLiteral('a\'b"c');
+     *     //prints concat('a', "'", 'b"c')
+     *  </code>
+     *
+     * @param string $s String to be escaped
+     *
+     * @return string Converted string
+     *
+     */
     static public function xpathLiteral($s)
     {
         if (false === strpos($s, "'")) {