This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 112
WIP Update headers and style refactor #55
Open
btry
wants to merge
4
commits into
TECLIB:develop
Choose a base branch
from
btry:feature/code_style
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,6 @@ | |
* | ||
* This file is part of CFPropertyList. | ||
* | ||
* The PHP implementation of Apple's PropertyList can handle XML PropertyLists | ||
* as well as binary PropertyLists. It offers functionality to easily convert | ||
* data between worlds, e.g. recalculating timestamps from unix epoch to apple | ||
* epoch and vice versa. A feature to automagically create (guess) the plist | ||
* structure from a normal PHP data structure will help you dump your data to | ||
* plist in no time. | ||
* | ||
* Copyright (c) 2018 Teclib' | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
@@ -34,7 +27,7 @@ | |
* ------------------------------------------------------------------------------ | ||
* @author Christian Kruse <[email protected]> | ||
* @copyright Copyright © 2018 Teclib | ||
* @package plist | ||
* @package CFPropertyList | ||
* @license MIT | ||
* @link https://github.com/TECLIB/CFPropertyList/ | ||
* ------------------------------------------------------------------------------ | ||
|
@@ -48,8 +41,8 @@ | |
namespace CFPropertyList; | ||
|
||
// just in case... | ||
error_reporting( E_ALL ); | ||
ini_set( 'display_errors', 'on' ); | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'on'); | ||
|
||
/** | ||
* Require CFPropertyList | ||
|
@@ -66,42 +59,40 @@ | |
* Manuall Create the sample.xml.plist | ||
*/ | ||
// the Root element of the PList is a Dictionary | ||
$plist->add( $dict = new CFDictionary() ); | ||
$plist->add($dict = new CFDictionary()); | ||
|
||
// <key>Year Of Birth</key><integer>1965</integer> | ||
$dict->add( 'Year Of Birth', new CFNumber( 1965 ) ); | ||
$dict->add('Year Of Birth', new CFNumber(1965)); | ||
|
||
// <key>Date Of Graduation</key><date>2004-06-22T19:23:43Z</date> | ||
$dict->add( 'Date Of Graduation', new CFDate( gmmktime( 19, 23, 43, 06, 22, 2004 ) ) ); | ||
$dict->add('Date Of Graduation', new CFDate(gmmktime(19, 23, 43, 06, 22, 2004))); | ||
|
||
// <key>Pets Names</key><array/> | ||
$dict->add( 'Pets Names', new CFArray() ); | ||
$dict->add('Pets Names', new CFArray()); | ||
|
||
// <key>Picture</key><data>PEKBpYGlmYFCPA==</data> | ||
// to keep it simple we insert an already base64-encoded string | ||
$dict->add( 'Picture', new CFData( 'PEKBpYGlmYFCPA==', true ) ); | ||
$dict->add('Picture', new CFData('PEKBpYGlmYFCPA==', true)); | ||
|
||
// <key>City Of Birth</key><string>Springfield</string> | ||
$dict->add( 'City Of Birth', new CFString( 'Springfield' ) ); | ||
$dict->add('City Of Birth', new CFString('Springfield')); | ||
|
||
// <key>Name</key><string>John Doe</string> | ||
$dict->add( 'Name', new CFString( 'John Doe' ) ); | ||
$dict->add('Name', new CFString('John Doe')); | ||
|
||
// <key>Kids Names</key><array><string>John</string><string>Kyra</string></array> | ||
$dict->add( 'Kids Names', $array = new CFArray() ); | ||
$array->add( new CFString( 'John' ) ); | ||
$array->add( new CFString( 'Kyra' ) ); | ||
$dict->add('Kids Names', $array = new CFArray()); | ||
$array->add(new CFString('John')); | ||
$array->add(new CFString('Kyra')); | ||
|
||
|
||
/* | ||
* Save PList as XML | ||
*/ | ||
$plist->saveXML( __DIR__.'/example-create-01.xml.plist' ); | ||
$plist->saveXML(__DIR__.'/example-create-01.xml.plist'); | ||
|
||
|
||
/* | ||
* Save PList as Binary | ||
*/ | ||
$plist->saveBinary( __DIR__.'/example-create-01.binary.plist' ); | ||
|
||
?> | ||
$plist->saveBinary(__DIR__.'/example-create-01.binary.plist'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,6 @@ | |
* | ||
* This file is part of CFPropertyList. | ||
* | ||
* The PHP implementation of Apple's PropertyList can handle XML PropertyLists | ||
* as well as binary PropertyLists. It offers functionality to easily convert | ||
* data between worlds, e.g. recalculating timestamps from unix epoch to apple | ||
* epoch and vice versa. A feature to automagically create (guess) the plist | ||
* structure from a normal PHP data structure will help you dump your data to | ||
* plist in no time. | ||
* | ||
* Copyright (c) 2018 Teclib' | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
@@ -34,7 +27,7 @@ | |
* ------------------------------------------------------------------------------ | ||
* @author Christian Kruse <[email protected]> | ||
* @copyright Copyright © 2018 Teclib | ||
* @package plist | ||
* @package CFPropertyList | ||
* @license MIT | ||
* @link https://github.com/TECLIB/CFPropertyList/ | ||
* ------------------------------------------------------------------------------ | ||
|
@@ -47,11 +40,13 @@ | |
* @subpackage plist.examples | ||
*/ | ||
namespace CFPropertyList; | ||
use \DateTime, \DateTimeZone; | ||
|
||
use \DateTime; | ||
use \DateTimeZone; | ||
|
||
// just in case... | ||
error_reporting( E_ALL ); | ||
ini_set( 'display_errors', 'on' ); | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'on'); | ||
|
||
/** | ||
* Require CFPropertyList | ||
|
@@ -73,8 +68,8 @@ | |
'Year Of Birth' => 1965, | ||
// Note: dates cannot be guessed, so this will become a CFNumber and be treated as an integer | ||
// See example-04.php for a possible workaround | ||
'Date Of Graduation' => gmmktime( 19, 23, 43, 06, 22, 2004 ), | ||
'Date Of Birth' => new DateTime( '1984-09-07 08:15:23', new DateTimeZone( 'Europe/Berlin' ) ), | ||
'Date Of Graduation' => gmmktime(19, 23, 43, 06, 22, 2004), | ||
'Date Of Birth' => new DateTime('1984-09-07 08:15:23', new DateTimeZone('Europe/Berlin')), | ||
'Pets Names' => array(), | ||
// Note: data cannot be guessed, so this will become a CFString | ||
// See example-03.php for a possible workaround | ||
|
@@ -85,18 +80,16 @@ | |
); | ||
|
||
$td = new CFTypeDetector(); | ||
$guessedStructure = $td->toCFType( $structure ); | ||
$plist->add( $guessedStructure ); | ||
$guessedStructure = $td->toCFType($structure); | ||
$plist->add($guessedStructure); | ||
|
||
|
||
/* | ||
* Save PList as XML | ||
*/ | ||
$plist->saveXML( __DIR__.'/example-create-02.xml.plist' ); | ||
$plist->saveXML(__DIR__.'/example-create-02.xml.plist'); | ||
|
||
/* | ||
* Save PList as Binary | ||
*/ | ||
$plist->saveBinary( __DIR__.'/example-create-02.binary.plist' ); | ||
|
||
?> | ||
$plist->saveBinary(__DIR__.'/example-create-02.binary.plist'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,6 @@ | |
* | ||
* This file is part of CFPropertyList. | ||
* | ||
* The PHP implementation of Apple's PropertyList can handle XML PropertyLists | ||
* as well as binary PropertyLists. It offers functionality to easily convert | ||
* data between worlds, e.g. recalculating timestamps from unix epoch to apple | ||
* epoch and vice versa. A feature to automagically create (guess) the plist | ||
* structure from a normal PHP data structure will help you dump your data to | ||
* plist in no time. | ||
* | ||
* Copyright (c) 2018 Teclib' | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
@@ -34,7 +27,7 @@ | |
* ------------------------------------------------------------------------------ | ||
* @author Christian Kruse <[email protected]> | ||
* @copyright Copyright © 2018 Teclib | ||
* @package plist | ||
* @package CFPropertyList | ||
* @license MIT | ||
* @link https://github.com/TECLIB/CFPropertyList/ | ||
* ------------------------------------------------------------------------------ | ||
|
@@ -50,8 +43,8 @@ | |
namespace CFPropertyList; | ||
|
||
// just in case... | ||
error_reporting( E_ALL ); | ||
ini_set( 'display_errors', 'on' ); | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'on'); | ||
|
||
/** | ||
* Require CFPropertyList | ||
|
@@ -72,28 +65,26 @@ | |
$structure = array( | ||
'Year Of Birth' => 1965, | ||
// Note: dates cannot be guessed, it thus has to be specified explicitly | ||
'Date Of Graduation' => new CFDate( gmmktime( 19, 23, 43, 06, 22, 2004 ) ), | ||
'Date Of Graduation' => new CFDate(gmmktime(19, 23, 43, 06, 22, 2004)), | ||
'Pets Names' => array(), | ||
// Note: data cannot be guessed, it thus has to be specified explicitly | ||
'Picture' => new CFData( 'PEKBpYGlmYFCPA==', true ), | ||
'Picture' => new CFData('PEKBpYGlmYFCPA==', true), | ||
'City Of Birth' => 'Springfield', | ||
'Name' => 'John Doe', | ||
'Kids Names' => array( 'John', 'Kyra' ), | ||
); | ||
|
||
$td = new CFTypeDetector(); | ||
$guessedStructure = $td->toCFType( $structure ); | ||
$plist->add( $guessedStructure ); | ||
$guessedStructure = $td->toCFType($structure); | ||
$plist->add($guessedStructure); | ||
|
||
|
||
/* | ||
* Save PList as XML | ||
*/ | ||
$plist->saveXML( __DIR__.'/example-create-03.xml.plist' ); | ||
$plist->saveXML(__DIR__.'/example-create-03.xml.plist'); | ||
|
||
/* | ||
* Save PList as Binary | ||
*/ | ||
$plist->saveBinary( __DIR__.'/example-create-03.binary.plist' ); | ||
|
||
?> | ||
$plist->saveBinary(__DIR__.'/example-create-03.binary.plist'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,6 @@ | |
* | ||
* This file is part of CFPropertyList. | ||
* | ||
* The PHP implementation of Apple's PropertyList can handle XML PropertyLists | ||
* as well as binary PropertyLists. It offers functionality to easily convert | ||
* data between worlds, e.g. recalculating timestamps from unix epoch to apple | ||
* epoch and vice versa. A feature to automagically create (guess) the plist | ||
* structure from a normal PHP data structure will help you dump your data to | ||
* plist in no time. | ||
* | ||
* Copyright (c) 2018 Teclib' | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
@@ -34,7 +27,7 @@ | |
* ------------------------------------------------------------------------------ | ||
* @author Christian Kruse <[email protected]> | ||
* @copyright Copyright © 2018 Teclib | ||
* @package plist | ||
* @package CFPropertyList | ||
* @license MIT | ||
* @link https://github.com/TECLIB/CFPropertyList/ | ||
* ------------------------------------------------------------------------------ | ||
|
@@ -49,24 +42,25 @@ | |
namespace CFPropertyList; | ||
|
||
// just in case... | ||
error_reporting( E_ALL ); | ||
ini_set( 'display_errors', 'on' ); | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 'on'); | ||
|
||
/** | ||
* Require CFPropertyList | ||
*/ | ||
require_once(__DIR__.'/../vendor/autoload.php'); | ||
|
||
class DemoDetector extends CFTypeDetector { | ||
|
||
public function toCFType($value) { | ||
if( $value instanceof PListException ) { | ||
return new CFString( $value->getMessage() ); | ||
} | ||
class DemoDetector extends CFTypeDetector | ||
{ | ||
|
||
return parent::toCFType($value); | ||
} | ||
public function toCFType($value) | ||
{ | ||
if ($value instanceof PListException) { | ||
return new CFString($value->getMessage()); | ||
} | ||
|
||
return parent::toCFType($value); | ||
} | ||
} | ||
|
||
/* | ||
|
@@ -89,45 +83,40 @@ public function toCFType($value) { | |
* Try default detection | ||
*/ | ||
try { | ||
$plist = new CFPropertyList(); | ||
$td = new CFTypeDetector(); | ||
$guessedStructure = $td->toCFType( $structure ); | ||
$plist->add( $guessedStructure ); | ||
$plist->saveXML( __DIR__.'/example-create-04.xml.plist' ); | ||
$plist->saveBinary( __DIR__.'/example-create-04.binary.plist' ); | ||
} | ||
catch( PListException $e ) { | ||
echo 'Normal detection: ', $e->getMessage(), "\n"; | ||
$plist = new CFPropertyList(); | ||
$td = new CFTypeDetector(); | ||
$guessedStructure = $td->toCFType($structure); | ||
$plist->add($guessedStructure); | ||
$plist->saveXML(__DIR__.'/example-create-04.xml.plist'); | ||
$plist->saveBinary(__DIR__.'/example-create-04.binary.plist'); | ||
} catch (PListException $e) { | ||
echo 'Normal detection: ', $e->getMessage(), "\n"; | ||
} | ||
|
||
/* | ||
* Try detection by omitting exceptions | ||
*/ | ||
try { | ||
$plist = new CFPropertyList(); | ||
$td = new CFTypeDetector( array('suppressExceptions' => true) ); | ||
$guessedStructure = $td->toCFType( $structure ); | ||
$plist->add( $guessedStructure ); | ||
$plist->saveXML( __DIR__.'/example-create-04.xml.plist' ); | ||
$plist->saveBinary( __DIR__.'/example-create-04.binary.plist' ); | ||
} | ||
catch( PListException $e ) { | ||
echo 'Silent detection: ', $e->getMessage(), "\n"; | ||
$plist = new CFPropertyList(); | ||
$td = new CFTypeDetector(array('suppressExceptions' => true)); | ||
$guessedStructure = $td->toCFType($structure); | ||
$plist->add($guessedStructure); | ||
$plist->saveXML(__DIR__.'/example-create-04.xml.plist'); | ||
$plist->saveBinary(__DIR__.'/example-create-04.binary.plist'); | ||
} catch (PListException $e) { | ||
echo 'Silent detection: ', $e->getMessage(), "\n"; | ||
} | ||
|
||
/* | ||
* Try detection with an extended version of CFTypeDetector | ||
*/ | ||
try { | ||
$plist = new CFPropertyList(); | ||
$td = new DemoDetector(); | ||
$guessedStructure = $td->toCFType( $structure ); | ||
$plist->add( $guessedStructure ); | ||
$plist->saveXML( __DIR__.'/example-create-04.xml.plist' ); | ||
$plist->saveBinary( __DIR__.'/example-create-04.binary.plist' ); | ||
$plist = new CFPropertyList(); | ||
$td = new DemoDetector(); | ||
$guessedStructure = $td->toCFType($structure); | ||
$plist->add($guessedStructure); | ||
$plist->saveXML(__DIR__.'/example-create-04.xml.plist'); | ||
$plist->saveBinary(__DIR__.'/example-create-04.binary.plist'); | ||
} catch (PListException $e) { | ||
echo 'User defined detection: ', $e->getMessage(), "\n"; | ||
} | ||
catch( PListException $e ) { | ||
echo 'User defined detection: ', $e->getMessage(), "\n"; | ||
} | ||
|
||
?> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really good to have this?....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are examples to show how to use the library. They must be as simple as possible, straightforward. For me this is fine.