当前位置: 首页>>代码示例>>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;未经允许,请勿转载。