Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b4b7d2b

Browse filesBrowse files
committed
[Component][Finder]: info about getContents()
1 parent 7a96f35 commit b4b7d2b
Copy full SHA for b4b7d2b

File tree

Expand file treeCollapse file tree

1 file changed

+19
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-0
lines changed

‎components/finder.rst

Copy file name to clipboardExpand all lines: components/finder.rst
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,25 @@ it is called with the file as a :class:`Symfony\\Component\\Finder\\SplFileInfo`
240240
instance. The file is excluded from the result set if the Closure returns
241241
``false``.
242242

243+
Reading contents of returned files
244+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245+
246+
.. versionadded:: 2.1
247+
Method ``getContents()`` have been introduced in version 2.1.
248+
249+
The contents of returned files can be read with
250+
:method:`Symfony\\Component\\Finder\\SplFileInfo::getContents`::
251+
252+
use Symfony\Component\Finder\Finder;
253+
254+
$finder = new Finder();
255+
$finder->files()->in(__DIR__);
256+
257+
foreach ($finder as $file) {
258+
$contents = $file->getContents();
259+
...
260+
}
261+
243262
.. _strtotime: http://www.php.net/manual/en/datetime.formats.php
244263
.. _Iterator: http://www.php.net/manual/en/spl.iterators.php
245264
.. _protocol: http://www.php.net/manual/en/wrappers.php

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.