當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Reader類代碼示例

本文整理匯總了PHP中Reader的典型用法代碼示例。如果您正苦於以下問題:PHP Reader類的具體用法?PHP Reader怎麽用?PHP Reader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Reader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testReadWrittenFile

 public function testReadWrittenFile()
 {
     $reader = new Reader(__DIR__ . '/../data/write.csv');
     $results = $reader->getAll()->toPrimitiveArray();
     $expected = array(array('column1' => '1test1', 'column2' => '1test2ing this out', 'column3' => '1test3'), array('column1' => '2test1', 'column2' => '2test2 ing this out ok', 'column3' => '2test3'));
     $this->assertEquals($expected, $results);
 }
開發者ID:php-mod,項目名稱:csv,代碼行數:7,代碼來源:WriterTest.php

示例2: getAccessProperties

 /**
  * Get a list of properties and the access that are given to them for given object.
  *
  * @param array  $properties The properties of the object to read.
  * @param Reader $annotationReader The annotation reader to use.
  *
  * @return array The list of properties and their access.
  */
 public static function getAccessProperties($properties, $annotationReader)
 {
     $objectAccessProperties = array();
     foreach ($properties as $propertyName => $property) {
         if (empty($objectAccessProperties[$propertyName])) {
             $objectAccessProperties[$propertyName] = array();
         }
         // Getters / Setters related annotations
         $propertyAccessAnnotation = $annotationReader->getPropertyAnnotation($property, self::$accessAnnotationClass);
         $accessProperties = array();
         if ($propertyAccessAnnotation !== null) {
             $accessProperties = $propertyAccessAnnotation->getAccessProperties();
         }
         // Collection related annotations
         $collectionAnnotation = null;
         foreach (self::$collectionAnnotationClasses as $annotationBehavior => $annotationClass) {
             $collectionAnnotation = $annotationReader->getPropertyAnnotation($property, $annotationClass);
             if ($collectionAnnotation !== null) {
                 break;
             }
         }
         $collectionMethods = array();
         if ($collectionAnnotation !== null) {
             $collectionMethods = $collectionAnnotation->getMethods();
         }
         // Merge and save the two arrays
         $objectAccessProperties[$propertyName] = array_merge($accessProperties, $collectionMethods);
     }
     return $objectAccessProperties;
 }
開發者ID:antarestupin,項目名稱:Accessible,代碼行數:38,代碼來源:AccessReader.php

示例3: unserialize

 public static function unserialize($data, $simple = false)
 {
     $stream = new BytesIO($data);
     $reader = new Reader($stream, $simple);
     $result = $reader->unserialize();
     $stream->close();
     return $result;
 }
開發者ID:wanggeopens,項目名稱:own-libs,代碼行數:8,代碼來源:Formatter.php

示例4: exampleStripNodes

 /**
  * Strip statements
  *
  * @expectOutputRegex #echo 'bar';#
  */
 public function exampleStripNodes()
 {
     $reader = new Reader("<?php require 'Foo.php'; echo 'bar';");
     $writer = new Writer();
     $writer->apply(new Action\NodeStripper('Expr_Include'));
     // Outputs the echo statement
     echo $writer->write($reader->readAll());
 }
開發者ID:bonroyage,項目名稱:classtools,代碼行數:13,代碼來源:TransformerExamples.php

示例5: buildForms

function buildForms($code)
{
    $lexer = new Lexer();
    $reader = new Reader();
    $builder = new FormTreeBuilder();
    $tokens = $lexer->tokenize($code);
    $ast = $reader->parse($tokens);
    return $builder->parseAst($ast);
}
開發者ID:igorw,項目名稱:ilias,代碼行數:9,代碼來源:macro-expand.php

示例6: testReadClassDefinition

 public function testReadClassDefinition()
 {
     $baseDirectory = __DIR__ . '/../Resources/finder/basemodel';
     $fileName = 'model.yml';
     $rym = new Reader();
     $rym->readYaml($baseDirectory . '/' . $fileName);
     $testEnumProperties = $rym->getClassDefinitionAttributes('TestEnum');
     $this->assertEquals('Yoghi\\Bundle\\Madda\\Domain\\ValueObject', $testEnumProperties['namespace'], 'namespace non letto corretamente');
 }
開發者ID:yoghi,項目名稱:madda,代碼行數:9,代碼來源:ReaderTest.php

示例7: testDeserialize

    /**
     * This particular xml body caused the parser to go into an infinite loop.
     * Need to know why.
     */
    function testDeserialize()
    {
        $body = '<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test">
  <d:set><d:prop></d:prop></d:set>
  <d:set><d:prop></d:prop></d:set>
</d:propertyupdate>';
        $reader = new Reader();
        $reader->elementMap = ['{DAV:}set' => 'Sabre\\Xml\\Element\\KeyValue'];
        $reader->xml($body);
        $output = $reader->parse();
        $this->assertEquals(['name' => '{DAV:}propertyupdate', 'value' => [['name' => '{DAV:}set', 'value' => ['{DAV:}prop' => null], 'attributes' => []], ['name' => '{DAV:}set', 'value' => ['{DAV:}prop' => null], 'attributes' => []]], 'attributes' => []], $output);
    }
開發者ID:sebbie42,項目名稱:casebox,代碼行數:17,代碼來源:InfiteLoopTest.php

示例8: run

 public function run()
 {
     $reader = new Reader();
     $render = new Render();
     if (Index::requireIndexing()) {
         $format = $render->attach(new Index());
         $reader->open(Config::xml_file());
         $render->execute($reader);
         $render->detach($format);
     }
     $render->attach($this->format);
     $reader->open(Config::xml_file());
     $render->execute($reader);
 }
開發者ID:marczych,項目名稱:hack-hhvm-docs,代碼行數:14,代碼來源:TestRender.php

示例9: testParse

    public function testParse()
    {
        $reader = new Reader();
        $content = <<<EOT
    <meta property="og:title" content="The Rock" />
    <meta property="og:type" content="video.movie" />
    <meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
    <meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
EOT;
        $result = $reader->parse($content);
        $this->assertCount(4, $result);
        $this->assertEquals(array('property' => 'og:title', 'content' => 'The Rock'), $result[0]->attributes());
        $this->assertEquals(array('property' => 'og:type', 'content' => 'video.movie'), $result[1]->attributes());
    }
開發者ID:mauris,項目名稱:htmlmeta,代碼行數:14,代碼來源:ReaderTest.php

示例10: testWorkaround

    function testWorkaround()
    {
        // See https://github.com/fruux/sabre-vobject/issues/36
        $event = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SUMMARY:Titel
SEQUENCE:1
TRANSP:TRANSPARENT
RRULE:FREQ=YEARLY
LAST-MODIFIED:20130323T225737Z
DTSTAMP:20130323T225737Z
UID:1833bd44-188b-405c-9f85-1a12105318aa
CATEGORIES:Jubiläum
X-MOZ-GENERATION:3
RECURRENCE-ID;RANGE=THISANDFUTURE;VALUE=DATE:20131013
DTSTART;VALUE=DATE:20131013
CREATED:20100721T121914Z
DURATION:P1D
END:VEVENT
END:VCALENDAR
ICS;
        $obj = Reader::read($event);
        // If this does not throw an exception, it's all good.
        $it = new Recur\EventIterator($obj, '1833bd44-188b-405c-9f85-1a12105318aa');
        $this->assertInstanceOf('Sabre\\VObject\\Recur\\EventIterator', $it);
    }
開發者ID:ddolbik,項目名稱:sabre-vobject,代碼行數:28,代碼來源:Issue36WorkAroundTest.php

示例11: testGetDTEnd

    function testGetDTEnd()
    {
        $ics = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//iCal 4.0.4//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
TRANSP:OPAQUE
DTEND;TZID=America/New_York:20070925T170000
UID:uuid
DTSTAMP:19700101T000000Z
LOCATION:
DESCRIPTION:
STATUS:CONFIRMED
SEQUENCE:18
SUMMARY:Stuff
DTSTART;TZID=America/New_York:20070925T160000
CREATED:20071004T144642Z
RRULE:FREQ=MONTHLY;INTERVAL=1;UNTIL=20071030T035959Z;BYDAY=5TU
END:VEVENT
END:VCALENDAR
ICS;
        $vObject = Reader::read($ics);
        $it = new RecurrenceIterator($vObject, (string) $vObject->VEVENT->UID);
        while ($it->valid()) {
            $it->next();
        }
        // If we got here, it means we were successful. The bug that was in teh
        // system before would fail on the 5th tuesday of the month, if the 5th
        // tuesday did not exist.
    }
開發者ID:ZerGabriel,項目名稱:friendica-addons,代碼行數:32,代碼來源:RecurrenceIteratorFifthTuesdayProblemTest.php

示例12: testRead

    function testRead()
    {
        $input = <<<VCF
BEGIN:VCARD
VERSION:2.1
N:Doe;Jon;;;
FN:Jon Doe
EMAIL;X-INTERN:foo@example.org
UID:foo
END:VCARD
VCF;
        $vcard = Reader::read($input);
        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard);
        $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
        $vcard = $vcard->serialize();
        $converted = Reader::read($vcard);
        $converted->validate();
        $this->assertTrue(isset($converted->EMAIL['X-INTERN']));
        $version = Version::VERSION;
        $expected = <<<VCF
BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject {$version}//EN
N:Doe;Jon;;;
FN:Jon Doe
EMAIL;X-INTERN=:foo@example.org
UID:foo
END:VCARD

VCF;
        $this->assertEquals($expected, str_replace("\r", "", $vcard));
    }
開發者ID:vernonlacerda,項目名稱:jorani,代碼行數:32,代碼來源:EmptyParameterTest.php

示例13: __construct

 /**
  * Constructs the ID3v1 class with given file. The file is not mandatory
  * argument and may be omitted. A new tag can be written to a file also by
  * giving the filename to the {@link #write} method of this class.
  *
  * @param string $filename The path to the file.
  */
 public function __construct($filename = false)
 {
     if (($this->_filename = $filename) === false || file_exists($filename) === false) {
         return;
     }
     $this->_reader = new Reader($filename);
     if ($this->_reader->getSize() < 128) {
         return;
     }
     $this->_reader->setOffset(-128);
     if ($this->_reader->read(3) != "TAG") {
         $this->_reader = false;
         // reset reader, see write
         return;
     }
     $this->_title = rtrim($this->_reader->readString8(30), " ");
     $this->_artist = rtrim($this->_reader->readString8(30), " ");
     $this->_album = rtrim($this->_reader->readString8(30), " ");
     $this->_year = $this->_reader->readString8(4);
     $this->_comment = rtrim($this->_reader->readString8(28), " ");
     /* ID3v1.1 support for tracks */
     $v11_null = $this->_reader->read(1);
     $v11_track = $this->_reader->read(1);
     if (ord($v11_null) == 0 && ord($v11_track) != 0) {
         $this->_track = ord($v11_track);
     } else {
         $this->_comment = rtrim($this->_comment . $v11_null . $v11_track, " ");
     }
     $this->_genre = $this->_reader->readInt8();
 }
開發者ID:AsteriaGamer,項目名稱:steamdriven-kohana,代碼行數:37,代碼來源:ID3v1.php

示例14: assertVObjEquals

 /**
  * This method tests wether two vcards or icalendar objects are
  * semantically identical.
  *
  * It supports objects being supplied as strings, streams or
  * Sabre\VObject\Component instances.
  *
  * PRODID is removed from both objects as this is often changes and would
  * just get in the way.
  *
  * CALSCALE will automatically get removed if it's set to GREGORIAN.
  *
  * Any property that has the value **ANY** will be treated as a wildcard.
  *
  * @param resource|string|Component $expected
  * @param resource|string|Component $actual
  * @param string $message
  */
 function assertVObjEquals($expected, $actual, $message = '')
 {
     $self = $this;
     $getObj = function ($input) use($self) {
         if (is_resource($input)) {
             $input = stream_get_contents($input);
         }
         if (is_string($input)) {
             $input = Reader::read($input);
         }
         if (!$input instanceof Component) {
             $this->fail('Input must be a string, stream or VObject component');
         }
         unset($input->PRODID);
         if ($input instanceof Component\VCalendar && (string) $input->CALSCALE === 'GREGORIAN') {
             unset($input->CALSCALE);
         }
         return $input;
     };
     $expected = $getObj($expected)->serialize();
     $actual = $getObj($actual)->serialize();
     // Finding wildcards in expected.
     preg_match_all('|^([A-Z]+):\\*\\*ANY\\*\\*\\r$|m', $expected, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         $actual = preg_replace('|^' . preg_quote($match[1], '|') . ':(.*)\\r$|m', $match[1] . ':**ANY**' . "\r", $actual);
     }
     $this->assertEquals($expected, $actual, $message);
 }
開發者ID:ddolbik,項目名稱:sabre-vobject,代碼行數:46,代碼來源:TestCase.php

示例15: __construct

 /**
  * Constructs the class with given parameters and options.
  *
  * @param Reader $reader  The reader object.
  * @param Array  $options The options array.
  */
 public function __construct($reader, &$options = array())
 {
   $this->_reader = $reader;
   $this->_options = $options;
   $this->_offset = $this->_reader->getOffset();
   $this->_id = $this->_reader->readGUID();
   $this->_size = $this->_reader->readInt64LE();
 }
開發者ID:rtdean93,項目名稱:therock,代碼行數:14,代碼來源:Object.php


注:本文中的Reader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。