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 05a858d

Browse filesBrowse files
committed
Merge pull request symfony#1539 from gajdaw/finder_contents
[Component][Finder]: info about getContents()
2 parents 64b3a50 + b4b7d2b commit 05a858d
Copy full SHA for 05a858d

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
@@ -242,6 +242,25 @@ it is called with the file as a :class:`Symfony\\Component\\Finder\\SplFileInfo`
242242
instance. The file is excluded from the result set if the Closure returns
243243
``false``.
244244

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