Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05a858d

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

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

components/finder.rst

Lines 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)